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

Verze ze dne 11. 02. 2022. Zobrazit nejnovější verzi.

  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.1
  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.1 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.1</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. if (!isBattleRoyale)
  2140. {
  2141. loaderChecker(data.mapName);
  2142. }
  2143. else
  2144. {
  2145. let dat;
  2146. let rtd = false;
  2147. if (typeof data.isRated !== 'undefined')
  2148. {
  2149. rtd = data.isRated;
  2150. }
  2151. if (data.isRated)
  2152. {
  2153. dat = "Public Game";
  2154. }
  2155. else
  2156. {
  2157. dat = "A United World";
  2158. }
  2159. loaderChecker(dat);
  2160. }
  2161.  
  2162. }).catch((error) => {
  2163. console.log(error);
  2164. });
  2165.  
  2166. }
  2167.  
  2168. function guaranteeUI()
  2169. {
  2170. // console.log("UI")
  2171. if (document.getElementById("GH-ui") !== null)
  2172. {
  2173. document.getElementById("GH-ui").style.display = "block";
  2174. }
  2175. else
  2176. {
  2177. setTimeout(guaranteeUI, 500);
  2178. }
  2179. }
  2180.  
  2181. /**
  2182. * Handles Return to start and undo
  2183. */
  2184.  
  2185. function handleReturnToStart() {
  2186. let rtsButton = document.querySelector("button[data-qa='return-to-start']");
  2187. if (rtsButton != null) {
  2188. console.log("handleReturnToStart listener attached");
  2189. rtsButton.addEventListener("click", (e) => {
  2190. if (nextPlayer != "Baidu")
  2191. {
  2192. goToLocation();
  2193. }
  2194. else
  2195. {
  2196. document.getElementById("i_container").src = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  2197. }
  2198. const elementClicked = e.target;
  2199. elementClicked.setAttribute('listener', 'true');
  2200. console.log("Return to start");
  2201. });
  2202. guessButtonCallback();
  2203. setTimeout(function () {goToLocation();}, 1000);
  2204. }
  2205. else
  2206. {
  2207. setTimeout(handleReturnToStart, 500);
  2208. }
  2209. }
  2210.  
  2211. function handleUndo() {
  2212. let undoButton = document.querySelector("button[data-qa='undo-move']");
  2213. if (undoButton != null)
  2214. {
  2215. console.log("Attach undo");
  2216. undoButton.addEventListener("click", (e) => {
  2217. if (locHistory.length > 0) {
  2218. goToUndoMove();
  2219. console.log("Undo Move");
  2220. }
  2221. })
  2222. }
  2223. else
  2224. {
  2225. setTimeout(handleUndo, 500);
  2226. }
  2227. }
  2228.  
  2229. /**
  2230. * Load game information
  2231. */
  2232.  
  2233. function getMapData() {
  2234. // myHighlight("Seed data");
  2235. getSeed().then((data) => {
  2236. // myHighlight("Seed data");
  2237. // console.log(data);
  2238. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2239. if (isBattleRoyale) {
  2240. if (data.status == "Finished" || typeof data.gameId == typeof undefined) {
  2241. // console.log("Battle Royale Lobby");
  2242. }
  2243. else
  2244. {
  2245. let origin = false;
  2246. if (!CURRENT_ROUND_DATA) {
  2247. CURRENT_ROUND_DATA = data
  2248. origin = true;
  2249. }
  2250.  
  2251. if (origin || !(data.currentRoundNumber === CURRENT_ROUND_DATA.currentRoundNumber)) {
  2252. // myHighlight("Battle Royale New round");
  2253. switchCovergeButton.init = true;
  2254. // NEW_ROUND_LOADED = true;
  2255. COMPASS = null;
  2256. locHistory = [];
  2257. one_reset = false;
  2258. setHidden(false);
  2259. if (!origin) {
  2260. CURRENT_ROUND_DATA = data;
  2261. }
  2262. locationCheck(data);
  2263. // console.log(data);
  2264. if (data.currentRoundNumber == 1)
  2265. {
  2266. setTimeout(function () {goToLocation();}, 3000);
  2267. }
  2268. else
  2269. {
  2270. goToLocation();
  2271. }
  2272. handleReturnToStart();
  2273. if (isDuel)
  2274. {
  2275. handleUndo();
  2276. hideButtons();
  2277. }
  2278. handleMinimapCallback();
  2279.  
  2280. }
  2281. }
  2282. }
  2283. else {
  2284. if (!cn_tips)
  2285. {
  2286. mainMenuBtn.style.visibility = "";
  2287. }
  2288. else
  2289. {
  2290. mainMenuBtn.style.visibility = "hidden";
  2291. AdjustBtnPos("14em", "0em");
  2292. }
  2293. locationCheck(data);
  2294. if (data.currentRoundNumber == 1)
  2295. {
  2296. setTimeout(function () {goToLocation();}, 3000);
  2297. }
  2298. else
  2299. {
  2300. goToLocation();
  2301. }
  2302. handleReturnToStart();
  2303. handleUndo();
  2304. hideButtons();
  2305. handleMinimapCallback();
  2306. }
  2307. }).catch((error) => {
  2308. console.log(error);
  2309. });
  2310. }
  2311.  
  2312. function handleMinimapCallback()
  2313. {
  2314. let trueCond = true;
  2315. let timeoutTime = 250;
  2316. if (isBattleRoyale) {
  2317. if (isDuel)
  2318. {
  2319. if (document.querySelector(".overlay_overlay__AR02x"))
  2320. {
  2321. trueCond = false;
  2322. }
  2323. else
  2324. {
  2325. trueCond = true;
  2326. }
  2327. }
  2328. else
  2329. {
  2330. if (document.querySelector(".popup__content"))
  2331. {
  2332. trueCond = false;
  2333. }
  2334. else
  2335. {
  2336. trueCond = true;
  2337. }
  2338. }
  2339. timeoutTime = 2500;
  2340. }
  2341.  
  2342. if (trueCond)
  2343. {
  2344. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2345. let cur = MinimapBtn.current;
  2346. console.log(cur)
  2347. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  2348. if (cur == mapDiv.id)
  2349. {
  2350. setTimeout(function () {mapDiv.click();}, 500);
  2351. setTimeout(function () {mapDiv.click();}, 1000);
  2352. setTimeout(function () {mapDiv.click();}, 3000);
  2353. }
  2354. }
  2355. }
  2356. else
  2357. {
  2358. setTimeout(handleMinimapCallback, 250);
  2359. }
  2360. }
  2361.  
  2362. /**
  2363. * Hide unnecessary buttons for non-Google coverages
  2364. */
  2365.  
  2366. function hideButtons() {
  2367. let CHECKPOINT = document.querySelector("button[data-qa='set-checkpoint']");
  2368. let ZOOM_IN = document.querySelector("button[data-qa='pano-zoom-in']");
  2369. let ZOOM_OUT = document.querySelector("button[data-qa='pano-zoom-out']");
  2370.  
  2371. if (CHECKPOINT != null)
  2372. {
  2373. if (nextPlayer === "Google") {
  2374.  
  2375. CHECKPOINT.style.visibility = "";
  2376. ZOOM_IN.style.visibility = "";
  2377. ZOOM_OUT.style.visibility = "";
  2378. console.log("Buttons Unhidden");
  2379.  
  2380. }
  2381. else {
  2382.  
  2383. CHECKPOINT.style.visibility = "hidden";
  2384. ZOOM_IN.style.visibility = "hidden";
  2385. ZOOM_OUT.style.visibility = "hidden";
  2386. console.log("Buttons Hidden");
  2387.  
  2388. }
  2389. }
  2390. else
  2391. {
  2392. setTimeout(hideButtons, 250);
  2393. }
  2394. }
  2395.  
  2396. /**
  2397. * Check which player to use for the next location
  2398. */
  2399.  
  2400. function locationCheck(data) {
  2401. // console.log(data);
  2402. let round;
  2403. if (isBattleRoyale) {
  2404. if (isDuel || isBullseye)
  2405. {
  2406. round = data.rounds[data.currentRoundNumber - 1].panorama;
  2407. }
  2408. else
  2409. {
  2410. round = data.rounds[data.currentRoundNumber - 1];
  2411. }
  2412. }
  2413. else {
  2414. round = data.rounds[data.round - 1];
  2415. }
  2416. global_lat = round.lat;
  2417. global_lng = round.lng;
  2418. global_panoID = round.panoId;
  2419. global_heading = round.heading;
  2420. global_pitch = round.pitch;
  2421.  
  2422. nextPlayer = "Google";
  2423.  
  2424. if (ms_sat_map)
  2425. {
  2426. nextPlayer = "MS Satellite";
  2427. }
  2428.  
  2429. if (global_panoID) {
  2430. let locInfo;
  2431. if (isBullseye)
  2432. {
  2433. locInfo = global_panoID;
  2434. }
  2435. else
  2436. {
  2437. locInfo = hex2a(global_panoID);
  2438. }
  2439. // console.log(locInfo)
  2440. if (locInfo.substring(0, 3) == "YTB")
  2441. {
  2442. nextPlayer = "Youtube";
  2443. let lengths = [3, 11, 4, 4];
  2444. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2445. let fullID = locInfo.substring(3).split('START');
  2446. yId = toPiece[1];
  2447. yTime = Number(toPiece[2]);
  2448. yEnd = Number(toPiece[3]);
  2449. }
  2450. else
  2451. {
  2452. let mapType = locInfo.substring(0, 5);
  2453.  
  2454. // panoId unchanged
  2455.  
  2456. if (mapType === "YDMAP" ) {
  2457. nextPlayer = "Yandex";
  2458. }
  2459. else if (mapType === "KKMAP" ) {
  2460. nextPlayer = "Kakao";
  2461. }
  2462.  
  2463. // New panoId formats
  2464.  
  2465. else if (mapType === "BAIDU" ) {
  2466. nextPlayer = "Baidu";
  2467. let lengths = [5, 7, 7, 3];
  2468. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2469. let panoId1 = base62.decode(toPiece[1]).toString().substring(1);
  2470. let panoId2 = base62.decode(toPiece[2]).toString().substring(1);
  2471. global_BDID = panoId1 + panoId2 + toPiece[3]
  2472. }
  2473. else if (mapType === "MAPIL")
  2474. {
  2475. nextPlayer = "Mapillary";
  2476. mmKey = locInfo.substring(5).replace(/\D/g,'');
  2477. }
  2478. else if (mapType === "IMAGE")
  2479. {
  2480. nextPlayer = "Image";
  2481. let lengths = [5, 4, 4, 7, 2];
  2482. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2483. iId = "https://i.ibb.co/" + toPiece[3] + "/" + toPiece[1] + "." + toPiece[2].replace(/[^0-9a-z]/gi, '')
  2484. }
  2485. else if (mapType === "BINGM" ) {
  2486. nextPlayer = "MS Streetside";
  2487. }
  2488. else if (mapType === "SATEL" ) {
  2489. nextPlayer = "MS Satellite";
  2490. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  2491. }
  2492.  
  2493. // legacy panoId formats support
  2494.  
  2495. else if (mapType === "BDMAP") {
  2496. nextPlayer = "Baidu";
  2497. let coord = locInfo.substring(5);
  2498.  
  2499. if(coord.includes('BDAh'))
  2500. {
  2501. global_BDID = coord.split('BDAh')[0].replace("panoId","");
  2502. let tem = coord.split('BDAh')[1];
  2503. global_BDAh = tem.split('BDBh')[0];
  2504. global_BDBh = tem.split('BDBh')[1];
  2505. }
  2506. else
  2507. {
  2508. global_BDID = coord.replace("panoId","");
  2509. }
  2510. }
  2511. else if (mapType === "MLMAP") {
  2512. nextPlayer = "Mapillary";
  2513. mmKey = locInfo.substring(5);
  2514. }
  2515. }
  2516. }
  2517. else
  2518. {
  2519. if (Kakao_map)
  2520. {
  2521. nextPlayer = "Kakao";
  2522. }
  2523. else if (yandex_map)
  2524. {
  2525. nextPlayer = "Yandex";
  2526. }
  2527. }
  2528.  
  2529. // if ( krCoordinates[0] > global_lat && krCoordinates[2] < global_lat && krCoordinates[1] < global_lng && krCoordinates[3] > global_lng)
  2530. // {
  2531. // nextSecondaryPlayer = "Kakao";
  2532. // }
  2533. // else if (nextPlayer = "Mapillary")
  2534. // {
  2535. // nextSecondaryPlayer = "Google";
  2536. // }
  2537. // else
  2538. // {
  2539. // nextSecondaryPlayer = "Mapillary";
  2540. // }
  2541.  
  2542. // Disable buttons if NM, NMPZ
  2543.  
  2544. if(!isBattleRoyale)
  2545. {
  2546. if (data.forbidMoving || data.forbidRotating || data.forbidZooming)
  2547. {
  2548. setDisable("NMPZ");
  2549. }
  2550. else
  2551. {
  2552. setDisable(nextPlayer);
  2553. }
  2554. }
  2555. else
  2556. {
  2557. // console.log(data)
  2558. if (isBullseye)
  2559. {
  2560. if (data.options.movementOptions.forbidMoving || data.options.movementOptions.forbidRotating || data.options.movementOptions.forbidZooming)
  2561. {
  2562. setDisable("NMPZ");
  2563. }
  2564. else
  2565. {
  2566. setDisable(nextPlayer);
  2567. }
  2568. }
  2569. else
  2570. {
  2571. if (data.movementOptions.forbidMoving || data.movementOptions.forbidRotating || data.movementOptions.forbidZooming)
  2572. {
  2573. setDisable("NMPZ");
  2574. }
  2575. else
  2576. {
  2577. setDisable(nextPlayer);
  2578. }
  2579.  
  2580. }
  2581. }
  2582.  
  2583. console.log(nextPlayer);
  2584. injectCanvas();
  2585. }
  2586.  
  2587.  
  2588. /**
  2589. * setID for canvas
  2590. */
  2591.  
  2592. function initializeCanvas() {
  2593. let GAME_CANVAS = "";
  2594. let DUEL_CANVAS = "";
  2595. //console.log("Is duels");
  2596. //console.log(duels);
  2597.  
  2598. if (isBattleRoyale) {
  2599. if (isDuel) {
  2600. GAME_CANVAS = document.querySelector(".game-panorama_panorama__rdhFg");
  2601. DUEL_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__PNKve");
  2602. }
  2603. else if (isBullseye) {
  2604. GAME_CANVAS = document.querySelector(".game-panorama_panorama__ncMwh");
  2605. DUEL_CANVAS = "dummy";
  2606. }
  2607. else
  2608. {
  2609. GAME_CANVAS = document.querySelector(".br-game-layout__panorama-wrapper");
  2610. DUEL_CANVAS = "dummy";
  2611. }
  2612. }
  2613. else {
  2614. GAME_CANVAS = document.querySelector(".game-layout__canvas");
  2615. DUEL_CANVAS = "dummy";
  2616. }
  2617. if (GAME_CANVAS && DUEL_CANVAS)
  2618. {
  2619. // console.log("Canvas injected");
  2620. GAME_CANVAS.id = "player";
  2621.  
  2622. if (isDuel) {
  2623. DUEL_CANVAS.id = "default_player";
  2624. }
  2625. if (typeof mapillary !== typeof undefined)
  2626. {
  2627. partialCreateMapillary = true;
  2628. }
  2629. else
  2630. {
  2631. partialCreateMapillary = false;
  2632. }
  2633. if (typeof ymaps !== typeof undefined)
  2634. {
  2635. partialCreateYandex = true;
  2636. }
  2637. else
  2638. {
  2639. partialCreateYandex = false;
  2640. }
  2641. if (typeof kakao !== typeof undefined)
  2642. {
  2643. partialCreateKakao = true;
  2644. }
  2645. else
  2646. {
  2647. partialCreateKakao = false;
  2648. }
  2649. if (typeof Microsoft !== typeof undefined)
  2650. {
  2651. partialCreateMS = true;
  2652. }
  2653. else
  2654. {
  2655. partialCreateMS = false;
  2656. }
  2657.  
  2658. loadPlayers();
  2659. injectMapillaryPlayer();
  2660. }
  2661. else
  2662. {
  2663. setTimeout(initializeCanvas, 250);
  2664. }
  2665.  
  2666. }
  2667.  
  2668. /**
  2669. * Hide or show players based on where the next location is
  2670. */
  2671.  
  2672. function injectCanvas() {
  2673. if (isDuel)
  2674. {
  2675. canvasSwitch();
  2676. }
  2677. else
  2678. {
  2679. Google();
  2680. Baidu();
  2681. Kakao();
  2682. Yandex();
  2683. Mapillary();
  2684. Bing();
  2685. }
  2686. ZoomControls();
  2687. }
  2688.  
  2689. // for duels (class ID change)
  2690.  
  2691. function canvasSwitch()
  2692. {
  2693. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2694. if (document.querySelector(".compass") !== null && document.querySelector("button[data-qa='undo-move']") !== null)
  2695. {
  2696. let GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__PNKve");
  2697. document.getElementById("default_player").style.position = "absolute";
  2698. document.getElementById("default_player").className = "inactive";
  2699. document.getElementById("i_container").style.position = "absolute";
  2700. document.getElementById("i_container").className = "inactive";
  2701. document.getElementById("mapillary-player").style.visibility = "hidden";
  2702. document.getElementById("mapillary-player").style.position = "absolute";
  2703. document.getElementById("mapillary-player").className = "inactive";
  2704. if (BR_LOAD_KAKAO)
  2705. {
  2706. document.getElementById("roadview").style.position = "absolute";
  2707. document.getElementById("roadview").className = "inactive";
  2708. }
  2709. if (BR_LOAD_YANDEX)
  2710. {
  2711. document.querySelector(".ymaps-2-1-79-panorama-screen").style.visibility = "hidden";
  2712. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  2713. }
  2714. if (BR_LOAD_MS)
  2715. {
  2716. document.getElementById("ms-player").style.position = "absolute";
  2717. document.getElementById("ms-player").className = "inactive";
  2718. }
  2719. switchCovergeButton.nextPlayer = nextPlayer;
  2720. teleportBtn.google = false;
  2721. switchCovergeButton.useGoogle = false;
  2722. document.querySelector(".compass").style.visibility = "";
  2723. document.querySelector("button[data-qa='undo-move']").visibility = "";
  2724. if (nextPlayer === "Google") {
  2725. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  2726. teleportBtn.google = true;
  2727. switchCovergeButton.useGoogle = true;
  2728. console.log("Google Duel Canvas loaded");
  2729. }
  2730. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image")
  2731. {
  2732. document.getElementById("i_container").className = "game-panorama_panorama__rdhFg";
  2733. document.querySelector(".compass").style.visibility = "hidden";
  2734. document.querySelector("button[data-qa='undo-move']").visibility = "hidden";
  2735. console.log("Container Duel Canvas loaded");
  2736. }
  2737. else if (nextPlayer === "Kakao")
  2738. {
  2739. if (BR_LOAD_KAKAO)
  2740. {
  2741. document.getElementById("roadview").className = "game-panorama_panorama__rdhFg";
  2742. }
  2743. console.log("Kakao Duel Canvas loaded");
  2744. }
  2745. else if (nextPlayer === "Yandex")
  2746. {
  2747. if (BR_LOAD_YANDEX)
  2748. {
  2749. document.querySelector(".ymaps-2-1-79-panorama-screen").style.visibility = "";
  2750. }
  2751. console.log("Yandex Duel Canvas loaded");
  2752. }
  2753. else if (nextPlayer === "Mapillary")
  2754. {
  2755. document.getElementById("mapillary-player").style.visibility = "";
  2756. document.getElementById("mapillary-player").className = "game-panorama_panorama__rdhFg";
  2757. document.querySelector(".compass").style.visibility = "hidden";
  2758. // MapillaryPlayer.resize();
  2759. console.log("Mapillary Duel Canvas loaded");
  2760. }
  2761. else if (nextPlayer === "MS Streetside" || nextPlayer === "MS Satellite")
  2762. {
  2763. if (BR_LOAD_MS)
  2764. {
  2765. document.getElementById("ms-player").className = "game-panorama_panorama__rdhFg";
  2766. }
  2767. document.querySelector(".compass").style.visibility = "hidden";
  2768. console.log("MS Duel Canvas loaded");
  2769. }
  2770. }
  2771. else
  2772. {
  2773. setTimeout(canvasSwitch, 250);
  2774. }
  2775. }
  2776.  
  2777. // for Battle Royale and classic (change visibility)
  2778.  
  2779. function Google() {
  2780. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2781. let GOOGLE_MAPS_CANVAS = ""
  2782. if (isBattleRoyale) {
  2783. if (!isBullseye)
  2784. {
  2785. GOOGLE_MAPS_CANVAS = document.querySelector(".br-game-layout__panorama-canvas");
  2786. }
  2787. else
  2788. {
  2789. GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__r_5ea");
  2790. }
  2791. }
  2792. else {
  2793. GOOGLE_MAPS_CANVAS = document.querySelector(".game-layout__panorama-canvas");
  2794. }
  2795. if (nextPlayer === "Google") {
  2796. GOOGLE_MAPS_CANVAS.style.visibility = "";
  2797. teleportBtn.google = true;
  2798. switchCovergeButton.nextPlayer = "Google";
  2799. switchCovergeButton.useGoogle = true;
  2800. console.log("Google Canvas loaded");
  2801. }
  2802. else {
  2803. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  2804. teleportBtn.google = false;
  2805. console.log("Google Canvas hidden");
  2806. }
  2807. }
  2808.  
  2809. function Baidu() {
  2810. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2811. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  2812. // console.log("Baidu canvas");
  2813. if (BAIDU_MAPS_CANVAS !== null && document.querySelector(".compass") !== null && document.querySelector("button[data-qa='undo-move']") !== null)
  2814. {
  2815. BAIDU_MAPS_CANVAS.style.position = "absolute";
  2816. if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  2817. BAIDU_MAPS_CANVAS.style.visibility = "";
  2818. switchCovergeButton.nextPlayer = "Baidu";
  2819. switchCovergeButton.useGoogle = false;
  2820. document.querySelector(".compass").style.visibility = "hidden";
  2821. document.querySelector("button[data-qa='undo-move']").style.visibility = "hidden";
  2822. console.log("Container Canvas loaded");
  2823. }
  2824. else {
  2825. document.querySelector(".compass").style.visibility = "";
  2826. document.querySelector("button[data-qa='undo-move']").style.visibility = "";
  2827. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  2828. console.log("Container Canvas hidden");
  2829. }
  2830. }
  2831. else
  2832. {
  2833. setTimeout(Baidu, 250);
  2834. }
  2835.  
  2836. }
  2837.  
  2838. function Kakao() {
  2839. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2840. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  2841. // console.log("Kakao canvas");
  2842. if (KAKAO_MAPS_CANVAS != null)
  2843. {
  2844. KAKAO_MAPS_CANVAS.style.position = "absolute";
  2845. if (nextPlayer === "Kakao") {
  2846. KAKAO_MAPS_CANVAS.style.visibility = "";
  2847. switchCovergeButton.nextPlayer = "Kakao";
  2848. switchCovergeButton.useGoogle = false;
  2849. console.log("Kakao Canvas loaded");
  2850. }
  2851. else {
  2852. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  2853. console.log("Kakao Canvas hidden");
  2854. }
  2855. }
  2856. else
  2857. {
  2858. setTimeout(Kakao, 250);
  2859. }
  2860.  
  2861. }
  2862.  
  2863. function Yandex() {
  2864. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2865. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  2866. if (YANDEX_MAPS_CANVAS != null)
  2867. {
  2868. if (isBullseye)
  2869. {
  2870. let div = document.getElementById("player");
  2871. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__ncMwh");
  2872. div.prepend(YANDEX_MAPS_CANVAS);
  2873. }
  2874. // console.log("Yandex canvas");
  2875. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  2876. // console.log("Yandex canvas");
  2877. /* console.log(YANDEX_MAPS_CANVAS); */
  2878. if (nextPlayer === "Yandex") {
  2879. YANDEX_MAPS_CANVAS.style.visibility = "";
  2880. switchCovergeButton.nextPlayer = "Yandex";
  2881. switchCovergeButton.useGoogle = false;
  2882. console.log("Yandex Canvas loaded");
  2883. }
  2884. else {
  2885. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  2886. console.log("Yandex Canvas hidden");
  2887. }
  2888. }
  2889. else
  2890. {
  2891. setTimeout(Yandex, 250);
  2892. }
  2893.  
  2894. }
  2895.  
  2896. function Mapillary()
  2897. {
  2898. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2899. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  2900. if (MAPILLARY_MAPS_CANVAS != null)
  2901. {
  2902. // console.log("Mapillary canvas");
  2903. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  2904. if (nextPlayer === "Mapillary") {
  2905. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  2906. switchCovergeButton.nextPlayer = "Mapillary";
  2907. switchCovergeButton.useGoogle = false;
  2908. console.log("Mapillary Canvas loaded");
  2909. }
  2910. else {
  2911. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  2912. console.log("Mapillary Canvas hidden");
  2913. }
  2914. }
  2915. else
  2916. {
  2917. setTimeout(Mapillary, 250);
  2918. }
  2919.  
  2920. }
  2921.  
  2922. function Bing() {
  2923. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2924. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  2925. if (BING_MAPS_CANVAS != null && document.querySelector(".compass") !== null)
  2926. {
  2927. // console.log("Mapillary canvas");
  2928. BING_MAPS_CANVAS.style.position = "absolute";
  2929. if (nextPlayer === "MS Satellite" || nextPlayer === "MS Streetside") {
  2930. BING_MAPS_CANVAS.style.visibility = "";
  2931. switchCovergeButton.nextPlayer = nextPlayer;
  2932. switchCovergeButton.useGoogle = false;
  2933. document.querySelector(".compass").style.visibility = "hidden";
  2934. console.log("Bing Canvas loaded");
  2935. }
  2936. else {
  2937. BING_MAPS_CANVAS.style.visibility = "hidden";
  2938. document.querySelector(".compass").style.visibility = "";
  2939. console.log("Bing Canvas hidden");
  2940. }
  2941. }
  2942. else
  2943. {
  2944. setTimeout(Bing, 250);
  2945. }
  2946. }
  2947.  
  2948.  
  2949. /**
  2950. * Adjust button placement
  2951. */
  2952.  
  2953. function ZoomControls() {
  2954. let style = `
  2955. .ymaps-2-1-79-panorama-gotoymaps {display: none !important;}
  2956. .game-layout__controls {bottom: 8rem !important; left: 1rem !important;}
  2957. `;
  2958.  
  2959. let style_element = document.createElement("style");
  2960. style_element.innerHTML = style;
  2961. document.body.appendChild(style_element);
  2962. }
  2963.  
  2964. /**
  2965. * Updates the compass to match Yandex Panorama facing
  2966. */
  2967. function updateCompass() {
  2968. if (!COMPASS) {
  2969. let compass = document.querySelector("img.compass__indicator");
  2970. if (compass != null) {
  2971. COMPASS = compass;
  2972. let direction = YandexPlayer.getDirection()[0] * -1;
  2973. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  2974. }
  2975. }
  2976. else {
  2977. let direction = YandexPlayer.getDirection()[0] * -1;
  2978. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  2979. }
  2980. }
  2981.  
  2982. /**
  2983. * Open next location in streetview player given next player and next coordinate
  2984. */
  2985.  
  2986. function goToLocation() {
  2987. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2988. console.log("Going to location");
  2989. if (nextPlayer === "Yandex") {
  2990. let options = {};
  2991. YandexPlayer.moveTo([global_lat, global_lng], options);
  2992. YandexPlayer.setDirection([0, 16]);
  2993. YandexPlayer.setSpan([10, 67]);
  2994. }
  2995. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  2996. if (document.getElementById("i_container") !== null)
  2997. {
  2998. let iframe = document.getElementById("i_container");
  2999. if (nextPlayer === "Baidu")
  3000. {
  3001. if (!isFirefox)
  3002. {
  3003. iframe.style.top = '-60px';
  3004. iframe.style.height = (window.innerHeight + 200) + 'px';
  3005. }
  3006. else
  3007. {
  3008. iframe.style.top = '-60px';
  3009. iframe.style.height = (window.innerHeight + 219) + 'px';
  3010. }
  3011.  
  3012. if (!isFirefox)
  3013. {
  3014. iframe.style.right = '-55px';
  3015. iframe.style.width = (window.innerWidth + 55) + 'px';
  3016. }
  3017. else
  3018. {
  3019. iframe.style.right = '-15px';
  3020. iframe.style.width = (window.innerWidth + 15) + 'px';
  3021. }
  3022. let urlStr2 = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  3023. 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;
  3024. // console.log(urlStr)
  3025. if (global_BDAh != null)
  3026. {
  3027. iframe.src = urlStr;
  3028. }
  3029. else
  3030. {
  3031. iframe.src = urlStr2;
  3032. }
  3033. iframe.style.visibility = "";
  3034. }
  3035. else if (nextPlayer === "Youtube")
  3036. {
  3037. document.getElementById("Youtube Button").style.visibility = "";
  3038. document.getElementById("Youtube Button").innerHTML = "Play video";
  3039. iframe.allow = "autoplay";
  3040. iframe.style.visibility = "hidden";
  3041. iframe.style.top = '-60px';
  3042. iframe.style.height = (window.innerHeight + 235) + 'px';
  3043. }
  3044. else if (nextPlayer === "Image")
  3045. {
  3046. iframe.style.top = '0px';
  3047. iframe.style.height = (window.innerHeight) + 'px';
  3048. iframe.style.visibility = "";
  3049. iframe.src = iId;
  3050. }
  3051. }
  3052. else
  3053. {
  3054. setTimeout(goToLocation, 250);
  3055. }
  3056. // let a = new BMap.Point(global_lng, global_lat);
  3057. // BaiduPlayer.setPov({ heading: -40, pitch: 6 });
  3058. // BaiduPlayer.setPosition(a);
  3059. }
  3060. else if (nextPlayer === "Kakao") {
  3061. var roadviewClient = new kakao.maps.RoadviewClient();
  3062. var position = new kakao.maps.LatLng(global_lat, global_lng);
  3063. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3064. KakaoPlayer.setPanoId(panoId, position);
  3065. KakaoPlayer.setViewpoint({ pan: global_heading, tilt: global_pitch, zoom: -3 })
  3066. });
  3067. }
  3068. else if (nextPlayer === "Mapillary") {
  3069. MapillaryPlayer.resize()
  3070. MapillaryPlayer.moveTo(mmKey).then(
  3071. image => { //console.log(image);
  3072. },
  3073. error => { console.log(error); });
  3074. }
  3075. else if (nextPlayer === "Google") {
  3076. handleMapillary({lat: global_lat, lng: global_lng}, {meters: 500, limit: 500});
  3077. }
  3078. else if (nextPlayer === "MS Streetside") {
  3079. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.streetside,
  3080. zoom: 18,
  3081. streetsideOptions: {
  3082. overviewMapMode: Microsoft.Maps.OverviewMapMode.hidden,
  3083. showCurrentAddress: false,
  3084. showProblemReporting: false,
  3085. showExitButton: false,
  3086. },
  3087. center: new Microsoft.Maps.Location(global_lat, global_lng),
  3088. heading: 90,
  3089. pitch: -30,
  3090. disableStreetside: false});
  3091. }
  3092. else if (nextPlayer === "MS Satellite") {
  3093. let ctr = new Microsoft.Maps.Location(global_lat, global_lng)
  3094. let loc_centre = {lat: global_lat, lng: global_lng};
  3095. for (var i = MSStreetPlayer.entities.getLength() - 1; i >= 0; i--) {
  3096. var pushpin = MSStreetPlayer.entities.get(i);
  3097. if (pushpin instanceof Microsoft.Maps.Pushpin) {
  3098. MSStreetPlayer.entities.removeAt(i);
  3099. }
  3100. }
  3101. let latlngBounds = getBBox2(loc_centre, ms_radius);
  3102. // console.log(latlngBounds)
  3103. let bounds = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(latlngBounds[0], latlngBounds[1]), new Microsoft.Maps.Location(latlngBounds[2], latlngBounds[3]));
  3104. // console.log(bounds)
  3105. MSStreetPlayer.setOptions({maxBounds: bounds})
  3106. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.aerial,
  3107. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  3108. center: ctr,
  3109. zoom: 15,
  3110. })
  3111. var pin = new Microsoft.Maps.Pushpin(ctr, {});
  3112.  
  3113. //Add the pushpin to the map
  3114. MSStreetPlayer.entities.push(pin);
  3115. // hideNav();
  3116. }
  3117. switchCovergeButton.lat = global_lat;
  3118. switchCovergeButton.lng = global_lng;
  3119. }
  3120.  
  3121. /**
  3122. * Handle undo using the location history of the current round
  3123. */
  3124.  
  3125. function goToUndoMove(data) {
  3126. /* console.log(global_lat);
  3127. console.log(global_lng); */
  3128. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3129. let options = {};
  3130. let prevStep = null;
  3131. if (locHistory.length === 1) {
  3132. prevStep = locHistory[0];
  3133. }
  3134. else {
  3135. prevStep = locHistory.pop();
  3136. }
  3137. // console.log(prevStep);
  3138. // console.log(locHistory)
  3139. if (nextPlayer === "Yandex") {
  3140. defaultPanoIdChange = false;
  3141. YandexPlayer.moveTo([prevStep[0], prevStep[1]], options);
  3142. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  3143. YandexPlayer.setSpan([10, 67]);
  3144. switchCovergeButton.lat = prevStep[0];
  3145. switchCovergeButton.lng = prevStep[1];
  3146. }
  3147. else if (nextPlayer === "Kakao") {
  3148. let btn = document.querySelector("button[data-qa='undo-move']");
  3149. btn.disabled = false;
  3150. btn.classList.remove('styles_disabled__2YdHD');
  3151. defaultPanoIdChange = false;
  3152. let position = new kakao.maps.LatLng(prevStep[0], prevStep[1]);
  3153. KakaoPlayer.setPanoId(prevStep[2], position);
  3154. switchCovergeButton.lat = prevStep[0];
  3155. switchCovergeButton.lng = prevStep[1];
  3156. switchCovergeButton.useGoogle = false;
  3157. teleportBtn.google = false;
  3158. // console.log("Undo 1 step");
  3159. // console.log(locHistory);
  3160. }
  3161. else if (nextPlayer === "Mapillary" ) {
  3162. // console.log(prevStep[1]);
  3163.  
  3164. MapillaryPlayer.moveTo(prevStep[2]).then(
  3165. image => {
  3166. //console.log(image);
  3167. switchCovergeButton.lat = prevStep[1];
  3168. switchCovergeButton.lng = prevStep[0];
  3169. },
  3170. error => { console.log(error); });
  3171. }
  3172. else if (nextPlayer === "MS Streetside") {
  3173. defaultPanoIdChange = false;
  3174. console.log(locHistory);
  3175. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(prevStep[0], prevStep[1]),
  3176.  
  3177. });
  3178. switchCovergeButton.lat = prevStep[0];
  3179. switchCovergeButton.lng = prevStep[1];
  3180. switchCovergeButton.heading = prevStep[2];
  3181. }
  3182.  
  3183. }
  3184.  
  3185. function BYKTeleport()
  3186. {
  3187. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3188. let teleportBtnBYK = teleportBtn;
  3189. if (teleportBtnBYK)
  3190. {
  3191. teleportBtnBYK.addEventListener("click", () => {
  3192. if (!teleportBtnBYK.google)
  3193. {
  3194. // console.log("non-Google Teleport");
  3195. let prevStep = null;
  3196. if (locHistory.length === 1) {
  3197. prevStep = locHistory[0];
  3198. }
  3199. else {
  3200. prevStep = locHistory[locHistory.length - 1];
  3201. }
  3202. console.log(locHistory);
  3203. let options = {};
  3204. let place, position, pID;
  3205. if (nextPlayer === "Yandex") {
  3206. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtnBYK.distance * 0.001);
  3207. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  3208. YandexPlayer.moveTo([place.lat, place.lng], options);
  3209. YandexPlayer.setSpan([10, 67]);
  3210. switchCovergeButton.lat = place.lat;
  3211. switchCovergeButton.lng = place.lng;
  3212. }
  3213. else if (nextPlayer === "Kakao") {
  3214. var roadviewClient = new kakao.maps.RoadviewClient();
  3215. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[3]), teleportBtnBYK.distance * 0.001);
  3216. position = new kakao.maps.LatLng(place.lat, place.lng);
  3217. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3218. KakaoPlayer.setPanoId(panoId, position);
  3219. });
  3220. switchCovergeButton.lat = place.lat;
  3221. switchCovergeButton.lng = place.lng;
  3222. }
  3223. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  3224. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtnBYK.distance * 0.001);
  3225. handleMapillary(place, {meters: 500, limit: 500});
  3226. switchCovergeButton.lat = place.lat;
  3227. switchCovergeButton.lng = place.lng;
  3228. // locHistory.push([place.lat, place.lng, prevStep[2], prevStep[3]]);
  3229. }
  3230. else if (nextPlayer === "MS Streetside") {
  3231. // console.log("teleport")
  3232. // console.log(prevStep);
  3233. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtnBYK.distance * 0.001);
  3234. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(place.lat, place.lng), 1, 1);
  3235. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  3236. function onSuccess(panoramaInfo) {
  3237. // console.log("Coverage")
  3238. // console.log([panoramaInfo.la, panoramaInfo.lo])
  3239. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  3240. });
  3241. }
  3242. function onMissingCoverage() {
  3243. console.log("No Coverage")
  3244. }
  3245. }
  3246.  
  3247. if (teleportBtnBYK.distance > 150)
  3248. {
  3249. teleportBtnBYK.distance = 100;
  3250. teleportBtnBYK.innerHTML = "Teleport " + teleportBtnBYK.distance + " m";
  3251. }
  3252. }
  3253. });
  3254. }
  3255. else
  3256. {
  3257. }
  3258. }
  3259.  
  3260. function SyncListener()
  3261. {
  3262. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3263. switchCovergeButton.addEventListener("click", () => {
  3264. if (switchCovergeButton.useGoogle == false) {
  3265. // switchCovergeButton.useGoogle = true;
  3266. console.log(switchCovergeButton.nextPlayer)
  3267. if (switchCovergeButton.nextPlayer === "Yandex") {
  3268. let options = {};
  3269. YandexPlayer.moveTo([switchCovergeButton.lat, switchCovergeButton.lng], options);
  3270. YandexPlayer.setDirection([switchCovergeButton.heading, 0]);
  3271.  
  3272. // switchCovergeButton.nextPlayer = "Yandex";
  3273. }
  3274. else if (switchCovergeButton.nextPlayer === "Kakao") {
  3275. let roadviewClient = new kakao.maps.RoadviewClient();
  3276. // console.log(switchCovergeButton.lat);
  3277. let position = new kakao.maps.LatLng(switchCovergeButton.lat, switchCovergeButton.lng);
  3278. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3279. KakaoPlayer.setPanoId(panoId, position);
  3280. });
  3281. KakaoPlayer.setViewpoint({
  3282. pan: switchCovergeButton.heading,
  3283. tilt: 0,
  3284. zoom: -3
  3285. });
  3286. // switchCovergeButton.nextPlayer = "Kakao";
  3287. }
  3288. else if (switchCovergeButton.nextPlayer === "Mapillary" || switchCovergeButton.nextPlayer === "Google") {
  3289. // switchCovergeButton.nextPlayer = "Kakao";
  3290. handleMapillary({lat: switchCovergeButton.lat, lng: switchCovergeButton.lng}, {meters: 100, limit: 100});
  3291. }
  3292. else if (switchCovergeButton.nextPlayer === "MS Streetside") {
  3293. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(switchCovergeButton.lat, switchCovergeButton.lng), 0.01, 0.01);
  3294. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  3295. function onSuccess(panoramaInfo) {
  3296. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  3297. heading: switchCovergeButton.heading
  3298. });
  3299. }
  3300. function onMissingCoverage() {
  3301. console.log("No Coverage")
  3302. }
  3303. }
  3304. }
  3305. });
  3306.  
  3307. }
  3308.  
  3309. /**
  3310. * Gets the seed data for the current game
  3311. *
  3312. * @returns Promise with seed data as object
  3313. */
  3314. function getSeed() {
  3315. // console.log("getSeed called");
  3316. return new Promise((resolve, reject) => {
  3317. let token = getToken();
  3318. let URL;
  3319. let cred = ""
  3320.  
  3321. const PATHNAME = window.location.pathname;
  3322.  
  3323. if (PATHNAME.startsWith("/game/")) {
  3324. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  3325. }
  3326. else if (PATHNAME.startsWith("/challenge/")) {
  3327. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  3328. }
  3329. else if (PATHNAME.startsWith("/battle-royale/")) {
  3330. URL = `https://game-server.geoguessr.com/api/battle-royale/${token}`;
  3331. }
  3332. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  3333. URL = `https://game-server.geoguessr.com/api/duels/${token}`;
  3334. }
  3335. else if (PATHNAME.startsWith("/bullseye/")) {
  3336. URL = `https://game-server.geoguessr.com/api/bullseye/${token}`;
  3337. }
  3338. if (isBattleRoyale) {
  3339. fetch(URL, {
  3340. // Include credentials to GET from the endpoint
  3341. credentials: 'include'
  3342. })
  3343. .then((response) => response.json())
  3344. .then((data) => {
  3345. resolve(data);
  3346. })
  3347. .catch((error) => {
  3348. reject(error);
  3349. });
  3350. }
  3351. else {
  3352. fetch(URL)
  3353. .then((response) => response.json())
  3354. .then((data) => {
  3355. resolve(data);
  3356. })
  3357. .catch((error) => {
  3358. reject(error);
  3359. });
  3360. }
  3361. });
  3362. }
  3363.  
  3364. /**
  3365. * Gets the token from the current URL
  3366. *
  3367. * @returns token
  3368. */
  3369. function getToken() {
  3370. const PATHNAME = window.location.pathname;
  3371. if (PATHNAME.startsWith("/game/")) {
  3372. return PATHNAME.replace("/game/", "");
  3373. }
  3374. else if (PATHNAME.startsWith("/challenge/")) {
  3375. return PATHNAME.replace("/challenge/", "");
  3376. }
  3377. else if (PATHNAME.startsWith("/battle-royale/")) {
  3378. return PATHNAME.replace("/battle-royale/", "");
  3379. }
  3380. else if (PATHNAME.startsWith("/duels/")) {
  3381. return PATHNAME.replace("/duels/", "");
  3382. }
  3383. else if (PATHNAME.startsWith("/team-duels/")) {
  3384. return PATHNAME.replace("/team-duels/", "");
  3385. }
  3386. else if (PATHNAME.startsWith("/bullseye/")) {
  3387. return PATHNAME.replace("/bullseye/", "");
  3388. }
  3389. }
  3390.  
  3391. /**
  3392. * Gets the round number from the ongoing game from the page itself
  3393. *
  3394. * @returns Round number
  3395. */
  3396. function getRoundFromPage() {
  3397. const roundData = document.querySelector("div[data-qa='round-number']");
  3398. if (roundData) {
  3399. let roundElement = roundData.querySelector("div:last-child");
  3400. if (roundElement) {
  3401. let round = parseInt(roundElement.innerText.charAt(0));
  3402. if (!isNaN(round) && round >= 1 && round <= 5) {
  3403. return round;
  3404. }
  3405. }
  3406. }
  3407. else {
  3408. return ROUND;
  3409. }
  3410. }
  3411.  
  3412.  
  3413. /**
  3414. * Injects Yandex Script
  3415. */
  3416. function injectYandexScript() {
  3417. return new Promise((resolve, reject) => {
  3418. if (!YANDEX_INJECTED) {
  3419. if (YANDEX_API_KEY === "") {
  3420. console.log("No Yandex Key")
  3421. reject();
  3422. }
  3423. else {
  3424. if (!partialCreateYandex)
  3425. {
  3426. const SCRIPT = document.createElement("script");
  3427. SCRIPT.type = "text/javascript";
  3428. SCRIPT.async = true;
  3429. SCRIPT.src = `https://api-maps.yandex.ru/2.1/?lang=en_US&apikey=${YANDEX_API_KEY}`;
  3430. document.body.appendChild(SCRIPT);
  3431. SCRIPT.onload = () => {
  3432. ymaps.ready(() => {
  3433. YANDEX_INJECTED = true;
  3434. myHighlight("Yandex API Loaded");
  3435. resolve();
  3436. });
  3437. }
  3438. }
  3439. else
  3440. {
  3441. YANDEX_INJECTED = true;
  3442. resolve();
  3443. }
  3444. }
  3445. }
  3446. else {
  3447. resolve();
  3448. }
  3449. });
  3450. }
  3451.  
  3452. /**
  3453. * Injects Yandex Player and calls handleReturnToStart
  3454. */
  3455. function injectYandexPlayer() {
  3456. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3457. let lat = 41.321861;
  3458. let lng = 69.212920;
  3459.  
  3460. let options = {
  3461. "direction": [0, 16],
  3462. "span": [10, 67],
  3463. "controls": ["zoomControl"]
  3464. };
  3465. ymaps.panorama.createPlayer("player", [lat, lng], options)
  3466. .done((player) => {
  3467. YandexPlayer = player;
  3468. YandexPlayer.events.add("directionchange", (e) => {
  3469. updateCompass();
  3470. let pov = YandexPlayer.getDirection();
  3471. if (locHistory.length > 0 && nextPlayer == "Yandex") {
  3472. switchCovergeButton.heading = pov[0];
  3473. locHistory[locHistory.length - 1][2] = pov[0];
  3474. locHistory[locHistory.length - 1][3] = pov[1];
  3475. }
  3476. });
  3477. YandexPlayer.events.add("panoramachange", (e) => {
  3478. if (defaultPanoIdChange) {
  3479. let num = YandexPlayer.getPanorama().getPosition();
  3480. let pov = YandexPlayer.getDirection();
  3481. // console.log(num);
  3482. // console.log(pov);
  3483. if (nextPlayer == "Yandex")
  3484. {
  3485. locHistory.push([num[0], num[1], pov[0], pov[1]]);
  3486. switchCovergeButton.lat = num[0];
  3487. switchCovergeButton.lng = num[1];
  3488. }
  3489. let btn = document.querySelector("button[data-qa='undo-move']");
  3490. if (locHistory.length > 1) {
  3491. btn.disabled = false;
  3492. btn.classList.remove('styles_disabled__2YdHD');
  3493. }
  3494. // console.log(locHistory);
  3495. }
  3496. defaultPanoIdChange = true;
  3497.  
  3498. });
  3499. console.log("Yandex Player injected");
  3500. });
  3501.  
  3502. }
  3503.  
  3504.  
  3505. /**
  3506. * Injects Baidu script
  3507. */
  3508.  
  3509. function reportWindowSize() {
  3510. let iframeC = document.getElementById("i_container");
  3511. if (iframeC)
  3512. {
  3513. if (nextPlayer == "Baidu")
  3514. {
  3515. iframeC.style.top = '-60px';
  3516. iframeC.style.height = (window.innerHeight + 200) + 'px';
  3517. iframeC.style.right = '-55px';
  3518. iframeC.style.width = (window.innerWidth + 55) + 'px';
  3519. }
  3520. else if (nextPlayer == "Youtube")
  3521. {
  3522. iframeC.style.top = '-60px';
  3523. iframeC.style.height = (window.innerHeight + 235) + 'px';
  3524. }
  3525. else if (nextPlayer == "Image")
  3526. {
  3527. iframeC.style.top = '0px';
  3528. iframeC.style.height = (window.innerHeight) + 'px';
  3529. }
  3530.  
  3531. }
  3532. }
  3533.  
  3534. window.onresize = reportWindowSize;
  3535.  
  3536. function injectContainer() {
  3537. myHighlight("iframe container loaded")
  3538. const iframe = document.createElement('iframe');
  3539. iframe.frameBorder = 0;
  3540. iframe.style.position = "absolute";
  3541. iframe.id = "i_container";
  3542. if (isBattleRoyale) {
  3543. if (isDuel)
  3544. {
  3545. iframe.className = "inactive"
  3546. }
  3547. else if (isBullseye)
  3548. {
  3549. iframe.className = "game-panorama_panorama__ncMwh"
  3550. }
  3551. else
  3552. {
  3553. iframe.className = "br-game-layout__panorama"
  3554. }
  3555. }
  3556. else {
  3557. iframe.className = "game-layout__panorama"
  3558. }
  3559. var div = document.getElementById("player");
  3560. div.style.overflow = "hidden";
  3561. if (isBullseye)
  3562. {
  3563. div.prepend(iframe);
  3564. }
  3565. else
  3566. {
  3567. div.appendChild(iframe);
  3568. }
  3569. }
  3570.  
  3571. // function injectMedia() {
  3572. // myHighlight("Baidu API loaded")
  3573. // const iframe = document.createElement('iframe');
  3574. // iframe.allow = "autoplay"
  3575. // iframe.src = "https://www.youtube.com/embed/72kRM86V-dw?&autoplay=1&modestbranding=1&controls=0&start=10"
  3576. // iframe.frameBorder = 0;
  3577. // iframe.style.position = "absolute";
  3578. // iframe.id = "media-player";
  3579. // 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;"
  3580. // if (isBattleRoyale) {
  3581. // if (isDuel)
  3582. // {
  3583. // iframe.className = "inactive"
  3584. // }
  3585. // else
  3586. // {
  3587. // iframe.className = "br-game-layout__panorama"
  3588. // }
  3589. // }
  3590. // else {
  3591. // iframe.className = "game-layout__panorama"
  3592. // }
  3593. // var div = document.getElementById("player");
  3594. // div.style.overflow = "hidden";
  3595. // div.appendChild(iframe);
  3596. // }
  3597.  
  3598. /**
  3599. * Injects Kakao script
  3600. */
  3601.  
  3602. function injectKakaoScript() {
  3603. return new Promise((resolve, reject) => {
  3604. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3605. if (!KAKAO_INJECTED) {
  3606. if (KAKAO_API_KEY === "") {
  3607. console.log("No Kakao Key")
  3608. }
  3609. else {
  3610.  
  3611. let canvas = document.createElement("kmap");
  3612. if (isBattleRoyale) {
  3613. if (isDuel)
  3614. {
  3615. canvas.innerHTML = `
  3616. <div id="roadview" class="inactive" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  3617. `;
  3618. }
  3619. else if (isBullseye)
  3620. {
  3621. canvas.innerHTML = `
  3622. <div id="roadview" class="game-panorama_panorama__ncMwh" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  3623. `;
  3624. }
  3625. else
  3626. {
  3627. canvas.innerHTML = `
  3628. <div id="roadview" class="br-game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  3629. `;
  3630. }
  3631. }
  3632. else {
  3633. canvas.innerHTML = `
  3634. <div id="roadview" class="game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  3635. `;
  3636. }
  3637.  
  3638.  
  3639. var div = document.getElementById("player");
  3640. if (isBullseye)
  3641. {
  3642. div.prepend(canvas);
  3643. }
  3644. else
  3645. {
  3646. div.appendChild(canvas);
  3647. }
  3648.  
  3649. let SCRIPT;
  3650. if (!partialCreateKakao)
  3651. {
  3652. SCRIPT = document.createElement("script");
  3653. SCRIPT.async = true;
  3654. // SCRIPT.type = "text/javascript";
  3655. SCRIPT.src = `//dapi.kakao.com/v2/maps/sdk.js?appkey=${KAKAO_API_KEY}&autoload=false`;
  3656. document.body.appendChild(SCRIPT);
  3657. }
  3658.  
  3659. function drawmapKakao()
  3660. {
  3661. kakao.maps.load(function () {
  3662. var position = new kakao.maps.LatLng(33.450701, 126.560667);
  3663. let roadviewContainer = document.getElementById('roadview');
  3664. KakaoPlayer = new kakao.maps.Roadview(roadviewContainer);
  3665. var panoId = 1023434522;
  3666. KakaoPlayer.setPanoId(panoId, position);
  3667. KAKAO_INJECTED = true;
  3668. // Remove the compass from Kakao
  3669. kakao.maps.event.addListener(KakaoPlayer, 'init', () => {
  3670. const compassContainer = roadviewContainer.querySelector('div[id*="_box_util_"]');
  3671. if (compassContainer) compassContainer.style.display = 'none';
  3672. });
  3673. kakao.maps.event.addListener(KakaoPlayer, 'panoid_changed', function() {
  3674. if (defaultPanoIdChange && KakaoPlayer) {
  3675. let latlng = KakaoPlayer.getPosition();
  3676. let lat = latlng.getLat();
  3677. let lng = latlng.getLng();
  3678. let pID = KakaoPlayer.getViewpointWithPanoId();
  3679. if (nextPlayer == "Kakao" && lat != 33.45047613915499)
  3680. {
  3681. // console.log("push");
  3682. locHistory.push([lat, lng, pID.panoId, pID.pan]);
  3683. switchCovergeButton.lat = lat;
  3684. switchCovergeButton.lng = lng;
  3685. switchCovergeButton.heading = pID.pan;
  3686. }
  3687. let btn = document.querySelector("button[data-qa='undo-move']");
  3688. if (locHistory.length > 1 && (btn != null)) {
  3689. btn.disabled = false;
  3690. btn.classList.remove('styles_disabled__2YdHD');
  3691. }
  3692. // console.log(locHistory);
  3693. }
  3694. defaultPanoIdChange = true;
  3695. });
  3696. kakao.maps.event.addListener(KakaoPlayer, 'viewpoint_changed', function() {
  3697. // console.log("pov_listener attached");
  3698. let pID = KakaoPlayer.getViewpointWithPanoId();
  3699. if (locHistory.length > 0 && nextPlayer == "Kakao") {
  3700. switchCovergeButton.heading = pID.pan;
  3701. locHistory[locHistory.length - 1][3] = pID.pan;
  3702. }
  3703. if (GooglePlayer) {
  3704. const { heading, pitch } = GooglePlayer.getPov()
  3705. if ((!almostEqual(pID.pan, heading) || !almostEqual(pID.tilt, pitch)) && nextPlayer == "Kakao") {
  3706. // Updating the google street view POV will update the compass
  3707. GooglePlayer.setPov({ heading: pID.pan, pitch: pID.tilt })
  3708. }
  3709. }
  3710. // console.log(locHistory);
  3711. })
  3712. });
  3713. }
  3714.  
  3715. if (partialCreateKakao)
  3716. {
  3717. drawmapKakao();
  3718. }
  3719. else
  3720. {
  3721. SCRIPT.onload = () => {
  3722. drawmapKakao();
  3723. myHighlight("Kakao API Loaded");
  3724. resolve();
  3725. };
  3726. }
  3727.  
  3728. }
  3729. }
  3730. else {
  3731. resolve();
  3732. }
  3733. });
  3734. }
  3735.  
  3736.  
  3737. function injectMSPlayer() {
  3738. return new Promise((resolve, reject) => {
  3739. if (!MS_INJECTED) {
  3740. if (MS_API_KEY === "") {
  3741. let canvas = document.getElementById("player");
  3742. console.log("No MS Key")
  3743. }
  3744. else {
  3745.  
  3746. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3747. let SCRIPT;
  3748. if (!partialCreateMS)
  3749. {
  3750. SCRIPT = document.createElement("script");
  3751. SCRIPT.type = "text/javascript";
  3752. SCRIPT.async = true;
  3753. SCRIPT.src = `https://www.bing.com/api/maps/mapcontrol?key=${MS_API_KEY}`;
  3754. document.body.appendChild(SCRIPT);
  3755. }
  3756. let canvas = document.createElement("msmap");
  3757. if (isBattleRoyale) {
  3758. if (isDuel)
  3759. {
  3760. canvas.innerHTML = `<div id="ms-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  3761. }
  3762. else if (isBullseye)
  3763. {
  3764. 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>`;
  3765. }
  3766. else
  3767. {
  3768. 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>`;
  3769. }
  3770. }
  3771. else {
  3772. canvas.innerHTML = `<div id="ms-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  3773. }
  3774.  
  3775. var div = document.getElementById("player");
  3776. if (isBullseye)
  3777. {
  3778. div.prepend(canvas);
  3779. }
  3780. else
  3781. {
  3782. div.appendChild(canvas);
  3783. }
  3784.  
  3785. function drawmapMS()
  3786. {
  3787. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true});
  3788. MS_INJECTED = true;
  3789. Microsoft.Maps.Events.addHandler(MSStreetPlayer, 'viewchange', function () { updateView(MSStreetPlayer); });
  3790. function updateView(map) {
  3791. let ctrm = map.getCenter();
  3792. if (nextPlayer == "MS Streetside" && (switchCovergeButton.lat !== ctrm.latitude && switchCovergeButton.lng !== ctrm.longitude))
  3793. {
  3794. let heading2 = bearing(switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude)
  3795. // console.log("moved");
  3796. // console.log([switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude])
  3797. // console.log(heading2);
  3798. locHistory.push([ctrm.latitude, ctrm.longitude, heading2]);
  3799. switchCovergeButton.lat = ctrm.latitude;
  3800. switchCovergeButton.lng = ctrm.longitude;
  3801. switchCovergeButton.heading = heading2;
  3802. let btn = document.querySelector("button[data-qa='undo-move']");
  3803. if (locHistory.length > 1 && (btn != null)) {
  3804. btn.disabled = false;
  3805. btn.classList.remove('styles_disabled__2YdHD');
  3806. }
  3807. }
  3808. }
  3809. }
  3810.  
  3811. if (partialCreateMS)
  3812. {
  3813. drawmapMS();
  3814. }
  3815. else
  3816. {
  3817. SCRIPT.addEventListener('load', () => {
  3818. myHighlight("Bing Maps API loaded");
  3819. let timeout = 0;
  3820. let interval = setInterval(() => {
  3821. if (timeout >= 40) {
  3822. reject();
  3823. clearInterval(interval);
  3824. }
  3825. if (document.getElementById('ms-player') !== null && typeof Microsoft.Maps.Map !== typeof undefined) {
  3826. drawmapMS();
  3827. resolve();
  3828. clearInterval(interval);
  3829. }
  3830. timeout += 1;
  3831. }, 1000);
  3832. })
  3833. }
  3834. }
  3835. }
  3836. else {
  3837. resolve();
  3838. }
  3839. });
  3840. }
  3841.  
  3842.  
  3843.  
  3844. function injectMapillaryPlayer() {
  3845. return new Promise((resolve, reject) => {
  3846. if (!MAPILLARY_INJECTED) {
  3847. if (MAPILLARY_API_KEY === "") {
  3848. let canvas = document.getElementById("player");
  3849. console.log("No Mapillary Key")
  3850. }
  3851. else {
  3852. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3853.  
  3854. let SCRIPT;
  3855. if (!partialCreateMapillary)
  3856. {
  3857. SCRIPT = document.createElement("script");
  3858. SCRIPT.type = "text/javascript";
  3859. SCRIPT.async = true;
  3860. SCRIPT.src = `https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.js`;
  3861. document.body.appendChild(SCRIPT);
  3862. document.querySelector('head').innerHTML += '<link href="https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.css" rel="stylesheet"/>';
  3863. }
  3864. let canvas = document.createElement("mmap");
  3865. if (isBattleRoyale) {
  3866. if (isDuel)
  3867. {
  3868.  
  3869. canvas.innerHTML = `<div id="mapillary-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  3870. }
  3871. else if (isBullseye)
  3872. {
  3873. 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>`;
  3874. }
  3875. else
  3876. {
  3877. 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>`;
  3878. }
  3879. }
  3880. else {
  3881. canvas.innerHTML = `<div id="mapillary-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  3882. }
  3883.  
  3884. var div = document.getElementById("player");
  3885. if (isBullseye)
  3886. {
  3887. div.prepend(canvas);
  3888. }
  3889. else
  3890. {
  3891. div.appendChild(canvas);
  3892. }
  3893.  
  3894. function drawMapML()
  3895. {
  3896. var {Viewer} = mapillary;
  3897.  
  3898. MapillaryPlayer = new Viewer({
  3899. accessToken: MAPILLARY_API_KEY,
  3900. container: 'mapillary-player', // the ID of our container defined in the HTML body
  3901. });
  3902.  
  3903. MapillaryPlayer.on('image', async (event) => {
  3904. // cnt = cnt + 1;
  3905. // console.log(cnt);
  3906. let image = event.image;
  3907. let pos = image.originalLngLat;
  3908. let cond = true;
  3909. for (const element of locHistory) {
  3910. if (element[2] == image.id)
  3911. {
  3912. cond = false;
  3913. }
  3914. }
  3915. if (cond)
  3916. {
  3917. switchCovergeButton.lat = pos.lat;
  3918. switchCovergeButton.lng = pos.lng;
  3919. switchCovergeButton.heading = image.compassAngle;
  3920. // console.log(pos);
  3921. locHistory.push([pos.lat, pos.lng, image.id, image.compassAngle]);
  3922. }
  3923. let btn = document.querySelector("button[data-qa='undo-move']");
  3924. if (btn !== null && locHistory.length > 1)
  3925. {
  3926. btn.disabled = false;
  3927. btn.classList.remove('styles_disabled__2YdHD');
  3928. }
  3929. });
  3930.  
  3931. MAPILLARY_INJECTED = true;
  3932. }
  3933. if (partialCreateMapillary)
  3934. {
  3935. drawMapML();
  3936. }
  3937. else
  3938. {
  3939.  
  3940. SCRIPT.addEventListener('load', () => {
  3941. myHighlight("Mapillary API Loaded");
  3942. // resolve(BMap);
  3943. drawMapML();
  3944. resolve();
  3945. })
  3946. }
  3947. }
  3948. }
  3949. else {
  3950. resolve();
  3951. }
  3952. });
  3953. }
  3954.  
  3955.  
  3956. function handleMapillary(latlng, options)
  3957. {
  3958. console.log("handleMapillary")
  3959. handleMapillaryHelper(latlng, options).then((data) => {
  3960. //console.log(data.data)
  3961. let idToSet = 0;
  3962. let curDist = 100000000;
  3963. for (const element of data.data) {
  3964. // console.log(element)
  3965. if (element.hasOwnProperty("computed_geometry"))
  3966. {
  3967. try {
  3968. let rCord = element.computed_geometry["coordinates"];
  3969. let dist = distance(latlng.lat,latlng.lng,rCord[1],rCord[0])
  3970. if (dist < curDist)
  3971. {
  3972. idToSet = element.id;
  3973. curDist = dist
  3974. }
  3975. } catch (e) {
  3976. console.log("Error")
  3977. }
  3978. }
  3979. }
  3980. if (idToSet !== 0)
  3981. {
  3982. MapillaryPlayer.moveTo(idToSet).then(
  3983. image => { //console.log(image);
  3984. },
  3985. error => { console.log(error); });
  3986. }}).catch((error) => {
  3987. console.log(error);
  3988. });
  3989. }
  3990.  
  3991. function handleMapillaryHelper(latlng, options)
  3992. {
  3993. return new Promise((resolve, reject) => {
  3994. // console.log("1")
  3995. let bbox = getBBox(latlng, options.meters);
  3996. 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)
  3997. // console.log(URL)
  3998. fetch(URL)
  3999. .then((response) => {resolve(response.json())})
  4000. .catch((error) => {console.log(error);});
  4001. });
  4002. }
  4003.  
  4004. function moveFrom(coords, angle, distance){
  4005. const R_EARTH = 6378.137;
  4006. const M = (1 / ((2 * Math.PI / 360) * R_EARTH)) / 1000;
  4007. let radianAngle = -angle * Math.PI / 180;
  4008. let x = 0 + (distance * Math.cos(radianAngle));
  4009. let y = 0 + (distance * Math.sin(radianAngle));
  4010.  
  4011. let newLat = coords.lat + (y * M);
  4012. let newLng = coords.lng + (x * M) / Math.cos(coords.lat * (Math.PI / 180));
  4013. return { lat: newLat, lng: newLng };
  4014. }
  4015.  
  4016. function getBBox(coordinates, meters){
  4017. let SW = moveFrom(coordinates, 135, meters);
  4018. let NE = moveFrom(coordinates, 315, meters);
  4019. return `${SW.lng},${SW.lat},${NE.lng},${NE.lat}`;
  4020. }
  4021.  
  4022. function getBBox2(coordinates, meters){
  4023. let SW = moveFrom(coordinates, 135, meters);
  4024. let NE = moveFrom(coordinates, 315, meters);
  4025. return [NE.lat,SW.lng,SW.lat,NE.lng];
  4026. }
  4027.  
  4028.  
  4029. function distance(lat1, lon1, lat2, lon2) {
  4030. var p = 0.017453292519943295; // Math.PI / 180
  4031. var c = Math.cos;
  4032. var a = 0.5 - c((lat2 - lat1) * p)/2 +
  4033. c(lat1 * p) * c(lat2 * p) *
  4034. (1 - c((lon2 - lon1) * p))/2;
  4035.  
  4036. return 1000 * 12742 * Math.asin(Math.sqrt(a)); // 2 * R; R = 6371 km
  4037. }
  4038.  
  4039.  
  4040. /**
  4041. * Minimap presets
  4042. */
  4043.  
  4044. let water_name_only =
  4045. [
  4046. {
  4047. "elementType": "geometry",
  4048. "stylers": [
  4049. {
  4050. "visibility": "off"
  4051. }
  4052. ]
  4053. },
  4054. {
  4055. "featureType": "administrative",
  4056. "stylers": [
  4057. {
  4058. "visibility": "off"
  4059. }
  4060. ]
  4061. },
  4062. {
  4063. "featureType": "landscape",
  4064. "stylers": [
  4065. {
  4066. "visibility": "off"
  4067. }
  4068. ]
  4069. },
  4070. {
  4071. "featureType": "poi",
  4072. "stylers": [
  4073. {
  4074. "visibility": "off"
  4075. }
  4076. ]
  4077. },
  4078. {
  4079. "featureType": "road",
  4080. "stylers": [
  4081. {
  4082. "visibility": "off"
  4083. }
  4084. ]
  4085. },
  4086. {
  4087. "featureType": "transit",
  4088. "stylers": [
  4089. {
  4090. "visibility": "off"
  4091. }
  4092. ]
  4093. }
  4094. ]
  4095. let country_name_only =
  4096. [
  4097. {
  4098. "elementType": "geometry",
  4099. "stylers": [
  4100. {
  4101. "visibility": "off"
  4102. }
  4103. ]
  4104. },
  4105. {
  4106. "featureType": "administrative",
  4107. "stylers": [
  4108. {
  4109. "visibility": "off"
  4110. }
  4111. ]
  4112. },
  4113. {
  4114. "featureType": "administrative.country",
  4115. "elementType": "labels",
  4116. "stylers": [
  4117. {
  4118. "visibility": "on"
  4119. }
  4120. ]
  4121. },
  4122. {
  4123. "featureType": "landscape",
  4124. "stylers": [
  4125. {
  4126. "visibility": "off"
  4127. }
  4128. ]
  4129. },
  4130. {
  4131. "featureType": "poi",
  4132. "stylers": [
  4133. {
  4134. "visibility": "off"
  4135. }
  4136. ]
  4137. },
  4138. {
  4139. "featureType": "road",
  4140. "stylers": [
  4141. {
  4142. "visibility": "off"
  4143. }
  4144. ]
  4145. },
  4146. {
  4147. "featureType": "transit",
  4148. "stylers": [
  4149. {
  4150. "visibility": "off"
  4151. }
  4152. ]
  4153. },
  4154. {
  4155. "featureType": "water",
  4156. "stylers": [
  4157. {
  4158. "visibility": "off"
  4159. }
  4160. ]
  4161. }
  4162. ]
  4163.  
  4164. let no_label_or_terrain =
  4165. [
  4166. {
  4167. "elementType": "geometry",
  4168. "stylers": [
  4169. {
  4170. "visibility": "off"
  4171. }
  4172. ]
  4173. },
  4174. {
  4175. "featureType": "administrative",
  4176. "stylers": [
  4177. {
  4178. "visibility": "off"
  4179. }
  4180. ]
  4181. },
  4182. {
  4183. "featureType": "landscape",
  4184. "stylers": [
  4185. {
  4186. "visibility": "off"
  4187. }
  4188. ]
  4189. },
  4190. {
  4191. "featureType": "poi",
  4192. "stylers": [
  4193. {
  4194. "visibility": "off"
  4195. }
  4196. ]
  4197. },
  4198. {
  4199. "featureType": "road",
  4200. "stylers": [
  4201. {
  4202. "visibility": "off"
  4203. }
  4204. ]
  4205. },
  4206. {
  4207. "featureType": "transit",
  4208. "stylers": [
  4209. {
  4210. "visibility": "off"
  4211. }
  4212. ]
  4213. },
  4214. {
  4215. "featureType": "water",
  4216. "stylers": [
  4217. {
  4218. "visibility": "on"
  4219. }
  4220. ]
  4221. },
  4222. {
  4223. "featureType": "water",
  4224. "elementType": "labels",
  4225. "stylers": [
  4226. {
  4227. "visibility": "off"
  4228. }
  4229. ]
  4230. }
  4231. ]
  4232.  
  4233. let no_label =
  4234. [
  4235. {
  4236. "elementType": "labels",
  4237. "stylers": [
  4238. {
  4239. "visibility": "off"
  4240. }
  4241. ]
  4242. },
  4243. {
  4244. "featureType": "administrative",
  4245. "stylers": [
  4246. {
  4247. "visibility": "off"
  4248. }
  4249. ]
  4250. }
  4251. ]
  4252.  
  4253. let blank =
  4254.  
  4255. [
  4256. {
  4257. "stylers": [
  4258. {
  4259. "visibility": "off"
  4260. }
  4261. ]
  4262. }
  4263. ]
  4264.  
  4265. let thick_border =
  4266.  
  4267. [
  4268. {
  4269. "featureType": "administrative.country",
  4270. "elementType": "geometry.stroke",
  4271. "stylers": [
  4272. {
  4273. "weight": 1.5
  4274. }
  4275. ]
  4276. },
  4277. {
  4278. "featureType": "administrative.province",
  4279. "elementType": "geometry.stroke",
  4280. "stylers": [
  4281. {
  4282. "weight": 3.5
  4283. }
  4284. ]
  4285. }
  4286. ]
  4287.  
  4288. let default_preset = []
  4289.  
  4290. let presetMinimap = [[default_preset, "Default"],
  4291. [blank, "Blank"],
  4292. [water_name_only, "Oceanman"],
  4293. [country_name_only, "Impossible"],
  4294. [no_label_or_terrain, "Streaks"],
  4295. [no_label, "Easy 5K"],
  4296. [thick_border, "Borders"],
  4297. [default_preset, "Satellite"],
  4298. [default_preset, "Terrain"],
  4299. [default_preset, "Hybrid"],
  4300. [custom, "Custom", customMode]]
  4301.  
  4302. let GEOJSON_INVISIBLE =
  4303. {
  4304. strokeOpacity: 0,
  4305. fillOpacity: 0,
  4306. }
  4307.  
  4308. let presetOverlay = [["Clear",""],
  4309. ["Coverage",""],
  4310. ["Official",""],
  4311. ["Longitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/lonl.json"],
  4312. ["Latitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/latl.json"],
  4313. ["US County","https://raw.githubusercontent.com/CodeForCary/CountyDataUSA5m/master/cb_2017_us_county_5m.json"],
  4314. ["France","https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements.geojson"],
  4315. ["Time Zone", "https://raw.githubusercontent.com/treyerl/timezones/master/timezones_wVVG8.geojson"],
  4316. ["UK Parliament", "https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/electoral/gb/wpc.json"],
  4317. ["Custom", YOUR_URL]]
  4318.  
  4319. /**
  4320. * Display map per local laws and regulations
  4321. */
  4322.  
  4323. let SEOverlay, NWOverlay, SEOverlay3;
  4324. let TW = [[24.80, 119.00, 22.00, 123.20],
  4325. [24.20, 119.90, 22.90, 121.85],
  4326. [24.00, 120.90, 23.80, 121.20],
  4327. [23.93, 121.03, 23.85, 121.15],
  4328. [23.92, 121.055, 23.89, 121.10],
  4329. [23.92, 121.055, 23.89, 121.10],
  4330. [23.92, 121.055, 23.89, 121.10],
  4331. ]
  4332.  
  4333. let TS = [[30.40, 93.40, 28, 97.20],
  4334. [29.40, 94.55, 28.20, 96.45]]
  4335.  
  4336. let NW = [36.20, 77.70, 34.40, 80.70]