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

2022-02-11 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

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