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-12 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

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