Geoguessr Unity Script

For a full list of features included in this script, see this document https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing

As of 2022-02-05. See the latest version.

  1. // ==UserScript==
  2. // @name Geoguessr Unity Script
  3. // @description For a full list of features included in this script, see this document https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing
  4. // @version 4.6.2
  5. // @include https://www.geoguessr.com/*
  6. // @run-at document-start
  7. // @license MIT
  8. // @namespace https://greatest.deepsurf.us/users/838374
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. /**
  13. * For custom Battle Royale / Duels,
  14. * If you want to play a map that includes Kakao or Yandex locations,
  15. * please change "false" to "true" in either fields below.
  16. * Otherwise you would get a black screen.
  17. */
  18.  
  19. let BR_LOAD_KAKAO = false;
  20. let BR_LOAD_YANDEX = false;
  21.  
  22. /**
  23. * Custom your minimap here!
  24. */
  25.  
  26. /**
  27. * 1: replace "roadmap" in the customMode field with any of the options below:
  28. * "roadmap" displays the default road map view. This is the default map type.
  29. * "satellite" displays Google Earth satellite images.
  30. * "hybrid" displays a mixture of normal and satellite views.
  31. * "terrain" displays a physical map based on terrain information.
  32. */
  33.  
  34. let customMode = "terrain";
  35.  
  36. /**
  37. * 2: Go to https://mapstyle.withgoogle.com/ first click "No thanks, take me to the old style wizard"
  38. * then click "MORE OPTIONS" to hide or reveal certain features.
  39. * When you are done, click "FINISH", then "COPY JSON", and replace my settings in custom with your settings below.
  40. */
  41.  
  42. let custom =
  43.  
  44. [
  45. {
  46. "featureType": "administrative",
  47. "stylers": [
  48. {
  49. "visibility": "off"
  50. }
  51. ]
  52. }
  53. ]
  54.  
  55. /**
  56. * End of Minimap customization instruction section
  57. */
  58.  
  59. /**
  60. * Overlay anything on the minimap here!
  61. * 1. overlay an GeoJSON object
  62. * 2. overlay a custom image
  63. */
  64.  
  65. /**
  66. * Overlay an GeoJSON object:
  67. */
  68.  
  69. // change the GeoJson display style.
  70. // strokeOpacity, strokeWeight, fillOpacity takes a value between 0 and 1.
  71. // strokeColor and fillColor supports Hexadecimal color (#00FF00 is green)
  72. // If clickable is set to true, you would not be able to make a guess within the shape
  73.  
  74. let GEOJSON_STYLE =
  75. {
  76. strokeColor: "black",
  77. strokeOpacity: 1,
  78. strokeWeight: 0.2,
  79. fillColor: "#00FF00",
  80. fillOpacity: 0,
  81. clickable: false,
  82. }
  83.  
  84. // replace the URL with your desired link
  85. // For example, search "Germany GeoJson" on Github, find this link (https://github.com/isellsoap/deutschlandGeoJSON/blob/main/4_kreise/4_niedrig.geo.json)
  86. // Then click "Download" to get the raw.githubusercontent.com link (https://raw.githubusercontent.com/isellsoap/deutschlandGeoJSON/main/4_kreise/4_niedrig.geo.json)
  87. // and replace the URL below with that URL.
  88. // State zipcode: see this site https://github.com/OpenDataDE/State-zip-code-GeoJSON
  89.  
  90. let YOUR_URL = "https://raw.githubusercontent.com/severinlandolt/map-switzerland/main/02%20GeoJSON/CH_Kantonsgrenzen_100_geo.json"
  91.  
  92. // set it to true to add your custom GeoJSON by copy it to the code below (this is for
  93.  
  94. let GeoJsonCustomUser = false
  95.  
  96. // replace with your custom GeoJson, go to https://geojson.io/ to customize it then copy the Json to here
  97.  
  98. let CUSTOM_GEOJSON =
  99.  
  100. {
  101. "type": "FeatureCollection",
  102. "features": [
  103. {
  104. "type": "Feature",
  105. "properties": {},
  106. "geometry": {
  107. "type": "LineString",
  108. "coordinates": [
  109. [
  110. 2.493896484375,
  111. 52.7163309360463
  112. ],
  113. [
  114. 2.4609375,
  115. 53.15994678846807
  116. ],
  117. [
  118. 3.2025146484375,
  119. 53.179703893605385
  120. ],
  121. [
  122. 3.2080078125,
  123. 52.96518371955126
  124. ],
  125. [
  126. 2.48291015625,
  127. 52.948637884883205
  128. ]
  129. ]
  130. }
  131. },
  132. {
  133. "type": "Feature",
  134. "properties": {},
  135. "geometry": {
  136. "type": "LineString",
  137. "coordinates": [
  138. [
  139. 3.218994140625,
  140. 52.05586831074774
  141. ],
  142. [
  143. 3.218994140625,
  144. 52.13685974852633
  145. ],
  146. [
  147. 2.515869140625,
  148. 52.1267438596429
  149. ],
  150. [
  151. 2.515869140625,
  152. 51.77803705914517
  153. ],
  154. [
  155. 3.2354736328125,
  156. 51.78993084774129
  157. ],
  158. [
  159. 3.228607177734375,
  160. 51.96119237712624
  161. ],
  162. [
  163. 2.8571319580078125,
  164. 51.95230623740452
  165. ]
  166. ]
  167. }
  168. },
  169. {
  170. "type": "Feature",
  171. "properties": {
  172. "stroke": "#555555",
  173. "stroke-width": 2,
  174. "stroke-opacity": 1
  175. },
  176. "geometry": {
  177. "type": "LineString",
  178. "coordinates": [
  179. [
  180. 2.5048828125,
  181. 52.619725272670266
  182. ],
  183. [
  184. 2.5103759765625,
  185. 52.274880130680536
  186. ],
  187. [
  188. 2.867431640625,
  189. 52.284962354465726
  190. ],
  191. [
  192. 3.2299804687499996,
  193. 52.29504228453735
  194. ],
  195. [
  196. 3.2135009765625,
  197. 52.63973017532399
  198. ],
  199. [
  200. 2.5096893310546875,
  201. 52.621392697207625
  202. ]
  203. ]
  204. }
  205. }
  206. ]
  207. }
  208.  
  209. /**
  210. * Overlay a custom image:
  211. */
  212.  
  213. // set it to true to add your image overlay
  214.  
  215. let OverlayCustom = false
  216.  
  217. // replace the URL with your desired link
  218.  
  219. let OVERLAY_URL = "https://www.battleface.com/blog/wp-content/uploads/2020/10/patreon-profile-tom-geowizard.jpg"
  220.  
  221. // set the bounds for the image - latitude (North and South), longitude (North and South)
  222.  
  223. let OVERLAY_BOUNDS =
  224. {
  225. north: 53,
  226. west: -3,
  227. south: 51,
  228. east: 1,
  229. };
  230.  
  231. // change the image overlay display style.
  232.  
  233. let OVERLAY_STYLE =
  234. {
  235. fillOpacity: 0.2,
  236. clickable: false,
  237. }
  238.  
  239. /**
  240. * End of Minimap Overlay instruction section
  241. */
  242.  
  243. // API Keys
  244.  
  245. var YANDEX_API_KEY = "b704b5a9-3d67-4d19-b702-ec7807cecfc6";
  246. var KAKAO_API_KEY = "cbacbe41e3a223d794f321de4f3e247b";
  247. const MAPS_API_URL = "https://maps.googleapis.com/maps/api/js"; // removed "?" from the link
  248. var MAPILLARY_API_KEY_LIST =
  249. ["MLY|6723031704435203|5afd537469b114cf814881137ad74b7c",
  250. "MLY|6691659414239148|b45e7e82cde126044cbc2cf5d4a7c9b1",
  251. "MLY|5074369465929308|f7ad2802cbaf26c63f88046a292df68b",
  252. "MLY|7451643761528219|6477f2db0e3928b51e45ec9311983936",
  253. "MLY|4855256237866198|6d0464771831c8a4bf2be095e1e1aabc",
  254. "MLY|4772941976102161|8458d4f08d2e1970cdfe0a4e242c04ff",
  255. "MLY|4492067214235489|94c44703942362ad6f6b70b5d32c3a45",
  256. "MLY|4618251611628426|0cef71d6ec8b997a5ec06ecdeabf11ec",
  257. "MLY|4096846270415982|fa2ce29641503e6ef665f17459633570",
  258. "MLY|4231415756962414|fe353880fd246e8a4a6ae32152f7dbb0",]
  259.  
  260. var MAPILLARY_API_KEY = MAPILLARY_API_KEY_LIST[Math.floor(Math.random() * MAPILLARY_API_KEY_LIST.length)];
  261.  
  262. console.log("Geoguessr Unity Script v4.6.2 by Jupaoqq");
  263. // console.log(MAPILLARY_API_KEY);
  264.  
  265. // Store each player instance
  266.  
  267. let YandexPlayer, KakaoPlayer, GooglePlayer, MapillaryPlayer;
  268. let YANDEX_INJECTED = false;
  269. let BAIDU_INJECTED = false;
  270. let KAKAO_INJECTED = false;
  271. let MAPILLARY_INJECTED = false;
  272.  
  273. // Game mode detection
  274.  
  275. let isBattleRoyale = false;
  276. let isDuel = false;
  277.  
  278. // Player detection and coordinate conversion
  279.  
  280. let nextPlayer = "Google";
  281. let global_lat = 0;
  282. let global_lng = 0;
  283. let global_panoID = null;
  284. let global_BDID, global_BDAh, global_BDBh;
  285. let yId, yTime, yEnd, iId;
  286. let global_heading = null;
  287. let global_pitch = null;
  288.  
  289. let krCoordinates = [38.75292321084364, 124.2804539232574, 33.18509676203202, 129.597381999198]
  290. let global_radi = 100
  291.  
  292. // Callback variables
  293.  
  294. let eventListenerAttached = false;
  295. let povListenerAttached = false;
  296. let playerLoaded = false;
  297. let teleportLoaded = false;
  298. let syncLoaded = false;
  299.  
  300. // Minimize Yandex API use
  301.  
  302. let yandex_map = false;
  303. let Kakao_map = false;
  304.  
  305. // Mapillary Image Key
  306.  
  307. let mmKey = 0;
  308.  
  309. // Handle Yandex compass
  310.  
  311. let COMPASS = null;
  312.  
  313. // Handle undo
  314.  
  315. let locHistory = [];
  316. let defaultPanoIdChange = true;
  317.  
  318. // Round check
  319.  
  320. let ROUND = 0;
  321. let CURRENT_ROUND_DATA = null;
  322.  
  323. let switch_call = true;
  324. let one_reset = false;
  325. // let cnt = 0;
  326.  
  327. let cn_tips = false;
  328. var isFirefox = typeof InstallTrigger !== 'undefined';
  329.  
  330. let linksList = []
  331. let fire1 = true;
  332.  
  333. let CNBorder = false;
  334.  
  335. // let NEW_ROUND_LOADED = false;
  336.  
  337. // Geoguessr Canvas String
  338.  
  339. let GENERAL_CANVAS = ".game-layout__panorama-canvas";
  340. let BR_CANVAS = ".br-game-layout__panorama-canvas";
  341. let FAIL_TO_LOAD_CANVAS = ".game-layout__panorama-message";
  342. let DUEL_LAYOUT = ".game_layout__TO_jf";
  343. let DUELS_CANVAS = ".game-panorama_panorama__rdhFg";
  344. let DUELS_CANVAS2 = ".game-panorama_panoramaCanvas__PNKve";
  345. let DUELS_POPUP = ".overlay_overlay__AR02x"
  346. let BR_POPUP = ".popup__content"
  347.  
  348. /**
  349. * Helper Functions
  350. */
  351.  
  352. // Pretty print
  353.  
  354. function myHighlight(...args) {
  355. console.log(`%c${[...args]}`, "color: dodgerblue; font-size: 24px;");
  356. }
  357.  
  358. // Hex to number conversion for Baidu coordinate conversion
  359.  
  360. function hex2a(hexx) {
  361. var hex = hexx.toString();
  362. var str = '';
  363. for (var i = 0; i < hex.length; i += 2)
  364. {
  365. str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
  366. }
  367. return str;
  368. }
  369.  
  370. // Coordinate computation given heading, distance and current coordinates for teleport
  371.  
  372. function FindPointAtDistanceFrom(lat, lng, initialBearingRadians, distanceKilometres) {
  373. const radiusEarthKilometres = 6371.01;
  374. var distRatio = distanceKilometres / radiusEarthKilometres;
  375. var distRatioSine = Math.sin(distRatio);
  376. var distRatioCosine = Math.cos(distRatio);
  377.  
  378. var startLatRad = DegreesToRadians(lat);
  379. var startLonRad = DegreesToRadians(lng);
  380.  
  381. var startLatCos = Math.cos(startLatRad);
  382. var startLatSin = Math.sin(startLatRad);
  383.  
  384. var endLatRads = Math.asin((startLatSin * distRatioCosine) + (startLatCos * distRatioSine * Math.cos(initialBearingRadians)));
  385.  
  386. var endLonRads = startLonRad
  387. + Math.atan2(
  388. Math.sin(initialBearingRadians) * distRatioSine * startLatCos,
  389. distRatioCosine - startLatSin * Math.sin(endLatRads));
  390.  
  391. return { lat: RadiansToDegrees(endLatRads), lng: RadiansToDegrees(endLonRads) };
  392. }
  393.  
  394. function DegreesToRadians(degrees) {
  395. const degToRadFactor = Math.PI / 180;
  396. return degrees * degToRadFactor;
  397. }
  398.  
  399. function RadiansToDegrees(radians) {
  400. const radToDegFactor = 180 / Math.PI;
  401. return radians * radToDegFactor;
  402. }
  403.  
  404. // Check if two floating point numbers are really really really really close to each other (to 10 decimal points)
  405. function almostEqual (a, b) {
  406. return a.toFixed(10) === b.toFixed(10)
  407. }
  408.  
  409. function almostEqual2 (a, b) {
  410. return a.toFixed(3) === b.toFixed(3)
  411. }
  412.  
  413. // Script injection, extracted from extenssr:
  414. // https://gitlab.com/nonreviad/extenssr/-/blob/main/src/injected_scripts/maps_api_injecter.ts
  415.  
  416. function overrideOnLoad(googleScript, observer, overrider) {
  417. const oldOnload = googleScript.onload
  418. googleScript.onload = (event) => {
  419. const google = window.google
  420. if (google) {
  421. observer.disconnect()
  422. overrider(google)
  423. }
  424. if (oldOnload) {
  425. oldOnload.call(googleScript, event)
  426. }
  427. }
  428. }
  429.  
  430. function grabGoogleScript(mutations) {
  431. for (const mutation of mutations) {
  432. for (const newNode of mutation.addedNodes) {
  433. const asScript = newNode
  434. if (asScript && asScript.src && asScript.src.startsWith('https://maps.googleapis.com/')) {
  435. return asScript
  436. }
  437. }
  438. }
  439. return null
  440. }
  441.  
  442. function injecter(overrider) {
  443. if (document.documentElement)
  444. {
  445. injecterCallback(overrider);
  446. }
  447. else
  448. {
  449. alert("Script didn't load, refresh to try loading the script");
  450. }
  451. }
  452.  
  453. function injecterCallback(overrider)
  454. {
  455. new MutationObserver((mutations, observer) => {
  456. const googleScript = grabGoogleScript(mutations)
  457. if (googleScript) {
  458. overrideOnLoad(googleScript, observer, overrider)
  459. }
  460. }).observe(document.documentElement, { childList: true, subtree: true })
  461. }
  462.  
  463. // Getter function for the button elements
  464.  
  465. function setButtons()
  466. {
  467. return [document.getElementById("Teleport Button"), document.getElementById("plus"), document.getElementById("minus"), document.getElementById("reset"), document.getElementById("switch"), document.getElementById("Show Buttons"), document.getElementById("Date Button"), document.getElementById("minus year"), document.getElementById("plus year"), document.getElementById("Minimap Button"), document.getElementById("Overlay Button"), document.getElementById("Help Button"), document.getElementById("Teleport Options Button")];
  468. }
  469.  
  470. function resetBtnPos()
  471. {
  472. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  473. teleportBtn.style.top = "8.5em";
  474. teleportMoreBtn.style.top = "8.5em";
  475. teleportLessBtn.style.top = "8.5em";
  476. teleportDistResetBtn.style.top = "11em";
  477. switchCovergeButton.style.top = "6em";
  478. mainMenuBtn.style.top = "6em";
  479. timeMachineBtn.style.top = "13.5em";
  480. timeMachineOlderBtn.style.top = "13.5em";
  481. timeMachineNewerBtn.style.top = "13.5em";
  482. MinimapBtn.style.top = "16em";
  483. OverlayBtn.style.top = "16em";
  484. HelpBtn.style.top = "6em";
  485. TeleportArisBtn.style.top = "11em";
  486. document.getElementById("Youtube Button").style.top = "13.5em";
  487.  
  488. teleportBtn.style.right = "9.5em";
  489. teleportMoreBtn.style.right = "7em";
  490. teleportLessBtn.style.right = "20em";
  491. teleportDistResetBtn.style.right = "13em";
  492. switchCovergeButton.style.right = "7em";
  493. mainMenuBtn.style.right = "0.5em";
  494. timeMachineBtn.style.right = "9.5em";
  495. timeMachineOlderBtn.style.right = "20em";
  496. timeMachineNewerBtn.style.right = "7em";
  497. MinimapBtn.style.right = "14.75em";
  498. OverlayBtn.style.right = "7em";
  499. HelpBtn.style.right = "16em";
  500. TeleportArisBtn.style.right = "7em";
  501. document.getElementById("Youtube Button").style.right = "0.5em";
  502.  
  503. let hC = 0
  504. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  505. mapDiv.style.top = (18.1 + (hC * 1.6)).toString() + "em";
  506. mapDiv.style.right = "14.75em";
  507. hC++;
  508. }
  509. let hC2 = 0
  510. for (let mapDiv2 of document.getElementsByClassName("overlay-minimap")){
  511. mapDiv2.style.top = (18.1 + (hC2 * 1.6)).toString() + "em";
  512. mapDiv2.style.right = "7em";
  513. hC2++;
  514. }
  515. }
  516.  
  517. function AdjustBtnPos(top, right)
  518. {
  519. resetBtnPos();
  520. for (let element of document.getElementsByClassName("unity-btn")){
  521. let eTop = element.style.top;
  522. let eRight = element.style.right;
  523. element.style.top = "calc(" + top.toString() + " + " + eTop + ")";
  524. element.style.right = "calc(" + right.toString() + " + " + eRight + ")";
  525. // console.log(element.style.top)
  526. }
  527. }
  528.  
  529. /**
  530. * Creates teleportation and Kakao switch button
  531. *
  532. * @returns Promise
  533. */
  534.  
  535. function UnityInitiate() {
  536. const google = window.google;
  537. let curPosition;
  538. let kakao_enabled = true;
  539.  
  540. function svCheck(data, status) {
  541. if (status === 'OK') {
  542. // console.log("STATUS OK");
  543. let l = data.location.latLng.toString().split(',');
  544. let lat = l[0].replaceAll('(', '');
  545. let lng = l[1].replaceAll(')', '');
  546. if (lat == curPosition.lat && lng == curPosition.lng && !switch_call)
  547. {
  548. console.log("Trying more distance");
  549. teleportBtn.distance += 100;
  550. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  551. }
  552. else
  553. {
  554. console.log("Teleport Success");
  555. GooglePlayer.setPosition(data.location.latLng);
  556. GooglePlayer.setPov({
  557. heading: switchCovergeButton.heading,
  558. pitch: 0,
  559. })
  560. if (teleportBtn.distance > 150)
  561. {
  562. teleportBtn.distance = 100;
  563. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  564. }
  565. }
  566. switch_call = false;
  567. }
  568. else {
  569. console.log("STATUS NOT OK");
  570. teleportBtn.distance += 100;
  571. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  572. }
  573. }
  574.  
  575. google.maps.Map = class extends google.maps.Map {
  576. constructor(...args) {
  577. super(...args);
  578. if (GeoJsonCustomUser)
  579. {
  580. if (GeoJsonCustomUser)
  581. {
  582. this.data.addGeoJson(CUSTOM_GEOJSON);
  583. }
  584. this.data.setStyle(function(feature) {
  585. return GEOJSON_STYLE
  586. });
  587. }
  588. if (OverlayCustom)
  589. {
  590. let customOverlay = new google.maps.GroundOverlay(OVERLAY_URL, OVERLAY_BOUNDS, OVERLAY_STYLE);
  591. customOverlay.setMap(this);
  592. }
  593.  
  594. if (CNBorder)
  595. {
  596. this.data.loadGeoJson("https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/10DD.json");
  597. this.data.setStyle(function(feature) {
  598. return {
  599. clickable: false,
  600. strokeWeight: 1
  601. }
  602. });
  603.  
  604. const imageBounds3 = {
  605. north: NW[0],
  606. west: NW[1],
  607. south: NW[2],
  608. east: NW[3],
  609. };
  610.  
  611. SEOverlay3 = new google.maps.GroundOverlay(
  612. "https://www.countryflags.com/wp-content/uploads/china-flag-png-large.png",
  613. imageBounds3, {clickable: false, opacity: 1}
  614. );
  615. SEOverlay3.setMap(this);
  616.  
  617. this.addListener("zoom_changed", () => {
  618. let zoomLevel = this.getZoom();
  619. let opacity = 1;
  620. if (SEOverlay)
  621. {
  622. SEOverlay.setMap(null);
  623. NWOverlay.setMap(null);
  624. }
  625. let borderSE = TW[0]
  626. let borderNW = TS[0]
  627. if (zoomLevel > 7 && zoomLevel < 14)
  628. {
  629. borderSE = TW[zoomLevel - 7];
  630. borderNW = TS[1];
  631. }
  632. if (zoomLevel >= 14)
  633. {
  634. opacity = 0;
  635. }
  636. const imageBounds = {
  637. north: borderSE[0],
  638. west: borderSE[1],
  639. south: borderSE[2],
  640. east: borderSE[3],
  641. };
  642. SEOverlay = new google.maps.GroundOverlay(
  643. "https://www.countryflags.com/wp-content/uploads/china-flag-png-large.png",
  644. imageBounds, {clickable: false, opacity: opacity}
  645. );
  646. SEOverlay.setMap(this);
  647. const imageBounds2 = {
  648. north: borderNW[0],
  649. west: borderNW[1],
  650. south: borderNW[2],
  651. east: borderNW[3],
  652. };
  653. NWOverlay = new google.maps.GroundOverlay(
  654. "https://www.countryflags.com/wp-content/uploads/china-flag-png-large.png",
  655. imageBounds2, {clickable: false, opacity: 1}
  656. );
  657. NWOverlay.setMap(this);
  658. });
  659. }
  660. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  661. google.maps.event.addDomListener(mapDiv, "click", () => {
  662. MinimapBtn.current = mapDiv.id;
  663. if (mapDiv.id == "Hybrid")
  664. {
  665. this.setMapTypeId('hybrid');
  666. }
  667. else if (mapDiv.id == "Terrain")
  668. {
  669. this.setMapTypeId('terrain');
  670. }
  671. else if (mapDiv.id == "Satellite")
  672. {
  673. this.setMapTypeId('satellite');
  674. }
  675. else if (mapDiv.id == "Custom")
  676. {
  677. this.setMapTypeId(customMode);
  678. }
  679. else
  680. {
  681. this.setMapTypeId('roadmap');
  682. }
  683. // this.setTilt(45);
  684. for (let ar of presetMinimap)
  685. {
  686. if (ar[1] == mapDiv.id)
  687. {
  688. this.set('styles', ar[0]);
  689. }
  690. }
  691. for (let element of document.getElementsByClassName("preset-minimap")){
  692. if (element.id == MinimapBtn.current)
  693. {
  694. element.style.background = "#ff6600";
  695. }
  696. else
  697. {
  698. element.style.background = "orange";
  699. }
  700. }
  701.  
  702. });
  703. }
  704. for (let mapDiv of document.getElementsByClassName("overlay-minimap")){
  705. google.maps.event.addDomListener(mapDiv, "click", () => {
  706. OverlayBtn.current = mapDiv.id;
  707. // console.log(mapDiv.url)
  708. // console.log(mapDiv.id)
  709. // console.log(mapDiv.loaded)
  710. if (!mapDiv.loaded)
  711. {
  712. this.data.loadGeoJson(mapDiv.url, {
  713. id: mapDiv.id
  714. });
  715. mapDiv.loaded = true;
  716. }
  717. if (mapDiv.id == "Clear")
  718. {
  719. this.overlayMapTypes.clear();
  720. this.data.setStyle(function(feature) {
  721. return GEOJSON_INVISIBLE
  722. });
  723. for (let element of document.getElementsByClassName("overlay-minimap")){
  724. if (element.id === "Clear")
  725. {
  726. element.style.background = "#ff6600";
  727. }
  728. else
  729. {
  730. element.style.background = "orange";
  731. }
  732. }
  733. }
  734. else
  735. {
  736. if (mapDiv.id == "Coverage" || mapDiv.id == "Official")
  737. {
  738. this.overlayMapTypes.clear();
  739. const coverageLayer = new google.maps.ImageMapType({
  740. getTileUrl ({ x, y }, z) {
  741. // Omits photospheres
  742. // return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:apiv3&style=5,8&x=${x}&y=${y}&z=${z}`
  743.  
  744. // Omits unofficial and trekker, but also half of mongolia
  745. if (mapDiv.id == "Official")
  746. {
  747. return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:app&style=5,8&x=${x}&y=${y}&z=${z}`
  748. }
  749. // return `https://maps.googleapis.com/maps/vt?pb=!1m5!1m4!1i${z}!2i${x}!3i${y}!4i256!2m8!1e2!2ssvv!4m2!1scb_client!2sapp!4m2!1scc!2s*211m3*211e3*212b1*213e2*211m3*211e2*212b1*213e2!3m3!3sUS!12m1!1e68!4e0`
  750.  
  751. // Includes everything
  752. else
  753. {
  754. return `https://maps.googleapis.com/maps/vt?pb=!1m5!1m4!1i${z}!2i${x}!3i${y}!4i256!2m8!1e2!2ssvv!4m2!1scb_client!2sapiv3!4m2!1scc!2s*211m3*211e3*212b1*213e2*211m3*211e2*212b1*213e2!3m3!3sUS!12m1!1e68!4e0`
  755. }
  756. },
  757. maxZoom: 20,
  758. tileSize: new google.maps.Size(256, 256),
  759. })
  760. this.overlayMapTypes.push(coverageLayer);
  761.  
  762. let other = "Official";
  763. if (mapDiv.id == "Official")
  764. {
  765. other = "Coverage"
  766. }
  767.  
  768. mapDiv.style.background = "#ff6600";
  769.  
  770. for (let element of document.getElementsByClassName("overlay-minimap")){
  771. if (element.id === "Clear" || element.id === other)
  772. {
  773. element.style.background = "orange";
  774. }
  775. }
  776. }
  777. else
  778. {
  779. this.data.setStyle(function(feature) {
  780. return GEOJSON_STYLE
  781. });
  782. for (let element of document.getElementsByClassName("overlay-minimap")){
  783. if (element.id !== "Coverage" && element.id !== "Official")
  784. {
  785. if (element.id !== "Clear" && element.loaded)
  786. {
  787. element.style.background = "#ff6600";
  788. }
  789. else
  790. {
  791. element.style.background = "orange";
  792. }
  793. }
  794. }
  795. }
  796. }
  797. });
  798. }
  799. }
  800.  
  801. }
  802.  
  803. const svService = new google.maps.StreetViewService();
  804. google.maps.StreetViewPanorama = class extends google.maps.StreetViewPanorama {
  805. constructor(...args) {
  806. super(...args);
  807. GooglePlayer = this;
  808.  
  809. const isGamePage = () => location.pathname.startsWith("/challenge/") || location.pathname.startsWith("/results/") || location.pathname.startsWith("/game/")|| location.pathname.startsWith("/battle-royale/") || location.pathname.startsWith("/duels/") || location.pathname.startsWith("/team-duels/");
  810.  
  811. this.addListener('position_changed', () => {
  812. // Maybe this could be used to update the position in the other players
  813. // so that they are always in sync
  814. try {
  815. if (!isGamePage()) return;
  816. // timeMachineBtn.panoId = GooglePlayer.pano;
  817. // timeMachineBtn.index = -1;
  818. const lat = this.getPosition().lat();
  819. const lng = this.getPosition().lng();
  820. const { heading } = this.getPov();
  821.  
  822. curPosition = { lat, lng, heading };
  823.  
  824. if (switchCovergeButton.useGoogle)
  825. {
  826. switchCovergeButton.lng = lng;
  827. switchCovergeButton.lat = lat;
  828. switchCovergeButton.heading = heading;
  829. if (!timeMachineBtn.list.some(row => row.includes(GooglePlayer.pano)))
  830. {
  831. timeMachineBtn.innerHTML = "Time Machine";
  832. timeMachineBtn.panoId = GooglePlayer.pano;
  833. timeMachineBtn.index = -1;
  834. timeMachineBtn.plusminusLock = true;
  835. timeMachineNewerBtn.style.backgroundColor = "red";
  836. timeMachineNewerBtn.disabled = true;
  837. timeMachineOlderBtn.style.backgroundColor = "red";
  838. timeMachineOlderBtn.disabled = true;
  839. }
  840. }
  841. switchCovergeButton.useGoogle = true;
  842. teleportBtn.google = true;
  843. // console.log("also run");
  844.  
  845. // switchCovergeButton.heading = position.lat;
  846. // console.log(position.heading);
  847. // console.log(switchCovergeButton.lng);
  848. }
  849. catch (e) {
  850. console.error("GeoGuessr Path Logger Error:", e);
  851. }
  852. });
  853. this.addListener('pov_changed', () => {
  854. const { heading, pitch } = this.getPov();
  855. if (KakaoPlayer) {
  856. if (typeof KakaoPlayer !== 'string' )
  857. {
  858. const vp = KakaoPlayer.getViewpoint();
  859. // Prevent a recursive loop: only update kakao's viewpoint if it got out of sync with google's
  860. if ((!almostEqual(vp.pan, heading) || !almostEqual(vp.tilt, pitch)) && nextPlayer == "Kakao") {
  861. KakaoPlayer.setViewpoint({ pan: heading, tilt: pitch, zoom: vp.zoom });
  862. }
  863. }
  864. }
  865. });
  866. }
  867. };
  868.  
  869.  
  870. var mainMenuBtn = document.createElement("Button");
  871. mainMenuBtn.classList.add("unity-btn");
  872. mainMenuBtn.id = "Show Buttons"
  873. mainMenuBtn.innerHTML = "Geoguessr Unity Script<br><font size=1>by Jupaoqq<br>v4.6.2</font>";
  874. mainMenuBtn.style =
  875. "visibility:hidden;width:6em;height:7em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  876. // document.querySelector(".game-layout__status").appendChild(mainMenuBtn)
  877. document.body.appendChild(mainMenuBtn);
  878. mainMenuBtn.addEventListener("click", () => {
  879. if (hide) {
  880. for (let element of document.getElementsByClassName("unity-btn")){
  881. if (!element.classList.contains("preset-minimap") && !element.classList.contains("overlay-minimap"))
  882. {
  883. element.style.visibility = "";
  884. if ((nextPlayer != "Youtube") && element.id == "Youtube Button")
  885. {
  886. element.style.visibility = "hidden";
  887. }
  888. }
  889. }
  890. hide = false;
  891. }
  892. else {
  893. for (let element of document.getElementsByClassName("unity-btn")){
  894. if (element.id !== "Show Buttons")
  895. {
  896. element.style.visibility = "hidden";
  897. }
  898. }
  899. hide = true;
  900. }
  901. });
  902.  
  903. var teleportBtn = document.createElement("Button");
  904. teleportBtn.classList.add("unity-btn");
  905. teleportBtn.teleType = "default";
  906. teleportBtn.id = "Teleport Button";
  907. teleportBtn.distance = 100;
  908. teleportBtn.google = true;
  909. teleportBtn.innerHTML = "Teleport 100m";
  910. teleportBtn.style =
  911. "visibility:hidden;width:10em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  912. document.body.appendChild(teleportBtn);
  913. teleportBtn.addEventListener("click", () => {
  914. // console.log("Google Teleport");
  915. if (switchCovergeButton.init)
  916. {
  917. // console.log("run");
  918. switchCovergeButton.init = false;
  919. if (teleportBtn.google)
  920. {
  921. switchCovergeButton.useGoogle = true;
  922. teleportBtn.google = true;
  923. }
  924. else
  925. {
  926. switchCovergeButton.useGoogle = false;
  927. teleportBtn.google = false;
  928. }
  929. }
  930. else
  931. {
  932. // console.log(teleportBtn.google)
  933. if (teleportBtn.google && GooglePlayer != null)
  934. {
  935. let heading = GooglePlayer.getPov().heading;
  936. let place = FindPointAtDistanceFrom(curPosition.lat, curPosition.lng , DegreesToRadians(heading), teleportBtn.distance * 0.001)
  937. svService.getPanorama({ location: place, radius: 1000, source: teleportBtn.teleType}, svCheck);
  938. }
  939. }
  940. });
  941.  
  942. var teleportMoreBtn = document.createElement("Button");
  943. teleportMoreBtn.classList.add("unity-btn");
  944. teleportMoreBtn.id = "plus"
  945. teleportMoreBtn.innerHTML = "+";
  946. teleportMoreBtn.style =
  947. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  948. document.body.appendChild(teleportMoreBtn);
  949. teleportMoreBtn.addEventListener("click", () => {
  950. if (teleportBtn.distance > 21 && teleportBtn.distance < 149) {
  951. teleportBtn.distance = teleportBtn.distance + 25;
  952. }
  953. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  954. });
  955.  
  956. var teleportLessBtn = document.createElement("Button");
  957. teleportLessBtn.classList.add("unity-btn");
  958. teleportLessBtn.id = "minus"
  959. teleportLessBtn.innerHTML = "-";
  960. teleportLessBtn.style =
  961. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  962. document.body.appendChild(teleportLessBtn);
  963. teleportLessBtn.addEventListener("click", () => {
  964. if (teleportBtn.distance > 26) {
  965. teleportBtn.distance = teleportBtn.distance - 25;
  966. }
  967. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  968. });
  969.  
  970. var teleportDistResetBtn = document.createElement("Button");
  971. teleportDistResetBtn.classList.add("unity-btn");
  972. teleportDistResetBtn.id = "reset"
  973. teleportDistResetBtn.innerHTML = "Reset Distance";
  974. teleportDistResetBtn.style =
  975. "visibility:hidden;width:9em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  976. document.body.appendChild(teleportDistResetBtn);
  977. teleportDistResetBtn.addEventListener("click", () => {
  978. teleportBtn.distance = 100;
  979. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  980. });
  981.  
  982. var switchCovergeButton = document.createElement("Button");
  983. switchCovergeButton.classList.add("unity-btn");
  984. switchCovergeButton.id = "switch";
  985. switchCovergeButton.init = false;
  986. switchCovergeButton.nextPlayer = "Google";
  987. switchCovergeButton.useGoogle = false;
  988. switchCovergeButton.lng = 0
  989. switchCovergeButton.lat = 0
  990. switchCovergeButton.heading = 0
  991. switchCovergeButton.innerHTML = "Switch Coverage";
  992. switchCovergeButton.small_canvas = false;
  993. switchCovergeButton.style =
  994. "visibility:hidden;width:8.5em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  995. document.body.appendChild(switchCovergeButton);
  996. switchCovergeButton.addEventListener("click", () => {
  997. let GOOGLE_MAPS_CANVAS1 = document.querySelector(".game-layout__panorama-canvas");
  998. let GOOGLE_MAPS_CANVAS2 = document.querySelector(".br-game-layout__panorama-canvas");
  999. let GOOGLE_MAPS_CANVAS3 = document.querySelector(".inactive");
  1000. let duel = false;
  1001.  
  1002. let GOOGLE_MAPS_CANVAS = null;
  1003. if (GOOGLE_MAPS_CANVAS1 !== null)
  1004. {
  1005. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS1;
  1006. }
  1007. else if (GOOGLE_MAPS_CANVAS2 !== null)
  1008. {
  1009. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS2;
  1010. }
  1011. if (GOOGLE_MAPS_CANVAS3 !== null)
  1012. {
  1013. duel = true;
  1014. }
  1015.  
  1016. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  1017. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  1018. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player")
  1019. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  1020. // if (switchCovergeButton.nextPlayer !== "Baidu") {
  1021. if (switchCovergeButton.useGoogle == false) {
  1022. if (duel)
  1023. {
  1024. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  1025. if (switchCovergeButton.nextPlayer == "Kakao")
  1026. {
  1027. document.getElementById("roadview").className = "inactive";
  1028. }
  1029. else
  1030. {
  1031. MAPILLARY_MAPS_CANVAS.className = "inactive";
  1032. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  1033. }
  1034. }
  1035. else
  1036. {
  1037. GOOGLE_MAPS_CANVAS.style.visibility = "";
  1038. if (switchCovergeButton.nextPlayer == "Kakao")
  1039. {
  1040. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  1041. }
  1042. else if (switchCovergeButton.nextPlayer == "Yandex")
  1043. {
  1044. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  1045. }
  1046. else if (switchCovergeButton.nextPlayer == "Baidu")
  1047. {
  1048. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  1049. }
  1050. else if (switchCovergeButton.nextPlayer == "Mapillary" || switchCovergeButton.nextPlayer == "Google")
  1051. {
  1052. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  1053. }
  1054.  
  1055. }
  1056. const lat = GooglePlayer.getPosition().lat();
  1057. const lng = GooglePlayer.getPosition().lng();
  1058. switch_call = true;
  1059. if (!almostEqual2(lat, switchCovergeButton.lat) || !almostEqual2(lat, switchCovergeButton.lng)) {
  1060. svService.getPanorama({ location: { lat: switchCovergeButton.lat, lng: switchCovergeButton.lng }, radius: 1000 }, svCheck);
  1061. }
  1062. switchCovergeButton.useGoogle = true;
  1063. teleportBtn.google = true;
  1064. switchCovergeButton.init = false;
  1065. console.log("use Google");
  1066. }
  1067. else {
  1068. if (duel)
  1069. {
  1070. document.getElementById("default_player").className = "inactive";
  1071. if (switchCovergeButton.nextPlayer == "Kakao")
  1072. {
  1073. document.getElementById("roadview").className = "game-panorama_panoramaCanvas__PNKve";
  1074. }
  1075. else
  1076. {
  1077. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  1078. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  1079. MapillaryPlayer.resize();
  1080. //window.dispatchEvent(new Event('resize'));
  1081. // document.querySelector(".mapillary-canvas").style.;
  1082. // mapillary-canvas
  1083. }
  1084.  
  1085. }
  1086. else
  1087. {
  1088. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  1089. if (switchCovergeButton.nextPlayer == "Kakao")
  1090. {
  1091. KAKAO_MAPS_CANVAS.style.visibility = "";
  1092. }
  1093. else if (switchCovergeButton.nextPlayer == "Yandex")
  1094. {
  1095. YANDEX_MAPS_CANVAS.style.visibility = "";
  1096. }
  1097. else if (switchCovergeButton.nextPlayer == "Baidu")
  1098. {
  1099. BAIDU_MAPS_CANVAS.style.visibility = "";
  1100. }
  1101. else if (switchCovergeButton.nextPlayer == "Mapillary" || switchCovergeButton.nextPlayer == "Google" )
  1102. {
  1103. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  1104. }
  1105. }
  1106. switchCovergeButton.useGoogle = false;
  1107. teleportBtn.google = false;
  1108. switchCovergeButton.init = true;
  1109. console.log("use Others");
  1110. }
  1111. // }
  1112. // else {
  1113. // switchCovergeButton.useGoogle = false;
  1114. // teleportBtn.google = false;
  1115. // console.log("use Others");
  1116. // }
  1117.  
  1118. });
  1119.  
  1120. var timeMachineNewerBtn = document.createElement("Button");
  1121. timeMachineNewerBtn.classList.add("unity-btn");
  1122. timeMachineNewerBtn.id = "plus year"
  1123. timeMachineNewerBtn.innerHTML = "+";
  1124. timeMachineNewerBtn.style =
  1125. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1126. document.body.appendChild(timeMachineNewerBtn);
  1127. timeMachineNewerBtn.addEventListener("click", () => {
  1128. if (timeMachineBtn.index < timeMachineBtn.list.length - 1 && !timeMachineBtn.plusminusLock) {
  1129. timeMachineBtn.index = timeMachineBtn.index + 1;
  1130. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  1131. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1132. // console.log(timeMachineBtn.index)
  1133. }
  1134. GenBtnColor();
  1135.  
  1136. });
  1137.  
  1138. var timeMachineOlderBtn = document.createElement("Button");
  1139. timeMachineOlderBtn.classList.add("unity-btn");
  1140. timeMachineOlderBtn.id = "minus year"
  1141. timeMachineOlderBtn.innerHTML = "-";
  1142. timeMachineOlderBtn.style =
  1143. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1144. document.body.appendChild(timeMachineOlderBtn);
  1145. timeMachineOlderBtn.addEventListener("click", () => {
  1146. if (timeMachineBtn.index > 0 && !timeMachineBtn.plusminusLock) {
  1147. timeMachineBtn.index = timeMachineBtn.index - 1;
  1148. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  1149. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1150. // console.log(timeMachineBtn.index)
  1151. }
  1152. GenBtnColor();
  1153. });
  1154.  
  1155. function svCheck2(data, status) {
  1156. let l = []
  1157. if (status === 'OK') {
  1158. // console.log("OK for " + data.location.latLng + " at ID " + data.location.pano);
  1159. // console.log(data.time)
  1160. for (const alt of data.time) {
  1161. let date = Object.values(alt).find((value) => value instanceof Date)
  1162.  
  1163. l.push([alt.pano, date.toDateString()]);
  1164. }
  1165. // console.log(l);
  1166. timeMachineBtn.list = l
  1167. timeMachineBtn.index = l.length - 1;
  1168. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1169. GenBtnColor();
  1170. timeMachineBtn.plusminusLock = false;
  1171. // timeMachineOlderBtn.click()
  1172. // timeMachineBtn.innerHTML = "Default Date";
  1173. }
  1174. }
  1175.  
  1176. var timeMachineBtn = document.createElement("Button");
  1177. timeMachineBtn.classList.add("unity-btn");
  1178. timeMachineBtn.id = "Date Button";
  1179. timeMachineBtn.plusminusLock = true;
  1180. timeMachineBtn.panoId = 0;
  1181. timeMachineBtn.index = -1;
  1182. timeMachineBtn.list = [];
  1183. timeMachineBtn.innerHTML = "Time Machine";
  1184. timeMachineBtn.style =
  1185. "visibility:hidden;width:10em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1186. document.body.appendChild(timeMachineBtn);
  1187. timeMachineBtn.addEventListener("click", () => {
  1188. // console.log(timeMachineBtn.index)
  1189. if (timeMachineBtn.panoId != 0)
  1190. {
  1191. if(timeMachineBtn.index == -1)
  1192. {
  1193. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  1194. }
  1195. else
  1196. {
  1197. timeMachineBtn.index = timeMachineBtn.list.length - 1;
  1198. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  1199. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1200. GenBtnColor();
  1201. }
  1202. }
  1203. else
  1204. {
  1205. timeMachineBtn.panoId = GooglePlayer.pano;
  1206. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  1207. }
  1208. });
  1209.  
  1210. // Battle Royale UI optimization
  1211.  
  1212. let hide = true;
  1213.  
  1214. var MinimapBtn = document.createElement("Button");
  1215. MinimapBtn.classList.add("unity-btn");
  1216. MinimapBtn.id = "Minimap Button";
  1217. MinimapBtn.innerHTML = "Minimap Style";
  1218. MinimapBtn.current = "Default";
  1219. MinimapBtn.childVisible = false;
  1220. MinimapBtn.style =
  1221. "visibility:hidden;width:7.25em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1222. document.body.appendChild(MinimapBtn);
  1223. MinimapBtn.addEventListener("click", () => {
  1224. if (MinimapBtn.childVisible)
  1225. {
  1226. for (let element of document.getElementsByClassName("preset-minimap")){
  1227. element.style.visibility="hidden";
  1228. }
  1229. MinimapBtn.childVisible = false;
  1230. }
  1231. else
  1232. {
  1233. for (let element of document.getElementsByClassName("preset-minimap")){
  1234. element.style.visibility="";
  1235. }
  1236. MinimapBtn.childVisible = true;
  1237. }
  1238.  
  1239. });
  1240.  
  1241.  
  1242. let HeightCount = 0
  1243. for (let a of presetMinimap)
  1244. {
  1245. let aButton = document.createElement("Button");
  1246. aButton.id = a[1];
  1247. aButton.classList.add("preset-minimap");
  1248. aButton.classList.add("unity-btn");
  1249. aButton.innerHTML = a[1];
  1250. aButton.style =
  1251. "visibility:hidden;width:7.25em;height:1.5em;position:absolute;z-index:99999;background-color: orange;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1252. document.body.appendChild(aButton);
  1253. HeightCount++;
  1254. }
  1255.  
  1256. var OverlayBtn = document.createElement("Button");
  1257. OverlayBtn.classList.add("unity-btn");
  1258. OverlayBtn.id = "Overlay Button";
  1259. OverlayBtn.innerHTML = "Overlay";
  1260. OverlayBtn.current = "Clear";
  1261. OverlayBtn.childVisible = false;
  1262. OverlayBtn.style =
  1263. "visibility:hidden;width:7.25em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1264. document.body.appendChild(OverlayBtn);
  1265.  
  1266. OverlayBtn.addEventListener("click", () => {
  1267. if (OverlayBtn.childVisible)
  1268. {
  1269. for (let element of document.getElementsByClassName("overlay-minimap")){
  1270. element.style.visibility = "hidden";
  1271. }
  1272. OverlayBtn.childVisible = false;
  1273. }
  1274. else
  1275. {
  1276. for (let element of document.getElementsByClassName("overlay-minimap")){
  1277. element.style.visibility = "";
  1278. }
  1279. OverlayBtn.childVisible = true;
  1280. }
  1281.  
  1282. });
  1283.  
  1284. let HeightCount2 = 0
  1285. for (let b of presetOverlay)
  1286. {
  1287. let bButton = document.createElement("Button");
  1288. bButton.id = b[0];
  1289. bButton.url = b[1];
  1290. bButton.loaded = false;
  1291. bButton.classList.add("overlay-minimap");
  1292. bButton.classList.add("unity-btn");
  1293. bButton.innerHTML = b[0];
  1294. bButton.style =
  1295. "visibility:hidden;width:7.25em;height:1.5em;position:absolute;z-index:99999;background-color: orange;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1296. if (bButton.id == "Clear")
  1297. {
  1298. bButton.loaded = true;
  1299. bButton.style.background = "#ff6600";
  1300. }
  1301. document.body.appendChild(bButton);
  1302. HeightCount2++;
  1303. }
  1304.  
  1305. var HelpBtn = document.createElement("Button");
  1306. HelpBtn.classList.add("unity-btn");
  1307. HelpBtn.id = "Help Button";
  1308. HelpBtn.innerHTML = "Script Help";
  1309. HelpBtn.style =
  1310. "visibility:hidden;width:6em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1311. document.body.appendChild(HelpBtn);
  1312. HelpBtn.addEventListener("click", () => {
  1313. window.open('https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing');
  1314. });
  1315.  
  1316. var TeleportArisBtn = document.createElement("Button");
  1317. TeleportArisBtn.classList.add("unity-btn");
  1318. TeleportArisBtn.id = "Teleport Options Button";
  1319. TeleportArisBtn.innerHTML = "Default";
  1320. TeleportArisBtn.style =
  1321. "visibility:hidden;width:5.5em;height:2em;position:absolute;z-index:99999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1322. document.body.appendChild(TeleportArisBtn);
  1323. TeleportArisBtn.addEventListener("click", () => {
  1324. if (teleportBtn.teleType == "default")
  1325. {
  1326. teleportBtn.teleType = "outdoor"
  1327. TeleportArisBtn.innerHTML = "Official";
  1328. }
  1329. else
  1330. {
  1331. teleportBtn.teleType = "default"
  1332. TeleportArisBtn.innerHTML = "Default";
  1333. }
  1334. });
  1335.  
  1336. var playYoutubeBtn = document.createElement("Button");
  1337. playYoutubeBtn.classList.add("unity-btn");
  1338. playYoutubeBtn.id = "Youtube Button";
  1339. playYoutubeBtn.innerHTML = "Play video";
  1340. playYoutubeBtn.style =
  1341. "visibility:hidden;width:6em;height:4.5em;position:absolute;z-index:999999;background-color: #4CAF50;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1342. document.body.appendChild(playYoutubeBtn);
  1343. playYoutubeBtn.addEventListener("click", () => {
  1344. let iframe = document.getElementById("i_container");
  1345. iframe.allow = "autoplay";
  1346. let srcString = "https://www.youtube.com/embed/" + yId + "?&playlist=" + yId + "&autoplay=1&modestbranding=1&controls=0&start=";
  1347. if (yTime == "0" && yEnd == "0")
  1348. {
  1349. }
  1350. else
  1351. {
  1352. srcString += yTime + "&end=" + yEnd;
  1353. }
  1354. iframe.src = srcString;
  1355. iframe.style.visibility = "";
  1356. playYoutubeBtn.innerHTML = "Play video from start";
  1357. });
  1358.  
  1359.  
  1360. console.log("Buttons Loaded");
  1361. }
  1362.  
  1363. function GenBtnColor()
  1364. {
  1365. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1366. if (timeMachineBtn.index == timeMachineBtn.list.length - 1)
  1367. {
  1368. timeMachineNewerBtn.style.backgroundColor = "red";
  1369. timeMachineNewerBtn.disabled = true;
  1370. }
  1371. else
  1372. {
  1373. timeMachineNewerBtn.style.backgroundColor = "#4CAF50";
  1374. timeMachineNewerBtn.disabled = false;
  1375. }
  1376. if (timeMachineBtn.index == 0)
  1377. {
  1378. timeMachineOlderBtn.style.backgroundColor = "red";
  1379. timeMachineOlderBtn.disabled = true;
  1380. }
  1381. else
  1382. {
  1383. timeMachineOlderBtn.style.backgroundColor = "#4CAF50";
  1384. timeMachineOlderBtn.disabled = false;
  1385. }
  1386. }
  1387.  
  1388. /**
  1389. * Handle Keyboard inputs
  1390. */
  1391.  
  1392. function kBoard()
  1393. {
  1394. document.addEventListener('keydown', logKey);
  1395. }
  1396.  
  1397. function logKey(e) {
  1398. // console.log(e.code);
  1399. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1400. if (e.code == "Space")
  1401. {
  1402. setHidden(true);
  1403. }
  1404. if (e.code == "Digit3")
  1405. {
  1406. teleportBtn.click();
  1407. }
  1408. else if (e.code == "Digit4")
  1409. {
  1410. timeMachineOlderBtn.click();
  1411. }
  1412. else if (e.code == "Digit5")
  1413. {
  1414. timeMachineBtn.click();
  1415. }
  1416. else if (e.code == "Digit6")
  1417. {
  1418. timeMachineNewerBtn.click();
  1419. }
  1420. else if (e.code == "Digit7")
  1421. {
  1422. if (mainMenuBtn.style.visibility == "hidden")
  1423. {
  1424. mainMenuBtn.style.visibility = "";
  1425. }
  1426. else
  1427. {
  1428. mainMenuBtn.style.visibility = "hidden";
  1429. }
  1430. }
  1431. }
  1432.  
  1433.  
  1434. /**
  1435. * Hide or reveal the buttons, and disable buttons if such feature is not available
  1436. */
  1437.  
  1438. function setHidden(cond)
  1439. {
  1440. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1441. if (cond)
  1442. {
  1443. if (mainMenuBtn != null)
  1444. {
  1445. if (teleportBtn != null)
  1446. {
  1447. for (let element of document.getElementsByClassName("unity-btn")){
  1448. element.style.visibility = "hidden";
  1449. }
  1450. }
  1451. let iframe = document.getElementById("i_container");
  1452. if (iframe != null)
  1453. {
  1454. if (!isBattleRoyale)
  1455. {
  1456. iframe.src = ""
  1457. }
  1458. else
  1459. {
  1460. // TODO
  1461. }
  1462. }
  1463. }
  1464. }
  1465. else
  1466. {
  1467. if (mainMenuBtn != null)
  1468. {
  1469. mainMenuBtn.style.visibility = "";
  1470. }
  1471. }
  1472. }
  1473.  
  1474. function setDisable(cond) {
  1475. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1476. if (teleportBtn != null) {
  1477. if (cond == "NMPZ") {
  1478. teleportMoreBtn.style.backgroundColor = "red";
  1479. teleportMoreBtn.disabled = true;
  1480. teleportLessBtn.style.backgroundColor = "red";
  1481. teleportLessBtn.disabled = true;
  1482. teleportDistResetBtn.style.backgroundColor = "red";
  1483. teleportDistResetBtn.disabled = true;
  1484. if (nextPlayer == "Kakao")
  1485. {
  1486. switchCovergeButton.style.backgroundColor = "#4CAF50";
  1487. switchCovergeButton.disabled = false;
  1488. }
  1489. else
  1490. {
  1491. switchCovergeButton.style.backgroundColor = "red";
  1492. switchCovergeButton.disabled = true;
  1493. }
  1494. teleportBtn.disabled = true;
  1495. teleportBtn.style.backgroundColor = "red";
  1496. TeleportArisBtn.style.backgroundColor = "red";
  1497. TeleportArisBtn.disabled = true;
  1498. timeMachineBtn.style.backgroundColor = "#4CAF50";
  1499. timeMachineBtn.disabled = false;
  1500. }
  1501. else if (cond == "Google") {
  1502. teleportMoreBtn.style.backgroundColor = "#4CAF50";
  1503. teleportMoreBtn.disabled = false;
  1504. teleportLessBtn.style.backgroundColor = "#4CAF50";
  1505. teleportLessBtn.disabled = false;
  1506. teleportDistResetBtn.style.backgroundColor = "#4CAF50";
  1507. teleportDistResetBtn.disabled = false;
  1508. switchCovergeButton.style.backgroundColor = "#4CAF50";
  1509. switchCovergeButton.disabled = false;
  1510. teleportBtn.disabled = false;
  1511. teleportBtn.style.backgroundColor = "#4CAF50";
  1512. TeleportArisBtn.disabled = false;
  1513. TeleportArisBtn.style.backgroundColor = "#4CAF50";
  1514. timeMachineBtn.style.backgroundColor = "#4CAF50";
  1515. timeMachineBtn.disabled = false;
  1516. }
  1517. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  1518. teleportMoreBtn.style.backgroundColor = "red";
  1519. teleportMoreBtn.disabled = true;
  1520. teleportLessBtn.style.backgroundColor = "red";
  1521. teleportLessBtn.disabled = true;
  1522. teleportDistResetBtn.style.backgroundColor = "red";
  1523. teleportDistResetBtn.disabled = true;
  1524. switchCovergeButton.style.backgroundColor = "#4CAF50";
  1525. switchCovergeButton.disabled = false;
  1526. teleportBtn.disabled = true;
  1527. teleportBtn.style.backgroundColor = "red";
  1528. TeleportArisBtn.style.backgroundColor = "red";
  1529. TeleportArisBtn.disabled = true;
  1530. timeMachineBtn.style.backgroundColor = "red";
  1531. timeMachineBtn.disabled = true;
  1532. }
  1533. else if (cond == "Kakao" || cond == "Yandex" || cond == "Mapillary") {
  1534. teleportMoreBtn.style.backgroundColor = "#4CAF50";
  1535. teleportMoreBtn.disabled = false;
  1536. teleportLessBtn.style.backgroundColor = "#4CAF50";
  1537. teleportLessBtn.disabled = false;
  1538. teleportDistResetBtn.style.backgroundColor = "#4CAF50";
  1539. teleportDistResetBtn.disabled = false;
  1540. switchCovergeButton.style.backgroundColor = "#4CAF50";
  1541. switchCovergeButton.disabled = false;
  1542. teleportBtn.disabled = false;
  1543. teleportBtn.style.backgroundColor = "#4CAF50";
  1544. TeleportArisBtn.disabled = false;
  1545. TeleportArisBtn.style.backgroundColor = "#4CAF50";
  1546. timeMachineBtn.style.backgroundColor = "red";
  1547. timeMachineBtn.disabled = true;
  1548. }
  1549. timeMachineNewerBtn.style.backgroundColor = "red";
  1550. timeMachineNewerBtn.disabled = true;
  1551. timeMachineOlderBtn.style.backgroundColor = "red";
  1552. timeMachineOlderBtn.disabled = true;
  1553. }
  1554. }
  1555.  
  1556.  
  1557. /**
  1558. * This observer stays alive while the script is running
  1559. */
  1560.  
  1561. function launchObserver() {
  1562. UnityInitiate();
  1563. BYKTeleport();
  1564. SyncListener();
  1565. kBoard();
  1566. console.log("Main Observer");
  1567. const OBSERVER = new MutationObserver((mutations, observer) => {
  1568. detectGamePage();
  1569. });
  1570. observerCallback(OBSERVER)
  1571. }
  1572. function observerCallback(obs)
  1573. {
  1574. if (obs)
  1575. {
  1576. obs.observe(document.head, { attributes: true, childList: true, subtree: true });
  1577. }
  1578. else
  1579. {
  1580. setTimeout(observerCallback, 250);
  1581. }
  1582. }
  1583.  
  1584. /**
  1585. * Once the Google Maps API was loaded we can do more stuff
  1586. */
  1587.  
  1588. window.addEventListener('DOMContentLoaded', (event) => {
  1589. injecter(() => {
  1590. launchObserver();
  1591. })
  1592. });
  1593.  
  1594.  
  1595.  
  1596. /**
  1597. * Check whether the current page is a game, if so which game mode
  1598. */
  1599.  
  1600. function detectGamePage() {
  1601. if (document.querySelector(".game-layout__panorama-message") !== null && !one_reset)
  1602. {
  1603. one_reset = true;
  1604. console.log("Hide fail to load panorama canvas");
  1605. document.querySelector(".game-layout__panorama-message").style.visibility = "hidden";
  1606. }
  1607. function loadModule()
  1608. {
  1609. if (toLoad) {
  1610. initializeCanvas();
  1611. }
  1612. waitLoad();
  1613. }
  1614. let toLoad = !playerLoaded && !YandexPlayer && !KakaoPlayer && !MapillaryPlayer && !YANDEX_INJECTED && !KAKAO_INJECTED && !MAPILLARY_INJECTED
  1615. const PATHNAME = window.location.pathname;
  1616. if (PATHNAME.startsWith("/game/") || PATHNAME.startsWith("/challenge/")) {
  1617. // console.log("Game page");
  1618. isBattleRoyale = false;
  1619. isDuel = false;
  1620. loadModule();
  1621. }
  1622. else if (PATHNAME.startsWith("/battle-royale/")) {
  1623. if (document.querySelector(".br-game-layout") == null) {
  1624. // console.log("Battle Royale Lobby");
  1625. rstValues();
  1626. }
  1627. else {
  1628. // console.log("Battle Royale");
  1629. isBattleRoyale = true;
  1630. isDuel = false;
  1631. loadModule();
  1632. }
  1633. }
  1634. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  1635. if (document.querySelector(".game_layout__TO_jf") == null) {
  1636. // console.log("Battle Royale Lobby");
  1637. rstValues();
  1638. }
  1639. else {
  1640. // console.log("Duels");
  1641. isBattleRoyale = true;
  1642. isDuel = true;
  1643. loadModule();
  1644. }
  1645. }
  1646. else {
  1647. rstValues();
  1648. //console.log("Not a Game page");
  1649. }
  1650. }
  1651.  
  1652. function rstValues()
  1653. {
  1654. ROUND = 0;
  1655. YandexPlayer = null;
  1656. KakaoPlayer = null;
  1657. MapillaryPlayer = null;
  1658.  
  1659. BAIDU_INJECTED = false;
  1660. YANDEX_INJECTED = false;
  1661. KAKAO_INJECTED = false;
  1662. MAPILLARY_INJECTED = false;
  1663.  
  1664. nextPlayer = "Google"
  1665. global_lat = 0;
  1666. global_lng = 0;
  1667. global_panoID = null;
  1668. global_BDAh = null;
  1669. global_BDBh = null;
  1670. global_BDID = null;
  1671. yId = null;
  1672. yTime = null;
  1673. yEnd = null;
  1674. iId = null;
  1675.  
  1676. COMPASS = null;
  1677. eventListenerAttached = false;
  1678. povListenerAttached = false;
  1679. playerLoaded = false;
  1680. locHistory = [];
  1681. one_reset = false;
  1682. setHidden(true);
  1683. yandex_map = false;
  1684. Kakao_map = false;
  1685. mmKey = 0;
  1686. CURRENT_ROUND_DATA = null;
  1687.  
  1688. linksList = [];
  1689. }
  1690.  
  1691. /**
  1692. * Wait for various players to load
  1693. */
  1694.  
  1695. function waitLoad() {
  1696. if (!YandexPlayer || !KakaoPlayer || !MapillaryPlayer || !YANDEX_INJECTED || !KAKAO_INJECTED || !MAPILLARY_INJECTED) {
  1697. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1698. if (document.querySelector(".br-game-layout__panorama-canvas") != null)
  1699. {
  1700. AdjustBtnPos("-6em + 2px", "300px");
  1701. }
  1702. else if (document.querySelector(".game-panorama_panorama__rdhFg") != null)
  1703. {
  1704. AdjustBtnPos("2em", "0em");
  1705. }
  1706. else
  1707. {
  1708. AdjustBtnPos("0em", "0em");
  1709. }
  1710. setTimeout(waitLoad, 250);
  1711. } else {
  1712. checkRound();
  1713. }
  1714. }
  1715.  
  1716. /**
  1717. * Checks for round changes
  1718. */
  1719.  
  1720. function checkRound() {
  1721. // console.log("Check Round");
  1722. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1723.  
  1724. if (!isBattleRoyale) {
  1725. // console.log("Check Round");
  1726. let currentRound = getRoundFromPage();
  1727. if (ROUND != currentRound) {
  1728. fire1 = true;
  1729. switchCovergeButton.init = true;
  1730. console.log("New round");
  1731. ROUND = currentRound;
  1732. // NEW_ROUND_LOADED = true;
  1733. COMPASS = null;
  1734. locHistory = [];
  1735. one_reset = false;
  1736. getMapData();
  1737. nextButtonCallback();
  1738. }
  1739. }
  1740. else {
  1741. getMapData();
  1742. }
  1743. }
  1744.  
  1745. /**
  1746. * Add listeners if buttons have been created
  1747. */
  1748.  
  1749. function finalDetail()
  1750. {
  1751. let target = document.querySelector("a[data-qa='play-same-map']");
  1752. if (target)
  1753. {
  1754. var div = document.createElement("div");
  1755. div.classList.add("buttons_buttons__0B3SB")
  1756. document.querySelector('.result-layout_content__jAHfP').appendChild(div);
  1757. for (var rd of linksList)
  1758. {
  1759. console.log(rd)
  1760. let cl = target.cloneNode( true );
  1761. let tx = "View R" + rd[0] + " in " + rd[1];
  1762. cl.querySelector('.button_label__kpJrA').innerHTML = tx;
  1763. cl.removeAttribute('data-qa');
  1764. cl.removeAttribute('href');
  1765. cl.urlStr = rd[2];
  1766. cl.addEventListener("click", (e) => {
  1767. window.open(cl.urlStr);
  1768. })
  1769. cl.style = "top:10px;right:-10px;";
  1770. div.appendChild(cl);
  1771. }
  1772. }
  1773. else
  1774. {
  1775. setTimeout(finalDetail, 500);
  1776. }
  1777. }
  1778.  
  1779. function nextButtonCallback()
  1780. {
  1781. let nextButton = document.querySelector("button[data-qa='close-round-result']");
  1782. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1783. if (nextButton != null && fire1)
  1784. {
  1785. fire1 = false;
  1786. nextButton.addEventListener("click", (e) => {
  1787. if (mainMenuBtn != null && !cn_tips && ROUND !== 5)
  1788. {
  1789. // console.log("try to show show buttons")
  1790. mainMenuBtn.style.visibility = "";
  1791. }
  1792. if (ROUND == 5)
  1793. {
  1794. console.log("Game Finished")
  1795. if (linksList)
  1796. {
  1797. finalDetail();
  1798. }
  1799. }
  1800. })
  1801. let urlStr = ""
  1802.  
  1803. if (nextPlayer !== "Google")
  1804. {
  1805. console.log("Clone buttons");
  1806. let clone = document.querySelector("button[data-qa='close-round-result']").cloneNode( true );
  1807. let tx = "View Location in " + nextPlayer;
  1808. clone.querySelector('.button_label__kpJrA').innerHTML = tx;
  1809. clone.setAttribute('id', "LinkBtn");
  1810. clone.removeAttribute('data-qa');
  1811. if (nextPlayer == "Baidu")
  1812. {
  1813. urlStr = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  1814. }
  1815. else if (nextPlayer == "Youtube")
  1816. {
  1817. urlStr = "https://www.youtube.com/watch?v=" + yId;
  1818. }
  1819. else if (nextPlayer == "Image")
  1820. {
  1821. urlStr = iId;
  1822. }
  1823. else if (nextPlayer == "Kakao")
  1824. {
  1825. urlStr = "https://map.kakao.com/link/roadview/" + global_lat + "," + global_lng;
  1826. }
  1827. else if (nextPlayer == "Mapillary")
  1828. {
  1829. urlStr = "https://www.mapillary.com/app/?pKey=" + mmKey + "&focus=photo";
  1830. }
  1831. else if (nextPlayer == "Yandex")
  1832. {
  1833. urlStr = "https://yandex.com/maps/?&panorama%5Bdirection%5D=16%2C0&panorama%5Bpoint%5D=" + global_lng + "%2C" + global_lat;
  1834. }
  1835. clone.addEventListener("click", (e) => {
  1836. window.open(urlStr);
  1837. })
  1838. if (ROUND == 5)
  1839. {
  1840. clone.style = "top:10px;";
  1841. }
  1842. else
  1843. {
  1844. clone.style = "right:-10px;";
  1845. }
  1846. linksList.push([ROUND, nextPlayer, urlStr]);
  1847. document.querySelector('.round-result_actions__5j26U').appendChild(clone);
  1848. }
  1849. }
  1850. else
  1851. {
  1852. setTimeout(nextButtonCallback, 500);
  1853. }
  1854. }
  1855.  
  1856. function guessButtonCallback()
  1857. {
  1858. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1859. let guessButton = document.querySelector("button[data-qa='perform-guess']");
  1860. if (guessButton != null)
  1861. {
  1862.  
  1863. guessButton.addEventListener("click", (e) => {
  1864. if (mainMenuBtn != null)
  1865. {
  1866. console.log("try to hide show buttons")
  1867. mainMenuBtn.style.visibility = "hidden";
  1868. setHidden(true);
  1869. }
  1870. })
  1871. }
  1872. else
  1873. {
  1874. setTimeout(guessButtonCallback, 500);
  1875. }
  1876. }
  1877.  
  1878. /**
  1879. * Load different streetview players
  1880. */
  1881.  
  1882. function injectYandex()
  1883. {
  1884. injectYandexScript().then(() => {
  1885. console.log("Ready to inject Yandex player");
  1886. injectYandexPlayer();
  1887. }).catch((error) => {
  1888. console.log(error);
  1889. });
  1890. }
  1891.  
  1892. function loadPlayers() {
  1893. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1894. playerLoaded = true;
  1895. injectContainer();
  1896. if (!isBattleRoyale)
  1897. {
  1898.  
  1899. getSeed().then((data) => {
  1900. // console.log(data);
  1901. if (data.mapName.includes("A United World") || data.mapName.includes("Unity Showcase"))
  1902. {
  1903. console.log("Complete Map");
  1904. injectYandex();
  1905. injectKakaoScript().then(() => {
  1906. console.log("Ready to inject Kakao player");
  1907. }).catch((error) => {
  1908. console.log(error);
  1909. });
  1910. }
  1911. else
  1912. {
  1913. if (data.mapName.includes("Yandex"))
  1914. {
  1915. console.log("Yandex Map");
  1916. yandex_map = true;
  1917. injectYandex();
  1918. }
  1919. else
  1920. {
  1921. console.log("Not Yandex map");
  1922. YANDEX_INJECTED = true;
  1923. YandexPlayer = "YD";
  1924. }
  1925.  
  1926. if (data.mapName.includes("Kakao"))
  1927. {
  1928. console.log("Kakao Map");
  1929. Kakao_map = true;
  1930. injectKakaoScript().then(() => {
  1931. console.log("Ready to inject Kakao player");
  1932. }).catch((error) => {
  1933. console.log(error);
  1934. });
  1935. }
  1936. else{
  1937. KAKAO_INJECTED = true;
  1938. KakaoPlayer = "KK";
  1939. console.log("Not Kakao map");
  1940. }
  1941. if (!data.mapName.includes("China Tips for each province"))
  1942. {
  1943. cn_tips = false;
  1944. mainMenuBtn.style.visibility = "";
  1945. setHidden(false);
  1946. }
  1947. else
  1948. {
  1949. cn_tips = true;
  1950. guaranteeUI();
  1951. }
  1952. }
  1953.  
  1954. }).catch((error) => {
  1955. console.log(error);
  1956. });
  1957. }
  1958. else
  1959. {
  1960. if (BR_LOAD_YANDEX)
  1961. {
  1962. console.log("BR load Yandex");
  1963. injectYandex();
  1964. }
  1965. else
  1966. {
  1967. console.log("BR not load Yandex");
  1968. YANDEX_INJECTED = true;
  1969. YandexPlayer = "YD";
  1970. }
  1971.  
  1972. if (BR_LOAD_KAKAO)
  1973. {
  1974. console.log("BR load Kakao");
  1975. injectKakaoScript().then(() => {
  1976. console.log("Ready to inject Kakao player");
  1977. }).catch((error) => {
  1978. console.log(error);
  1979. });
  1980. }
  1981. else{
  1982. KAKAO_INJECTED = true;
  1983. KakaoPlayer = "KK";
  1984. console.log("BR not load Kakao");
  1985. }
  1986. // injectYandex();
  1987. // injectKakaoScript().then(() => {
  1988. // console.log("Ready to inject Kakao player");
  1989. // }).catch((error) => {
  1990. // console.log(error);
  1991. // });
  1992. }
  1993. }
  1994.  
  1995. function guaranteeUI()
  1996. {
  1997. // console.log("UI")
  1998. if (document.getElementById("GH-ui") !== null)
  1999. {
  2000. document.getElementById("GH-ui").style.display = "block";
  2001. }
  2002. else
  2003. {
  2004. setTimeout(guaranteeUI, 500);
  2005. }
  2006. }
  2007.  
  2008. /**
  2009. * Handles Return to start and undo
  2010. */
  2011.  
  2012. function handleReturnToStart() {
  2013. let rtsButton = document.querySelector("button[data-qa='return-to-start']");
  2014. if (rtsButton != null) {
  2015. console.log("handleReturnToStart listener attached");
  2016. rtsButton.addEventListener("click", (e) => {
  2017. if (nextPlayer != "Baidu")
  2018. {
  2019. goToLocation();
  2020. }
  2021. else
  2022. {
  2023. document.getElementById("i_container").src = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  2024. }
  2025. const elementClicked = e.target;
  2026. elementClicked.setAttribute('listener', 'true');
  2027. console.log("Return to start");
  2028. });
  2029. guessButtonCallback();
  2030. setTimeout(function () {goToLocation();}, 1000);
  2031. }
  2032. else
  2033. {
  2034. setTimeout(handleReturnToStart, 500);
  2035. }
  2036. }
  2037.  
  2038. function handleUndo() {
  2039. let undoButton = document.querySelector("button[data-qa='undo-move']");
  2040. if (undoButton != null)
  2041. {
  2042. console.log("Attach undo");
  2043. undoButton.addEventListener("click", (e) => {
  2044. if (locHistory.length > 0) {
  2045. goToUndoMove();
  2046. console.log("Undo Move");
  2047. }
  2048. })
  2049. }
  2050. else
  2051. {
  2052. setTimeout(handleUndo, 500);
  2053. }
  2054. }
  2055.  
  2056. /**
  2057. * Load game information
  2058. */
  2059.  
  2060. function getMapData() {
  2061. // myHighlight("Seed data");
  2062. getSeed().then((data) => {
  2063. // myHighlight("Seed data");
  2064. // console.log(data);
  2065. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2066. if (isBattleRoyale) {
  2067. if ((document.querySelector(".br-game-layout") == null && document.querySelector(".version3-in-game_layout__Hi_Iw") == null) || typeof data.gameId == typeof undefined) {
  2068. // console.log("Battle Royale Lobby");
  2069. }
  2070. else
  2071. {
  2072. let origin = false;
  2073. if (!CURRENT_ROUND_DATA) {
  2074. CURRENT_ROUND_DATA = data
  2075. origin = true;
  2076. }
  2077.  
  2078. if (origin || !(data.currentRoundNumber === CURRENT_ROUND_DATA.currentRoundNumber)) {
  2079. // myHighlight("Battle Royale New round");
  2080. switchCovergeButton.init = true;
  2081. // NEW_ROUND_LOADED = true;
  2082. COMPASS = null;
  2083. locHistory = [];
  2084. one_reset = false;
  2085. setHidden(false);
  2086. if (!origin) {
  2087. CURRENT_ROUND_DATA = data;
  2088. }
  2089. locationCheck(data);
  2090. // console.log(data);
  2091. if (data.currentRoundNumber == 1)
  2092. {
  2093. setTimeout(function () {goToLocation();}, 3000);
  2094. }
  2095. else
  2096. {
  2097. goToLocation();
  2098. }
  2099. handleReturnToStart();
  2100. if (isDuel)
  2101. {
  2102. handleUndo();
  2103. hideButtons();
  2104. }
  2105. handleMinimapCallback();
  2106.  
  2107. }
  2108. }
  2109. }
  2110. else {
  2111. if (!cn_tips)
  2112. {
  2113. mainMenuBtn.style.visibility = "";
  2114. }
  2115. else
  2116. {
  2117. mainMenuBtn.style.visibility = "hidden";
  2118. AdjustBtnPos("14em", "0em");
  2119. }
  2120. locationCheck(data);
  2121. if (data.currentRoundNumber == 1)
  2122. {
  2123. setTimeout(function () {goToLocation();}, 3000);
  2124. }
  2125. else
  2126. {
  2127. goToLocation();
  2128. }
  2129. handleReturnToStart();
  2130. handleUndo();
  2131. hideButtons();
  2132. handleMinimapCallback();
  2133. }
  2134. }).catch((error) => {
  2135. console.log(error);
  2136. });
  2137. }
  2138.  
  2139. function handleMinimapCallback()
  2140. {
  2141. let trueCond = true;
  2142. let timeoutTime = 250;
  2143. if (isBattleRoyale) {
  2144. if (isDuel)
  2145. {
  2146. if (document.querySelector(".overlay_overlay__AR02x"))
  2147. {
  2148. trueCond = false;
  2149. }
  2150. else
  2151. {
  2152. trueCond = true;
  2153. }
  2154. }
  2155. else
  2156. {
  2157. if (document.querySelector(".popup__content"))
  2158. {
  2159. trueCond = false;
  2160. }
  2161. else
  2162. {
  2163. trueCond = true;
  2164. }
  2165. }
  2166. timeoutTime = 2500;
  2167. }
  2168.  
  2169. if (trueCond)
  2170. {
  2171. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2172. let cur = MinimapBtn.current;
  2173. console.log(cur)
  2174. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  2175. if (cur == mapDiv.id)
  2176. {
  2177. setTimeout(function () {mapDiv.click();}, 500);
  2178. setTimeout(function () {mapDiv.click();}, 1000);
  2179. setTimeout(function () {mapDiv.click();}, 3000);
  2180. }
  2181. }
  2182. }
  2183. else
  2184. {
  2185. setTimeout(handleMinimapCallback, 250);
  2186. }
  2187. }
  2188.  
  2189. /**
  2190. * Hide unnecessary buttons for non-Google coverages
  2191. */
  2192.  
  2193. function hideButtons() {
  2194. let CHECKPOINT = document.querySelector("button[data-qa='set-checkpoint']");
  2195. let ZOOM_IN = document.querySelector("button[data-qa='pano-zoom-in']");
  2196. let ZOOM_OUT = document.querySelector("button[data-qa='pano-zoom-out']");
  2197.  
  2198. if (CHECKPOINT != null)
  2199. {
  2200. if (nextPlayer === "Google") {
  2201.  
  2202. CHECKPOINT.style.visibility = "";
  2203. ZOOM_IN.style.visibility = "";
  2204. ZOOM_OUT.style.visibility = "";
  2205. console.log("Buttons Unhidden");
  2206.  
  2207. }
  2208. else {
  2209.  
  2210. CHECKPOINT.style.visibility = "hidden";
  2211. ZOOM_IN.style.visibility = "hidden";
  2212. ZOOM_OUT.style.visibility = "hidden";
  2213. console.log("Buttons Hidden");
  2214.  
  2215. }
  2216. }
  2217. else
  2218. {
  2219. setTimeout(hideButtons, 250);
  2220. }
  2221. }
  2222.  
  2223. /**
  2224. * Check which player to use for the next location
  2225. */
  2226.  
  2227. function locationCheck(data) {
  2228. // console.log(data);
  2229. let round;
  2230. if (isBattleRoyale) {
  2231. if (isDuel)
  2232. {
  2233. round = data.rounds[data.currentRoundNumber - 1].panorama;
  2234. }
  2235. else
  2236. {
  2237. round = data.rounds[data.currentRoundNumber - 1];
  2238. }
  2239. }
  2240. else {
  2241. round = data.rounds[data.round - 1];
  2242. }
  2243. global_lat = round.lat;
  2244. global_lng = round.lng;
  2245. global_panoID = round.panoId;
  2246. global_heading = round.heading;
  2247. global_pitch = round.pitch;
  2248. // console.log(global_lat);
  2249. // console.log(global_lng);
  2250. // console.log(krCoordinates);
  2251.  
  2252. nextPlayer = "Google";
  2253. // console.log(global_panoID)
  2254.  
  2255. if (Kakao_map)
  2256. {
  2257. nextPlayer = "Kakao";
  2258. }
  2259. else if (yandex_map)
  2260. {
  2261. nextPlayer = "Yandex";
  2262. }
  2263. else
  2264. {
  2265. if (global_panoID) {
  2266. let locInfo = hex2a(global_panoID);
  2267. // console.log(locInfo)
  2268. let mapType = locInfo.substring(0, 5);
  2269. if (mapType === "BDMAP") {
  2270. nextPlayer = "Baidu";
  2271. let coord = locInfo.substring(5);
  2272.  
  2273. if(coord.includes('BDAh'))
  2274. {
  2275. global_BDID = coord.split('BDAh')[0].replace("panoId","");
  2276. let tem = coord.split('BDAh')[1];
  2277. global_BDAh = tem.split('BDBh')[0];
  2278. global_BDBh = tem.split('BDBh')[1];
  2279. }
  2280. else
  2281. {
  2282. global_BDID = coord.replace("panoId","");
  2283. }
  2284. // console.log(global_BDID)
  2285. // console.log(global_BDAh)
  2286. // console.log(global_BDBh)
  2287. // global_lat = coord.split(",")[0];
  2288. // global_lng = coord.split(",")[1];
  2289. // console.log(global_lat);
  2290. }
  2291. else if (mapType === "MLMAP") {
  2292. nextPlayer = "Mapillary";
  2293. mmKey = locInfo.substring(5);
  2294. }
  2295. else if (mapType === "YDMAP" ) {
  2296. nextPlayer = "Yandex";
  2297. }
  2298. else if (mapType === "KKMAP" ) {
  2299. nextPlayer = "Kakao";
  2300. }
  2301. else if (mapType === "YTUBE" )
  2302. {
  2303. nextPlayer = "Youtube";
  2304. let fullID = locInfo.substring(5).split('START');
  2305. yId = fullID[0];
  2306. yTime = fullID[1].split('END')[0];
  2307. yEnd = fullID[1].split('END')[1];
  2308. }
  2309. else if (mapType === "IMAGE" )
  2310. {
  2311. nextPlayer = "Image";
  2312. iId = locInfo.substring(5);
  2313. }
  2314. }
  2315. }
  2316.  
  2317. // if ( krCoordinates[0] > global_lat && krCoordinates[2] < global_lat && krCoordinates[1] < global_lng && krCoordinates[3] > global_lng)
  2318. // {
  2319. // nextSecondaryPlayer = "Kakao";
  2320. // }
  2321. // else if (nextPlayer = "Mapillary")
  2322. // {
  2323. // nextSecondaryPlayer = "Google";
  2324. // }
  2325. // else
  2326. // {
  2327. // nextSecondaryPlayer = "Mapillary";
  2328. // }
  2329.  
  2330. // Disable buttons if NM, NMPZ
  2331.  
  2332. if(!isBattleRoyale)
  2333. {
  2334. if (data.forbidMoving || data.forbidRotating || data.forbidZooming)
  2335. {
  2336. setDisable("NMPZ");
  2337. }
  2338. else
  2339. {
  2340. setDisable(nextPlayer);
  2341. }
  2342. }
  2343. else
  2344. {
  2345. if (data.movementOptions.forbidMoving || data.movementOptions.forbidRotating || data.movementOptions.forbidZooming)
  2346. {
  2347. setDisable("NMPZ");
  2348. }
  2349. else
  2350. {
  2351. setDisable(nextPlayer);
  2352. }
  2353. }
  2354.  
  2355. console.log(nextPlayer);
  2356. injectCanvas();
  2357. }
  2358.  
  2359.  
  2360. /**
  2361. * setID for canvas
  2362. */
  2363.  
  2364. function initializeCanvas() {
  2365. let GAME_CANVAS = "";
  2366. let DUEL_CANVAS = "";
  2367. //console.log("Is duels");
  2368. //console.log(duels);
  2369.  
  2370. if (isBattleRoyale) {
  2371. if (isDuel) {
  2372. GAME_CANVAS = document.querySelector(".game-panorama_panorama__rdhFg");
  2373. DUEL_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__PNKve");
  2374. }
  2375. else
  2376. {
  2377. GAME_CANVAS = document.querySelector(".br-game-layout__panorama-wrapper");
  2378. DUEL_CANVAS = "dummy";
  2379. }
  2380. }
  2381. else {
  2382. GAME_CANVAS = document.querySelector(".game-layout__canvas");
  2383. DUEL_CANVAS = "dummy";
  2384. }
  2385. if (GAME_CANVAS && DUEL_CANVAS)
  2386. {
  2387. // console.log("Canvas injected");
  2388. GAME_CANVAS.id = "player";
  2389. if (isDuel) {
  2390. DUEL_CANVAS.id = "default_player";
  2391. }
  2392. loadPlayers();
  2393. injectMapillaryPlayer();
  2394. }
  2395. else
  2396. {
  2397. setTimeout(initializeCanvas, 250);
  2398. }
  2399.  
  2400. }
  2401.  
  2402. /**
  2403. * Hide or show players based on where the next location is
  2404. */
  2405.  
  2406. function injectCanvas() {
  2407. if (isDuel)
  2408. {
  2409. canvasSwitch();
  2410. }
  2411. else
  2412. {
  2413. Google();
  2414. Baidu();
  2415. Kakao();
  2416. Yandex();
  2417. Mapillary();
  2418. }
  2419. ZoomControls();
  2420. }
  2421.  
  2422. // for duels (class ID change)
  2423.  
  2424. function canvasSwitch()
  2425. {
  2426. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2427. if (document.querySelector(".compass") !== null && document.querySelector("button[data-qa='undo-move']") !== null)
  2428. {
  2429. let GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__PNKve");
  2430. if (BR_LOAD_YANDEX)
  2431. {
  2432. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  2433. }
  2434. if (nextPlayer === "Google") {
  2435. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  2436. document.getElementById("i_container").className = "inactive";
  2437. if (BR_LOAD_KAKAO)
  2438. {
  2439. document.getElementById("roadview").className = "inactive";
  2440. }
  2441. if (BR_LOAD_YANDEX)
  2442. {
  2443. document.querySelector(".ymaps-2-1-79-panorama-screen").style.visibility = "hidden";
  2444. }
  2445. teleportBtn.google = true;
  2446. switchCovergeButton.nextPlayer = "Google";
  2447. switchCovergeButton.useGoogle = true;
  2448. document.getElementById("default_player").style.position = "absolute";
  2449. document.querySelector(".compass").style.visibility = "";
  2450. document.querySelector("button[data-qa='undo-move']").visibility = "";
  2451. console.log("Google Duel Canvas loaded");
  2452. }
  2453. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image")
  2454. {
  2455. document.getElementById("default_player").className = "inactive";
  2456. document.getElementById("i_container").className = "game-panorama_panorama__rdhFg";
  2457. document.getElementById("mapillary-player").style.visibility = "hidden";
  2458. if (BR_LOAD_KAKAO)
  2459. {
  2460. document.getElementById("roadview").className = "inactive";
  2461. }
  2462. if (BR_LOAD_YANDEX)
  2463. {
  2464. document.querySelector(".ymaps-2-1-79-panorama-screen").style.visibility = "hidden";
  2465. }
  2466. teleportBtn.google = false;
  2467. switchCovergeButton.nextPlayer = "Baidu";
  2468. switchCovergeButton.useGoogle = false;
  2469. document.getElementById("i_container").style.position = "absolute";
  2470. document.querySelector(".compass").style.visibility = "hidden";
  2471. document.querySelector("button[data-qa='undo-move']").visibility = "hidden";
  2472. console.log("Container Duel Canvas loaded");
  2473. }
  2474. else if (nextPlayer === "Kakao")
  2475. {
  2476. document.getElementById("default_player").className = "inactive";
  2477. document.getElementById("i_container").className = "inactive";
  2478. document.getElementById("mapillary-player").style.visibility = "hidden";
  2479. if (BR_LOAD_KAKAO)
  2480. {
  2481. document.getElementById("roadview").className = "game-panorama_panorama__rdhFg";
  2482. }
  2483. if (BR_LOAD_YANDEX)
  2484. {
  2485. document.querySelector(".ymaps-2-1-79-panorama-screen").style.visibility = "hidden";
  2486. }
  2487. teleportBtn.google = false;
  2488. switchCovergeButton.nextPlayer = "Kakao";
  2489. switchCovergeButton.useGoogle = false;
  2490. document.getElementById("roadview").style.position = "absolute";
  2491. document.querySelector(".compass").style.visibility = "";
  2492. document.querySelector("button[data-qa='undo-move']").visibility = "";
  2493. console.log("Kakao Duel Canvas loaded");
  2494. }
  2495. else if (nextPlayer === "Yandex")
  2496. {
  2497. document.getElementById("default_player").className = "inactive";
  2498. document.getElementById("i_container").className = "inactive";
  2499. document.getElementById("mapillary-player").style.visibility = "hidden";
  2500. if (BR_LOAD_KAKAO)
  2501. {
  2502. document.getElementById("roadview").className = "inactive";
  2503. }
  2504. if (BR_LOAD_YANDEX)
  2505. {
  2506. document.querySelector(".ymaps-2-1-79-panorama-screen").style.visibility = "";
  2507. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  2508. }
  2509. teleportBtn.google = false;
  2510. switchCovergeButton.nextPlayer = "Yandex";
  2511. switchCovergeButton.useGoogle = false;
  2512. document.querySelector(".compass").style.visibility = "";
  2513. document.querySelector("button[data-qa='undo-move']").visibility = "";
  2514. console.log("Yandex Duel Canvas loaded");
  2515. }
  2516. else if (nextPlayer === "Mapillary")
  2517. {
  2518. document.getElementById("default_player").className = "inactive";
  2519. document.getElementById("i_container").className = "inactive";
  2520. if (BR_LOAD_KAKAO)
  2521. {
  2522. document.getElementById("roadview").className = "inactive";
  2523. }
  2524. if (BR_LOAD_YANDEX)
  2525. {
  2526. document.querySelector(".ymaps-2-1-79-panorama-screen").style.visibility = "hidden";
  2527. }
  2528. document.getElementById("mapillary-player").style.visibility = "";
  2529. teleportBtn.google = false;
  2530. switchCovergeButton.nextPlayer = "Mapillary";
  2531. switchCovergeButton.useGoogle = false;
  2532. document.getElementById("mapillary-player").style.position = "absolute";
  2533. document.querySelector(".compass").style.visibility = "hidden";
  2534. document.querySelector("button[data-qa='undo-move']").visibility = "";
  2535. console.log("Mapillary Duel Canvas loaded");
  2536. }
  2537. }
  2538. else
  2539. {
  2540. setTimeout(canvasSwitch, 250);
  2541. }
  2542. }
  2543.  
  2544. // for Battle Royale and classic (change visibility)
  2545.  
  2546. function Google() {
  2547. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2548. let GOOGLE_MAPS_CANVAS = ""
  2549. if (isBattleRoyale) {
  2550. GOOGLE_MAPS_CANVAS = document.querySelector(".br-game-layout__panorama-canvas");
  2551. }
  2552. else {
  2553. GOOGLE_MAPS_CANVAS = document.querySelector(".game-layout__panorama-canvas");
  2554. }
  2555. if (nextPlayer === "Google") {
  2556. GOOGLE_MAPS_CANVAS.style.visibility = "";
  2557. teleportBtn.google = true;
  2558. switchCovergeButton.nextPlayer = "Google";
  2559. switchCovergeButton.useGoogle = true;
  2560. console.log("Google Canvas loaded");
  2561. }
  2562. else {
  2563. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  2564. teleportBtn.google = false;
  2565. console.log("Google Canvas hidden");
  2566. }
  2567.  
  2568. }
  2569.  
  2570. function Baidu() {
  2571. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2572. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  2573. // console.log("Baidu canvas");
  2574. if (BAIDU_MAPS_CANVAS !== null && document.querySelector(".compass") !== null && document.querySelector("button[data-qa='undo-move']") !== null)
  2575. {
  2576. BAIDU_MAPS_CANVAS.style.position = "absolute";
  2577. if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  2578. BAIDU_MAPS_CANVAS.style.visibility = "";
  2579. switchCovergeButton.nextPlayer = "Baidu";
  2580. switchCovergeButton.useGoogle = false;
  2581. document.querySelector(".compass").style.visibility = "hidden";
  2582. document.querySelector("button[data-qa='undo-move']").style.visibility = "hidden";
  2583. console.log("Container Canvas loaded");
  2584. }
  2585. else {
  2586. document.querySelector(".compass").style.visibility = "";
  2587. document.querySelector("button[data-qa='undo-move']").style.visibility = "";
  2588. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  2589. console.log("Container Canvas hidden");
  2590. }
  2591. }
  2592. else
  2593. {
  2594. setTimeout(Baidu, 250);
  2595. }
  2596.  
  2597. }
  2598.  
  2599. function Kakao() {
  2600. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2601. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  2602. // console.log("Kakao canvas");
  2603. if (KAKAO_MAPS_CANVAS != null)
  2604. {
  2605. KAKAO_MAPS_CANVAS.style.position = "absolute";
  2606. if (nextPlayer === "Kakao") {
  2607. KAKAO_MAPS_CANVAS.style.visibility = "";
  2608. switchCovergeButton.nextPlayer = "Kakao";
  2609. switchCovergeButton.useGoogle = false;
  2610. console.log("Kakao Canvas loaded");
  2611. }
  2612. else {
  2613. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  2614. console.log("Kakao Canvas hidden");
  2615. }
  2616. }
  2617. else
  2618. {
  2619. setTimeout(Kakao, 250);
  2620. }
  2621.  
  2622. }
  2623.  
  2624. function Yandex() {
  2625. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2626. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  2627. if (YANDEX_MAPS_CANVAS != null)
  2628. {
  2629. // console.log("Yandex canvas");
  2630. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  2631. // console.log("Yandex canvas");
  2632. /* console.log(YANDEX_MAPS_CANVAS); */
  2633. if (nextPlayer === "Yandex") {
  2634. YANDEX_MAPS_CANVAS.style.visibility = "";
  2635. switchCovergeButton.nextPlayer = "Yandex";
  2636. switchCovergeButton.useGoogle = false;
  2637. console.log("Yandex Canvas loaded");
  2638. }
  2639. else {
  2640. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  2641. console.log("Yandex Canvas hidden");
  2642. }
  2643. }
  2644. else
  2645. {
  2646. setTimeout(Yandex, 250);
  2647. }
  2648.  
  2649. }
  2650.  
  2651. function Mapillary()
  2652. {
  2653. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2654. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  2655. if (MAPILLARY_MAPS_CANVAS != null)
  2656. {
  2657. // console.log("Mapillary canvas");
  2658. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  2659. if (nextPlayer === "Mapillary") {
  2660. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  2661. switchCovergeButton.nextPlayer = "Mapillary";
  2662. switchCovergeButton.useGoogle = false;
  2663. console.log("Mapillary Canvas loaded");
  2664. }
  2665. else {
  2666. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  2667. console.log("Mapillary Canvas hidden");
  2668. }
  2669. }
  2670. else
  2671. {
  2672. setTimeout(Mapillary, 250);
  2673. }
  2674.  
  2675. }
  2676.  
  2677. /**
  2678. * Adjust button placement
  2679. */
  2680.  
  2681. function ZoomControls() {
  2682. let style = `
  2683. .ymaps-2-1-79-panorama-gotoymaps {display: none !important;}
  2684. .game-layout__controls {bottom: 8rem !important; left: 1rem !important;}
  2685. `;
  2686.  
  2687. let style_element = document.createElement("style");
  2688. style_element.innerHTML = style;
  2689. document.body.appendChild(style_element);
  2690. }
  2691.  
  2692. /**
  2693. * Updates the compass to match Yandex Panorama facing
  2694. */
  2695. function updateCompass() {
  2696. if (!COMPASS) {
  2697. let compass = document.querySelector("img.compass__indicator");
  2698. if (compass != null) {
  2699. COMPASS = compass;
  2700. let direction = YandexPlayer.getDirection()[0] * -1;
  2701. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  2702. }
  2703. }
  2704. else {
  2705. let direction = YandexPlayer.getDirection()[0] * -1;
  2706. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  2707. }
  2708. }
  2709.  
  2710. /**
  2711. * Open next location in streetview player given next player and next coordinate
  2712. */
  2713.  
  2714. function goToLocation() {
  2715. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2716. console.log("Going to location");
  2717. if (nextPlayer === "Yandex") {
  2718. let options = {};
  2719. YandexPlayer.moveTo([global_lat, global_lng], options);
  2720. YandexPlayer.setDirection([0, 16]);
  2721. YandexPlayer.setSpan([10, 67]);
  2722. }
  2723. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  2724. if (document.getElementById("i_container") !== null)
  2725. {
  2726. let iframe = document.getElementById("i_container");
  2727. if (nextPlayer === "Baidu")
  2728. {
  2729. if (!isFirefox)
  2730. {
  2731. iframe.style.top = '-60px';
  2732. iframe.style.height = (window.innerHeight + 200) + 'px';
  2733. }
  2734. else
  2735. {
  2736. iframe.style.top = '-60px';
  2737. iframe.style.height = (window.innerHeight + 219) + 'px';
  2738. }
  2739.  
  2740. if (!isFirefox)
  2741. {
  2742. iframe.style.right = '-55px';
  2743. iframe.style.width = (window.innerWidth + 55) + 'px';
  2744. }
  2745. else
  2746. {
  2747. iframe.style.right = '-15px';
  2748. iframe.style.width = (window.innerWidth + 15) + 'px';
  2749. }
  2750. let urlStr2 = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  2751. let urlStr = "https://map.baidu.com/@" + global_BDAh + "," + global_BDBh + "#panoid=" + global_BDID + "&panotype=street&l=12&tn=B_NORMAL_MAP&sc=0&newmap=1&shareurl=1&pid=" + global_BDID;
  2752. // console.log(urlStr)
  2753. if (global_BDAh != null)
  2754. {
  2755. iframe.src = urlStr;
  2756. }
  2757. else
  2758. {
  2759. iframe.src = urlStr2;
  2760. }
  2761. iframe.style.visibility = "";
  2762. }
  2763. else if (nextPlayer === "Youtube")
  2764. {
  2765. document.getElementById("Youtube Button").style.visibility = "";
  2766. document.getElementById("Youtube Button").innerHTML = "Play video";
  2767. iframe.allow = "autoplay";
  2768. iframe.style.visibility = "hidden";
  2769. iframe.style.top = '-60px';
  2770. iframe.style.height = (window.innerHeight + 235) + 'px';
  2771. }
  2772. else if (nextPlayer === "Image")
  2773. {
  2774. iframe.style.top = '0px';
  2775. iframe.style.height = (window.innerHeight) + 'px';
  2776. iframe.style.visibility = "";
  2777. iframe.src = iId;
  2778. }
  2779. }
  2780. else
  2781. {
  2782. setTimeout(goToLocation, 250);
  2783. }
  2784. // let a = new BMap.Point(global_lng, global_lat);
  2785. // BaiduPlayer.setPov({ heading: -40, pitch: 6 });
  2786. // BaiduPlayer.setPosition(a);
  2787. }
  2788. else if (nextPlayer === "Kakao") {
  2789. var roadviewClient = new kakao.maps.RoadviewClient();
  2790. var position = new kakao.maps.LatLng(global_lat, global_lng);
  2791. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  2792. KakaoPlayer.setPanoId(panoId, position);
  2793. KakaoPlayer.setViewpoint({ pan: global_heading, tilt: global_pitch, zoom: -3 })
  2794. });
  2795. }
  2796. else if (nextPlayer === "Mapillary") {
  2797. MapillaryPlayer.moveTo(mmKey).then(
  2798. image => { //console.log(image);
  2799. },
  2800. error => { console.log(error); });
  2801. }
  2802. else if (nextPlayer === "Google") {
  2803. handleMapillary({lat: global_lat, lng: global_lng}, {meters: 500, limit: 500});
  2804. }
  2805. switchCovergeButton.lat = global_lat;
  2806. switchCovergeButton.lng = global_lng;
  2807. }
  2808.  
  2809. /**
  2810. * Handle undo using the location history of the current round
  2811. */
  2812.  
  2813. function goToUndoMove(data) {
  2814. /* console.log(global_lat);
  2815. console.log(global_lng); */
  2816. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2817. let options = {};
  2818. let prevStep = null;
  2819. if (locHistory.length === 1) {
  2820. prevStep = locHistory[0];
  2821. }
  2822. else {
  2823. prevStep = locHistory.pop();
  2824. }
  2825. // console.log(prevStep);
  2826. // console.log(locHistory)
  2827. if (nextPlayer === "Yandex") {
  2828. defaultPanoIdChange = false;
  2829. YandexPlayer.moveTo([prevStep[0], prevStep[1]], options);
  2830. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  2831. YandexPlayer.setSpan([10, 67]);
  2832. switchCovergeButton.lat = prevStep[0];
  2833. switchCovergeButton.lng = prevStep[1];
  2834. }
  2835. else if (nextPlayer === "Kakao") {
  2836. let btn = document.querySelector("button[data-qa='undo-move']");
  2837. btn.disabled = false;
  2838. btn.classList.remove('styles_disabled__W_k45');
  2839. defaultPanoIdChange = false;
  2840. let position = new kakao.maps.LatLng(prevStep[0], prevStep[1]);
  2841. KakaoPlayer.setPanoId(prevStep[2], position);
  2842. switchCovergeButton.lat = prevStep[0];
  2843. switchCovergeButton.lng = prevStep[1];
  2844. switchCovergeButton.useGoogle = false;
  2845. teleportBtn.google = false;
  2846. // console.log("Undo 1 step");
  2847. // console.log(locHistory);
  2848. }
  2849. else if (nextPlayer === "Mapillary" ) {
  2850. // console.log(prevStep[1]);
  2851.  
  2852. MapillaryPlayer.moveTo(prevStep[2]).then(
  2853. image => {
  2854. //console.log(image);
  2855. switchCovergeButton.lat = prevStep[1];
  2856. switchCovergeButton.lng = prevStep[0];
  2857. },
  2858. error => { console.log(error); });
  2859. }
  2860.  
  2861. }
  2862.  
  2863. function BYKTeleport()
  2864. {
  2865. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2866. let teleportBtnBYK = teleportBtn;
  2867. if (teleportBtnBYK)
  2868. {
  2869. teleportBtnBYK.addEventListener("click", () => {
  2870. if (!teleportBtnBYK.google)
  2871. {
  2872. // console.log("non-Google Teleport");
  2873. let prevStep = null;
  2874. if (locHistory.length === 1) {
  2875. prevStep = locHistory[0];
  2876. }
  2877. else {
  2878. prevStep = locHistory[locHistory.length - 1];
  2879. }
  2880. // console.log(prevStep);
  2881. let options = {};
  2882. let place, position, pID;
  2883. if (nextPlayer === "Yandex") {
  2884. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtnBYK.distance * 0.001);
  2885. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  2886. YandexPlayer.moveTo([place.lat, place.lng], options);
  2887. YandexPlayer.setSpan([10, 67]);
  2888. }
  2889. else if (nextPlayer === "Kakao") {
  2890. var roadviewClient = new kakao.maps.RoadviewClient();
  2891. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[3]), teleportBtnBYK.distance * 0.001);
  2892. position = new kakao.maps.LatLng(place.lat, place.lng);
  2893. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  2894. KakaoPlayer.setPanoId(panoId, position);
  2895. });
  2896. }
  2897. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  2898. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtnBYK.distance * 0.001);
  2899. handleMapillary(place, {meters: 500, limit: 500});
  2900. // locHistory.push([place.lat, place.lng, prevStep[2], prevStep[3]]);
  2901. }
  2902. switchCovergeButton.lat = place.lat;
  2903. switchCovergeButton.lng = place.lng;
  2904. if (teleportBtnBYK.distance > 150)
  2905. {
  2906. teleportBtnBYK.distance = 100;
  2907. teleportBtnBYK.innerHTML = "Teleport " + teleportBtnBYK.distance + " m";
  2908. }
  2909. }
  2910. });
  2911. }
  2912. else
  2913. {
  2914. }
  2915. }
  2916.  
  2917. function SyncListener()
  2918. {
  2919. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2920. switchCovergeButton.addEventListener("click", () => {
  2921. if (switchCovergeButton.useGoogle == false) {
  2922. // switchCovergeButton.useGoogle = true;
  2923. if (switchCovergeButton.nextPlayer === "Yandex") {
  2924. let options = {};
  2925. YandexPlayer.moveTo([switchCovergeButton.lat, switchCovergeButton.lng], options);
  2926. YandexPlayer.setDirection([switchCovergeButton.heading, 0]);
  2927.  
  2928. // switchCovergeButton.nextPlayer = "Yandex";
  2929. }
  2930. else if (switchCovergeButton.nextPlayer === "Kakao") {
  2931. let roadviewClient = new kakao.maps.RoadviewClient();
  2932. // console.log(switchCovergeButton.lat);
  2933. let position = new kakao.maps.LatLng(switchCovergeButton.lat, switchCovergeButton.lng);
  2934. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  2935. KakaoPlayer.setPanoId(panoId, position);
  2936. });
  2937. KakaoPlayer.setViewpoint({
  2938. pan: switchCovergeButton.heading,
  2939. tilt: 0,
  2940. zoom: -3
  2941. });
  2942. // switchCovergeButton.nextPlayer = "Kakao";
  2943. }
  2944. else if (switchCovergeButton.nextPlayer === "Mapillary" || switchCovergeButton.nextPlayer === "Google") {
  2945. // switchCovergeButton.nextPlayer = "Kakao";
  2946. handleMapillary({lat: switchCovergeButton.lat, lng: switchCovergeButton.lng}, {meters: 100, limit: 100});
  2947. }
  2948. }
  2949. });
  2950.  
  2951. }
  2952.  
  2953. /**
  2954. * Gets the seed data for the current game
  2955. *
  2956. * @returns Promise with seed data as object
  2957. */
  2958. function getSeed() {
  2959. // console.log("getSeed called");
  2960. return new Promise((resolve, reject) => {
  2961. let token = getToken();
  2962. let URL;
  2963. let cred = ""
  2964.  
  2965. const PATHNAME = window.location.pathname;
  2966.  
  2967. if (PATHNAME.startsWith("/game/")) {
  2968. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  2969. }
  2970. else if (PATHNAME.startsWith("/challenge/")) {
  2971. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  2972. }
  2973. else if (PATHNAME.startsWith("/battle-royale/")) {
  2974. URL = `https://game-server.geoguessr.com/api/battle-royale/${token}`;
  2975. }
  2976. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  2977. URL = `https://game-server.geoguessr.com/api/duels/${token}`;
  2978. }
  2979. if (isBattleRoyale) {
  2980. fetch(URL, {
  2981. // Include credentials to GET from the endpoint
  2982. credentials: 'include'
  2983. })
  2984. .then((response) => response.json())
  2985. .then((data) => {
  2986. resolve(data);
  2987. })
  2988. .catch((error) => {
  2989. reject(error);
  2990. });
  2991. }
  2992. else {
  2993. fetch(URL)
  2994. .then((response) => response.json())
  2995. .then((data) => {
  2996. resolve(data);
  2997. })
  2998. .catch((error) => {
  2999. reject(error);
  3000. });
  3001. }
  3002. });
  3003. }
  3004.  
  3005. /**
  3006. * Gets the token from the current URL
  3007. *
  3008. * @returns token
  3009. */
  3010. function getToken() {
  3011. const PATHNAME = window.location.pathname;
  3012. if (PATHNAME.startsWith("/game/")) {
  3013. return PATHNAME.replace("/game/", "");
  3014. }
  3015. else if (PATHNAME.startsWith("/challenge/")) {
  3016. return PATHNAME.replace("/challenge/", "");
  3017. }
  3018. else if (PATHNAME.startsWith("/battle-royale/")) {
  3019. return PATHNAME.replace("/battle-royale/", "");
  3020. }
  3021. else if (PATHNAME.startsWith("/duels/")) {
  3022. return PATHNAME.replace("/duels/", "");
  3023. }
  3024. else if (PATHNAME.startsWith("/team-duels/")) {
  3025. return PATHNAME.replace("/team-duels/", "");
  3026. }
  3027. }
  3028.  
  3029. /**
  3030. * Gets the round number from the ongoing game from the page itself
  3031. *
  3032. * @returns Round number
  3033. */
  3034. function getRoundFromPage() {
  3035. const roundData = document.querySelector("div[data-qa='round-number']");
  3036. if (roundData) {
  3037. let roundElement = roundData.querySelector("div:last-child");
  3038. if (roundElement) {
  3039. let round = parseInt(roundElement.innerText.charAt(0));
  3040. if (!isNaN(round) && round >= 1 && round <= 5) {
  3041. return round;
  3042. }
  3043. }
  3044. }
  3045. else {
  3046. return ROUND;
  3047. }
  3048. }
  3049.  
  3050.  
  3051. /**
  3052. * Injects Yandex Script
  3053. */
  3054. function injectYandexScript() {
  3055. return new Promise((resolve, reject) => {
  3056. if (!YANDEX_INJECTED) {
  3057. if (YANDEX_API_KEY === "") {
  3058. console.log("No Yandex Key")
  3059. reject();
  3060. }
  3061. else {
  3062. const SCRIPT = document.createElement("script");
  3063. SCRIPT.type = "text/javascript";
  3064. SCRIPT.async = true;
  3065. SCRIPT.onload = () => {
  3066. ymaps.ready(() => {
  3067. YANDEX_INJECTED = true;
  3068. myHighlight("Yandex API Loaded");
  3069. resolve();
  3070. });
  3071. }
  3072. SCRIPT.src = `https://api-maps.yandex.ru/2.1/?lang=en_US&apikey=${YANDEX_API_KEY}`;
  3073. document.body.appendChild(SCRIPT);
  3074. }
  3075. }
  3076. else {
  3077. resolve();
  3078. }
  3079. });
  3080. }
  3081.  
  3082. /**
  3083. * Injects Yandex Player and calls handleReturnToStart
  3084. */
  3085. function injectYandexPlayer() {
  3086. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3087. let lat = 41.321861;
  3088. let lng = 69.212920;
  3089.  
  3090. let options = {
  3091. "direction": [0, 16],
  3092. "span": [10, 67],
  3093. "controls": ["zoomControl"]
  3094. };
  3095. ymaps.panorama.createPlayer("player", [lat, lng], options)
  3096. .done((player) => {
  3097. YandexPlayer = player;
  3098. YandexPlayer.events.add("directionchange", (e) => {
  3099. updateCompass();
  3100. let pov = YandexPlayer.getDirection();
  3101. if (locHistory.length > 0 && nextPlayer == "Yandex") {
  3102. switchCovergeButton.heading = pov[0];
  3103. locHistory[locHistory.length - 1][2] = pov[0];
  3104. locHistory[locHistory.length - 1][3] = pov[1];
  3105. }
  3106. });
  3107. YandexPlayer.events.add("panoramachange", (e) => {
  3108. if (defaultPanoIdChange) {
  3109. let num = YandexPlayer.getPanorama().getPosition();
  3110. let pov = YandexPlayer.getDirection();
  3111. // console.log(num);
  3112. // console.log(pov);
  3113. if (nextPlayer == "Yandex")
  3114. {
  3115. locHistory.push([num[0], num[1], pov[0], pov[1]]);
  3116. switchCovergeButton.lat = num[0];
  3117. switchCovergeButton.lng = num[1];
  3118. }
  3119. let btn = document.querySelector("button[data-qa='undo-move']");
  3120. if (locHistory.length > 1) {
  3121. btn.disabled = false;
  3122. btn.classList.remove('styles_disabled__W_k45');
  3123. }
  3124. // console.log(locHistory);
  3125. }
  3126. defaultPanoIdChange = true;
  3127.  
  3128. });
  3129. console.log("Yandex Player injected");
  3130. });
  3131.  
  3132. }
  3133.  
  3134.  
  3135. /**
  3136. * Injects Baidu script
  3137. */
  3138.  
  3139. function reportWindowSize() {
  3140. let iframeC = document.getElementById("i_container");
  3141. if (iframeC)
  3142. {
  3143. if (nextPlayer == "Baidu")
  3144. {
  3145. iframeC.style.top = '-60px';
  3146. iframeC.style.height = (window.innerHeight + 200) + 'px';
  3147. iframeC.style.right = '-55px';
  3148. iframeC.style.width = (window.innerWidth + 55) + 'px';
  3149. }
  3150. else if (nextPlayer == "Youtube")
  3151. {
  3152. iframeC.style.top = '-60px';
  3153. iframeC.style.height = (window.innerHeight + 235) + 'px';
  3154. }
  3155. else if (nextPlayer == "Image")
  3156. {
  3157. iframeC.style.top = '0px';
  3158. iframeC.style.height = (window.innerHeight) + 'px';
  3159. }
  3160.  
  3161. }
  3162. }
  3163.  
  3164. window.onresize = reportWindowSize;
  3165.  
  3166. function injectContainer() {
  3167. myHighlight("Container loaded")
  3168. const iframe = document.createElement('iframe');
  3169. iframe.frameBorder = 0;
  3170. iframe.style.position = "absolute";
  3171. iframe.id = "i_container";
  3172. if (isBattleRoyale) {
  3173. if (isDuel)
  3174. {
  3175. iframe.className = "inactive"
  3176. }
  3177. else
  3178. {
  3179. iframe.className = "br-game-layout__panorama"
  3180. }
  3181. }
  3182. else {
  3183. iframe.className = "game-layout__panorama"
  3184. }
  3185. var div = document.getElementById("player");
  3186. div.style.overflow = "hidden";
  3187. div.appendChild(iframe);
  3188. }
  3189.  
  3190. // function injectMedia() {
  3191. // myHighlight("Baidu API loaded")
  3192. // const iframe = document.createElement('iframe');
  3193. // iframe.allow = "autoplay"
  3194. // iframe.src = "https://www.youtube.com/embed/72kRM86V-dw?&autoplay=1&modestbranding=1&controls=0&start=10"
  3195. // iframe.frameBorder = 0;
  3196. // iframe.style.position = "absolute";
  3197. // iframe.id = "media-player";
  3198. // iframe.style="position:fixed; top: -60px; left:0; bottom: calc(100% + 175px); right:0; width:100%; height:calc(100% + 235px); border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"
  3199. // if (isBattleRoyale) {
  3200. // if (isDuel)
  3201. // {
  3202. // iframe.className = "inactive"
  3203. // }
  3204. // else
  3205. // {
  3206. // iframe.className = "br-game-layout__panorama"
  3207. // }
  3208. // }
  3209. // else {
  3210. // iframe.className = "game-layout__panorama"
  3211. // }
  3212. // var div = document.getElementById("player");
  3213. // div.style.overflow = "hidden";
  3214. // div.appendChild(iframe);
  3215. // }
  3216.  
  3217. /**
  3218. * Injects Kakao script
  3219. */
  3220.  
  3221. function injectKakaoScript() {
  3222. return new Promise((resolve, reject) => {
  3223. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3224. if (!KAKAO_INJECTED) {
  3225. if (KAKAO_API_KEY === "") {
  3226. console.log("No Kakao Key")
  3227. }
  3228. else {
  3229.  
  3230. let canvas = document.createElement("kmap");
  3231. if (isBattleRoyale) {
  3232. if (isDuel)
  3233. {
  3234. canvas.innerHTML = `
  3235. <div id="roadview" class="inactive" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  3236. `;
  3237. }
  3238. else
  3239. {
  3240. canvas.innerHTML = `
  3241. <div id="roadview" class="br-game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  3242. `;
  3243. }
  3244. }
  3245. else {
  3246. canvas.innerHTML = `
  3247. <div id="roadview" class="game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  3248. `;
  3249. }
  3250.  
  3251. var div = document.getElementById("player");
  3252. div.appendChild(canvas);
  3253.  
  3254. const SCRIPT = document.createElement("script");
  3255. SCRIPT.async = true;
  3256. // SCRIPT.type = "text/javascript";
  3257. SCRIPT.src = `//dapi.kakao.com/v2/maps/sdk.js?appkey=${KAKAO_API_KEY}&autoload=false`;
  3258. document.body.appendChild(SCRIPT);
  3259. SCRIPT.onload = () => {
  3260. kakao.maps.load(function () {
  3261. var position = new kakao.maps.LatLng(33.450701, 126.560667);
  3262. let roadviewContainer = document.getElementById('roadview');
  3263. KakaoPlayer = new kakao.maps.Roadview(roadviewContainer);
  3264. var panoId = 1023434522;
  3265. KakaoPlayer.setPanoId(panoId, position);
  3266. KAKAO_INJECTED = true;
  3267. // Remove the compass from Kakao
  3268. kakao.maps.event.addListener(KakaoPlayer, 'init', () => {
  3269. const compassContainer = roadviewContainer.querySelector('div[id*="_box_util_"]');
  3270. if (compassContainer) compassContainer.style.display = 'none';
  3271. });
  3272. kakao.maps.event.addListener(KakaoPlayer, 'panoid_changed', function() {
  3273. if (defaultPanoIdChange && KakaoPlayer) {
  3274. let latlng = KakaoPlayer.getPosition();
  3275. let lat = latlng.getLat();
  3276. let lng = latlng.getLng();
  3277. let pID = KakaoPlayer.getViewpointWithPanoId();
  3278. if (nextPlayer == "Kakao" && lat != 33.45047613915499)
  3279. {
  3280. // console.log("push");
  3281. locHistory.push([lat, lng, pID.panoId, pID.pan]);
  3282. switchCovergeButton.lat = lat;
  3283. switchCovergeButton.lng = lng;
  3284. switchCovergeButton.heading = pID.pan;
  3285. }
  3286. let btn = document.querySelector("button[data-qa='undo-move']");
  3287. if (locHistory.length > 1 && (btn != null)) {
  3288. btn.disabled = false;
  3289. btn.classList.remove('styles_disabled__W_k45');
  3290. }
  3291. // console.log(locHistory);
  3292. }
  3293. defaultPanoIdChange = true;
  3294. });
  3295. kakao.maps.event.addListener(KakaoPlayer, 'viewpoint_changed', function() {
  3296. // console.log("pov_listener attached");
  3297. let pID = KakaoPlayer.getViewpointWithPanoId();
  3298. if (locHistory.length > 0 && nextPlayer == "Kakao") {
  3299. switchCovergeButton.heading = pID.pan;
  3300. locHistory[locHistory.length - 1][3] = pID.pan;
  3301. }
  3302. if (GooglePlayer) {
  3303. const { heading, pitch } = GooglePlayer.getPov()
  3304. if ((!almostEqual(pID.pan, heading) || !almostEqual(pID.tilt, pitch)) && nextPlayer == "Kakao") {
  3305. // Updating the google street view POV will update the compass
  3306. GooglePlayer.setPov({ heading: pID.pan, pitch: pID.tilt })
  3307. }
  3308. }
  3309. // console.log(locHistory);
  3310. })
  3311. myHighlight("Kakao API Loaded");
  3312. resolve();
  3313. });
  3314. };
  3315.  
  3316. }
  3317. }
  3318. else {
  3319. resolve();
  3320. }
  3321. });
  3322. }
  3323.  
  3324.  
  3325.  
  3326. function injectMapillaryPlayer() {
  3327. return new Promise((resolve, reject) => {
  3328. if (!MAPILLARY_INJECTED) {
  3329. if (MAPILLARY_API_KEY === "") {
  3330. let canvas = document.getElementById("player");
  3331. console.log("No Mapillary Key")
  3332. }
  3333. else {
  3334. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3335.  
  3336. const SCRIPT = document.createElement("script");
  3337. SCRIPT.type = "text/javascript";
  3338. SCRIPT.async = true;
  3339. SCRIPT.src = `https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.js`;
  3340. document.body.appendChild(SCRIPT);
  3341. document.querySelector('head').innerHTML += '<link href="https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.css" rel="stylesheet"/>';
  3342. let canvas = document.createElement("mmap");
  3343. if (isBattleRoyale) {
  3344. if (isDuel)
  3345. {
  3346.  
  3347. canvas.innerHTML = `<div id="mapillary-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  3348. }
  3349. else
  3350. {
  3351. canvas.innerHTML = `<div id="mapillary-player" class="br-game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  3352. }
  3353. }
  3354. else {
  3355. canvas.innerHTML = `<div id="mapillary-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  3356. }
  3357.  
  3358. var div = document.getElementById("player");
  3359. div.appendChild(canvas);
  3360.  
  3361. SCRIPT.addEventListener('load', () => {
  3362. myHighlight("Mapillary API Loaded");
  3363. // resolve(BMap);
  3364. var {Viewer} = mapillary;
  3365.  
  3366. MapillaryPlayer = new Viewer({
  3367. accessToken: MAPILLARY_API_KEY,
  3368. container: 'mapillary-player', // the ID of our container defined in the HTML body
  3369. });
  3370.  
  3371. MapillaryPlayer.on('image', async (event) => {
  3372. // cnt = cnt + 1;
  3373. // console.log(cnt);
  3374. let image = event.image;
  3375. let pos = image.originalLngLat;
  3376. let cond = true;
  3377. for (const element of locHistory) {
  3378. if (element[2] == image.id)
  3379. {
  3380. cond = false;
  3381. }
  3382. }
  3383. if (cond)
  3384. {
  3385. switchCovergeButton.lat = pos.lat;
  3386. switchCovergeButton.lng = pos.lng;
  3387. switchCovergeButton.heading = image.compassAngle;
  3388. // console.log(pos);
  3389. locHistory.push([pos.lat, pos.lng, image.id, image.compassAngle]);
  3390. }
  3391. let btn = document.querySelector("button[data-qa='undo-move']");
  3392. if (btn !== null && locHistory.length > 1)
  3393. {
  3394. btn.disabled = false;
  3395. btn.classList.remove('styles_disabled__W_k45');
  3396. }
  3397. });
  3398.  
  3399. MAPILLARY_INJECTED = true;
  3400. resolve();
  3401. })
  3402. }
  3403. }
  3404. else {
  3405. resolve();
  3406. }
  3407. });
  3408. }
  3409.  
  3410.  
  3411. function handleMapillary(latlng, options)
  3412. {
  3413. console.log("handleMapillary")
  3414. handleMapillaryHelper(latlng, options).then((data) => {
  3415. //console.log(data.data)
  3416. let idToSet = 0;
  3417. let curDist = 100000000;
  3418. for (const element of data.data) {
  3419. // console.log(element)
  3420. if (element.hasOwnProperty("computed_geometry"))
  3421. {
  3422. try {
  3423. let rCord = element.computed_geometry["coordinates"];
  3424. let dist = distance(latlng.lat,latlng.lng,rCord[1],rCord[0])
  3425. if (dist < curDist)
  3426. {
  3427. idToSet = element.id;
  3428. curDist = dist
  3429. }
  3430. } catch (e) {
  3431. console.log("Error")
  3432. }
  3433. }
  3434. }
  3435. if (idToSet !== 0)
  3436. {
  3437. MapillaryPlayer.moveTo(idToSet).then(
  3438. image => { //console.log(image);
  3439. },
  3440. error => { console.log(error); });
  3441. }}).catch((error) => {
  3442. console.log(error);
  3443. });
  3444. }
  3445.  
  3446. function handleMapillaryHelper(latlng, options)
  3447. {
  3448. return new Promise((resolve, reject) => {
  3449. // console.log("1")
  3450. let bbox = getBBox(latlng, options.meters);
  3451. let URL = "https://graph.mapillary.com/images?access_token={0}&fields=id,computed_geometry&bbox={1}&limit={2}".replace('{0}', MAPILLARY_API_KEY).replace('{1}', bbox).replace('{2}', options.limit)
  3452. // console.log(URL)
  3453. fetch(URL)
  3454. .then((response) => {resolve(response.json())})
  3455. .catch((error) => {console.log(error);});
  3456. });
  3457. }
  3458.  
  3459. function moveFrom(coords, angle, distance){
  3460. const R_EARTH = 6378.137;
  3461. const M = (1 / ((2 * Math.PI / 360) * R_EARTH)) / 1000;
  3462. let radianAngle = -angle * Math.PI / 180;
  3463. let x = 0 + (distance * Math.cos(radianAngle));
  3464. let y = 0 + (distance * Math.sin(radianAngle));
  3465.  
  3466. let newLat = coords.lat + (y * M);
  3467. let newLng = coords.lng + (x * M) / Math.cos(coords.lat * (Math.PI / 180));
  3468. return { lat: newLat, lng: newLng };
  3469. }
  3470.  
  3471. function getBBox(coordinates, meters){
  3472. let SW = moveFrom(coordinates, 135, meters);
  3473. let NE = moveFrom(coordinates, 315, meters);
  3474. return `${SW.lng},${SW.lat},${NE.lng},${NE.lat}`;
  3475. }
  3476.  
  3477.  
  3478. function distance(lat1, lon1, lat2, lon2) {
  3479. var p = 0.017453292519943295; // Math.PI / 180
  3480. var c = Math.cos;
  3481. var a = 0.5 - c((lat2 - lat1) * p)/2 +
  3482. c(lat1 * p) * c(lat2 * p) *
  3483. (1 - c((lon2 - lon1) * p))/2;
  3484.  
  3485. return 1000 * 12742 * Math.asin(Math.sqrt(a)); // 2 * R; R = 6371 km
  3486. }
  3487.  
  3488.  
  3489. /**
  3490. * Minimap presets
  3491. */
  3492.  
  3493. let water_name_only =
  3494. [
  3495. {
  3496. "elementType": "geometry",
  3497. "stylers": [
  3498. {
  3499. "visibility": "off"
  3500. }
  3501. ]
  3502. },
  3503. {
  3504. "featureType": "administrative",
  3505. "stylers": [
  3506. {
  3507. "visibility": "off"
  3508. }
  3509. ]
  3510. },
  3511. {
  3512. "featureType": "landscape",
  3513. "stylers": [
  3514. {
  3515. "visibility": "off"
  3516. }
  3517. ]
  3518. },
  3519. {
  3520. "featureType": "poi",
  3521. "stylers": [
  3522. {
  3523. "visibility": "off"
  3524. }
  3525. ]
  3526. },
  3527. {
  3528. "featureType": "road",
  3529. "stylers": [
  3530. {
  3531. "visibility": "off"
  3532. }
  3533. ]
  3534. },
  3535. {
  3536. "featureType": "transit",
  3537. "stylers": [
  3538. {
  3539. "visibility": "off"
  3540. }
  3541. ]
  3542. }
  3543. ]
  3544. let country_name_only =
  3545. [
  3546. {
  3547. "elementType": "geometry",
  3548. "stylers": [
  3549. {
  3550. "visibility": "off"
  3551. }
  3552. ]
  3553. },
  3554. {
  3555. "featureType": "administrative",
  3556. "stylers": [
  3557. {
  3558. "visibility": "off"
  3559. }
  3560. ]
  3561. },
  3562. {
  3563. "featureType": "administrative.country",
  3564. "elementType": "labels",
  3565. "stylers": [
  3566. {
  3567. "visibility": "on"
  3568. }
  3569. ]
  3570. },
  3571. {
  3572. "featureType": "landscape",
  3573. "stylers": [
  3574. {
  3575. "visibility": "off"
  3576. }
  3577. ]
  3578. },
  3579. {
  3580. "featureType": "poi",
  3581. "stylers": [
  3582. {
  3583. "visibility": "off"
  3584. }
  3585. ]
  3586. },
  3587. {
  3588. "featureType": "road",
  3589. "stylers": [
  3590. {
  3591. "visibility": "off"
  3592. }
  3593. ]
  3594. },
  3595. {
  3596. "featureType": "transit",
  3597. "stylers": [
  3598. {
  3599. "visibility": "off"
  3600. }
  3601. ]
  3602. },
  3603. {
  3604. "featureType": "water",
  3605. "stylers": [
  3606. {
  3607. "visibility": "off"
  3608. }
  3609. ]
  3610. }
  3611. ]
  3612.  
  3613. let no_label_or_terrain =
  3614. [
  3615. {
  3616. "elementType": "geometry",
  3617. "stylers": [
  3618. {
  3619. "visibility": "off"
  3620. }
  3621. ]
  3622. },
  3623. {
  3624. "featureType": "administrative",
  3625. "stylers": [
  3626. {
  3627. "visibility": "off"
  3628. }
  3629. ]
  3630. },
  3631. {
  3632. "featureType": "landscape",
  3633. "stylers": [
  3634. {
  3635. "visibility": "off"
  3636. }
  3637. ]
  3638. },
  3639. {
  3640. "featureType": "poi",
  3641. "stylers": [
  3642. {
  3643. "visibility": "off"
  3644. }
  3645. ]
  3646. },
  3647. {
  3648. "featureType": "road",
  3649. "stylers": [
  3650. {
  3651. "visibility": "off"
  3652. }
  3653. ]
  3654. },
  3655. {
  3656. "featureType": "transit",
  3657. "stylers": [
  3658. {
  3659. "visibility": "off"
  3660. }
  3661. ]
  3662. },
  3663. {
  3664. "featureType": "water",
  3665. "stylers": [
  3666. {
  3667. "visibility": "on"
  3668. }
  3669. ]
  3670. },
  3671. {
  3672. "featureType": "water",
  3673. "elementType": "labels",
  3674. "stylers": [
  3675. {
  3676. "visibility": "off"
  3677. }
  3678. ]
  3679. }
  3680. ]
  3681.  
  3682. let no_label =
  3683. [
  3684. {
  3685. "elementType": "labels",
  3686. "stylers": [
  3687. {
  3688. "visibility": "off"
  3689. }
  3690. ]
  3691. },
  3692. {
  3693. "featureType": "administrative",
  3694. "stylers": [
  3695. {
  3696. "visibility": "off"
  3697. }
  3698. ]
  3699. }
  3700. ]
  3701.  
  3702. let blank =
  3703.  
  3704. [
  3705. {
  3706. "stylers": [
  3707. {
  3708. "visibility": "off"
  3709. }
  3710. ]
  3711. }
  3712. ]
  3713.  
  3714. let thick_border =
  3715.  
  3716. [
  3717. {
  3718. "featureType": "administrative.country",
  3719. "elementType": "geometry.stroke",
  3720. "stylers": [
  3721. {
  3722. "weight": 1.5
  3723. }
  3724. ]
  3725. },
  3726. {
  3727. "featureType": "administrative.province",
  3728. "elementType": "geometry.stroke",
  3729. "stylers": [
  3730. {
  3731. "weight": 3.5
  3732. }
  3733. ]
  3734. }
  3735. ]
  3736.  
  3737. let default_preset = []
  3738.  
  3739. let presetMinimap = [[default_preset, "Default"],
  3740. [blank, "Blank"],
  3741. [water_name_only, "Oceanman"],
  3742. [country_name_only, "Impossible"],
  3743. [no_label_or_terrain, "Streaks"],
  3744. [no_label, "Easy 5K"],
  3745. [thick_border, "Highlighted Borders"],
  3746. [default_preset, "Satellite"],
  3747. [default_preset, "Terrain"],
  3748. [default_preset, "Hybrid"],
  3749. [custom, "Custom", customMode]]
  3750.  
  3751. let GEOJSON_INVISIBLE =
  3752. {
  3753. strokeOpacity: 0,
  3754. fillOpacity: 0,
  3755. }
  3756.  
  3757. let presetOverlay = [["Clear",""],
  3758. ["Coverage",""],
  3759. ["Official",""],
  3760. ["Longitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/lonl.json"],
  3761. ["Latitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/latl.json"],
  3762. ["US County","https://raw.githubusercontent.com/CodeForCary/CountyDataUSA5m/master/cb_2017_us_county_5m.json"],
  3763. ["France","https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements.geojson"],
  3764. ["Time Zone", "https://raw.githubusercontent.com/treyerl/timezones/master/timezones_wVVG8.geojson"],
  3765. ["UK Parliament", "https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/electoral/gb/wpc.json"],
  3766. ["Custom", YOUR_URL]]
  3767.  
  3768.  
  3769. /**
  3770. * Display map per local laws and regulations
  3771. */
  3772.  
  3773. let SEOverlay, NWOverlay, SEOverlay3;
  3774. let TW = [[24.80, 119.00, 22.00, 123.20],
  3775. [24.20, 119.90, 22.90, 121.85],
  3776. [24.00, 120.90, 23.80, 121.20],
  3777. [23.93, 121.03, 23.85, 121.15],
  3778. [23.92, 121.055, 23.89, 121.10],
  3779. [23.92, 121.055, 23.89, 121.10],
  3780. [23.92, 121.055, 23.89, 121.10],
  3781. ]
  3782.  
  3783. let TS = [[30.40, 93.40, 28, 97.20],
  3784. [29.40, 94.55, 28.20, 96.45]]
  3785.  
  3786. let NW = [36.20, 77.70, 34.40, 80.70]