Geoguessr Unity Script

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

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

  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 6.1.0
  5. // @author Jupaoqq
  6. // @include https://www.geoguessr.com/*
  7. // @run-at document-start
  8. // @license MIT
  9. // @namespace https://greatest.deepsurf.us/users/838374
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. /**
  14. * Custom your minimap here!
  15. */
  16.  
  17. /**
  18. * 1: replace "roadmap" in the customMode field with any of the options below:
  19. * "roadmap" displays the default road map view. This is the default map type.
  20. * "satellite" displays Google Earth satellite images.
  21. * "hybrid" displays a mixture of normal and satellite views.
  22. * "terrain" displays a physical map based on terrain information.
  23. */
  24.  
  25. let customMode = "roadmap";
  26.  
  27. /**
  28. * 2: Go to https://mapstyle.withgoogle.com/ first click "No thanks, take me to the old style wizard"
  29. * then click "MORE OPTIONS" to hide or reveal certain features.
  30. * When you are done, click "FINISH", then "COPY JSON", and replace my settings in custom with your settings below.
  31. */
  32.  
  33. let custom =
  34.  
  35. [
  36. {
  37. "featureType": "administrative",
  38. "stylers": [
  39. {
  40. "visibility": "off"
  41. }
  42. ]
  43. },
  44. {
  45. "featureType": "landscape",
  46. "stylers": [
  47. {
  48. "visibility": "off"
  49. }
  50. ]
  51. },
  52. {
  53. "featureType": "poi.park",
  54. "stylers": [
  55. {
  56. "visibility": "off"
  57. }
  58. ]
  59. },
  60. {
  61. "featureType": "road",
  62. "elementType": "labels",
  63. "stylers": [
  64. {
  65. "visibility": "off"
  66. }
  67. ]
  68. },
  69. {
  70. "featureType": "transit",
  71. "stylers": [
  72. {
  73. "visibility": "off"
  74. }
  75. ]
  76. }
  77. ]
  78.  
  79. /**
  80. * End of Minimap customization instruction section
  81. */
  82.  
  83. /**
  84. * Overlay anything on the minimap here!
  85. * 1. overlay an GeoJSON object
  86. * 2. overlay a custom image
  87. */
  88.  
  89. /**
  90. * Overlay an GeoJSON object:
  91. */
  92.  
  93. // change the GeoJson display style.
  94. // strokeOpacity, strokeWeight, fillOpacity takes a value between 0 and 1.
  95. // strokeColor and fillColor supports Hexadecimal color (#00FF00 is green)
  96. // If clickable is set to true, you would not be able to make a guess within the shape
  97.  
  98. let GEOJSON_STYLE =
  99. {
  100. strokeColor: "black",
  101. strokeOpacity: 1,
  102. strokeWeight: 0.2,
  103. fillColor: "#00FF00",
  104. fillOpacity: 0,
  105. clickable: false,
  106. }
  107.  
  108. // replace the URL with your desired link
  109. // For example, search "Germany GeoJson" on Github, find this link (https://github.com/isellsoap/deutschlandGeoJSON/blob/main/4_kreise/4_niedrig.geo.json)
  110. // Then click "Download" to get the raw.githubusercontent.com link (https://raw.githubusercontent.com/isellsoap/deutschlandGeoJSON/main/4_kreise/4_niedrig.geo.json)
  111. // and replace the URL below with that URL.
  112. // State zipcode: see this site https://github.com/OpenDataDE/State-zip-code-GeoJSON
  113.  
  114. let YOUR_URL = "https://raw.githubusercontent.com/severinlandolt/map-switzerland/main/02%20GeoJSON/CH_Kantonsgrenzen_100_geo.json"
  115.  
  116. // set it to true to add your custom GeoJSON by copy it to the code below (this is for
  117.  
  118. let GeoJsonCustomUser = false
  119.  
  120. // replace with your custom GeoJson, go to https://geojson.io/ to customize it then copy the Json to here
  121.  
  122. let CUSTOM_GEOJSON =
  123.  
  124. {
  125. "type": "FeatureCollection",
  126. "features": [
  127. {
  128. "type": "Feature",
  129. "properties": {},
  130. "geometry": {
  131. "type": "LineString",
  132. "coordinates": [
  133. [
  134. 2.493896484375,
  135. 52.7163309360463
  136. ],
  137. [
  138. 2.4609375,
  139. 53.15994678846807
  140. ],
  141. [
  142. 3.2025146484375,
  143. 53.179703893605385
  144. ],
  145. [
  146. 3.2080078125,
  147. 52.96518371955126
  148. ],
  149. [
  150. 2.48291015625,
  151. 52.948637884883205
  152. ]
  153. ]
  154. }
  155. },
  156. {
  157. "type": "Feature",
  158. "properties": {},
  159. "geometry": {
  160. "type": "LineString",
  161. "coordinates": [
  162. [
  163. 3.218994140625,
  164. 52.05586831074774
  165. ],
  166. [
  167. 3.218994140625,
  168. 52.13685974852633
  169. ],
  170. [
  171. 2.515869140625,
  172. 52.1267438596429
  173. ],
  174. [
  175. 2.515869140625,
  176. 51.77803705914517
  177. ],
  178. [
  179. 3.2354736328125,
  180. 51.78993084774129
  181. ],
  182. [
  183. 3.228607177734375,
  184. 51.96119237712624
  185. ],
  186. [
  187. 2.8571319580078125,
  188. 51.95230623740452
  189. ]
  190. ]
  191. }
  192. },
  193. {
  194. "type": "Feature",
  195. "properties": {
  196. "stroke": "#555555",
  197. "stroke-width": 2,
  198. "stroke-opacity": 1
  199. },
  200. "geometry": {
  201. "type": "LineString",
  202. "coordinates": [
  203. [
  204. 2.5048828125,
  205. 52.619725272670266
  206. ],
  207. [
  208. 2.5103759765625,
  209. 52.274880130680536
  210. ],
  211. [
  212. 2.867431640625,
  213. 52.284962354465726
  214. ],
  215. [
  216. 3.2299804687499996,
  217. 52.29504228453735
  218. ],
  219. [
  220. 3.2135009765625,
  221. 52.63973017532399
  222. ],
  223. [
  224. 2.5096893310546875,
  225. 52.621392697207625
  226. ]
  227. ]
  228. }
  229. }
  230. ]
  231. }
  232.  
  233. /**
  234. * Overlay a custom image:
  235. */
  236.  
  237. // set it to true to add your image overlay
  238.  
  239. let OverlayCustom = false
  240.  
  241. // replace the URL with your desired link
  242.  
  243. let OVERLAY_URL = "https://www.battleface.com/blog/wp-content/uploads/2020/10/patreon-profile-tom-geowizard.jpg"
  244.  
  245. // set the bounds for the image - latitude (North and South), longitude (North and South)
  246.  
  247. let OVERLAY_BOUNDS =
  248. {
  249. north: 53,
  250. west: -3,
  251. south: 51,
  252. east: 1,
  253. };
  254.  
  255. // change the image overlay display style.
  256.  
  257. let OVERLAY_STYLE =
  258. {
  259. fillOpacity: 0.2,
  260. clickable: false,
  261. }
  262.  
  263. /**
  264. * End of Minimap Overlay instruction section
  265. */
  266.  
  267. // API Keys
  268.  
  269. var MS_API_KEY = "Ap2DwDDitzY7jJuYeIJF6YyfqDkYt-QxIBjeQ6SDEJelSfb6ghAVb-V4I-G3om-s";
  270. var YANDEX_API_KEY = "b704b5a9-3d67-4d19-b702-ec7807cecfc6";
  271. var KAKAO_API_KEY = "cbacbe41e3a223d794f321de4f3e247b";
  272. var MAPBOX_API_KEY = "pk.eyJ1IjoianVwYW9xcSIsImEiOiJjbDB2dTBnbngweWIzM2NtdWR5NXZ1dncyIn0.bJixk3kN5Mmedw_C3vQmmw";
  273. const MAPS_API_URL = "https://maps.googleapis.com/maps/api/js"; // removed "?" from the link
  274. var MAPILLARY_API_KEY_LIST =
  275. ["MLY|6723031704435203|5afd537469b114cf814881137ad74b7c",
  276. "MLY|6691659414239148|b45e7e82cde126044cbc2cf5d4a7c9b1",
  277. "MLY|5074369465929308|f7ad2802cbaf26c63f88046a292df68b",
  278. "MLY|7451643761528219|6477f2db0e3928b51e45ec9311983936",
  279. "MLY|4855256237866198|6d0464771831c8a4bf2be095e1e1aabc",
  280. "MLY|4772941976102161|8458d4f08d2e1970cdfe0a4e242c04ff",
  281. "MLY|4492067214235489|94c44703942362ad6f6b70b5d32c3a45",
  282. "MLY|4618251611628426|0cef71d6ec8b997a5ec06ecdeabf11ec",
  283. "MLY|4096846270415982|fa2ce29641503e6ef665f17459633570",
  284. "MLY|4231415756962414|fe353880fd246e8a4a6ae32152f7dbb0",]
  285.  
  286. var MAPILLARY_API_KEY = MAPILLARY_API_KEY_LIST[Math.floor(Math.random() * MAPILLARY_API_KEY_LIST.length)];
  287.  
  288. console.log("Geoguessr Unity Script v6.1.0 by Jupaoqq");
  289.  
  290.  
  291. // Store each player instance
  292.  
  293. let YandexPlayer, KakaoPlayer, GooglePlayer, MapillaryPlayer, MSStreetPlayer, MapboxPlayer, MapboxMarker;
  294. let YANDEX_INJECTED = false;
  295. let BAIDU_INJECTED = false;
  296. let KAKAO_INJECTED = false;
  297. let MAPILLARY_INJECTED = false;
  298. let MS_INJECTED = false;
  299. let MAPBOX_INJECTED = false;
  300. let rainLayer;
  301.  
  302. // Game mode detection
  303.  
  304. let isBattleRoyale = false;
  305. let isDuel = false;
  306. let isBullseye = false;
  307. let isLiveChallenge = false;
  308.  
  309. // Player detection and coordinate conversion
  310.  
  311. let nextPlayer = "Google";
  312. let nextPlayer_save = "Google";
  313. let global_lat = 0;
  314. let global_lng = 0;
  315. let global_cc = null;
  316. let global_panoID = null;
  317. let global_BDID, global_BDAh, global_BDBh;
  318. let yId, yTime, yEnd, iId;
  319. let global_heading = null;
  320. let global_pitch = null;
  321.  
  322. let krCoordinates = [38.75292321084364, 124.2804539232574, 33.18509676203202, 129.597381999198]
  323. let global_radi = 100
  324.  
  325. // Callback variables
  326.  
  327. let eventListenerAttached = false;
  328. let povListenerAttached = false;
  329. let playerLoaded = false;
  330. let teleportLoaded = false;
  331. let syncLoaded = false;
  332.  
  333. // Minimize Yandex API use
  334.  
  335. let yandex_map = false;
  336. let Kakao_map = false;
  337. let Wikipedia_map = false;
  338. let Minecraft_map = false;
  339. let bing_map = false;
  340.  
  341. // Mapillary Image Key
  342.  
  343. let mmKey = 0;
  344.  
  345. // Handle Yandex compass
  346.  
  347. let COMPASS = null;
  348.  
  349. // Handle undo
  350.  
  351. let locHistory = [];
  352. let defaultPanoIdChange = true;
  353.  
  354. // Round check
  355.  
  356. let ROUND = 0;
  357. let CURRENT_ROUND_DATA = null;
  358.  
  359. let switch_call = true;
  360. let one_reset = false;
  361. // let cnt = 0;
  362.  
  363. let cn_tips = false;
  364. var isFirefox = typeof InstallTrigger !== 'undefined';
  365.  
  366. let linksList = []
  367. let fire1 = true;
  368. let allowDetect = false;
  369. let planetType = "None";
  370.  
  371. // Satellite Map Radius (in Meters)
  372. let ms_radius = 15000;
  373. let sat_choice = false;
  374.  
  375. // Create the Maps, but not reload API
  376. let partialCreateYandex = false;
  377. let partialCreateKakao = false;
  378. let partialCreateMapillary = false;
  379. let partialCreateMS = false;
  380. let partialCreateMapbox = false;
  381.  
  382. // let NEW_ROUND_LOADED = false;
  383.  
  384. // Geoguessr Canvas String Names
  385.  
  386. let GENERAL_LAYOUT = ".game-layout__canvas";
  387. let GENERAL_CANVAS = ".game-layout__panorama-canvas";
  388. let BR_CANVAS = ".br-game-layout__panorama-canvas";
  389. let BR_WRAPPER = ".br-game-layout__panorama-wrapper";
  390. let BR_LAYOUT = ".br-game-layout";
  391. let FAIL_TO_LOAD_CANVAS = ".game-layout__panorama-message";
  392. let DUEL_LAYOUT = ".game_layout__TO_jf";
  393. let DUELS_CANVAS = ".game-panorama_panorama__rdhFg";
  394. let DUELS_CANVAS2 = ".game-panorama_panoramaCanvas__PNKve";
  395. let BULLSEYE_CANVAS = ".game-panorama_panorama__ncMwh";
  396. let BULLSEYE_CANVAS2 = ".game-panorama_panoramaCanvas__r_5ea";
  397. let LIVE_CANVAS = ".game-panorama_panorama__Qpsxl";
  398. let LIVE_CANVAS2 = ".game-panorama_panoramaCanvas__LaXCd";
  399. let DUELS_POPUP = ".overlay_overlay__AR02x";
  400. let BR_POPUP = ".popup__content";
  401.  
  402. let BR_LOAD_KAKAO = false;
  403. let BR_LOAD_YANDEX = false;
  404. let BR_LOAD_MS = false;
  405. let BR_LOAD_MP = false;
  406. let BR_LOAD_MAPILLARY = false;
  407.  
  408. let ms_sat_map = false;
  409. let rtded = false;
  410. let NM = false;
  411. let NP = false;
  412. let NZ = false;
  413.  
  414. let initBing = false;
  415.  
  416. let menuLocCounter = 0;
  417. let wikiUrl = "";
  418. let bullseyeMapillary = false;
  419.  
  420. function sleep(milliseconds) {
  421. var start = new Date().getTime();
  422. for (var i = 0; i < 1e7; i++) {
  423. if ((new Date().getTime() - start) > milliseconds){
  424. break;
  425. }
  426. }
  427. }
  428.  
  429. // window.addEventListener('popstate', function(event) {
  430. // var photo = document.getElementById("sat_map");
  431. // console.log(photo);
  432. // document.body.appendChild(photo);
  433. // }, false);
  434.  
  435.  
  436.  
  437. /**
  438. * Helper Functions
  439. */
  440.  
  441. // Highlight API Load Message
  442.  
  443. function myHighlight(...args) {
  444. console.log(`%c${[...args]}`, "color: dodgerblue; font-size: 24px;");
  445. }
  446.  
  447. // Hex to number conversion for Baidu coordinate conversion
  448.  
  449. function hex2a(hexx) {
  450. var hex = hexx.toString();
  451. var str = '';
  452. for (var i = 0; i < hex.length; i += 2)
  453. {
  454. str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
  455. }
  456. return str;
  457. }
  458.  
  459. // Coordinate computation given heading, distance and current coordinates for teleport
  460.  
  461. function FindPointAtDistanceFrom(lat, lng, initialBearingRadians, distanceKilometres) {
  462. const radiusEarthKilometres = 6371.01;
  463. var distRatio = distanceKilometres / radiusEarthKilometres;
  464. var distRatioSine = Math.sin(distRatio);
  465. var distRatioCosine = Math.cos(distRatio);
  466.  
  467. var startLatRad = DegreesToRadians(lat);
  468. var startLonRad = DegreesToRadians(lng);
  469.  
  470. var startLatCos = Math.cos(startLatRad);
  471. var startLatSin = Math.sin(startLatRad);
  472.  
  473. var endLatRads = Math.asin((startLatSin * distRatioCosine) + (startLatCos * distRatioSine * Math.cos(initialBearingRadians)));
  474.  
  475. var endLonRads = startLonRad
  476. + Math.atan2(
  477. Math.sin(initialBearingRadians) * distRatioSine * startLatCos,
  478. distRatioCosine - startLatSin * Math.sin(endLatRads));
  479.  
  480. return { lat: RadiansToDegrees(endLatRads), lng: RadiansToDegrees(endLonRads) };
  481. }
  482.  
  483. function DegreesToRadians(degrees) {
  484. const degToRadFactor = Math.PI / 180;
  485. return degrees * degToRadFactor;
  486. }
  487.  
  488. function RadiansToDegrees(radians) {
  489. const radToDegFactor = 180 / Math.PI;
  490. return radians * radToDegFactor;
  491. }
  492.  
  493. function toRadians(degrees) {
  494. return degrees * Math.PI / 180;
  495. };
  496.  
  497. // Converts from radians to degrees.
  498. function toDegrees(radians) {
  499. return radians * 180 / Math.PI;
  500. }
  501.  
  502. function bearing(start_latitude, start_longitude, stop_latitude, stop_longitude){
  503. let y = Math.sin(stop_longitude-start_longitude) * Math.cos(stop_latitude);
  504. let x = Math.cos(start_latitude)*Math.sin(stop_latitude) -
  505. Math.sin(start_latitude)*Math.cos(stop_latitude)*Math.cos(stop_longitude-start_longitude);
  506. let brng = Math.atan2(y, x) * 180 / Math.PI;
  507. return brng
  508. }
  509.  
  510. // Check if two floating point numbers are really really really really close to each other (to 10 decimal points)
  511. function almostEqual (a, b) {
  512. return a.toFixed(10) === b.toFixed(10)
  513. }
  514.  
  515. function almostEqual2 (a, b) {
  516. return a.toFixed(3) === b.toFixed(3)
  517. }
  518.  
  519. function moveFrom(coords, angle, distance){
  520. const R_EARTH = 6378.137;
  521. const M = (1 / ((2 * Math.PI / 360) * R_EARTH)) / 1000;
  522. let radianAngle = -angle * Math.PI / 180;
  523. let x = 0 + (distance * Math.cos(radianAngle));
  524. let y = 0 + (distance * Math.sin(radianAngle));
  525.  
  526. let newLat = coords.lat + (y * M);
  527. let newLng = coords.lng + (x * M) / Math.cos(coords.lat * (Math.PI / 180));
  528. return { lat: newLat, lng: newLng };
  529. }
  530.  
  531. function getBBox(coordinates, meters){
  532. let SW = moveFrom(coordinates, 135, meters);
  533. let NE = moveFrom(coordinates, 315, meters);
  534. return `${SW.lng},${SW.lat},${NE.lng},${NE.lat}`;
  535. }
  536.  
  537. // function getBBox2(coordinates, meters){
  538. // let SW = moveFrom(coordinates, 135, meters * 1.44);
  539. // let NE = moveFrom(coordinates, 315, meters * 1.44);
  540. // return [NE.lat,SW.lng,SW.lat,NE.lng];
  541. // }
  542.  
  543. function getBBox2(coordinates, meters){
  544. let SW = moveFrom(coordinates, 135, meters * 1.44);
  545. let NE = moveFrom(coordinates, 315, meters * 1.44);
  546. if (NE.lat > 90)
  547. {
  548. SW.lat -= (NE.lat - 90);
  549. NE.lat = 90;
  550. }
  551. if (SW.lat < -90)
  552. {
  553. NE.lat += (-90 - SW.lat);
  554. SW.lat = -90;
  555. }
  556. if (SW.lng < -180)
  557. {
  558. NE.lng += (-180 - SW.lng);
  559. SW.lng = -180;
  560. }
  561. if (NE.lng > 180)
  562. {
  563. SW.lng -= (NE.lng - 180);
  564. NE.lng = 180;
  565. }
  566. return [NE.lat,SW.lng,SW.lat,NE.lng];
  567. }
  568.  
  569. function distance(lat1, lon1, lat2, lon2) {
  570. var p = 0.017453292519943295; // Math.PI / 180
  571. var c = Math.cos;
  572. var a = 0.5 - c((lat2 - lat1) * p)/2 +
  573. c(lat1 * p) * c(lat2 * p) *
  574. (1 - c((lon2 - lon1) * p))/2;
  575.  
  576. return 1000 * 12742 * Math.asin(Math.sqrt(a)); // 2 * R; R = 6371 km
  577. }
  578.  
  579. // Script injection, extracted from extenssr:
  580. // https://gitlab.com/nonreviad/extenssr/-/blob/main/src/injected_scripts/maps_api_injecter.ts
  581.  
  582. function overrideOnLoad(googleScript, observer, overrider) {
  583. const oldOnload = googleScript.onload
  584. googleScript.onload = (event) => {
  585. const google = window.google
  586. if (google) {
  587. observer.disconnect()
  588. overrider(google)
  589. }
  590. if (oldOnload) {
  591. oldOnload.call(googleScript, event)
  592. }
  593. }
  594. }
  595.  
  596. function grabGoogleScript(mutations) {
  597. for (const mutation of mutations) {
  598. for (const newNode of mutation.addedNodes) {
  599. const asScript = newNode
  600. if (asScript && asScript.src && asScript.src.startsWith('https://maps.googleapis.com/')) {
  601. //asScript.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyDqRTXlnHXELLKn7645Q1L_5oc4CswKZK4&v=3&libraries=places,drawing&language=ja&region=JP"
  602. return asScript
  603. }
  604. }
  605. }
  606. return null
  607. }
  608.  
  609. function injecter(overrider) {
  610. if (document.documentElement)
  611. {
  612. injecterCallback(overrider);
  613. }
  614. else
  615. {
  616. alert("Script didn't load, refresh to try loading the script");
  617. }
  618. }
  619.  
  620.  
  621. function injecterCallback(overrider)
  622. {
  623. new MutationObserver((mutations, observer) => {
  624. const googleScript = grabGoogleScript(mutations)
  625. if (googleScript) {
  626. overrideOnLoad(googleScript, observer, overrider)
  627. }
  628. }).observe(document.documentElement, { childList: true, subtree: true })
  629. }
  630.  
  631. function magic_formula(boundary)
  632. {
  633. let area = Math.abs((boundary[0] - boundary[2]) * (boundary[1] - boundary[3]))
  634. // console.log(boundary);
  635. // console.log(area);
  636. let dist = Math.pow((area / 50000), 0.25) * 20000
  637. if (dist < 250) dist = 250
  638. return dist
  639. }
  640.  
  641. function formatDist()
  642. {
  643. if (ms_radius > 999)
  644. {
  645. let d = ms_radius / 1000.0;
  646. return parseFloat(d.toPrecision(2)).toString() + "km";
  647. }
  648. else
  649. {
  650. let d = ms_radius;
  651. return parseFloat(d.toPrecision(3)).toString() + "m";
  652. }
  653. }
  654.  
  655. // Getter function for the button elements
  656.  
  657. function setButtons()
  658. {
  659. // console.log("set")
  660. return [document.getElementById("Teleport Forward"), document.getElementById("Teleport Reverse"), document.getElementById("Teleport Button"), document.getElementById("plus"), document.getElementById("minus"),
  661. document.getElementById("reset"), document.getElementById("switch"), document.getElementById("Show Buttons"),
  662. document.getElementById("Date Button"), document.getElementById("minus year"), document.getElementById("plus year"),
  663. document.getElementById("Minimap Button"), document.getElementById("Overlay Button"), document.getElementById("Help Button"),
  664. document.getElementById("Teleport Options Button"), document.getElementById("Satellite Switch")];
  665. }
  666.  
  667. function setButtons2()
  668. {
  669. // console.log("set")
  670. return [document.getElementById("Show Buttons"),
  671. document.getElementById("Youtube Button"),
  672.  
  673. document.getElementById("Info Menu"),
  674. document.getElementById("Update Button"),
  675. document.getElementById("Help Button"),
  676. document.getElementById("Info Button"),
  677.  
  678. document.getElementById("Menu Reset"),
  679. document.getElementById("Menu Up"),
  680. document.getElementById("Menu down"),
  681.  
  682. document.getElementById("Teleport Menu"),
  683. document.getElementById("Teleport Forward"),
  684. document.getElementById("Teleport Reverse"),
  685.  
  686. document.getElementById("Teleport Button"),
  687. document.getElementById("plus"),
  688. document.getElementById("minus"),
  689.  
  690. document.getElementById("reset"),
  691. document.getElementById("Teleport Options Button"),
  692.  
  693. document.getElementById("switch"),
  694.  
  695. document.getElementById("Satellite Switch"),
  696.  
  697. document.getElementById("Satellite Menu"),
  698.  
  699. document.getElementById("Satellite Type Button"),
  700. document.getElementById("Satellite Style Button"),
  701.  
  702. document.getElementById("Time Machine Menu"),
  703. document.getElementById("Date Button"),
  704. document.getElementById("minus year"),
  705. document.getElementById("plus year"),
  706.  
  707. document.getElementById("Minimap Menu Button"),
  708. document.getElementById("Minimap Button"),
  709. document.getElementById("Overlay Button"),
  710.  
  711. document.getElementById("Space Menu Button"),
  712. document.getElementById("SpMini Button"),
  713. document.getElementById("SpOver Button"),
  714. document.getElementById("local language"),
  715. ]
  716. }
  717.  
  718. // Store default position for the button elements
  719.  
  720. function btnPosFinal(element)
  721. {
  722. if (element.id !== "Show Buttons")
  723. {
  724. if (element.classList.contains("menu-btn"))
  725. {
  726. element.style.right = "0.5em";
  727. }
  728.  
  729. if (element.classList.contains("full"))
  730. {
  731. element.style.right = "4em";
  732. }
  733. else if (element.classList.contains("half"))
  734. {
  735. if (element.classList.contains("horizontal-1"))
  736. {
  737. element.style.right = "4em";
  738. }
  739. else if (element.classList.contains("horizontal-2"))
  740. {
  741. element.style.right = "11.75em";
  742. }
  743. }
  744. else if (element.classList.contains("small"))
  745. {
  746. if (element.classList.contains("horizontal-1"))
  747. {
  748. element.style.right = "17em";
  749. }
  750. else if (element.classList.contains("horizontal-3"))
  751. {
  752. element.style.right = "4em";
  753. }
  754. }
  755. else if (element.classList.contains("large"))
  756. {
  757. element.style.right = "6.5em";
  758. }
  759.  
  760. if (element.classList.contains("vertical-0"))
  761. {
  762. element.style.top = "6em";
  763. }
  764. else if (element.classList.contains("vertical-1"))
  765. {
  766. element.style.top = "9.5em";
  767. }
  768. else if (element.classList.contains("vertical-2"))
  769. {
  770. element.style.top = "12em";
  771. }
  772. else if (element.classList.contains("vertical-3"))
  773. {
  774. element.style.top = "14.5em";
  775. }
  776. else if (element.classList.contains("vertical-4"))
  777. {
  778. element.style.top = "17em";
  779. }
  780. }
  781. }
  782.  
  783. function handleDropdown()
  784. {
  785. function dropdownHelper1(nm)
  786. {
  787. let hC = 0
  788. for (let mapDiv of document.getElementsByClassName(nm)){
  789. mapDiv.style.top = (11.85 + (hC * 1.65)).toString() + "em";
  790. hC++;
  791. }
  792. }
  793. function dropdownHelper2(nm)
  794. {
  795. let hC = 0
  796. for (let mapDiv of document.getElementsByClassName(nm)){
  797. mapDiv.style.top = (14.1 + (hC * 1.65)).toString() + "em";
  798. hC++;
  799. }
  800. }
  801. // let classN = ["preset-minimap", "overlay-minimap", "space-mainmap", "space-minimap"]
  802. let classN = ["preset-minimap", "overlay-minimap", "space-minimap"]
  803. for (let x of classN)
  804. {
  805. dropdownHelper1(x);
  806. }
  807. let classN2 = ["satellite-style", "satellite-type"]
  808. for (let x of classN2)
  809. {
  810. dropdownHelper2(x);
  811. }
  812. allowDetect = true;
  813. }
  814.  
  815. function resetBtnPos()
  816. {
  817. let [
  818. mainMenuBtn,
  819. YoutubeBtn,
  820.  
  821. infoMenu,
  822. UpdateBtn,
  823. HelpBtn,
  824. InfoBtn,
  825.  
  826. menuResetBtn,
  827. menuUpBtn,
  828. menuDownBtn,
  829.  
  830. teleportMenu,
  831. teleportForward,
  832. teleportReverse,
  833.  
  834. teleportMain,
  835. teleportMoreBtn,
  836. teleportLessBtn,
  837.  
  838. teleportDistResetBtn,
  839. TeleportArisBtn,
  840.  
  841. switchCovergeButton,
  842.  
  843. satelliteSwitchButton,
  844.  
  845. satelliteMenu,
  846.  
  847. satelliteTypeBtn,
  848. satelliteStyleBtn,
  849.  
  850. timeMachineMenu,
  851. timeMachineBtn,
  852. timeMachineOlderBtn,
  853. timeMachineNewerBtn,
  854.  
  855. MinimapMenuBtn,
  856. MinimapBtn,
  857. OverlayBtn,
  858.  
  859. SpaceMenuBtn,
  860. SpaceMinimapBtn,
  861. SpaceOverlayBtn,
  862. wikiLocalLang
  863. ] = setButtons2();
  864.  
  865. // Manu Buttons
  866.  
  867. mainMenuBtn.style.top = "6em";
  868. YoutubeBtn.style.top = "6em";
  869. infoMenu.style.top = "9.5em";
  870. teleportMenu.style.top = "12.5em";
  871. MinimapMenuBtn.style.top = "15.5em";
  872. timeMachineMenu.style.top = "18.5em";
  873. satelliteMenu.style.top = "21.5em";
  874. SpaceMenuBtn.style.top = "24.5em";
  875.  
  876. mainMenuBtn.style.right = "0.5em";
  877. mainMenuBtn.style.width = "3em";
  878.  
  879. for (let element of document.getElementsByClassName("unity-btn")){
  880. btnPosFinal(element);
  881. }
  882. handleDropdown();
  883.  
  884. }
  885.  
  886. // Adjust Buttons for different game modes
  887.  
  888. function AdjustBtnPos(top, right, arg)
  889. {
  890. if (arg)
  891. {
  892. resetBtnPos();
  893. }
  894. for (let element of document.getElementsByClassName("unity-btn")){
  895. let eTop = element.style.top;
  896. let eRight = element.style.right;
  897. element.style.top = "calc(" + top.toString() + " + " + eTop + ")";
  898. element.style.right = "calc(" + right.toString() + " + " + eRight + ")";
  899. // console.log(element.style.top)
  900. }
  901. }
  902.  
  903. function handleStyles()
  904. {
  905. let unityCSS =
  906. `visibility:hidden;
  907. border-radius: 25px;
  908. opacity: 0.8;
  909. height:2em;
  910. position:fixed;
  911. z-index:99999;
  912. background-color: #ba55d3;
  913. box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
  914. border: none;
  915. color: white;
  916. padding: none;
  917. text-align: center;
  918. vertical-align: text-top;
  919. text-decoration: none;
  920. display: inline-block;
  921. font-size: 16px;`;
  922.  
  923. for (let element of document.getElementsByClassName("unity-btn")){
  924. if (element.id !== "Show Buttons")
  925. {
  926. element.style = unityCSS;
  927. // const classNames = ["preset-minimap", "overlay-minimap", "satellite-style", "satellite-type", "space-mainmap", "space-minimap"]
  928. const classNames = ["preset-minimap", "overlay-minimap", "satellite-style", "satellite-type", "space-minimap"]
  929. if (classNames.some(className => element.classList.contains(className)))
  930. {
  931. element.style.height = "1.5em";
  932. element.style.background = "#ff69b4";
  933. if (["Clear", "Default", "Satellite", "solarNoon", "Earth"].includes(element.id))
  934. {
  935. if (element.id == "Clear")
  936. {
  937. element.loaded = true;
  938. }
  939. element.style.background = "#ff1493";
  940. if (typeof element.dim !== typeof null)
  941. {
  942. if (element.dim == "2D" || element.dim == "3D")
  943. {
  944. element.style.background = "#ff69b4";
  945. }
  946. }
  947. }
  948. }
  949.  
  950. if (element.classList.contains("menu-btn"))
  951. {
  952. element.style.width = "3em";
  953. element.style.height = "2.5em";
  954. // element.style.borderStyle = "solid";
  955. // element.style.borderWidth = "0.1px"
  956. // element.style.borderColor = "black";
  957.  
  958. }
  959.  
  960. if (element.classList.contains("extra-height"))
  961. {
  962. element.style.height = "4.5em";
  963. }
  964.  
  965. if (element.classList.contains("full"))
  966. {
  967. element.style.width = "15em";
  968. }
  969. else if (element.classList.contains("half"))
  970. {
  971. element.style.width = "7.25em";
  972. }
  973. else if (element.classList.contains("small"))
  974. {
  975. element.style.width = "2em";
  976. }
  977. else if (element.classList.contains("large"))
  978. {
  979. element.style.width = "10em";
  980. }
  981. btnPosFinal(element);
  982. }
  983. }
  984.  
  985. let dict = {
  986. 'Info Menu': ["url(https://www.svgrepo.com/show/299161/big-data.svg)", "#ff9999"],
  987. 'Teleport Menu': ["url(https://www.svgrepo.com/show/12767/car.svg)", "#ffcba4"],
  988. 'Minimap Menu Button': ["url(https://www.svgrepo.com/show/116365/map.svg)", "#faf0be"],
  989. 'Time Machine Menu': ["url(https://www.svgrepo.com/show/38630/clock.svg)", "#e8f48c"],
  990. 'Satellite Menu': ["url(https://www.svgrepo.com/show/29288/satellite.svg)", "#e0ffff"],
  991. 'Space Menu Button': ["url(https://www.svgrepo.com/show/120980/saturn.svg)", "#e5e4e2"]
  992. };
  993.  
  994. for (let element of document.getElementsByClassName("menu-btn"))
  995. {
  996. element.style.backgroundImage = dict[element.id][0];
  997. element.style.backgroundColor = dict[element.id][1];
  998. element.style.backgroundRepeat = "no-repeat";
  999. element.style.backgroundOrigin = "content-box";
  1000. element.style.visibility = "";
  1001. }
  1002.  
  1003. handleDropdown();
  1004. }
  1005.  
  1006. /**
  1007. * Creates Unity buttons
  1008. *
  1009. * @returns Promise
  1010. */
  1011.  
  1012. function hideOtherBtn()
  1013. {
  1014. for (let element of document.getElementsByClassName("unity-btn")){
  1015. if (element.id !== "Show Buttons")
  1016. {
  1017. element.style.visibility = "hidden";
  1018. }
  1019. if (nextPlayer == "Youtube" && element.id == "Youtube Button")
  1020. {
  1021. element.style.visibility = "";
  1022. }
  1023. if (nextPlayer == "Wikipedia" && element.id == "local language")
  1024. {
  1025. element.style.visibility = "";
  1026. }
  1027. }
  1028. }
  1029.  
  1030. function switchBtn(arg)
  1031. {
  1032. for (let element of document.getElementsByClassName("unity-btn")){
  1033. if (element.id !== "Show Buttons" && !element.classList.contains("menu-btn") && !element.classList.contains(arg))
  1034. {
  1035. element.style.visibility = "hidden";
  1036. }
  1037. if (nextPlayer == "Youtube" && element.id == "Youtube Button")
  1038. {
  1039. element.style.visibility = "";
  1040. }
  1041. if (nextPlayer == "Wikipedia" && element.id == "local language")
  1042. {
  1043. element.style.visibility = "";
  1044. }
  1045. }
  1046. }
  1047.  
  1048.  
  1049.  
  1050. function UnityInitiate() {
  1051. const google = window.google;
  1052. let curPosition;
  1053. let kakao_enabled = true;
  1054.  
  1055. ZoomControls();
  1056.  
  1057. function svCheck(data, status) {
  1058. if (status === 'OK') {
  1059. // console.log("STATUS OK");
  1060. let l = data.location.latLng.toString().split(',');
  1061. let lat = l[0].replaceAll('(', '');
  1062. let lng = l[1].replaceAll(')', '');
  1063. if (lat == curPosition.lat && lng == curPosition.lng && !switch_call)
  1064. {
  1065. console.log("Trying more distance");
  1066. teleportMain.distance += 100;
  1067. teleportMain.innerHTML = teleportMain.distance + " m";
  1068. }
  1069. else
  1070. {
  1071. console.log("Teleport Success");
  1072. GooglePlayer.setPosition(data.location.latLng);
  1073. GooglePlayer.setPov({
  1074. heading: switchCovergeButton.heading,
  1075. pitch: 0,
  1076. })
  1077. if (teleportMain.distance > 150)
  1078. {
  1079. teleportMain.distance = 100;
  1080. teleportMain.innerHTML = teleportMain.distance + " m";
  1081. }
  1082. }
  1083. switch_call = false;
  1084. }
  1085. else {
  1086. console.log("STATUS NOT OK");
  1087. teleportMain.distance += 100;
  1088. teleportMain.innerHTML = teleportMain.distance + " m";
  1089. }
  1090. }
  1091.  
  1092. google.maps.Map = class extends google.maps.Map {
  1093. constructor(...args) {
  1094. super(...args);
  1095. if (GeoJsonCustomUser)
  1096. {
  1097. if (GeoJsonCustomUser)
  1098. {
  1099. this.data.addGeoJson(CUSTOM_GEOJSON);
  1100. }
  1101. this.data.setStyle(function(feature) {
  1102. return GEOJSON_STYLE
  1103. });
  1104. }
  1105. if (OverlayCustom)
  1106. {
  1107. let customOverlay = new google.maps.GroundOverlay(OVERLAY_URL, OVERLAY_BOUNDS, OVERLAY_STYLE);
  1108. customOverlay.setMap(this);
  1109. }
  1110.  
  1111. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  1112. google.maps.event.addDomListener(mapDiv, "click", () => {
  1113.  
  1114. MinimapBtn.current = mapDiv.id;
  1115. if (mapDiv.id == "Hybrid")
  1116. {
  1117. this.setMapTypeId('hybrid');
  1118. }
  1119. else if (mapDiv.id == "Terrain")
  1120. {
  1121. this.setMapTypeId('terrain');
  1122. }
  1123. else if (mapDiv.id == "Satellite")
  1124. {
  1125. this.setMapTypeId('satellite');
  1126. }
  1127. else if (mapDiv.id == "Custom")
  1128. {
  1129. this.setMapTypeId(customMode);
  1130. }
  1131. else
  1132. {
  1133. this.setMapTypeId('roadmap');
  1134. }
  1135. // this.setTilt(45);
  1136. for (let ar of presetMinimap)
  1137. {
  1138. if (ar[1] == mapDiv.id)
  1139. {
  1140. this.set('styles', ar[0]);
  1141. }
  1142. }
  1143. for (let element of document.getElementsByClassName("preset-minimap")){
  1144. if (element.id == MinimapBtn.current)
  1145. {
  1146. element.style.background = "#ff1493";
  1147. }
  1148. else
  1149. {
  1150. element.style.background = "#ff69b4";
  1151. }
  1152. if (rtded || nextPlayer == "Planets") {
  1153. if (["Borders", "Satellite", "Terrain", "Hybrid", "Custom"].includes(element.id))
  1154. {
  1155. element.style.backgroundColor = "red";
  1156. element.disabled = true;
  1157. }
  1158. }
  1159. }
  1160. });
  1161. }
  1162.  
  1163. for (let mapDiv of document.getElementsByClassName("overlay-minimap")){
  1164. google.maps.event.addDomListener(mapDiv, "click", () => {
  1165. OverlayBtn.current = mapDiv.id;
  1166. // console.log(mapDiv.url)
  1167. // console.log(mapDiv.id)
  1168. // console.log(mapDiv.loaded)
  1169. if (!mapDiv.loaded)
  1170. {
  1171. this.data.loadGeoJson(mapDiv.url, {
  1172. id: mapDiv.id
  1173. });
  1174. mapDiv.loaded = true;
  1175. }
  1176. if (mapDiv.id == "Clear")
  1177. {
  1178. this.overlayMapTypes.clear();
  1179. this.data.setStyle(function(feature) {
  1180. return GEOJSON_INVISIBLE
  1181. });
  1182. for (let element of document.getElementsByClassName("overlay-minimap")){
  1183. if (element.id === "Clear")
  1184. {
  1185. element.style.background = "#ff1493";
  1186. }
  1187. else
  1188. {
  1189. element.style.background = "#ff69b4";
  1190. if (["Coverage", "Official", "OSM"].includes(element.id))
  1191. {
  1192. if (rtded || nextPlayer == "Planets")
  1193. {
  1194. element.style.background = "red";
  1195. }
  1196. }
  1197. if (["Coverage", "Official", "City Lights", "OSM", "Watercolor", "Toner", "Fire"].includes(element.id))
  1198. {
  1199. element.loaded = false;
  1200. }
  1201. }
  1202. }
  1203. }
  1204. else
  1205. {
  1206. if (["Coverage", "Official", "City Lights", "OSM", "Watercolor", "Toner", "Fire"].includes(mapDiv.id))
  1207. {
  1208. this.overlayMapTypes.clear();
  1209. const coverageLayer = new google.maps.ImageMapType({
  1210. getTileUrl ({ x, y }, z) {
  1211.  
  1212. // Omits photospheres
  1213. // return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:apiv3&style=5,8&x=${x}&y=${y}&z=${z}`
  1214.  
  1215. // Omits unofficial and trekker, but also half of mongolia
  1216.  
  1217. if (mapDiv.id == "Official")
  1218. {
  1219. return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:app&style=5,8&x=${x}&y=${y}&z=${z}`
  1220. }
  1221. else if (mapDiv.id == "OSM")
  1222. {
  1223. return `https://tile.openstreetmap.org/${z}/${x}/${y}.png`
  1224. }
  1225. else if (mapDiv.id == "City Lights")
  1226. {
  1227. return `https://map1.vis.earthdata.nasa.gov/wmts-webmerc/VIIRS_CityLights_2012/default/{time}/GoogleMapsCompatible_Level8/${z}/${y}/${x}.jpg`
  1228. }
  1229. else if (mapDiv.id == "Watercolor")
  1230. {
  1231. return `https://stamen-tiles.a.ssl.fastly.net/watercolor/${z}/${x}/${y}.jpg`
  1232. }
  1233. else if (mapDiv.id == "Toner")
  1234. {
  1235. return `https://stamen-tiles.a.ssl.fastly.net/toner/${z}/${x}/${y}.png`
  1236. }
  1237. else if (mapDiv.id == "Fire")
  1238. {
  1239. return `https://tile.thunderforest.com/spinal-map/${z}/${x}/${y}.png?apikey=1360c6d2440c4202bf725238d1b9c761`
  1240. }
  1241. // 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`
  1242.  
  1243. // Includes everything
  1244. else if (mapDiv.id == "Coverage")
  1245. {
  1246. 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`
  1247. }
  1248. },
  1249. maxZoom: 20,
  1250. tileSize: new google.maps.Size(256, 256),
  1251. })
  1252. this.overlayMapTypes.push(coverageLayer);
  1253.  
  1254. // let other = "Official";
  1255. // if (mapDiv.id == "Official")
  1256. // {
  1257. // other = "Coverage";
  1258. // }
  1259.  
  1260. for (let element of document.getElementsByClassName("overlay-minimap")){
  1261. if (["Clear", "City Lights", "Watercolor", "Toner", "Fire"].includes(element.id))
  1262. {
  1263. element.style.background = "#ff69b4";
  1264. element.loaded = false;
  1265. }
  1266. if (["Coverage", "Official", "OSM"].includes(element.id))
  1267. {
  1268. if (!rtded && nextPlayer !== "Planets")
  1269. {
  1270. element.style.background = "#ff69b4";
  1271. element.loaded = false;
  1272. }
  1273. }
  1274. }
  1275. mapDiv.style.background = "#ff1493";
  1276. mapDiv.loaded = true;
  1277. }
  1278. else
  1279. {
  1280. this.data.setStyle(function(feature) {
  1281. return GEOJSON_STYLE
  1282. });
  1283. for (let element of document.getElementsByClassName("overlay-minimap")){
  1284. if (element.id !== "Clear" && element.loaded)
  1285. {
  1286. element.style.background = "#ff1493";
  1287. }
  1288. else
  1289. {
  1290. element.style.background = "#ff69b4";
  1291. }
  1292. if (["Coverage", "Official", "OSM"].includes(element.id))
  1293. {
  1294. if (rtded || nextPlayer == "Planets")
  1295. {
  1296. element.style.background = "red";
  1297. }
  1298. }
  1299.  
  1300. }
  1301. }
  1302. }
  1303. });
  1304. }
  1305.  
  1306.  
  1307.  
  1308.  
  1309. for (let spMini of document.getElementsByClassName("space-minimap")) {
  1310. google.maps.event.addDomListener(spMini, "click", () => {
  1311. OverlayBtn.current = spMini.id;
  1312. setMapstylePlanet(planetType);
  1313. if (spMini.id == "Earth") {
  1314. this.overlayMapTypes.clear();
  1315. this.setMapTypeId('roadmap');
  1316. this.set('styles', default_preset);
  1317. // for (let element of document.getElementsByClassName("space-minimap")) {
  1318. // if (element.id === spMini.id) {
  1319. // element.style.background = "#ff1493";
  1320. // }
  1321. // else {
  1322. // element.style.background = "#ff69b4";
  1323. // }
  1324. // }
  1325. }
  1326. else
  1327. {
  1328. this.set('styles', blank);
  1329. setTimeout(this.set('styles', blank), 1000)
  1330. this.overlayMapTypes.clear();
  1331. const coverageLayer = new google.maps.ImageMapType({
  1332. getTileUrl({ x, y }, z) {
  1333. if (spMini.id.includes("Label")) {
  1334. return spMini.url + z + "/" + x + "/" + y + ".png";
  1335. }
  1336. else
  1337. {
  1338. y = Math.pow(2, z) - y - 1;
  1339. return spMini.url + z + "/" + x + "/" + y + ".png";;
  1340. }
  1341. },
  1342. maxZoom: 20,
  1343. tileSize: new google.maps.Size(256, 256),
  1344. })
  1345.  
  1346. this.overlayMapTypes.push(coverageLayer);
  1347.  
  1348. if (spMini.id == ("Mars (Labels)"))
  1349. {
  1350. const coverageLayer2 = new google.maps.ImageMapType({
  1351. getTileUrl({ x, y }, z) {
  1352. y = Math.pow(2, z) - y - 1;
  1353. return `http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/${z}/${x}/${y}.png`;
  1354. },
  1355. maxZoom: 20,
  1356. tileSize: new google.maps.Size(256, 256),
  1357. opacity: 0.5
  1358. })
  1359. this.overlayMapTypes.push(coverageLayer2);
  1360. }
  1361. }
  1362. for (let element of document.getElementsByClassName("space-minimap")) {
  1363. if (element.id === spMini.id) {
  1364. element.style.background = "#ff1493";
  1365. }
  1366. else if (element.id.includes(planetType)) {
  1367. element.style.background = "#ff69b4";
  1368. }
  1369. }
  1370. });
  1371. }
  1372.  
  1373.  
  1374. }
  1375.  
  1376. }
  1377.  
  1378. const svService = new google.maps.StreetViewService();
  1379. google.maps.StreetViewPanorama = class extends google.maps.StreetViewPanorama {
  1380. constructor(...args) {
  1381. super(...args);
  1382. GooglePlayer = this;
  1383.  
  1384. const isGamePage = () => location.pathname.startsWith("/challenge/") || location.pathname.startsWith("/results/") ||
  1385. location.pathname.startsWith("/game/")|| location.pathname.startsWith("/battle-royale/") ||
  1386. location.pathname.startsWith("/duels/") || location.pathname.startsWith("/team-duels/") || location.pathname.startsWith("/bullseye/")
  1387. || location.pathname.startsWith("/live-challenge/");
  1388.  
  1389. this.addListener('position_changed', () => {
  1390. // Maybe this could be used to update the position in the other players
  1391. // so that they are always in sync
  1392. try {
  1393. if (!isGamePage()) return;
  1394. // timeMachineBtn.panoId = GooglePlayer.pano;
  1395. // timeMachineBtn.index = -1;
  1396. const lat = this.getPosition().lat();
  1397. const lng = this.getPosition().lng();
  1398. const { heading } = this.getPov();
  1399.  
  1400. curPosition = { lat, lng, heading };
  1401.  
  1402. if (switchCovergeButton.useGoogle)
  1403. {
  1404. switchCovergeButton.lng = lng;
  1405. switchCovergeButton.lat = lat;
  1406. switchCovergeButton.heading = heading;
  1407. if (!timeMachineBtn.list.some(row => row.includes(GooglePlayer.pano)))
  1408. {
  1409. timeMachineBtn.innerHTML = "Time Machine";
  1410. timeMachineBtn.panoId = GooglePlayer.pano;
  1411. timeMachineBtn.index = -1;
  1412. timeMachineBtn.plusminusLock = true;
  1413. timeMachineNewerBtn.style.backgroundColor = "red";
  1414. timeMachineNewerBtn.disabled = true;
  1415. timeMachineOlderBtn.style.backgroundColor = "red";
  1416. timeMachineOlderBtn.disabled = true;
  1417. }
  1418. }
  1419. switchCovergeButton.useGoogle = true;
  1420. teleportMain.google = true;
  1421. // console.log("also run");
  1422.  
  1423. // switchCovergeButton.heading = position.lat;
  1424. // console.log(position.heading);
  1425. // console.log(switchCovergeButton.lng);
  1426. }
  1427. catch (e) {
  1428. console.error("GeoGuessr Path Logger Error:", e);
  1429. }
  1430. });
  1431. this.addListener('pov_changed', () => {
  1432. const { heading, pitch } = this.getPov();
  1433. if (KakaoPlayer) {
  1434. if (typeof KakaoPlayer !== 'string' )
  1435. {
  1436. const vp = KakaoPlayer.getViewpoint();
  1437. // Prevent a recursive loop: only update kakao's viewpoint if it got out of sync with google's
  1438. if ((!almostEqual(vp.pan, heading) || !almostEqual(vp.tilt, pitch)) && nextPlayer == "Kakao") {
  1439. KakaoPlayer.setViewpoint({ pan: heading, tilt: pitch, zoom: vp.zoom });
  1440. }
  1441. }
  1442. }
  1443. });
  1444. }
  1445. };
  1446.  
  1447. var mainMenuBtn = document.createElement("Button");
  1448. mainMenuBtn.classList.add("unity-btn", "main-btn");
  1449. mainMenuBtn.id = "Show Buttons";
  1450. mainMenuBtn.hide = true;
  1451. mainMenuBtn.menuBtnCache = true;
  1452. mainMenuBtn.innerHTML = "<font size=2>Unity<br><font size=1>v6.1.0</font>";
  1453. mainMenuBtn.style =
  1454. "border-radius: 10px;visibility:hidden;height:2.5em;position:absolute;z-index:99999;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;line-height: 15px;";
  1455. // document.querySelector(".game-layout__status").appendChild(mainMenuBtn)
  1456. document.body.appendChild(mainMenuBtn);
  1457. mainMenuBtn.addEventListener("click", () => {
  1458. if (mainMenuBtn.hide) {
  1459. for (let element of document.getElementsByClassName("unity-btn")){
  1460. // if (!element.classList.contains("preset-minimap") && !element.classList.contains("overlay-minimap"))
  1461. // {
  1462. // element.style.visibility = "";
  1463. // if ((nextPlayer != "Youtube") && element.id == "Youtube Button")
  1464. // {
  1465. // element.style.visibility = "hidden";
  1466. // }
  1467. // }
  1468. if (element.classList.contains("menu-btn"))
  1469. {
  1470. element.style.visibility = "";
  1471. }
  1472. }
  1473. mainMenuBtn.hide = false;
  1474. }
  1475. else {
  1476. hideOtherBtn();
  1477. mainMenuBtn.hide = true;
  1478. }
  1479. });
  1480.  
  1481.  
  1482. var infoBtn = document.createElement("Button");
  1483. infoBtn.classList.add("unity-btn", "info-btn", "full", "vertical-1", "extra-height");
  1484. infoBtn.id = "Info Button";
  1485. infoBtn.innerHTML = "Geoguessr Unity Script<font size=1><br>by Jupaoqq | v6.1.0</font>";
  1486. document.body.appendChild(infoBtn);
  1487. // infoBtn.addEventListener("click", () => {
  1488. // window.open('https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing');
  1489. // });
  1490.  
  1491. var HelpBtn = document.createElement("Button");
  1492. HelpBtn.classList.add("unity-btn", "info-btn", "half", "horizontal-1", "vertical-3");
  1493. HelpBtn.id = "Help Button";
  1494. HelpBtn.innerHTML = "Help & Credits";
  1495.  
  1496. document.body.appendChild(HelpBtn);
  1497. HelpBtn.addEventListener("click", () => {
  1498. window.open('https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing');
  1499. });
  1500.  
  1501. var UpdateBtn = document.createElement("Button");
  1502. UpdateBtn.classList.add("unity-btn", "info-btn", "half", "horizontal-2", "vertical-3");
  1503. UpdateBtn.id = "Update Button";
  1504. UpdateBtn.innerHTML = "Check Update";
  1505.  
  1506. document.body.appendChild(UpdateBtn);
  1507. UpdateBtn.addEventListener("click", () => {
  1508. window.open('https://greatest.deepsurf.us/en/scripts/436813-geoguessr-unity-script');
  1509. });
  1510.  
  1511. var menuResetBtn = document.createElement("Button");
  1512. menuResetBtn.classList.add("unity-btn", "info-btn", "large", "vertical-4");
  1513. menuResetBtn.id = "Menu Reset";
  1514. menuResetBtn.innerHTML = "Menu Position";
  1515. document.body.appendChild(menuResetBtn);
  1516. menuResetBtn.addEventListener("click", () => {
  1517. btnAll();
  1518. });
  1519.  
  1520. var menuUpBtn = document.createElement("Button");
  1521. menuUpBtn.classList.add("unity-btn", "info-btn", "small", "horizontal-1", "vertical-4");
  1522. menuUpBtn.id = "Menu Up";
  1523. menuUpBtn.innerHTML = "↑";
  1524. document.body.appendChild(menuUpBtn);
  1525. menuUpBtn.addEventListener("click", () => {
  1526. AdjustBtnPos("-2em", "0em", false);
  1527. menuLocCounter++;
  1528. });
  1529.  
  1530. var menuDownBtn = document.createElement("Button");
  1531. menuDownBtn.classList.add("unity-btn", "info-btn", "small", "horizontal-3", "vertical-4");
  1532. menuDownBtn.id = "Menu down";
  1533. menuDownBtn.innerHTML = "↓";
  1534. document.body.appendChild(menuDownBtn);
  1535. menuDownBtn.addEventListener("click", () => {
  1536. AdjustBtnPos("2em", "0em", false);
  1537. menuLocCounter--;
  1538. });
  1539.  
  1540. var infoMenu = document.createElement("Button");
  1541. infoMenu.classList.add("unity-btn", "menu-btn");
  1542. infoMenu.classList.add();
  1543. infoMenu.id = "Info Menu";
  1544. // infoMenu.innerHTML = "In";
  1545. document.body.appendChild(infoMenu);
  1546. infoMenu.addEventListener("click", () => {
  1547. switchBtn("info-btn");
  1548. if (menuDownBtn.style.visibility == "hidden")
  1549. {
  1550. for (let element of document.getElementsByClassName("info-btn"))
  1551. {
  1552. element.style.visibility = "";
  1553. }
  1554. }
  1555. else
  1556. {
  1557. for (let element of document.getElementsByClassName("info-btn"))
  1558. {
  1559. element.style.visibility = "hidden";
  1560. }
  1561. }
  1562. });
  1563.  
  1564. var playYoutubeBtn = document.createElement("Button");
  1565. playYoutubeBtn.classList.add("unity-btn", "full", "vertical-0");
  1566. playYoutubeBtn.id = "Youtube Button";
  1567. playYoutubeBtn.innerHTML = "Play video";
  1568. document.body.appendChild(playYoutubeBtn);
  1569. playYoutubeBtn.addEventListener("click", () => {
  1570. let iframe = document.getElementById("i_container");
  1571. iframe.style.position = "absolute";
  1572. iframe.allow = "autoplay";
  1573. let srcString = "https://www.youtube.com/embed/" + yId + "?&playlist=" + yId + "&autoplay=1&modestbranding=1&controls=0&start=";
  1574. if (yTime == "0" && yEnd == "0")
  1575. {
  1576. }
  1577. else
  1578. {
  1579. srcString += yTime + "&end=" + yEnd;
  1580. }
  1581. iframe.src = srcString;
  1582. iframe.style.visibility = "";
  1583. playYoutubeBtn.innerHTML = "Play video from start";
  1584. });
  1585.  
  1586. // Teleport Module Buttons
  1587. // Class: teleport-btn
  1588. // Button: teleportMenu
  1589. // Buttons: teleportForward, teleportReverse, teleportMain, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, TeleportArisBtn
  1590.  
  1591. function teleportModule(dir)
  1592. {
  1593. if (switchCovergeButton.init)
  1594. {
  1595. // console.log("run");
  1596. switchCovergeButton.init = false;
  1597. if (teleportMain.google)
  1598. {
  1599. switchCovergeButton.useGoogle = true;
  1600. teleportMain.google = true;
  1601. }
  1602. else
  1603. {
  1604. switchCovergeButton.useGoogle = false;
  1605. teleportMain.google = false;
  1606. }
  1607. }
  1608. else
  1609. {
  1610. // console.log(teleportMenu.google)
  1611. if (teleportMain.google && GooglePlayer != null)
  1612. {
  1613. let heading = GooglePlayer.getPov().heading;
  1614. if (!dir)
  1615. {
  1616. heading = (heading + 180) % 360;
  1617. }
  1618. let place = FindPointAtDistanceFrom(curPosition.lat, curPosition.lng , DegreesToRadians(heading), teleportMain.distance * 0.001)
  1619. svService.getPanorama({ location: place, radius: 1000, source: teleportMain.teleType}, svCheck);
  1620. }
  1621. }
  1622. }
  1623.  
  1624. var teleportForward = document.createElement("Button");
  1625. teleportForward.classList.add("unity-btn", "teleport-btn", "half", "horizontal-1", "vertical-1");
  1626. teleportForward.id = "Teleport Forward";
  1627. teleportForward.innerHTML = "↑ Forward";
  1628. document.body.appendChild(teleportForward);
  1629.  
  1630. teleportForward.addEventListener("click", () => {
  1631. teleportModule(true);
  1632. });
  1633.  
  1634. var teleportReverse = document.createElement("Button");
  1635. teleportReverse.classList.add("unity-btn", "teleport-btn", "half", "horizontal-2", "vertical-1");
  1636. teleportReverse.id = "Teleport Reverse";
  1637. teleportReverse.innerHTML = "↓ Reverse";
  1638. document.body.appendChild(teleportReverse);
  1639.  
  1640. teleportReverse.addEventListener("click", () => {
  1641. teleportModule(false);
  1642. });
  1643.  
  1644. var teleportMain = document.createElement("Button");
  1645. teleportMain.classList.add("unity-btn", "teleport-btn", "large", "vertical-2");
  1646. teleportMain.teleType = "default";
  1647. teleportMain.id = "Teleport Button";
  1648. teleportMain.distance = 100;
  1649. teleportMain.google = true;
  1650. teleportMain.innerHTML = "100m";
  1651. document.body.appendChild(teleportMain);
  1652.  
  1653. var teleportMoreBtn = document.createElement("Button");
  1654. teleportMoreBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-3", "vertical-2");
  1655. teleportMoreBtn.id = "plus"
  1656. teleportMoreBtn.innerHTML = "+";
  1657. document.body.appendChild(teleportMoreBtn);
  1658. teleportMoreBtn.addEventListener("click", () => {
  1659. if (teleportMain.distance > 21 && teleportMain.distance < 149) {
  1660. teleportMain.distance = teleportMain.distance + 25;
  1661. }
  1662. teleportMain.innerHTML = teleportMain.distance + " m";
  1663. });
  1664.  
  1665. var teleportLessBtn = document.createElement("Button");
  1666. teleportLessBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-1", "vertical-2");
  1667. teleportLessBtn.id = "minus"
  1668. teleportLessBtn.innerHTML = "-";
  1669. document.body.appendChild(teleportLessBtn);
  1670. teleportLessBtn.addEventListener("click", () => {
  1671. if (teleportMain.distance > 26) {
  1672. teleportMain.distance = teleportMain.distance - 25;
  1673. }
  1674. teleportMain.innerHTML = teleportMain.distance + " m";
  1675. });
  1676.  
  1677. var teleportDistResetBtn = document.createElement("Button");
  1678. teleportDistResetBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-1", "vertical-3");
  1679. teleportDistResetBtn.id = "reset"
  1680. teleportDistResetBtn.innerHTML = "Reset";
  1681. document.body.appendChild(teleportDistResetBtn);
  1682. teleportDistResetBtn.addEventListener("click", () => {
  1683. teleportMain.distance = 100;
  1684. teleportMain.innerHTML = teleportMain.distance + " m";
  1685. });
  1686.  
  1687. var TeleportArisBtn = document.createElement("Button");
  1688. TeleportArisBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-2", "vertical-3");
  1689. TeleportArisBtn.id = "Teleport Options Button";
  1690. TeleportArisBtn.innerHTML = "Default";
  1691. document.body.appendChild(TeleportArisBtn);
  1692. TeleportArisBtn.addEventListener("click", () => {
  1693. if (teleportMain.teleType == "default")
  1694. {
  1695. teleportMain.teleType = "outdoor"
  1696. TeleportArisBtn.innerHTML = "Official";
  1697. }
  1698. else
  1699. {
  1700. teleportMain.teleType = "default"
  1701. TeleportArisBtn.innerHTML = "Default";
  1702. }
  1703. });
  1704.  
  1705. var teleportMenu = document.createElement("Button");
  1706. teleportMenu.classList.add("unity-btn", "menu-btn");
  1707. teleportMenu.id = "Teleport Menu";
  1708. document.body.appendChild(teleportMenu);
  1709. teleportMenu.addEventListener("click", () => {
  1710. switchBtn("teleport-btn");
  1711. if (teleportForward.style.visibility == "hidden")
  1712. {
  1713. for (let element of document.getElementsByClassName("teleport-btn"))
  1714. {
  1715. element.style.visibility = "";
  1716. }
  1717. }
  1718. else
  1719. {
  1720. for (let element of document.getElementsByClassName("teleport-btn"))
  1721. {
  1722. element.style.visibility = "hidden";
  1723. }
  1724. }
  1725. });
  1726.  
  1727. // Satellite Module Buttons
  1728. // Class: satelliteSwitchButton, satellite-menu
  1729. // subclass 1: satellite-btn-type
  1730. // subclass 2: satellite-btn-style
  1731. // Buttons: satelliteRadius, satelliteType, satelliteStyle
  1732. // satelliteDefault, satelliteNight, satelliteClassic, roadDefault, roadClassic
  1733. // skyDefault, skyCurrent, skyLocal
  1734.  
  1735. // var satelliteRadius = document.createElement("Button");
  1736. // satelliteRadius.classList.add("unity-btn", "satellite-btn", "full", "vertical-1");
  1737. // satelliteRadius.classList.add("satellite-btn");
  1738. // satelliteRadius.id = "Satellite Radius";
  1739. // satelliteRadius.innerHTML = "Radius";
  1740. // document.body.appendChild(satelliteRadius);
  1741.  
  1742. var satelliteTypeBtn = document.createElement("Button");
  1743. satelliteTypeBtn.classList.add("unity-btn", "satellite-btn", "half", "horizontal-1", "vertical-2");
  1744. satelliteTypeBtn.id = "Satellite Type Button";
  1745. satelliteTypeBtn.innerHTML = "Map Style";
  1746. satelliteTypeBtn.currentId = "Satellite"
  1747. satelliteTypeBtn.currentDim = "2.5D"
  1748. document.body.appendChild(satelliteTypeBtn);
  1749.  
  1750.  
  1751. var satelliteStyleBtn = document.createElement("Button");
  1752. satelliteStyleBtn.classList.add("unity-btn", "satellite-btn", "half", "horizontal-2", "vertical-2");
  1753. satelliteStyleBtn.id = "Satellite Style Button";
  1754. satelliteStyleBtn.innerHTML = "Time";
  1755. satelliteStyleBtn.current = "solarNoon";
  1756. document.body.appendChild(satelliteStyleBtn);
  1757.  
  1758. for (let satT of satType)
  1759. {
  1760. let satTButton = document.createElement("Button");
  1761. satTButton.id = satT[0];
  1762. satTButton.dim = satT[1];
  1763. satTButton.classList.add("unity-btn", "satellite-btn", "satellite-type", "half", "horizontal-1");
  1764. satTButton.innerHTML = satTButton.id + " " + satTButton.dim;
  1765. // if (satTButton.dim == "2.5D")
  1766. // {
  1767. // satTButton.title = "Hide House";
  1768. // }
  1769. satTButton.addEventListener("click", () => {
  1770. let changeSatStyle = styleMapboxAll(satelliteTypeBtn.currentId, satelliteTypeBtn.currentDim, satelliteStyleBtn.current, satTButton.id, satTButton.dim, satelliteStyleBtn.current, true);
  1771. satelliteTypeBtn.currentId = satTButton.id;
  1772. satelliteTypeBtn.currentDim = satTButton.dim;
  1773. if (changeSatStyle)
  1774. {
  1775. satelliteStyleBtn.current = "solarNoon";
  1776. }
  1777. handleSatColor();
  1778. })
  1779. document.body.appendChild(satTButton);
  1780. }
  1781.  
  1782. for (let satS of satStyle)
  1783. {
  1784. let satSButton = document.createElement("Button");
  1785. satSButton.id = satS[0];
  1786. satSButton.classList.add("unity-btn", "satellite-btn", "satellite-style", "half", "horizontal-2");
  1787. satSButton.innerHTML = satS[1];
  1788. satSButton.addEventListener("click", () => {
  1789. let changeSatStyle = styleMapboxAll(satelliteTypeBtn.currentId, satelliteTypeBtn.currentDim, satelliteStyleBtn.current, satelliteTypeBtn.currentId, satelliteTypeBtn.currentDim, satSButton.id, false);
  1790. satelliteStyleBtn.current = satSButton.id;
  1791. handleSatColor();
  1792. })
  1793.  
  1794. document.body.appendChild(satSButton);
  1795. }
  1796.  
  1797. function handleSatColor()
  1798. {
  1799. for (let element of document.getElementsByClassName("satellite-type")){
  1800. if (element.id == satelliteTypeBtn.currentId && element.dim == satelliteTypeBtn.currentDim)
  1801. {
  1802. element.style.background = "#ff1493";
  1803. }
  1804. else
  1805. {
  1806. element.style.background = "#ff69b4";
  1807. }
  1808. }
  1809. for (let element of document.getElementsByClassName("satellite-style")){
  1810. if (element.id == satelliteStyleBtn.current)
  1811. {
  1812. element.style.background = "#ff1493";
  1813. }
  1814. else
  1815. {
  1816. element.style.background = "#ff69b4";
  1817. }
  1818. }
  1819. }
  1820.  
  1821. function handleSatMenu(cond)
  1822. {
  1823. let transition = true;
  1824. if (cond)
  1825. {
  1826. transition = (satelliteSwitchButton.innerHTML == "Streetview mode");
  1827. }
  1828. else
  1829. {
  1830. transition = (satelliteSwitchButton.innerHTML !== "Streetview mode");
  1831. }
  1832. if (transition)
  1833. {
  1834. for (let element of document.getElementsByClassName("satellite-btn"))
  1835. {
  1836. if (element.id !== "Satellite Switch")
  1837. {
  1838. element.style.visibility = "hidden";
  1839. }
  1840. }
  1841. }
  1842. else
  1843. {
  1844. for (let element of document.getElementsByClassName("satellite-btn"))
  1845. {
  1846. if (element.id !== "Satellite Switch")
  1847. {
  1848. element.style.visibility = "";
  1849. }
  1850. }
  1851. }
  1852. }
  1853.  
  1854. var satelliteSwitchButton = document.createElement("Button");
  1855. satelliteSwitchButton.classList.add("unity-btn", "satellite-btn", "full", "vertical-1");
  1856. satelliteSwitchButton.id = "Satellite Switch";
  1857. satelliteSwitchButton.state = false;
  1858. satelliteSwitchButton.innerHTML = "Streetview mode";
  1859. document.body.appendChild(satelliteSwitchButton);
  1860. satelliteSwitchButton.addEventListener("click", () => {
  1861. handleSatMenu(false);
  1862. if (!initBing)
  1863. {
  1864. let di = formatDist();
  1865. // satelliteRadius.innerHTML = `Satellite (${di})`;
  1866. satelliteSwitchButton.innerHTML = `Satellite (${di})`;
  1867.  
  1868. initBing = true;
  1869. MAPBOX_INJECTED = false;
  1870. BR_LOAD_MP = true;
  1871.  
  1872. let canvas = document.getElementById("sat_map");
  1873. if (!canvas)
  1874. {
  1875. injectMapboxPlayer();
  1876. }
  1877. else
  1878. {
  1879. changeInnerHTML(canvas, false);
  1880. MAPBOX_INJECTED = true;
  1881. }
  1882. nextPlayer = "Mapbox Satellite";
  1883. injectCanvas();
  1884. satCallback();
  1885.  
  1886. sat_choice = true;
  1887. console.log("Load Mapbox Satellite API")
  1888. //
  1889. }
  1890. else
  1891. {
  1892. if (!satelliteSwitchButton.innerHTML.includes("Satellite"))
  1893. {
  1894. // console.log("true!!")
  1895. let di2 = formatDist();
  1896. satelliteSwitchButton.innerHTML = `Satellite (${di2})`;
  1897.  
  1898. nextPlayer = "Mapbox Satellite";
  1899. injectCanvas();
  1900. satCallback();
  1901. nextPlayer = nextPlayer_save;
  1902.  
  1903. sat_choice = true;
  1904. // console.log("hello")
  1905. }
  1906. else
  1907. {
  1908. satelliteSwitchButton.innerHTML = "Streetview mode";
  1909. if (nextPlayer_save == "Mapbox Satellite")
  1910. {
  1911. nextPlayer = "Google";
  1912. }
  1913. else
  1914. {
  1915. nextPlayer = nextPlayer_save;
  1916. }
  1917.  
  1918. injectCanvas();
  1919. if (sat_choice)
  1920. {
  1921. if (nextPlayer !== "Google")
  1922. {
  1923. goToLocation(true);
  1924. }
  1925. handleButtons();
  1926. }
  1927. sat_choice = false;
  1928. }
  1929. if (satelliteSwitchButton.innerHTML !== "Streetview mode" || nextPlayer == "Baidu")
  1930. {
  1931. switchCovergeButton.disabled = true;
  1932. switchCovergeButton.style.background = "red";
  1933. }
  1934. else
  1935. {
  1936. switchCovergeButton.disabled = false;
  1937. switchCovergeButton.style.background = "#ba55d3";
  1938. }
  1939. }
  1940. });
  1941.  
  1942. var satelliteMenu = document.createElement("Button");
  1943. satelliteMenu.classList.add("unity-btn", "menu-btn");
  1944. satelliteMenu.id = "Satellite Menu";
  1945. document.body.appendChild(satelliteMenu);
  1946. satelliteMenu.addEventListener("click", () => {
  1947. switchBtn("satellite-btn");
  1948. if (satelliteSwitchButton.style.visibility == "hidden")
  1949. {
  1950. satelliteSwitchButton.style.visibility = "";
  1951. handleSatMenu(true);
  1952. }
  1953. else
  1954. {
  1955. for (let element of document.getElementsByClassName("satellite-btn"))
  1956. {
  1957. element.style.visibility = "hidden";
  1958. }
  1959. }
  1960.  
  1961. });
  1962.  
  1963. // Switch Coverage Module
  1964.  
  1965. var switchCovergeButton = document.createElement("Button");
  1966. switchCovergeButton.classList.add("unity-btn", "timemachine-btn", "full", "vertical-1");
  1967. switchCovergeButton.sat = false;
  1968. switchCovergeButton.id = "switch";
  1969. switchCovergeButton.init = false;
  1970. switchCovergeButton.useGoogle = false;
  1971. switchCovergeButton.lng = 0
  1972. switchCovergeButton.lat = 0
  1973. switchCovergeButton.heading = 0
  1974. switchCovergeButton.innerHTML = "Switch to Google";
  1975. document.body.appendChild(switchCovergeButton);
  1976. switchCovergeButton.addEventListener("click", () => {
  1977. nextPlayer = nextPlayer_save;
  1978. let GOOGLE_MAPS_CANVAS1 = document.querySelector(GENERAL_CANVAS);
  1979. let GOOGLE_MAPS_CANVAS2 = document.querySelector(BR_CANVAS);
  1980. let GOOGLE_MAPS_CANVAS3 = document.querySelector(".inactive");
  1981. let GOOGLE_MAPS_CANVAS4 = document.querySelector(BULLSEYE_CANVAS2);
  1982. let GOOGLE_MAPS_CANVAS5 = document.querySelector(LIVE_CANVAS2);
  1983. let duel = false;
  1984.  
  1985. let GOOGLE_MAPS_CANVAS = null;
  1986. if (GOOGLE_MAPS_CANVAS1 !== null)
  1987. {
  1988. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS1;
  1989. }
  1990. else if (GOOGLE_MAPS_CANVAS2 !== null)
  1991. {
  1992. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS2;
  1993. }
  1994. else if (GOOGLE_MAPS_CANVAS4 !== null)
  1995. {
  1996. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS4;
  1997. }
  1998. else if (GOOGLE_MAPS_CANVAS5 !== null)
  1999. {
  2000. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS5;
  2001. }
  2002. if (GOOGLE_MAPS_CANVAS3 !== null)
  2003. {
  2004. duel = true;
  2005. }
  2006.  
  2007. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  2008. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  2009. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player")
  2010. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  2011. let MS_MAPS_CANVAS = document.getElementById("ms-player");
  2012. let MAPBOX_MAPS_CANVAS = document.getElementById("sat_map");
  2013. // if (nextPlayer !== "Baidu") {
  2014. if (switchCovergeButton.useGoogle == false) {
  2015. if (duel)
  2016. {
  2017. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  2018. if (nextPlayer == "Kakao")
  2019. {
  2020. KAKAO_MAPS_CANVAS.className = "inactive";
  2021. }
  2022. else if (nextPlayer == "Bing Streetside")
  2023. {
  2024. MS_MAPS_CANVAS.className = "inactive";
  2025. }
  2026. else if (nextPlayer == "Mapbox Satellite")
  2027. {
  2028. MAPBOX_MAPS_CANVAS.className = "inactive";
  2029. }
  2030. else if (nextPlayer == "Yandex")
  2031. {
  2032. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  2033. YANDEX_MAPS_CANVAS.style.zIndex = "none";
  2034. }
  2035. else
  2036. {
  2037. MAPILLARY_MAPS_CANVAS.className = "inactive";
  2038. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  2039. }
  2040. }
  2041. else
  2042. {
  2043. GOOGLE_MAPS_CANVAS.style.visibility = "";
  2044. if (nextPlayer == "Kakao")
  2045. {
  2046. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  2047. }
  2048. else if (nextPlayer == "Yandex")
  2049. {
  2050. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  2051. }
  2052. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft")
  2053. {
  2054. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  2055. }
  2056. else if (nextPlayer == "Mapillary" || nextPlayer == "Google")
  2057. {
  2058. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  2059. }
  2060. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  2061. {
  2062. MS_MAPS_CANVAS.style.visibility = "hidden";
  2063. }
  2064. else if (nextPlayer == "Mapbox Satellite")
  2065. {
  2066. MAPBOX_MAPS_CANVAS.style.visibility = "hidden";
  2067. }
  2068.  
  2069.  
  2070. }
  2071. const lat = GooglePlayer.getPosition().lat();
  2072. const lng = GooglePlayer.getPosition().lng();
  2073. switch_call = true;
  2074. if (!almostEqual2(lat, switchCovergeButton.lat) || !almostEqual2(lat, switchCovergeButton.lng)) {
  2075. svService.getPanorama({ location: { lat: switchCovergeButton.lat, lng: switchCovergeButton.lng }, radius: 1000 }, svCheck);
  2076. }
  2077. switchCovergeButton.useGoogle = true;
  2078. teleportMain.google = true;
  2079. switchCovergeButton.init = false;
  2080.  
  2081. console.log("use Google");
  2082. }
  2083. else {
  2084. if (MS_MAPS_CANVAS)
  2085. {
  2086. MS_MAPS_CANVAS.style.visibility = "hidden";
  2087. }
  2088.  
  2089. if (duel)
  2090. {
  2091. document.getElementById("default_player").className = "inactive";
  2092. if (nextPlayer == "Kakao")
  2093. {
  2094. KAKAO_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  2095. }
  2096. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  2097. {
  2098. MS_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  2099. }
  2100. else if (nextPlayer == "Mapbox Satellite")
  2101. {
  2102. MAPBOX_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  2103. }
  2104. else if (nextPlayer == "Yandex")
  2105. {
  2106. YANDEX_MAPS_CANVAS.style.visibility = "";
  2107. YANDEX_MAPS_CANVAS.style.zIndex = "1";
  2108. }
  2109. else
  2110. {
  2111. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  2112. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  2113. MapillaryPlayer.resize();
  2114. //window.dispatchEvent(new Event('resize'));
  2115. // document.querySelector(".mapillary-canvas").style.;
  2116. // mapillary-canvas
  2117. }
  2118.  
  2119. }
  2120. else
  2121. {
  2122. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  2123. if (nextPlayer == "Kakao")
  2124. {
  2125. KAKAO_MAPS_CANVAS.style.visibility = "";
  2126. }
  2127. else if (nextPlayer == "Yandex")
  2128. {
  2129. YANDEX_MAPS_CANVAS.style.visibility = "";
  2130. }
  2131. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft")
  2132. {
  2133. BAIDU_MAPS_CANVAS.style.visibility = "";
  2134. }
  2135. else if (nextPlayer == "Mapillary" || nextPlayer == "Google" )
  2136. {
  2137. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  2138. }
  2139. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  2140. {
  2141. MS_MAPS_CANVAS.style.visibility = "";
  2142. }
  2143. else if (nextPlayer == "Mapbox Satellite")
  2144. {
  2145. MAPBOX_MAPS_CANVAS.style.visibility = "";
  2146. }
  2147. }
  2148. switchCovergeButton.useGoogle = false;
  2149. teleportMain.google = false;
  2150. switchCovergeButton.init = true;
  2151. console.log("use Others");
  2152. }
  2153. if (switchCovergeButton.useGoogle)
  2154. {
  2155. if (nextPlayer == "Google")
  2156. {
  2157. switchCovergeButton.innerHTML = "Switch to Mapillary";
  2158. satelliteSwitchButton.disabled = false;
  2159. satelliteSwitchButton.style.background = "#ba55d3";
  2160. }
  2161. else
  2162. {
  2163. switchCovergeButton.innerHTML = "Switch to " + nextPlayer;
  2164. satelliteSwitchButton.disabled = true;
  2165. satelliteSwitchButton.style.background = "red";
  2166. }
  2167. }
  2168. else
  2169. {
  2170. if (nextPlayer == "Google" || nextPlayer == "Baidu")
  2171. {
  2172. switchCovergeButton.innerHTML = "Switch to Google";
  2173. satelliteSwitchButton.disabled = true;
  2174. satelliteSwitchButton.style.background = "red";
  2175. }
  2176. else
  2177. {
  2178. switchCovergeButton.innerHTML = "Switch to Google";
  2179. satelliteSwitchButton.disabled = false;
  2180. satelliteSwitchButton.style.background = "#ba55d3";
  2181. }
  2182. }
  2183. });
  2184.  
  2185.  
  2186. var timeMachineNewerBtn = document.createElement("Button");
  2187. timeMachineNewerBtn.classList.add("unity-btn", "timemachine-btn", "small", "horizontal-3", "vertical-2");
  2188. timeMachineNewerBtn.id = "plus year"
  2189. timeMachineNewerBtn.innerHTML = "+";
  2190. document.body.appendChild(timeMachineNewerBtn);
  2191. timeMachineNewerBtn.addEventListener("click", () => {
  2192. if (timeMachineBtn.index < timeMachineBtn.list.length - 1 && !timeMachineBtn.plusminusLock) {
  2193. timeMachineBtn.index = timeMachineBtn.index + 1;
  2194. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  2195. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  2196. // console.log(timeMachineBtn.index)
  2197. }
  2198. GenBtnColor();
  2199.  
  2200. });
  2201.  
  2202. var timeMachineOlderBtn = document.createElement("Button");
  2203. timeMachineOlderBtn.classList.add("unity-btn", "timemachine-btn", "small", "horizontal-1", "vertical-2");
  2204. timeMachineOlderBtn.id = "minus year"
  2205. timeMachineOlderBtn.innerHTML = "-";
  2206. document.body.appendChild(timeMachineOlderBtn);
  2207. timeMachineOlderBtn.addEventListener("click", () => {
  2208. if (timeMachineBtn.index > 0 && !timeMachineBtn.plusminusLock) {
  2209. timeMachineBtn.index = timeMachineBtn.index - 1;
  2210. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  2211. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  2212. // console.log(timeMachineBtn.index)
  2213. }
  2214. GenBtnColor();
  2215. });
  2216.  
  2217. function svCheck2(data, status) {
  2218. let l = []
  2219. if (status === 'OK') {
  2220. // console.log("OK for " + data.location.latLng + " at ID " + data.location.pano);
  2221. // console.log(data.time)
  2222. for (const alt of data.time) {
  2223. let date = Object.values(alt).find((value) => value instanceof Date)
  2224.  
  2225. l.push([alt.pano, date.toDateString()]);
  2226. }
  2227. // console.log(l);
  2228. timeMachineBtn.list = l
  2229. timeMachineBtn.index = l.length - 1;
  2230. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  2231. GenBtnColor();
  2232. timeMachineBtn.plusminusLock = false;
  2233. // timeMachineOlderBtn.click()
  2234. // timeMachineBtn.innerHTML = "Default Date";
  2235. }
  2236. }
  2237.  
  2238. var timeMachineBtn = document.createElement("Button");
  2239. timeMachineBtn.classList.add("unity-btn", "timemachine-btn", "large", "vertical-2");
  2240. timeMachineBtn.id = "Date Button";
  2241. timeMachineBtn.plusminusLock = true;
  2242. timeMachineBtn.panoId = 0;
  2243. timeMachineBtn.index = -1;
  2244. timeMachineBtn.list = [];
  2245. timeMachineBtn.innerHTML = "Time Machine";
  2246. document.body.appendChild(timeMachineBtn);
  2247. timeMachineBtn.addEventListener("click", () => {
  2248. // console.log(timeMachineBtn.index)
  2249. if (timeMachineBtn.panoId != 0)
  2250. {
  2251. if(timeMachineBtn.index == -1)
  2252. {
  2253. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  2254. }
  2255. else
  2256. {
  2257. timeMachineBtn.index = timeMachineBtn.list.length - 1;
  2258. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  2259. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  2260. GenBtnColor();
  2261. }
  2262. }
  2263. else
  2264. {
  2265. timeMachineBtn.panoId = GooglePlayer.pano;
  2266. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  2267. }
  2268. });
  2269.  
  2270. var timeMachineMenu = document.createElement("Button");
  2271. timeMachineMenu.classList.add("unity-btn", "menu-btn");
  2272. timeMachineMenu.id = "Time Machine Menu";
  2273. document.body.appendChild(timeMachineMenu);
  2274. timeMachineMenu.addEventListener("click", () => {
  2275. switchBtn("timemachine-btn");
  2276. if (timeMachineNewerBtn.style.visibility == "hidden")
  2277. {
  2278. for (let element of document.getElementsByClassName("timemachine-btn"))
  2279. {
  2280. element.style.visibility = "";
  2281. }
  2282. }
  2283. else
  2284. {
  2285. for (let element of document.getElementsByClassName("timemachine-btn"))
  2286. {
  2287. element.style.visibility = "hidden";
  2288. }
  2289. }
  2290. });
  2291.  
  2292. // Minimap Module
  2293.  
  2294. var MinimapBtn = document.createElement("Button");
  2295. MinimapBtn.classList.add("unity-btn", "minimap-btn", "half", "horizontal-2", "vertical-1");
  2296. MinimapBtn.id = "Minimap Button";
  2297. MinimapBtn.innerHTML = "Minimap Style";
  2298. MinimapBtn.current = "Default";
  2299. // MinimapBtn.childVisible = false;
  2300. document.body.appendChild(MinimapBtn);
  2301.  
  2302. for (let a of presetMinimap)
  2303. {
  2304. let aButton = document.createElement("Button");
  2305. aButton.id = a[1];
  2306. aButton.classList.add("unity-btn", "minimap-btn", "preset-minimap", "half", "horizontal-2");
  2307. aButton.innerHTML = a[1];
  2308. document.body.appendChild(aButton);
  2309. }
  2310.  
  2311. var OverlayBtn = document.createElement("Button");
  2312. OverlayBtn.classList.add("unity-btn", "minimap-btn", "half", "horizontal-1", "vertical-1");
  2313. OverlayBtn.id = "Overlay Button";
  2314. OverlayBtn.innerHTML = "Overlay";
  2315. OverlayBtn.current = "Clear";
  2316. // OverlayBtn.childVisible = false;
  2317. document.body.appendChild(OverlayBtn);
  2318.  
  2319. for (let b of presetOverlay)
  2320. {
  2321. let bButton = document.createElement("Button");
  2322. bButton.id = b[0];
  2323. bButton.url = b[1];
  2324. bButton.loaded = false;
  2325. bButton.classList.add("unity-btn", "minimap-btn", "overlay-minimap", "half", "horizontal-1");
  2326. bButton.innerHTML = b[0];
  2327. document.body.appendChild(bButton);
  2328. }
  2329.  
  2330. var MinimapMenuBtn = document.createElement("Button");
  2331. MinimapMenuBtn.classList.add("unity-btn", "menu-btn");
  2332. MinimapMenuBtn.id = "Minimap Menu Button";
  2333. document.body.appendChild(MinimapMenuBtn);
  2334. MinimapMenuBtn.addEventListener("click", () => {
  2335. switchBtn("minimap-btn");
  2336. if (OverlayBtn.style.visibility !== "hidden")
  2337. {
  2338. for (let element of document.getElementsByClassName("minimap-btn")){
  2339. element.style.visibility="hidden";
  2340. }
  2341. }
  2342. else
  2343. {
  2344. for (let element of document.getElementsByClassName("minimap-btn")){
  2345. element.style.visibility="";
  2346. }
  2347. }
  2348. });
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356. // Space Buttons Module
  2357.  
  2358. // var SpaceMainmapBtn = document.createElement("Button");
  2359. // SpaceMainmapBtn.classList.add("unity-btn", "space-btn", "half", "horizontal-2", "vertical-1");
  2360. // SpaceMainmapBtn.id = "SpMini Button";
  2361. // SpaceMainmapBtn.innerHTML = "Minimap Style";
  2362. // SpaceMainmapBtn.current = "Default";
  2363. // // SpaceMainmapBtn.childVisible = false;
  2364. // document.body.appendChild(SpaceMainmapBtn);
  2365.  
  2366. // for (let a of spaceMainmap)
  2367. // {
  2368. // let saButton = document.createElement("Button");
  2369. // saButton.id = a[0];
  2370. // saButton.url = a[1];
  2371. // saButton.classList.add("unity-btn", "space-btn", "space-mainmap", "half", "horizontal-2");
  2372. // saButton.innerHTML = a[0];
  2373. // document.body.appendChild(saButton);
  2374. // }
  2375.  
  2376. var SpaceOverlayBtn = document.createElement("Button");
  2377. SpaceOverlayBtn.classList.add("unity-btn", "space-btn", "half", "horizontal-1", "vertical-1");
  2378. SpaceOverlayBtn.id = "SpOver Button";
  2379. SpaceOverlayBtn.innerHTML = "Space";
  2380. SpaceOverlayBtn.current = "Clear";
  2381. // SpaceOverlayBtn.childVisible = false;
  2382. document.body.appendChild(SpaceOverlayBtn);
  2383.  
  2384. for (let b of spaceMinimap)
  2385. {
  2386. let sbButton = document.createElement("Button");
  2387. sbButton.id = b[0];
  2388. sbButton.url = b[1];
  2389. sbButton.classList.add("unity-btn", "space-btn", "space-minimap", "half", "horizontal-1");
  2390. sbButton.innerHTML = b[0];
  2391. document.body.appendChild(sbButton);
  2392. }
  2393.  
  2394.  
  2395.  
  2396.  
  2397.  
  2398.  
  2399.  
  2400.  
  2401. var SpaceMenuBtn = document.createElement("Button");
  2402. SpaceMenuBtn.classList.add("unity-btn", "menu-btn");
  2403. SpaceMenuBtn.id = "Space Menu Button";
  2404. document.body.appendChild(SpaceMenuBtn);
  2405. SpaceMenuBtn.addEventListener("click", () => {
  2406. switchBtn("space-btn");
  2407. if (OverlayBtn.style.visibility !== "hidden")
  2408. {
  2409. for (let element of document.getElementsByClassName("space-btn")){
  2410. element.style.visibility = "hidden";
  2411. }
  2412. }
  2413. else
  2414. {
  2415. for (let element of document.getElementsByClassName("space-btn")){
  2416. element.style.visibility = "";
  2417. }
  2418. }
  2419. });
  2420.  
  2421. var wikiLocalLang = document.createElement("Button");
  2422. wikiLocalLang.classList.add("unity-btn", "full", "horizontal-1", "vertical-0");
  2423. wikiLocalLang.id = "local language";
  2424. wikiLocalLang.state = true;
  2425. wikiLocalLang.innerHTML = "Switch to Local Language";
  2426. document.body.appendChild(wikiLocalLang);
  2427. wikiLocalLang.addEventListener("click", () => {
  2428. if (wikiLocalLang.state && global_cc)
  2429. {
  2430. let cc = langDict[global_cc];
  2431. let fi = "en";
  2432. if (typeof cc !== typeof undefined)
  2433. {
  2434. fi = cc[Math.floor(Math.random() * cc.length)];
  2435. }
  2436. wiki(fi, document.getElementById("i_container"), teleportMenu);
  2437. wikiLocalLang.innerHTML = "Switch to English";
  2438. wikiLocalLang.state = false;
  2439. }
  2440. else
  2441. {
  2442. wiki("en", document.getElementById("i_container"), teleportMenu);
  2443. wikiLocalLang.innerHTML = "Switch to Local Language";
  2444. wikiLocalLang.state = true;
  2445. }
  2446. });
  2447.  
  2448.  
  2449.  
  2450. handleStyles();
  2451.  
  2452.  
  2453.  
  2454. console.log("Script buttons Loaded");
  2455. }
  2456.  
  2457. function GenBtnColor()
  2458. {
  2459. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2460. if (timeMachineBtn.index == timeMachineBtn.list.length - 1)
  2461. {
  2462. timeMachineNewerBtn.style.backgroundColor = "red";
  2463. timeMachineNewerBtn.disabled = true;
  2464. }
  2465. else
  2466. {
  2467. timeMachineNewerBtn.style.backgroundColor = "#ba55d3";
  2468. timeMachineNewerBtn.disabled = false;
  2469. }
  2470. if (timeMachineBtn.index == 0)
  2471. {
  2472. timeMachineOlderBtn.style.backgroundColor = "red";
  2473. timeMachineOlderBtn.disabled = true;
  2474. }
  2475. else
  2476. {
  2477. timeMachineOlderBtn.style.backgroundColor = "#ba55d3";
  2478. timeMachineOlderBtn.disabled = false;
  2479. }
  2480. }
  2481.  
  2482. /**
  2483. * Handle Keyboard inputs
  2484. */
  2485.  
  2486. function kBoard()
  2487. {
  2488. document.addEventListener('keydown', logKey);
  2489. }
  2490.  
  2491. function logKey(e) {
  2492. // console.log(e.code);
  2493. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2494. if (e.code == "Space")
  2495. {
  2496. setHidden(true);
  2497. }
  2498. if (e.code == "Digit4")
  2499. {
  2500. teleportBtn.click();
  2501. }
  2502. if (e.code == "Digit3")
  2503. {
  2504. teleportReverse.click();
  2505. }
  2506. else if (e.code == "Digit5")
  2507. {
  2508. timeMachineOlderBtn.click();
  2509. }
  2510. else if (e.code == "Digit6")
  2511. {
  2512. timeMachineBtn.click();
  2513. }
  2514. else if (e.code == "Digit7")
  2515. {
  2516. timeMachineNewerBtn.click();
  2517. }
  2518. else if (e.code == "Digit8")
  2519. {
  2520. if (mainMenuBtn.style.visibility == "hidden")
  2521. {
  2522. mainMenuBtn.style.visibility = "";
  2523. }
  2524. else
  2525. {
  2526. mainMenuBtn.style.visibility = "hidden";
  2527. }
  2528. }
  2529. }
  2530.  
  2531.  
  2532. /**
  2533. * Hide or reveal the buttons, and disable buttons if such feature is not available
  2534. */
  2535.  
  2536. function setHidden(cond)
  2537. {
  2538. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2539. if (mainMenuBtn != null)
  2540. {
  2541. mainMenuBtn.style.visibility = "";
  2542. mainMenuBtn.hide = true;
  2543. if (document.getElementById("Info Menu").style.visibility !== "hidden")
  2544. {
  2545. mainMenuBtn.menuBtnCache = true;
  2546. }
  2547. else
  2548. {
  2549. mainMenuBtn.menuBtnCache = false;
  2550. }
  2551. if (cond)
  2552. {
  2553. if (teleportBtn != null)
  2554. {
  2555. for (let element of document.getElementsByClassName("unity-btn")){
  2556. element.style.visibility = "hidden";
  2557. }
  2558. }
  2559. let iframe = document.getElementById("i_container");
  2560. if (iframe != null)
  2561. {
  2562. if (!isBattleRoyale)
  2563. {
  2564. iframe.src = ""
  2565. }
  2566. else
  2567. {
  2568. // TODO
  2569. }
  2570. }
  2571.  
  2572. }
  2573. else
  2574. {
  2575. for (let element of document.getElementsByClassName("unity-btn")){
  2576. if (element.id !== "Show Buttons" && !element.classList.contains("menu-btn"))
  2577. {
  2578. element.style.visibility = "hidden";
  2579. }
  2580. }
  2581. }
  2582. }
  2583. }
  2584.  
  2585. function setDisable(cond) {
  2586. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2587. function setAll(cond1, cond2)
  2588. {
  2589. teleportMoreBtn.style.backgroundColor = cond1;
  2590. teleportMoreBtn.disabled = cond2;
  2591. teleportLessBtn.style.backgroundColor = cond1;
  2592. teleportLessBtn.disabled = cond2;
  2593. teleportDistResetBtn.style.backgroundColor = cond1;
  2594. teleportDistResetBtn.disabled = cond2;
  2595. switchCovergeButton.style.backgroundColor = cond1;
  2596. switchCovergeButton.disabled = cond2;
  2597. teleportBtn.style.backgroundColor = cond1;
  2598. teleportBtn.disabled = cond2;
  2599. teleportReverse.style.backgroundColor = cond1;
  2600. teleportReverse.disabled = cond2;
  2601. teleportMenu.style.backgroundColor = cond1;
  2602. teleportMenu.disabled = cond2;
  2603. TeleportArisBtn.style.backgroundColor = cond1;
  2604. TeleportArisBtn.disabled = cond2;
  2605. timeMachineBtn.style.backgroundColor = cond1;
  2606. timeMachineBtn.disabled = cond2;
  2607. satelliteSwitchButton.style.backgroundColor = cond1;
  2608. satelliteSwitchButton.disabled = cond2;
  2609. }
  2610.  
  2611. function setMapstyle(cond1, cond2)
  2612. {
  2613. for (let mapDiv of document.getElementsByClassName("preset-minimap"))
  2614. {
  2615. if (["Borders", "Satellite", "Terrain", "Hybrid", "Custom"].includes(mapDiv.id))
  2616. {
  2617. mapDiv.style.backgroundColor = cond1;
  2618. mapDiv.disabled = cond2;
  2619. }
  2620. }
  2621. for (let mapDiv2 of document.getElementsByClassName("overlay-minimap"))
  2622. {
  2623. if (["Coverage", "Official", "OSM"].includes(mapDiv2.id))
  2624. {
  2625. mapDiv2.style.backgroundColor = cond1;
  2626. mapDiv2.disabled = cond2;
  2627. }
  2628. }
  2629. }
  2630.  
  2631.  
  2632.  
  2633. // console.log(cond)
  2634.  
  2635. if (teleportBtn != null) {
  2636. setMapstylePlanet("None");
  2637. if (rtded) {
  2638. setAll("red", true);
  2639. setMapstyle("red", true);
  2640. }
  2641. else
  2642. {
  2643. setMapstyle("#ff69b4", false)
  2644. if (cond == ms_sat_map)
  2645. {
  2646. setAll("red", true);
  2647. }
  2648. else if (cond == "NMPZ") {
  2649. setAll("red", true);
  2650. if (cond !== "Baidu")
  2651. {
  2652. satelliteSwitchButton.style.backgroundColor = "#ba55d3";
  2653. satelliteSwitchButton.disabled = false;
  2654. }
  2655. if (NZ)
  2656. {
  2657. if (ms_radius > 5000)
  2658. {
  2659. ms_radius = 5000;
  2660. }
  2661. }
  2662. if (NM)
  2663. {
  2664. if (ms_radius > 2000)
  2665. {
  2666. ms_radius = 2000;
  2667. }
  2668. }
  2669. if (NM && NZ)
  2670. {
  2671. if (ms_radius > 1000)
  2672. {
  2673. ms_radius = 1000;
  2674. }
  2675. }
  2676. if (NM && NP && NZ)
  2677. {
  2678. if (ms_radius > 500)
  2679. {
  2680. ms_radius = 500;
  2681. }
  2682. }
  2683. }
  2684. else if (cond == "Google" || nextPlayer === "Wikipedia") {
  2685. setAll("#ba55d3", false);
  2686. if (bullseyeMapillary && cond == "Google")
  2687. {
  2688. switchCovergeButton.style.backgroundColor = "red";
  2689. switchCovergeButton.disabled = true;
  2690. }
  2691. }
  2692. else if (cond === "Baidu" || cond === "Youtube" || cond === "Image" || nextPlayer === "Minecraft") {
  2693. setAll("red", true);
  2694. switchCovergeButton.style.backgroundColor = "#ba55d3";
  2695. switchCovergeButton.disabled = false;
  2696. if (cond !== "Baidu")
  2697. {
  2698. satelliteSwitchButton.style.backgroundColor = "#ba55d3";
  2699. satelliteSwitchButton.disabled = false;
  2700. }
  2701. }
  2702. else if (cond == "Kakao" || cond == "Yandex" || cond == "Mapillary" || cond == "Bing Streetside" || cond == "Mapbox Satellite") {
  2703. setAll("#ba55d3", false);
  2704. timeMachineBtn.style.backgroundColor = "red";
  2705. timeMachineBtn.disabled = true;
  2706. }
  2707. else if (cond == "Planets") {
  2708. setAll("red", true);
  2709. console.log("setting map style");
  2710. setMapstyle("red", true);
  2711. setMapstylePlanet(planetType);
  2712. }
  2713. // else if (cond == "Mapbox Satellite") {
  2714. // setAll("red", true);
  2715. // switchCovergeButton.style.backgroundColor = "#BF40BF";
  2716. // switchCovergeButton.disabled = false;
  2717. // satelliteSwitchButton.style.backgroundColor = "#BF40BF";
  2718. // satelliteSwitchButton.disabled = false;
  2719. // }
  2720. }
  2721. timeMachineNewerBtn.style.backgroundColor = "red";
  2722. timeMachineNewerBtn.disabled = true;
  2723. timeMachineOlderBtn.style.backgroundColor = "red";
  2724. timeMachineOlderBtn.disabled = true;
  2725.  
  2726. }
  2727. }
  2728.  
  2729. function setMapstylePlanet(cond)
  2730. {
  2731. for (let mapDiv of document.getElementsByClassName("space-minimap"))
  2732. {
  2733.  
  2734. if (cond == "None" && mapDiv.id.includes("Earth"))
  2735. {
  2736. mapDiv.style.backgroundColor = "#ff1493";
  2737. mapDiv.disabled = false;
  2738. }
  2739. else if (mapDiv.id.includes(cond) || mapDiv.id.includes("Earth"))
  2740. {
  2741. mapDiv.style.backgroundColor = "#ff69b4";
  2742. mapDiv.disabled = false;
  2743. }
  2744. else
  2745. {
  2746. mapDiv.style.backgroundColor = "red";
  2747. mapDiv.disabled = true;
  2748. }
  2749.  
  2750.  
  2751. }
  2752. }
  2753.  
  2754.  
  2755. /**
  2756. * This observer stays alive while the script is running
  2757. */
  2758.  
  2759.  
  2760.  
  2761. function launchObserver() {
  2762. UnityInitiate();
  2763. handleTeleport();
  2764. SyncListener();
  2765. kBoard();
  2766. console.log("Main Observer");
  2767. // const OBSERVER = new MutationObserver((mutations, observer) => {
  2768. // detectGamePage();
  2769. // });
  2770. // OBSERVER.observe(document.head, { attributes: true, childList: true, subtree: true });
  2771. let observer3 = new MutationObserver((mutations) => {
  2772. mutations.forEach((mutation) => {
  2773. if (oldHref != document.location.href && allowDetect) {
  2774. oldHref = document.location.href;
  2775. detectGamePage();
  2776. }
  2777. if (mutation.removedNodes)
  2778. {
  2779. for (let m of mutation.removedNodes) {
  2780. if (m.classList)
  2781. {
  2782. let sat = m.getElementsByTagName('sat-map');
  2783. if (sat.length !== 0)
  2784. {
  2785. let sat0 = sat[0];
  2786. sat0.style.display = "none";
  2787. // console.log(sat0)
  2788. sat0.querySelector('.mapboxgl-map').classList.remove("inactive", "game-panorama_panorama__ncMwh", "game-panorama_panorama__Qpsxl", "br-game-layout__panorama", "game-layout__panorama", "game-panorama_panorama__rdhFg")
  2789. document.body.appendChild(sat0);
  2790. }
  2791. }
  2792. }
  2793. }
  2794. if (mutation.addedNodes)
  2795. {
  2796. for (let m of mutation.addedNodes) {
  2797. // console.log(m);
  2798. if (m.classList)
  2799. {
  2800. // let sat3 = m.getElementsByClassName("tooltip_tooltip__CHe2s");
  2801. let PATHNAME = window.location.pathname;
  2802. // let sat4 = m.getElementsByClassName('fullscreen-spinner_square__mwMfl');
  2803. // console.log(m.classList.contains('round-starting_wrapper__1G_FC'));
  2804. if (m.getElementsByClassName("tooltip_tooltip__CHe2s").length !== 0)
  2805. {
  2806. // console.log("detect setting")
  2807. detectGamePage();
  2808. }
  2809. else if ((PATHNAME.startsWith("/challenge/") ||PATHNAME.startsWith("/results/") ||
  2810. PATHNAME.startsWith("/game/")|| PATHNAME.startsWith("/battle-royale/") ||
  2811. PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/") ||
  2812. PATHNAME.startsWith("/bullseye/")) && (m.getElementsByClassName('fullscreen-spinner_square__mwMfl').length !== 0))
  2813. {
  2814. // console.log("detect spinner")
  2815. if (allowDetect)
  2816. {
  2817. detectGamePage();
  2818. }
  2819. }
  2820. else if ((PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) && (m.classList.contains('new-round_roundInfo__UlMCc')))
  2821. {
  2822. // console.log("detect duel")
  2823. if (allowDetect)
  2824. {
  2825. detectGamePage();
  2826. }
  2827. }
  2828. else if (PATHNAME.startsWith("/live-challenge/") && (m.classList.contains('round-starting_wrapper__1G_FC')))
  2829. {
  2830. // console.log("detect live challie")
  2831. if (allowDetect)
  2832. {
  2833. detectGamePage();
  2834. }
  2835. }
  2836.  
  2837. let sat = m.getElementsByClassName('result-layout_bottom__qLPd2');
  2838.  
  2839. if (m.getElementsByClassName('result-layout_bottom__qLPd2').length !== 0)
  2840. {
  2841. // console.log("Round middle Callback");
  2842. nextButtonCallback();
  2843. }
  2844.  
  2845. let sat2 = m.getElementsByClassName('guess-map__canvas-container');
  2846. if (sat2.length !== 0)
  2847. {
  2848. // console.log("Minimap Callback");
  2849. handleMinimapCallback();
  2850. }
  2851. }
  2852. }
  2853. }
  2854. })
  2855. })
  2856. observer3.observe(document.body, {childList: true, subtree: true, attributes: false, characterData: false})
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862. }
  2863. // function observerCallback(obs)
  2864. // {
  2865. // if (obs)
  2866. // {
  2867. // obs.observe(document.head, { attributes: true, childList: true, subtree: true });
  2868. // }
  2869. // else
  2870. // {
  2871. // setTimeout(observerCallback, 250);
  2872. // }
  2873. // }
  2874.  
  2875. /**
  2876. * Once the Google Maps API was loaded we can do more stuff
  2877. */
  2878.  
  2879. var oldHref = document.location.href;
  2880.  
  2881. window.addEventListener('DOMContentLoaded', (event) => {
  2882.  
  2883. if (!document.getElementById("Info Menu"))
  2884. {
  2885. injecter(() => {
  2886. launchObserver();
  2887. })
  2888. }
  2889. });
  2890.  
  2891. const base62 = {
  2892. charset: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  2893. .split(''),
  2894. encode: integer => {
  2895. if (integer === 0) {
  2896. return 0;
  2897. }
  2898. let s = [];
  2899. while (integer > 0) {
  2900. s = [base62.charset[integer % 62], ...s];
  2901. integer = Math.floor(integer / 62);
  2902. }
  2903. return s.join('');
  2904. },
  2905. decode: chars => chars.split('').reverse().reduce((prev, curr, i) =>
  2906. prev + (base62.charset.indexOf(curr) * (62 ** i)), 0)
  2907. };
  2908.  
  2909.  
  2910. /**
  2911. * Check whether the current page is a game, if so which game mode
  2912. */
  2913.  
  2914. function detectGamePage() {
  2915. // console.log("detect game change");
  2916. if (document.querySelector(FAIL_TO_LOAD_CANVAS) !== null && !one_reset)
  2917. {
  2918. one_reset = true;
  2919. console.log("Hide fail to load panorama canvas");
  2920. document.querySelector(FAIL_TO_LOAD_CANVAS).style.visibility = "hidden";
  2921. }
  2922. function loadModule()
  2923. {
  2924. // console.log("load module")
  2925.  
  2926. if (toLoad) {
  2927. // console.log("initializeCanvas")
  2928. initializeCanvas();
  2929. }
  2930. waitLoad();
  2931.  
  2932. }
  2933. let toLoad = !playerLoaded && !YANDEX_INJECTED && !KAKAO_INJECTED && !MAPILLARY_INJECTED && !MS_INJECTED && !MAPBOX_INJECTED;
  2934. const PATHNAME = window.location.pathname;
  2935. // console.log(PATHNAME)
  2936. if (PATHNAME.startsWith("/game/") || PATHNAME.startsWith("/challenge/")) {
  2937. // console.log("Game page");
  2938. isBattleRoyale = false;
  2939. isDuel = false;
  2940. loadModule();
  2941. }
  2942. else if (PATHNAME.startsWith("/battle-royale/")) {
  2943. if (document.querySelector(BR_LAYOUT) == null) {
  2944. // console.log("Battle Royale Lobby");
  2945. rstValues();
  2946. }
  2947. else {
  2948. // console.log("Battle Royale");
  2949. isBattleRoyale = true;
  2950. isDuel = false;
  2951. loadModule();
  2952. }
  2953. }
  2954. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  2955. if (document.querySelector(DUEL_LAYOUT) == null) {
  2956. // console.log("Battle Royale Lobby");
  2957. rstValues();
  2958. }
  2959. else {
  2960. // console.log("Duels");
  2961. isBattleRoyale = true;
  2962. isDuel = true;
  2963. loadModule();
  2964. }
  2965. }
  2966. else if (PATHNAME.startsWith("/bullseye/")) {
  2967. if (document.querySelector(".game_layout__0vAWj") == null) {
  2968. // console.log("Battle Royale Lobby");
  2969. rstValues();
  2970. }
  2971. else {
  2972. // console.log("bullseye");
  2973. isBattleRoyale = true;
  2974. isBullseye = true;
  2975. // console.log(document.getElementById("player"));
  2976. if (document.getElementById("player") == null)
  2977. {
  2978. loadModule();
  2979. }
  2980. }
  2981. }
  2982. else if (PATHNAME.startsWith("/live-challenge/")) {
  2983. if (document.querySelector(".panorama-question_layout__DYh_Y") == null) {
  2984. // console.log("Battle Royale Lobby");
  2985. rstValues();
  2986. }
  2987. else {
  2988. // console.log("bullseye");
  2989. isLiveChallenge = true;
  2990. isBattleRoyale = true;
  2991. loadModule();
  2992. }
  2993. }
  2994. else {
  2995. rstValues();
  2996. // console.log("Not a Game page");
  2997. }
  2998. }
  2999.  
  3000. function rstValues()
  3001. {
  3002. ROUND = 0;
  3003. YandexPlayer = null;
  3004. KakaoPlayer = null;
  3005. MapillaryPlayer = null;
  3006. MSStreetPlayer = null;
  3007. // MapboxPlayer = null;
  3008. // MapboxMarker = null;
  3009.  
  3010. BAIDU_INJECTED = false;
  3011. YANDEX_INJECTED = false;
  3012. KAKAO_INJECTED = false;
  3013. MAPILLARY_INJECTED = false;
  3014. MS_INJECTED = false;
  3015. MAPBOX_INJECTED = false;
  3016.  
  3017. nextPlayer = "Google";
  3018. nextPlayer_save = "Google";
  3019. global_lat = 0;
  3020. global_lng = 0;
  3021. global_panoID = null;
  3022. global_cc = null;
  3023. global_BDAh = null;
  3024. global_BDBh = null;
  3025. global_BDID = null;
  3026. yId = null;
  3027. yTime = null;
  3028. yEnd = null;
  3029. iId = null;
  3030.  
  3031. COMPASS = null;
  3032. eventListenerAttached = false;
  3033. povListenerAttached = false;
  3034. playerLoaded = false;
  3035. locHistory = [];
  3036. one_reset = false;
  3037. setHidden(true);
  3038. yandex_map = false;
  3039. Kakao_map = false;
  3040. Wikipedia_map = false;
  3041. Minecraft_map = false;
  3042. bing_map = false;
  3043. mmKey = 0;
  3044. CURRENT_ROUND_DATA = null;
  3045. ms_radius = 15000;
  3046.  
  3047. isDuel = false;
  3048. isBattleRoyale = false;
  3049. isBullseye = false;
  3050. isLiveChallenge = false;
  3051.  
  3052. BR_LOAD_KAKAO = false;
  3053. BR_LOAD_YANDEX = false;
  3054. BR_LOAD_MS = false;
  3055. BR_LOAD_MP = false;
  3056. BR_LOAD_MAPILLARY = false;
  3057.  
  3058. ms_sat_map = false;
  3059. rtded = false;
  3060.  
  3061. linksList = [];
  3062.  
  3063. NM = false;
  3064. NP = false;
  3065. NZ = false;
  3066. initBing = false;
  3067.  
  3068. planetType = "None";
  3069. wikiUrl = "";
  3070. bullseyeMapillary = false;
  3071. }
  3072.  
  3073. /**
  3074. * Wait for various players to load
  3075. */
  3076.  
  3077. function btnAll()
  3078. {
  3079. // console.log([document.querySelector(BULLSEYE_CANVAS), "???"])
  3080. if (document.querySelector(".ticket-bar_root__H8RcX") != null)
  3081. {
  3082. if (document.querySelector(BR_CANVAS) != null)
  3083. {
  3084. AdjustBtnPos("-2em + 2px", "300px", true);
  3085. }
  3086. else if (document.querySelector(DUELS_CANVAS) != null)
  3087. {
  3088. AdjustBtnPos("6em", "0em", true);
  3089. }
  3090. else if (document.querySelector(BULLSEYE_CANVAS) != null)
  3091. {
  3092. AdjustBtnPos("5em", "18.5em", true);
  3093. }
  3094. else if (document.querySelector(LIVE_CANVAS) != null)
  3095. {
  3096. AdjustBtnPos("4em", "15.5em", true);
  3097. }
  3098. else
  3099. {
  3100. AdjustBtnPos("4em", "0em", true);
  3101. }
  3102. }
  3103. else
  3104. {
  3105. if (document.querySelector(BR_CANVAS) != null)
  3106. {
  3107. AdjustBtnPos("-6em + 2px", "300px", true);
  3108. }
  3109. else if (document.querySelector(DUELS_CANVAS) != null)
  3110. {
  3111. AdjustBtnPos("2em", "0em", true);
  3112. }
  3113. else if (document.querySelector(BULLSEYE_CANVAS) != null)
  3114. {
  3115. AdjustBtnPos("1em", "18.5em", true);
  3116. }
  3117. else if (document.querySelector(LIVE_CANVAS) != null)
  3118. {
  3119. AdjustBtnPos("0em", "15.5em", true);
  3120. }
  3121. else
  3122. {
  3123. AdjustBtnPos("0em", "0em", true);
  3124. }
  3125. }
  3126. if (menuLocCounter > 0)
  3127. {
  3128. for (let i = 0; i < menuLocCounter; i++) {
  3129. AdjustBtnPos("-2em", "0em", false);
  3130. }
  3131. }
  3132. else if (menuLocCounter < 0)
  3133. {
  3134. for (let i = 0; i < -menuLocCounter; i++) {
  3135. AdjustBtnPos("2em", "0em", false);
  3136. }
  3137. }
  3138. }
  3139.  
  3140. function waitLoad() {
  3141. if (!YandexPlayer || !KakaoPlayer || !MapillaryPlayer || !MSStreetPlayer || !MapboxPlayer || !document.getElementById("i_container") || !YANDEX_INJECTED || !KAKAO_INJECTED || !MAPILLARY_INJECTED || !MS_INJECTED || !MAPBOX_INJECTED) {
  3142. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3143.  
  3144. if (isBullseye && (document.getElementById("player") == null))
  3145. {
  3146. BAIDU_INJECTED = false;
  3147. YANDEX_INJECTED = false;
  3148. KAKAO_INJECTED = false;
  3149. MAPILLARY_INJECTED = false;
  3150. MS_INJECTED = false;
  3151. MAPBOX_INJECTED = false;
  3152. initializeCanvas();
  3153. // document.querySelector(BULLSEYE_CANVAS).id = "player";
  3154. // injectContainer();
  3155. }
  3156. btnAll();
  3157. // console.log("wait");
  3158. // console.log([!YandexPlayer, !KakaoPlayer,!MapillaryPlayer,!MSStreetPlayer,!MapboxPlayer,!document.getElementById("i_container"),!YANDEX_INJECTED,!KAKAO_INJECTED,!MAPILLARY_INJECTED,!MS_INJECTED,!MAPBOX_INJECTED])
  3159. setTimeout(waitLoad, 250);
  3160. } else {
  3161. checkRound();
  3162. }
  3163. }
  3164.  
  3165. /**
  3166. * Checks for round changes
  3167. */
  3168.  
  3169. function checkRound() {
  3170. // console.log("Check Round");
  3171. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3172.  
  3173. if (!isBattleRoyale) {
  3174. // console.log("Check Round");
  3175. let currentRound = getRoundFromPage();
  3176. if (ROUND != currentRound) {
  3177. // fire1 = true;
  3178. switchCovergeButton.init = true;
  3179. console.log("New round");
  3180. ROUND = currentRound;
  3181. // NEW_ROUND_LOADED = true;
  3182. COMPASS = null;
  3183. locHistory = [];
  3184. wikiUrl = "";
  3185. one_reset = false;
  3186. getMapData();
  3187. // nextButtonCallback();
  3188. }
  3189. }
  3190. else {
  3191. getMapData();
  3192. }
  3193. }
  3194.  
  3195. /**
  3196. * Add listeners if buttons have been created
  3197. */
  3198.  
  3199. function finalDetail()
  3200. {
  3201. let target = document.querySelector("a[data-qa='play-same-map']");
  3202. if (target)
  3203. {
  3204. var div = document.createElement("div");
  3205. div.classList.add("buttons_buttons__0B3SB")
  3206. document.querySelector('.result-layout_content__jAHfP').appendChild(div);
  3207. for (var rd of linksList)
  3208. {
  3209. let str;
  3210. if (rd[1] == "Mapbox Satellite")
  3211. {
  3212. str = "Google Maps";
  3213. }
  3214. else
  3215. {
  3216. str = rd[1];
  3217. }
  3218. // console.log(rd)
  3219. let cl = target.cloneNode( true );
  3220. let tx = "View R" + rd[0] + " in " + str;
  3221. cl.querySelector('.button_label__kpJrA').innerHTML = tx;
  3222. cl.removeAttribute('data-qa');
  3223. cl.removeAttribute('href');
  3224. cl.urlStr = rd[2];
  3225. cl.addEventListener("click", (e) => {
  3226. window.open(cl.urlStr);
  3227. })
  3228. cl.style = "top:10px;right:-10px;";
  3229. div.appendChild(cl);
  3230. }
  3231. }
  3232. else
  3233. {
  3234. setTimeout(finalDetail, 500);
  3235. }
  3236. }
  3237.  
  3238. function nextButtonCallback()
  3239. {
  3240. let nextButton = document.querySelector("button[data-qa='close-round-result']");
  3241. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3242. // if (nextButton != null && fire1)
  3243. // {
  3244. // fire1 = false;
  3245. nextButton.addEventListener("click", (e) => {
  3246. if (mainMenuBtn != null && !cn_tips && ROUND !== 5)
  3247. {
  3248. // console.log("try to show show buttons")
  3249. mainMenuBtn.style.visibility = "";
  3250. if (mainMenuBtn.menuBtnCache)
  3251. {
  3252. for (let element of document.getElementsByClassName("menu-btn"))
  3253. {
  3254. element.style.visibility = "";
  3255. }
  3256. }
  3257. }
  3258. if (ROUND == 5)
  3259. {
  3260. console.log("Game Finished")
  3261. if (linksList)
  3262. {
  3263. finalDetail();
  3264. }
  3265. }
  3266. })
  3267. let urlStr = ""
  3268.  
  3269. if (nextPlayer !== "Google" && nextPlayer !== "Planets")
  3270. {
  3271. // console.log("Clone buttons");
  3272. let clone = document.querySelector("button[data-qa='close-round-result']").cloneNode( true );
  3273. let tx;
  3274. if (nextPlayer == "Mapbox Satellite")
  3275. {
  3276. tx = "View Location in Google Maps";
  3277. }
  3278. else
  3279. {
  3280. tx = "View Location in " + nextPlayer;
  3281. }
  3282. clone.querySelector('.button_label__kpJrA').innerHTML = tx;
  3283. clone.setAttribute('id', "LinkBtn");
  3284. clone.removeAttribute('data-qa');
  3285. if (nextPlayer == "Baidu")
  3286. {
  3287. urlStr = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  3288. }
  3289. else if (nextPlayer == "Youtube")
  3290. {
  3291. urlStr = "https://www.youtube.com/watch?v=" + yId;
  3292. }
  3293. else if (nextPlayer == "Image")
  3294. {
  3295. urlStr = iId;
  3296. }
  3297. else if (nextPlayer == "Kakao")
  3298. {
  3299. urlStr = "https://map.kakao.com/link/roadview/" + global_lat + "," + global_lng;
  3300. }
  3301. else if (nextPlayer == "Mapillary")
  3302. {
  3303. urlStr = "https://www.mapillary.com/app/?pKey=" + mmKey + "&focus=photo";
  3304. }
  3305. else if (nextPlayer == "Yandex")
  3306. {
  3307. urlStr = "https://yandex.com/maps/?&panorama%5Bdirection%5D=16%2C0&panorama%5Bpoint%5D=" + global_lng + "%2C" + global_lat;
  3308. }
  3309. else if (nextPlayer == "Bing Streetside")
  3310. {
  3311. urlStr = "https://bing.com/maps/default.aspx?cp=" + global_lat + "~" + global_lng + "&lvl=20&style=r";
  3312. }
  3313. else if (nextPlayer == "Mapbox Satellite")
  3314. {
  3315. urlStr = `http://www.google.com/maps/place/${global_lat},${global_lng}`;
  3316. }
  3317. else if (nextPlayer == "Wikipedia")
  3318. {
  3319. urlStr = wikiUrl;
  3320. }
  3321. // IMPLEMENT WIKIPEDIA
  3322. clone.addEventListener("click", (e) => {
  3323. window.open(urlStr);
  3324. })
  3325. if (ROUND == 5)
  3326. {
  3327. clone.style = "top:10px;";
  3328. }
  3329. else
  3330. {
  3331. clone.style = "right:-10px;";
  3332. }
  3333. linksList.push([ROUND, nextPlayer, urlStr]);
  3334. document.querySelector('.round-result_actions__5j26U').appendChild(clone);
  3335. }
  3336. // }
  3337. // else
  3338. // {
  3339. // setTimeout(nextButtonCallback, 1000);
  3340. // }
  3341. }
  3342.  
  3343. function guessButtonCallback()
  3344. {
  3345. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3346. let guessButton = document.querySelector("button[data-qa='perform-guess']");
  3347. if (guessButton != null)
  3348. {
  3349.  
  3350. guessButton.addEventListener("click", (e) => {
  3351. if (mainMenuBtn != null)
  3352. {
  3353. console.log("try to hide show buttons")
  3354. mainMenuBtn.style.visibility = "hidden";
  3355. setHidden(true);
  3356. }
  3357. })
  3358. }
  3359. else
  3360. {
  3361. setTimeout(guessButtonCallback, 1000);
  3362. }
  3363. }
  3364.  
  3365. /**
  3366. * Load different streetview players
  3367. */
  3368.  
  3369. function loaderChecker(data)
  3370. {
  3371. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3372.  
  3373. let substrings = ["Yandex", "Bing Streetside", "Kakao", "Mapbox", "Bing Satellite", "Planets"]
  3374. bullseyeMapillary = ((isBullseye || isLiveChallenge) && !["Mapillary", "A United World", "A Unity World", "Unity Test","Unity Special Edition"].some(v => data.includes(v)));
  3375. if (substrings.some(v => data.includes(v)) || rtded || bullseyeMapillary)
  3376. {
  3377. MapillaryPlayer = "MA";
  3378. MAPILLARY_INJECTED = true;
  3379.  
  3380. console.log("Not loading Mapillary");
  3381. }
  3382. else
  3383. {
  3384. BR_LOAD_MAPILLARY = true;
  3385. injectMapillaryPlayer();
  3386. }
  3387.  
  3388. if (data.includes("A United World") || data.includes("A Unity World") || data.includes("Unity Test") || data.includes("Unity Special Edition"))
  3389. {
  3390. console.log("Complete Map");
  3391. data = "Yandex Bing Streetside Kakao Mapbox";
  3392. }
  3393.  
  3394. if (data.includes("Yandex"))
  3395. {
  3396. console.log("Yandex Map");
  3397. if (data == "Yandex Bing Streetside Kakao Mapbox")
  3398. {
  3399. yandex_map = false;
  3400. }
  3401. else
  3402. {
  3403. yandex_map = true;
  3404. }
  3405. injectYandexScript().then(() => {
  3406. console.log("Ready to inject Yandex player");
  3407. injectYandexPlayer();
  3408. }).catch((error) => {
  3409. console.log(error);
  3410. });
  3411. BR_LOAD_YANDEX = true;
  3412. }
  3413. else
  3414. {
  3415. // console.log("Not Yandex map");
  3416. YANDEX_INJECTED = true;
  3417. YandexPlayer = "YD";
  3418. }
  3419.  
  3420. if (data.includes("Bing Streetside") || data.includes("Planets"))
  3421. {
  3422. console.log("Bing Map");
  3423. if (data.includes("Planets"))
  3424. {
  3425. let tempRad2;
  3426. tempRad2 = data.split("Planets")[1];
  3427. if (/\d/.test(tempRad2))
  3428. {
  3429. ms_radius = parseInt(tempRad2.replace(/\D/g,'')) * 1000;
  3430. }
  3431. bing_map = true;
  3432. if (data.includes("Mars"))
  3433. {
  3434. planetType = "Mars";
  3435. }
  3436. else if (data.includes("Moon"))
  3437. {
  3438. planetType = "Moon";
  3439. }
  3440. // else if (data.includes("GTA V"))
  3441. // {
  3442. // planetType = "GTAV";
  3443. // }
  3444. // else if (data.includes("GTA San Andreas"))
  3445. // {
  3446. // planetType = "GTASA";
  3447. // }
  3448. else
  3449. {
  3450. // ??
  3451. }
  3452. }
  3453. if (data == "Yandex Bing Streetside Kakao Mapbox")
  3454. {
  3455. bing_map = false;
  3456. }
  3457. injectMSPlayer();
  3458. // initBing = true;
  3459. BR_LOAD_MS = true;
  3460. }
  3461. else
  3462. {
  3463. // console.log("Not Bing map");
  3464. MS_INJECTED = true;
  3465. MSStreetPlayer = "MS";
  3466. }
  3467.  
  3468.  
  3469. let canvas = document.getElementById("sat_map");
  3470. if (data.includes("Bing Satellite") || data.includes("Mapbox") || data.includes("Unity Satellite") || (sat_choice && !rtded))
  3471. {
  3472. if (data == "Yandex Bing Streetside Kakao Mapbox")
  3473. {
  3474. ms_sat_map = false;
  3475. }
  3476. else
  3477. {
  3478. ms_sat_map = true;
  3479. }
  3480. let tempRad;
  3481. if (data.includes("Bing Satellite"))
  3482. {
  3483. tempRad = data.split("Bing Satellite")[1];
  3484. }
  3485. else if (data.includes("Mapbox"))
  3486. {
  3487. tempRad = data.split("Mapbox")[1];
  3488. }
  3489. else if (data.includes("Unity Satellite"))
  3490. {
  3491. tempRad = data.split("Unity Satellite")[1];
  3492. }
  3493.  
  3494.  
  3495. if (/\d/.test(tempRad))
  3496. {
  3497. ms_radius = parseInt(tempRad.replace(/\D/g,'')) * 1000;
  3498. }
  3499. console.log("Mapbox Satellite Map");
  3500. // console.log(canvas)
  3501.  
  3502. if (!canvas)
  3503. {
  3504. injectMapboxPlayer();
  3505. }
  3506. else
  3507. {
  3508. changeInnerHTML(canvas, false);
  3509. MAPBOX_INJECTED = true;
  3510. }
  3511. initBing = true;
  3512. BR_LOAD_MP = true;
  3513. }
  3514. else
  3515. {
  3516. if (canvas == null)
  3517. {
  3518. MapboxPlayer = "MP";
  3519. }
  3520. MAPBOX_INJECTED = true;
  3521. // console.log("Not Mapbox Satellite map");
  3522.  
  3523. }
  3524.  
  3525. if (data.includes("Kakao"))
  3526. {
  3527. console.log("Kakao Map");
  3528. if (data == "Yandex Bing Streetside Kakao Mapbox")
  3529. {
  3530. Kakao_map = false;
  3531. }
  3532. else
  3533. {
  3534. Kakao_map = true;
  3535. }
  3536. injectKakaoScript().then(() => {
  3537. console.log("Ready to inject Kakao player");
  3538. }).catch((error) => {
  3539. console.log(error);
  3540. });
  3541. BR_LOAD_KAKAO = true;
  3542. }
  3543. else{
  3544. KAKAO_INJECTED = true;
  3545. KakaoPlayer = "KK";
  3546. // console.log("Not Kakao map");
  3547. }
  3548.  
  3549. if (data.includes("Wikipedia"))
  3550. {
  3551. console.log("Wikipedia Map");
  3552. Wikipedia_map = true;
  3553.  
  3554. }
  3555. else{
  3556. // console.log("Not Wikipedia map");
  3557. }
  3558.  
  3559. if (data.includes("Minecraft"))
  3560. {
  3561. console.log("Minecraft Map");
  3562. Minecraft_map = true;
  3563.  
  3564. }
  3565. else{
  3566. // console.log("Not Minecraft map");
  3567. }
  3568.  
  3569.  
  3570.  
  3571.  
  3572. if (!data.includes("China Tips for each province"))
  3573. {
  3574. cn_tips = false;
  3575. mainMenuBtn.style.visibility = "";
  3576. setHidden(false);
  3577. }
  3578. else
  3579. {
  3580. cn_tips = true;
  3581. guaranteeUI();
  3582. }
  3583.  
  3584.  
  3585.  
  3586. }
  3587.  
  3588. function loadPlayers() {
  3589. let mapBounds;
  3590. playerLoaded = true;
  3591. injectContainer();
  3592.  
  3593. getSeed().then((data) => {
  3594. // console.log(data)
  3595. let map_name = "Default"
  3596. if (typeof data.isRated !== 'undefined')
  3597. {
  3598. rtded = data.isRated;
  3599. }
  3600. if (typeof data.options !== 'undefined')
  3601. {
  3602. if (typeof data.options.isRated !== 'undefined')
  3603. {
  3604. rtded = data.options.isRated;
  3605. }
  3606. }
  3607. if (rtded)
  3608. {
  3609. map_name = "Public Game";
  3610. }
  3611. else
  3612. {
  3613. if (!isBattleRoyale)
  3614. {
  3615. mapBounds = [data.bounds.max.lat, data.bounds.max.lng, data.bounds.min.lat, data.bounds.min.lng];
  3616. map_name = data.mapName;
  3617. }
  3618. else
  3619. {
  3620. if (isBullseye)
  3621. {
  3622. mapBounds = [data.boundingBox.max.lat, data.boundingBox.max.lng, data.boundingBox.min.lat, data.boundingBox.min.lng];
  3623. map_name = data.mapName;
  3624. }
  3625. else if (isDuel)
  3626. {
  3627. mapBounds = [data.mapBounds.max.lat, data.mapBounds.max.lng, data.mapBounds.min.lat, data.mapBounds.min.lng];
  3628. map_name = data.options.map.name;
  3629. }
  3630. else if (isLiveChallenge)
  3631. {
  3632. mapBounds = [data.rounds[0].question.panoramaQuestionPayload.mapBounds.max.lat, data.rounds[0].question.panoramaQuestionPayload.mapBounds.max.lng,
  3633. data.rounds[0].question.panoramaQuestionPayload.mapBounds.min.lat, data.rounds[0].question.panoramaQuestionPayload.mapBounds.min.lng];
  3634. map_name = data.rounds[0].question.panoramaQuestionPayload.mapName;
  3635. }
  3636. else
  3637. {
  3638. map_name = "Unity Test";
  3639. }
  3640. }
  3641. }
  3642. if (mapBounds)
  3643. {
  3644. ms_radius = magic_formula(mapBounds);
  3645. // console.log(ms_radius / 1000)
  3646. }
  3647. loaderChecker(map_name)
  3648.  
  3649. }).catch((error) => {
  3650. console.log(error);
  3651. });
  3652.  
  3653. }
  3654.  
  3655. function guaranteeUI()
  3656. {
  3657. // console.log("UI")
  3658. if (document.getElementById("GH-ui") !== null)
  3659. {
  3660. document.getElementById("GH-ui").style.display = "block";
  3661. }
  3662. else
  3663. {
  3664. setTimeout(guaranteeUI, 500);
  3665. }
  3666. }
  3667.  
  3668. /**
  3669. * Handles Return to start and undo
  3670. */
  3671.  
  3672. function handleReturnToStart() {
  3673. let rtsButton = document.querySelector("button[data-qa='return-to-start']");
  3674. // console.log("Handle Return to start");
  3675. rtsButton.addEventListener("click", (e) => {
  3676. if (nextPlayer !== "Baidu")
  3677. {
  3678. goToLocation(true);
  3679. }
  3680. else
  3681. {
  3682. document.getElementById("i_container").src = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  3683. }
  3684. const elementClicked = e.target;
  3685. elementClicked.setAttribute('listener', 'true');
  3686. console.log("Return to start");
  3687. });
  3688. guessButtonCallback();
  3689. // setTimeout(function () {goToLocation();}, 1000);
  3690. }
  3691.  
  3692. function handleUndo() {
  3693. let undoButton = document.querySelector("button[data-qa='undo-move']");
  3694. // console.log("Handle undo");
  3695. undoButton.addEventListener("click", (e) => {
  3696. if (locHistory.length > 0) {
  3697. goToUndoMove();
  3698. console.log("Undo Move");
  3699. }
  3700. })
  3701. }
  3702.  
  3703. /**
  3704. * Load game information
  3705. */
  3706.  
  3707. function satCallback()
  3708. {
  3709. // console.log("Sat callback")
  3710. // if (typeof MSStreetPlayer.entities !== typeof undefined && typeof Microsoft.Maps !== typeof undefined)
  3711. // {
  3712. // goToLocation(false);
  3713. // }
  3714. // else
  3715. // {
  3716. // setTimeout(satCallback, 250);
  3717. // }
  3718. if (typeof MapboxPlayer.flyTo !== typeof undefined)
  3719. {
  3720. goToLocation(false);
  3721. }
  3722. else
  3723. {
  3724. setTimeout(satCallback, 250);
  3725. }
  3726. }
  3727.  
  3728. function kakaoCallback()
  3729. {
  3730. console.log("Kakao callback")
  3731. if (typeof kakao.maps !== typeof undefined)
  3732. {
  3733. goToLocation(true);
  3734. setTimeout(function () {goToLocation(true);}, 3000);
  3735. }
  3736. else
  3737. {
  3738. setTimeout(kakaoCallback, 250);
  3739. }
  3740. }
  3741.  
  3742.  
  3743. function modularget(data)
  3744. {
  3745. if (data)
  3746. {
  3747. locationCheck(data);
  3748. if (nextPlayer == "Kakao")
  3749. {
  3750. kakaoCallback();
  3751. }
  3752. else
  3753. {
  3754. goToLocation(true);
  3755. }
  3756. // handleMinimapCallback();
  3757. handleButtons();
  3758. }
  3759. }
  3760.  
  3761. function getMapData() {
  3762. // myHighlight("Seed data");
  3763.  
  3764. getSeed().then((data) => {
  3765. let switchCovergeButton = document.getElementById("switch");
  3766. let mainMenuBtn = document.getElementById("Show Buttons")
  3767. if (isBattleRoyale) {
  3768. if (data.status == "Finished" || typeof data.gameId == typeof undefined) {
  3769. // console.log("Battle Royale Lobby");
  3770. }
  3771. else
  3772. {
  3773. let origin = false;
  3774. if (!CURRENT_ROUND_DATA) {
  3775. CURRENT_ROUND_DATA = data
  3776. origin = true;
  3777. }
  3778.  
  3779. if (origin || !(data.currentRoundNumber === CURRENT_ROUND_DATA.currentRoundNumber)) {
  3780. // myHighlight("Battle Royale New round");
  3781. switchCovergeButton.init = true;
  3782. // NEW_ROUND_LOADED = true;
  3783. COMPASS = null;
  3784. locHistory = [];
  3785. one_reset = false;
  3786. setHidden(false);
  3787. if (!origin) {
  3788. CURRENT_ROUND_DATA = data;
  3789. }
  3790. modularget(data);
  3791. }
  3792. }
  3793. }
  3794. else {
  3795. if (!cn_tips)
  3796. {
  3797. mainMenuBtn.style.visibility = "";
  3798. }
  3799. else
  3800. {
  3801. mainMenuBtn.style.visibility = "hidden";
  3802. AdjustBtnPos("14em", "0em", true);
  3803. }
  3804. modularget(data);
  3805. }
  3806.  
  3807. }).catch((error) => {
  3808. console.log(error);
  3809. });
  3810. }
  3811.  
  3812. function handleMinimapCallback()
  3813. {
  3814. // let trueCond = true;
  3815. // let timeoutTime = 250;
  3816. // if (isBattleRoyale) {
  3817. // if (isDuel)
  3818. // {
  3819. // if (document.querySelector(DUELS_POPUP))
  3820. // {
  3821. // trueCond = false;
  3822. // }
  3823. // else
  3824. // {
  3825. // trueCond = true;
  3826. // }
  3827. // }
  3828. // else
  3829. // {
  3830. // if (document.querySelector(BR_POPUP))
  3831. // {
  3832. // trueCond = false;
  3833. // }
  3834. // else
  3835. // {
  3836. // trueCond = true;
  3837. // }
  3838. // }
  3839. // timeoutTime = 2500;
  3840. // }
  3841.  
  3842. // if (trueCond)
  3843. // {
  3844. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3845. if (MinimapBtn)
  3846. {
  3847. let cur = MinimapBtn.current;
  3848. // console.log(cur)
  3849. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  3850. if (cur == mapDiv.id)
  3851. {
  3852. setTimeout(function () {mapDiv.click();}, 500);
  3853. setTimeout(function () {mapDiv.click();}, 1000);
  3854. setTimeout(function () {mapDiv.click();}, 3000);
  3855. }
  3856. }
  3857. }
  3858. else
  3859. {
  3860. setTimeout(handleMinimapCallback, 1000);
  3861. }
  3862. // }
  3863. // else
  3864. // {
  3865. // setTimeout(handleMinimapCallback, timeoutTime);
  3866. // }
  3867. }
  3868.  
  3869. /**
  3870. * Hide unnecessary buttons for non-Google coverages
  3871. */
  3872.  
  3873. function handleButtons() {
  3874. let CHECKPOINT = document.querySelector("button[data-qa='set-checkpoint']");
  3875. let ZOOM_IN = document.querySelector("button[data-qa='pano-zoom-in']");
  3876. let ZOOM_OUT = document.querySelector("button[data-qa='pano-zoom-out']");
  3877. let UNDO_MOVE = document.querySelector("button[data-qa='undo-move']");
  3878. let DEFAULT_COMPASS = document.querySelector(".compass");
  3879. let NEW_COMPASS = document.querySelector(".panorama-compass_compassContainer__MEnh0");
  3880. let RETURN_TO_START = document.querySelector("button[data-qa='return-to-start']");
  3881.  
  3882. let C1 = (CHECKPOINT !== null);
  3883. let C2 = (ZOOM_IN !== null);
  3884. let C3 = (ZOOM_OUT !== null);
  3885. let C4 = (UNDO_MOVE !== null);
  3886. let C5 = (DEFAULT_COMPASS !== null);
  3887. let C6 = (NEW_COMPASS !== null);
  3888. let C7 = (RETURN_TO_START !== null);
  3889.  
  3890. let waitCond = C5 || C6;
  3891. let cpCond = true;
  3892. let comCond = true;
  3893. if (!NM)
  3894. {
  3895. cpCond = C1 && C4 && C7;
  3896. }
  3897. if (!NZ)
  3898. {
  3899. comCond = C2 && C3;
  3900. }
  3901.  
  3902. function moduleButtons(cond)
  3903. {
  3904.  
  3905. if (!NM)
  3906. {
  3907. CHECKPOINT.style.visibility = cond;
  3908. UNDO_MOVE.style.visibility = cond;
  3909. }
  3910. if (!NZ)
  3911. {
  3912. ZOOM_IN.style.visibility = cond;
  3913. ZOOM_OUT.style.visibility = cond;
  3914. }
  3915. if (C5)
  3916. {
  3917. DEFAULT_COMPASS.style.visibility = cond;
  3918. }
  3919. if (C6)
  3920. {
  3921. NEW_COMPASS.style.visibility = cond;
  3922. }
  3923. }
  3924.  
  3925. if (waitCond && cpCond && comCond)
  3926. {
  3927. // console.log("Handle Buttons");
  3928. if (nextPlayer === "Google" || nextPlayer === "Wikipedia") {
  3929. moduleButtons("");
  3930. }
  3931. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Mapbox Satellite" || nextPlayer === "Minecraft" || nextPlayer === "Planets")
  3932. {
  3933. moduleButtons("hidden");
  3934. }
  3935. else if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Mapillary" || nextPlayer === "Bing Streetside")
  3936. {
  3937. moduleButtons("hidden");
  3938. if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Wikipedia")
  3939. {
  3940. if (C5)
  3941. {
  3942. DEFAULT_COMPASS.style.visibility = "";
  3943. }
  3944. if (C6)
  3945. {
  3946. NEW_COMPASS.style.visibility = "";
  3947. }
  3948. }
  3949. if (!NM)
  3950. {
  3951. UNDO_MOVE.style.visibility = "";
  3952. handleUndo();
  3953. }
  3954. }
  3955. if (!NM)
  3956. {
  3957. handleReturnToStart();
  3958. }
  3959. }
  3960. else
  3961. {
  3962. setTimeout(handleButtons, 250);
  3963. }
  3964. }
  3965.  
  3966. /**
  3967. * Check which player to use for the next location
  3968. */
  3969.  
  3970. function locationCheck(data) {
  3971. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3972. let round;
  3973. // console.log(data)
  3974.  
  3975. if (isBattleRoyale) {
  3976. if (isDuel || isBullseye)
  3977. {
  3978. round = data.rounds[data.currentRoundNumber - 1].panorama;
  3979. global_cc = round.countryCode;
  3980. }
  3981. else if (isLiveChallenge)
  3982. {
  3983. round = data.rounds[data.currentRoundNumber - 1].question.panoramaQuestionPayload.panorama;
  3984. global_cc = round.countryCode;
  3985. }
  3986. else
  3987. {
  3988. round = data.rounds[data.currentRoundNumber - 1];
  3989. global_cc = "us"; // No field available
  3990. }
  3991.  
  3992. }
  3993. else {
  3994. round = data.rounds[data.round - 1];
  3995. global_cc = round.streakLocationCode;
  3996. }
  3997.  
  3998. global_lat = round.lat;
  3999. global_lng = round.lng;
  4000. global_panoID = round.panoId;
  4001.  
  4002. global_heading = round.heading;
  4003. global_pitch = round.pitch;
  4004.  
  4005. // console.log(data);
  4006.  
  4007. // console.log(global_panoID);
  4008.  
  4009. nextPlayer = "Google";
  4010.  
  4011. // if (ms_sat_map)
  4012. // {
  4013. // nextPlayer = "Mapbox Satellite";
  4014. // }
  4015.  
  4016. if (global_panoID) {
  4017. let locInfo;
  4018. if (isBullseye)
  4019. {
  4020. locInfo = global_panoID;
  4021. }
  4022. else
  4023. {
  4024. locInfo = hex2a(global_panoID);
  4025. }
  4026. // console.log(locInfo)
  4027. if (locInfo.substring(0, 3) == "YTB")
  4028. {
  4029. nextPlayer = "Youtube";
  4030. let lengths = [3, 11, 4, 4];
  4031. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  4032. let fullID = locInfo.substring(3).split('START');
  4033. yId = toPiece[1];
  4034. yTime = Number(toPiece[2]);
  4035. yEnd = Number(toPiece[3]);
  4036. }
  4037. else
  4038. {
  4039. let mapType = locInfo.substring(0, 5);
  4040.  
  4041. // panoId unchanged
  4042.  
  4043. if (mapType === "YDMAP" ) {
  4044. nextPlayer = "Yandex";
  4045. }
  4046. else if (mapType === "KKMAP" ) {
  4047. nextPlayer = "Kakao";
  4048. }
  4049.  
  4050. // New panoId formats
  4051.  
  4052. else if (mapType === "BAIDU" ) {
  4053. nextPlayer = "Baidu";
  4054. let lengths = [5, 7, 7, 3];
  4055. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  4056. let panoId1 = base62.decode(toPiece[1]).toString().substring(1);
  4057. let panoId2 = base62.decode(toPiece[2]).toString().substring(1);
  4058. global_BDID = panoId1 + panoId2 + toPiece[3]
  4059. }
  4060. else if (mapType === "MAPIL")
  4061. {
  4062. nextPlayer = "Mapillary";
  4063. mmKey = locInfo.substring(5).replace(/\D/g,'');
  4064. }
  4065. else if (mapType === "IMAGE")
  4066. {
  4067. nextPlayer = "Image";
  4068. let lengths = [5, 4, 4, 7, 2];
  4069. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  4070. iId = "https://i.ibb.co/" + toPiece[3] + "/" + toPiece[1] + "." + toPiece[2].replace(/[^0-9a-z]/gi, '')
  4071. }
  4072. else if (mapType.includes("BING")) {
  4073. if (mapType === "BINGM")
  4074. {
  4075. nextPlayer = "Bing Streetside";
  4076. }
  4077. else
  4078. {
  4079. nextPlayer = "Planets";
  4080. if (mapType === "BINGA" )
  4081. {
  4082. planetType = "Moon";
  4083. }
  4084. else if (mapType === "BINGB" )
  4085. {
  4086. planetType = "Mars";
  4087. }
  4088. // else if (mapType === "BINGC")
  4089. // {
  4090. // planetType = "GTAV";
  4091. // }
  4092. // else if (mapType === "BINGD")
  4093. // {
  4094. // planetType = "GTASA";
  4095. // }
  4096. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  4097. }
  4098. }
  4099. else if (mapType === "SATEL" ) {
  4100. nextPlayer = "Mapbox Satellite";
  4101. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  4102. }
  4103. else if (mapType === "MINEC" ) {
  4104. nextPlayer = "Minecraft";
  4105. }
  4106. else if (mapType === "WIKIP" ) {
  4107. nextPlayer = "Wikipedia";
  4108. }
  4109.  
  4110. // legacy panoId formats support
  4111.  
  4112. // else if (mapType === "BDMAP") {
  4113. // nextPlayer = "Baidu";
  4114. // let coord = locInfo.substring(5);
  4115.  
  4116. // if(coord.includes('BDAh'))
  4117. // {
  4118. // global_BDID = coord.split('BDAh')[0].replace("panoId","");
  4119. // let tem = coord.split('BDAh')[1];
  4120. // global_BDAh = tem.split('BDBh')[0];
  4121. // global_BDBh = tem.split('BDBh')[1];
  4122. // }
  4123. // else
  4124. // {
  4125. // global_BDID = coord.replace("panoId","");
  4126. // }
  4127. // }
  4128. // else if (mapType === "MLMAP") {
  4129. // nextPlayer = "Mapillary";
  4130. // mmKey = locInfo.substring(5);
  4131. // }
  4132.  
  4133. else if (Kakao_map)
  4134. {
  4135. nextPlayer = "Kakao";
  4136. }
  4137. else if (yandex_map)
  4138. {
  4139. nextPlayer = "Yandex";
  4140. }
  4141. else if (Wikipedia_map)
  4142. {
  4143. nextPlayer = "Wikipedia";
  4144. }
  4145. else if (Minecraft_map)
  4146. {
  4147. nextPlayer = "Minecraft";
  4148. }
  4149. else if (bing_map)
  4150. {
  4151. nextPlayer = "Planets";
  4152. }
  4153. else
  4154. {
  4155. nextPlayer = "Google";
  4156. // GooglePlayer.setPano(locInfo);
  4157. }
  4158. }
  4159. }
  4160. else
  4161. {
  4162. if (Kakao_map)
  4163. {
  4164. nextPlayer = "Kakao";
  4165. }
  4166. else if (yandex_map)
  4167. {
  4168. nextPlayer = "Yandex";
  4169. }
  4170. else if (Wikipedia_map)
  4171. {
  4172. nextPlayer = "Wikipedia";
  4173. }
  4174. else if (Minecraft_map)
  4175. {
  4176. nextPlayer = "Minecraft";
  4177. }
  4178. else if (bing_map)
  4179. {
  4180. nextPlayer = "Planets";
  4181. }
  4182. else
  4183. {
  4184. nextPlayer = "Google";
  4185. }
  4186. }
  4187.  
  4188.  
  4189. // if ( krCoordinates[0] > global_lat && krCoordinates[2] < global_lat && krCoordinates[1] < global_lng && krCoordinates[3] > global_lng)
  4190. // {
  4191. // nextSecondaryPlayer = "Kakao";
  4192. // }
  4193. // else if (nextPlayer = "Mapillary")
  4194. // {
  4195. // nextSecondaryPlayer = "Google";
  4196. // }
  4197. // else
  4198. // {
  4199. // nextSecondaryPlayer = "Mapillary";
  4200. // }
  4201.  
  4202. // Disable buttons if NM, NMPZ
  4203.  
  4204. if(!isBattleRoyale)
  4205. {
  4206. NM = data.forbidMoving;
  4207. NP = data.forbidRotating;
  4208. NZ = data.forbidZooming;
  4209. }
  4210. else
  4211. {
  4212. // console.log(data)
  4213. if (isBullseye || isLiveChallenge)
  4214. {
  4215. NM = data.options.movementOptions.forbidMoving;
  4216. NP = data.options.movementOptions.forbidRotating;
  4217. NZ = data.options.movementOptions.forbidZooming;
  4218. }
  4219. else
  4220. {
  4221. NM = data.movementOptions.forbidMoving;
  4222. NP = data.movementOptions.forbidRotating;
  4223. NZ = data.movementOptions.forbidZooming;
  4224. }
  4225. }
  4226. if (NM || NP || NZ)
  4227. {
  4228. setDisable("NMPZ");
  4229. }
  4230. else
  4231. {
  4232. setDisable(nextPlayer);
  4233. }
  4234.  
  4235. if (nextPlayer == "Google")
  4236. {
  4237. switchCovergeButton.innerHTML = "Switch to Mapillary";
  4238. }
  4239. else
  4240. {
  4241. switchCovergeButton.innerHTML = "Switch to Google";
  4242. }
  4243. nextPlayer_save = nextPlayer;
  4244.  
  4245.  
  4246. // console.log("??")
  4247. // console.log(sessionStorage.getItem('Satellite') == "T")
  4248. // console.log(ms_sat_map)
  4249. if (ms_sat_map || (sat_choice && nextPlayer !== "Baidu" && !rtded))
  4250. {
  4251. nextPlayer = "Mapbox Satellite";
  4252. }
  4253.  
  4254. if (nextPlayer == "Mapbox Satellite")
  4255. {
  4256. let di3 = formatDist();
  4257. satelliteSwitchButton.innerHTML = `Satellite (${di3})`;
  4258. }
  4259. else
  4260. {
  4261. satelliteSwitchButton.innerHTML = "Streetview mode";
  4262. }
  4263. console.log(nextPlayer_save + "," + nextPlayer);
  4264. if (!rtded)
  4265. {
  4266. injectCanvas();
  4267. }
  4268. else
  4269. {
  4270. console.log("rated game, no canvas injection");
  4271. }
  4272. }
  4273.  
  4274.  
  4275. /**
  4276. * setID for canvas
  4277. */
  4278.  
  4279. function initializeCanvas() {
  4280. let GAME_CANVAS = "";
  4281. let DUEL_CANVAS = "";
  4282. //console.log("Is duels");
  4283. //console.log(duels);
  4284.  
  4285. if (isBattleRoyale) {
  4286. if (isDuel) {
  4287. GAME_CANVAS = document.querySelector(DUELS_CANVAS);
  4288. DUEL_CANVAS = document.querySelector(DUELS_CANVAS2);
  4289. }
  4290. else if (isBullseye) {
  4291. GAME_CANVAS = document.querySelector(BULLSEYE_CANVAS);
  4292. DUEL_CANVAS = "dummy";
  4293. }
  4294. else if (isLiveChallenge)
  4295. {
  4296. GAME_CANVAS = document.querySelector(LIVE_CANVAS);
  4297. DUEL_CANVAS = "dummy";
  4298. }
  4299. else
  4300. {
  4301. GAME_CANVAS = document.querySelector(BR_WRAPPER);
  4302. DUEL_CANVAS = "dummy";
  4303. }
  4304. }
  4305. else {
  4306. GAME_CANVAS = document.querySelector(GENERAL_LAYOUT);
  4307. DUEL_CANVAS = "dummy";
  4308. }
  4309. if (GAME_CANVAS && DUEL_CANVAS)
  4310. {
  4311. console.log("Canvas injected");
  4312. GAME_CANVAS.id = "player";
  4313.  
  4314. if (isDuel) {
  4315. DUEL_CANVAS.id = "default_player";
  4316. }
  4317. partialCreateMapillary = (typeof mapillary !== typeof undefined)
  4318. partialCreateYandex = (typeof ymaps !== typeof undefined)
  4319. partialCreateKakao = (typeof kakao !== typeof undefined)
  4320. partialCreateMS = (typeof Microsoft !== typeof undefined);
  4321. partialCreateMapbox = (typeof mapboxgl !== typeof undefined);
  4322. loadPlayers();
  4323.  
  4324.  
  4325. }
  4326. else
  4327. {
  4328. setTimeout(initializeCanvas, 250);
  4329. }
  4330.  
  4331. }
  4332.  
  4333. /**
  4334. * Hide or show players based on where the next location is
  4335. */
  4336.  
  4337. function injectCanvas() {
  4338. if (isDuel)
  4339. {
  4340. if (!rtded)
  4341. {
  4342. canvasSwitch();
  4343. }
  4344. }
  4345. else
  4346. {
  4347. Google();
  4348. Baidu();
  4349. if (BR_LOAD_KAKAO)
  4350. {
  4351. Kakao();
  4352. }
  4353. if (BR_LOAD_YANDEX)
  4354. {
  4355. Yandex();
  4356. }
  4357. if (BR_LOAD_MS)
  4358. {
  4359. // console.log("Yes")
  4360. Bing();
  4361. }
  4362. if (BR_LOAD_MP)
  4363. {
  4364. // console.log("Yes")
  4365. Mapbox();
  4366. }
  4367. if (BR_LOAD_MAPILLARY)
  4368. {
  4369. Mapillary();
  4370. }
  4371. }
  4372.  
  4373. }
  4374.  
  4375. // for duels (class ID change)
  4376.  
  4377. function canvasSwitch()
  4378. {
  4379.  
  4380. // console.log("canvas switch")
  4381. // let cond = true;
  4382. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4383. let GOOGLE_MAPS_CANVAS = document.querySelector(DUELS_CANVAS);
  4384. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  4385. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  4386. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  4387. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  4388. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  4389. let MAPBOX_MAPS_CANVAS = document.getElementById("mapbox-player");
  4390. // console.log([GOOGLE_MAPS_CANVAS, BAIDU_MAPS_CANVAS, MAPILLARY_MAPS_CANVAS, BR_LOAD_KAKAO, KAKAO_MAPS_CANVAS, BR_LOAD_MS, BING_MAPS_CANVAS, BR_LOAD_YANDEX, YANDEX_MAPS_CANVAS])
  4391.  
  4392. if (GOOGLE_MAPS_CANVAS && BAIDU_MAPS_CANVAS && (!BR_LOAD_MAPILLARY || MAPILLARY_MAPS_CANVAS) && (!BR_LOAD_KAKAO || KAKAO_MAPS_CANVAS) &&
  4393. (!BR_LOAD_MS || BING_MAPS_CANVAS) && (!BR_LOAD_YANDEX || YANDEX_MAPS_CANVAS) && (!BR_LOAD_MP || MAPBOX_MAPS_CANVAS))
  4394. {
  4395. document.getElementById("default_player").style.position = "absolute";
  4396. document.getElementById("default_player").className = "inactive";
  4397. BAIDU_MAPS_CANVAS.style.position = "absolute";
  4398. BAIDU_MAPS_CANVAS.className = "inactive";
  4399. BAIDU_MAPS_CANVAS.visibility = "hidden";
  4400.  
  4401. if (BR_LOAD_MAPILLARY)
  4402. {
  4403. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  4404. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  4405. MAPILLARY_MAPS_CANVAS.className = "inactive";
  4406. }
  4407.  
  4408. if (BR_LOAD_KAKAO)
  4409. {
  4410. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  4411. KAKAO_MAPS_CANVAS.style.position = "absolute";
  4412. KAKAO_MAPS_CANVAS.className = "inactive";
  4413. }
  4414. if (BR_LOAD_YANDEX)
  4415. {
  4416. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  4417. YANDEX_MAPS_CANVAS.style.position = "absolute";
  4418. }
  4419. if (BR_LOAD_MS)
  4420. {
  4421. BING_MAPS_CANVAS.style.visibility = "hidden";
  4422. BING_MAPS_CANVAS.style.position = "absolute";
  4423. BING_MAPS_CANVAS.className = "inactive";
  4424. }
  4425.  
  4426. if (BR_LOAD_MP)
  4427. {
  4428. MAPBOX_MAPS_CANVAS.style.visibility = "hidden";
  4429. MAPBOX_MAPS_CANVAS.style.position = "absolute";
  4430. MAPBOX_MAPS_CANVAS.classList.remove("game-panorama_panorama__rdhFg")
  4431. MAPBOX_MAPS_CANVAS.classList.add("inactive");
  4432. }
  4433.  
  4434. teleportMenu.google = false;
  4435. switchCovergeButton.useGoogle = false;
  4436.  
  4437. if (nextPlayer === "Google") {
  4438. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  4439. if (BR_LOAD_KAKAO)
  4440. {
  4441. //console.log("doing")
  4442. window.dispatchEvent(new Event('resize'));
  4443. }
  4444. document.getElementById("default_player").visibility = "";
  4445. teleportMenu.google = true;
  4446. switchCovergeButton.useGoogle = true;
  4447. console.log("Google Duel Canvas loaded");
  4448. }
  4449. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft")
  4450. {
  4451. BAIDU_MAPS_CANVAS.visibility = "";
  4452. BAIDU_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  4453. console.log("Container Duel Canvas loaded");
  4454. }
  4455. else if (nextPlayer === "Kakao")
  4456. {
  4457. if (BR_LOAD_KAKAO)
  4458. {
  4459. KAKAO_MAPS_CANVAS.style.visibility = "";
  4460. KAKAO_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  4461. }
  4462. console.log("Kakao Duel Canvas loaded");
  4463. }
  4464. else if (nextPlayer === "Yandex")
  4465. {
  4466. if (BR_LOAD_YANDEX)
  4467. {
  4468. YANDEX_MAPS_CANVAS.style.visibility = "";
  4469. }
  4470. console.log("Yandex Duel Canvas loaded");
  4471. }
  4472. else if (nextPlayer === "Mapillary")
  4473. {
  4474. if (BR_LOAD_MAPILLARY)
  4475. {
  4476. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  4477. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  4478. MapillaryPlayer.resize();
  4479. }
  4480. //
  4481. console.log("Mapillary Duel Canvas loaded");
  4482. }
  4483. else if (nextPlayer === "Bing Streetside" || nextPlayer === "Planets")
  4484. {
  4485. if (BR_LOAD_MS)
  4486. {
  4487. BING_MAPS_CANVAS.style.visibility = "";
  4488. BING_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  4489. }
  4490. console.log("MS Duel Canvas loaded");
  4491. }
  4492. else if (nextPlayer === "Mapbox Satellite")
  4493. {
  4494. if (BR_LOAD_MP)
  4495. {
  4496. MAPBOX_MAPS_CANVAS.style.visibility = "";
  4497. MAPBOX_MAPS_CANVAS.classList.remove("inactive");
  4498. MAPBOX_MAPS_CANVAS.classList.add("game-panorama_panorama__rdhFg");
  4499. MapboxPlayer.resize();
  4500. }
  4501. console.log("Mapbox Satellite Duel Canvas loaded");
  4502. }
  4503. }
  4504. else
  4505. {
  4506. setTimeout(canvasSwitch(), 1000);
  4507. }
  4508. }
  4509.  
  4510. // for Battle Royale and classic (change visibility)
  4511.  
  4512. function gCanvas()
  4513. {
  4514. let GOOGLE_MAPS_CANVAS = ""
  4515. if (isBattleRoyale) {
  4516. if (isBullseye)
  4517. {
  4518. GOOGLE_MAPS_CANVAS = document.querySelector(BULLSEYE_CANVAS2);
  4519. }
  4520. else if (isLiveChallenge)
  4521. {
  4522. GOOGLE_MAPS_CANVAS = document.querySelector(LIVE_CANVAS2);
  4523. }
  4524. else
  4525. {
  4526. GOOGLE_MAPS_CANVAS = document.querySelector(BR_CANVAS);
  4527. }
  4528. }
  4529. else {
  4530. GOOGLE_MAPS_CANVAS = document.querySelector(GENERAL_CANVAS);
  4531. }
  4532. return GOOGLE_MAPS_CANVAS;
  4533. }
  4534.  
  4535. function Google() {
  4536. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4537. let GOOGLE_MAPS_CANVAS = gCanvas();
  4538.  
  4539. if (GOOGLE_MAPS_CANVAS !== null)
  4540. {
  4541. if (nextPlayer === "Google") {
  4542. GOOGLE_MAPS_CANVAS.style.visibility = "";
  4543. teleportMenu.google = true;
  4544. switchCovergeButton.useGoogle = true;
  4545. }
  4546. else {
  4547. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  4548. teleportMenu.google = false;
  4549. }
  4550. }
  4551. else
  4552. {
  4553. setTimeout(Google, 250);
  4554. }
  4555. }
  4556.  
  4557. function Baidu() {
  4558. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  4559. let switchCovergeButton = document.getElementById("switch");
  4560. // console.log("Baidu canvas");
  4561. if (BAIDU_MAPS_CANVAS !== null)
  4562. {
  4563. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4564. BAIDU_MAPS_CANVAS.style.position = "absolute";
  4565. if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft") {
  4566. BAIDU_MAPS_CANVAS.style.visibility = "";
  4567. switchCovergeButton.useGoogle = false;
  4568. console.log("Container Canvas loaded");
  4569. }
  4570. else {
  4571. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  4572. // console.log("Container Canvas hidden");
  4573. }
  4574. }
  4575. else
  4576. {
  4577. setTimeout(Baidu, 250);
  4578. }
  4579.  
  4580. }
  4581.  
  4582. function Kakao() {
  4583. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  4584. let switchCovergeButton = document.getElementById("switch");
  4585. // console.log("Kakao canvas");
  4586. if (KAKAO_MAPS_CANVAS != null)
  4587. {
  4588. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4589. KAKAO_MAPS_CANVAS.style.position = "absolute";
  4590. if (nextPlayer === "Kakao") {
  4591. KAKAO_MAPS_CANVAS.style.visibility = "";
  4592. switchCovergeButton.useGoogle = false;
  4593. console.log("Kakao Canvas loaded");
  4594. }
  4595. else {
  4596. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  4597. // console.log("Kakao Canvas hidden");
  4598. }
  4599. }
  4600. else
  4601. {
  4602. setTimeout(Kakao, 250);
  4603. }
  4604.  
  4605. }
  4606.  
  4607. function Yandex() {
  4608. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  4609. let switchCovergeButton = document.getElementById("switch");
  4610. if (YANDEX_MAPS_CANVAS != null)
  4611. {
  4612. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4613. if (isBullseye)
  4614. {
  4615. let div = document.getElementById("player");
  4616. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__ncMwh");
  4617. div.prepend(YANDEX_MAPS_CANVAS);
  4618. }
  4619. if (isLiveChallenge)
  4620. {
  4621. let div = document.getElementById("player");
  4622. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__Qpsxl");
  4623. div.prepend(YANDEX_MAPS_CANVAS);
  4624. }
  4625. // console.log("Yandex canvas");
  4626. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  4627. // console.log("Yandex canvas");
  4628. /* console.log(YANDEX_MAPS_CANVAS); */
  4629. if (nextPlayer === "Yandex") {
  4630. YANDEX_MAPS_CANVAS.style.visibility = "";
  4631. switchCovergeButton.useGoogle = false;
  4632. console.log("Yandex Canvas loaded");
  4633. }
  4634. else {
  4635. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  4636. console.log("Yandex Canvas hidden");
  4637. }
  4638. }
  4639. else
  4640. {
  4641. setTimeout(Yandex, 250);
  4642. }
  4643.  
  4644. }
  4645.  
  4646. function Mapillary()
  4647. {
  4648. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  4649. let switchCovergeButton = document.getElementById("switch");
  4650. if (MAPILLARY_MAPS_CANVAS != null)
  4651. {
  4652. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4653. // console.log("Mapillary canvas");
  4654. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  4655. if (nextPlayer === "Mapillary") {
  4656. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  4657. switchCovergeButton.useGoogle = false;
  4658. console.log("Mapillary Canvas loaded");
  4659.  
  4660. }
  4661. else {
  4662. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  4663. // console.log("Mapillary Canvas hidden");
  4664. }
  4665. }
  4666. else
  4667. {
  4668. setTimeout(Mapillary, 250);
  4669. }
  4670.  
  4671. }
  4672.  
  4673. function Bing() {
  4674. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  4675. let switchCovergeButton = document.getElementById("switch");
  4676. // console.log("stuck")
  4677. if (BING_MAPS_CANVAS != null)
  4678. {
  4679. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4680. // console.log("Mapillary canvas");
  4681. BING_MAPS_CANVAS.style.position = "absolute";
  4682. if (nextPlayer === "Bing Streetside" || nextPlayer === "Planets") {
  4683. BING_MAPS_CANVAS.style.visibility = "";
  4684. switchCovergeButton.useGoogle = false;
  4685. console.log("Bing Canvas loaded");
  4686. }
  4687. else {
  4688. BING_MAPS_CANVAS.style.visibility = "hidden";
  4689. console.log("Bing Canvas hidden");
  4690. }
  4691. }
  4692. else
  4693. {
  4694. setTimeout(Bing, 500)
  4695. }
  4696. }
  4697.  
  4698. function Mapbox()
  4699. {
  4700. let MAPBOX_CANVAS = document.getElementById("mapbox-player");
  4701. let switchCovergeButton = document.getElementById("switch");
  4702. if (MAPBOX_CANVAS != null)
  4703. {
  4704. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4705. // console.log("Mapillary canvas");
  4706. MAPBOX_CANVAS.style.position = "absolute";
  4707. if (nextPlayer === "Mapbox Satellite") {
  4708. MAPBOX_CANVAS.style.visibility = "";
  4709. switchCovergeButton.useGoogle = false;
  4710. console.log("Mapbox Satellite Canvas loaded");
  4711.  
  4712. }
  4713. else {
  4714. MAPBOX_CANVAS.style.visibility = "hidden";
  4715. // console.log("Mapillary Canvas hidden");
  4716. }
  4717. }
  4718. else
  4719. {
  4720. setTimeout(Mapbox, 250);
  4721. }
  4722.  
  4723. }
  4724.  
  4725.  
  4726. /**
  4727. * Adjust button placement
  4728. */
  4729.  
  4730. function ZoomControls() {
  4731. let style = `
  4732. .ymaps-2-1-79-panorama-gotoymaps {display: none !important;}
  4733. .ymaps-2-1-79-panorama-control__zoom {top: 2rem !important; left: 2rem !important; z-Index: 0}
  4734. .mapillary-bearing-indicator-container {top: 2rem !important; left: 2rem !important;}
  4735. .mapillary-zoom-container {top: 6rem !important; left: 2.20rem !important;}
  4736. .NavBar_MapTypeButtonContainerWrapper {visibility: hidden !important;}
  4737. .bm_LocateMeControl {visibility: hidden !important;}
  4738. .NavBar_Container {top: -6rem !important; left: 2rem !important;}
  4739. .streetsideToolPanel {top: 4rem !important; left: 2rem !important;}
  4740. .NavBarButton_Container {visibility: hidden !important;}
  4741. .mapboxgl-ctrl-top-left {z-Index: 999}
  4742. `;
  4743.  
  4744. // let nav = document.querySelector('.NavBar_MapTypeButtonContainerWrapper');
  4745. // let locate = document.getElementById("LocateMeButton");
  4746. // let navAll = document.getElementById("MicrosoftNav");
  4747. // if (nav)
  4748. // {
  4749. // nav.style.visibility = "hidden";
  4750. // }
  4751. // if (locate)
  4752. // {
  4753. // locate.style.visibility = "hidden";
  4754. // }
  4755. // if (navAll)
  4756. // {
  4757. // navAll.style.top = "15em"
  4758. // }
  4759.  
  4760. let style_element = document.createElement("style");
  4761. style_element.innerHTML = style;
  4762. document.body.appendChild(style_element);
  4763. // document.getElementById("mapillary-bearing-indicator-container").style.top = "20em"
  4764. }
  4765.  
  4766. /**
  4767. * Updates the compass to match Yandex Panorama facing
  4768. */
  4769. function updateCompass() {
  4770. if (!COMPASS) {
  4771. let compass = document.querySelector("img.compass__indicator");
  4772. if (compass != null) {
  4773. COMPASS = compass;
  4774. let direction = YandexPlayer.getDirection()[0] * -1;
  4775. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  4776. }
  4777. }
  4778. else {
  4779. let direction = YandexPlayer.getDirection()[0] * -1;
  4780. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  4781. }
  4782. }
  4783.  
  4784. /**
  4785. * Open next location in streetview player given next player and next coordinate
  4786. */
  4787.  
  4788. function wiki(cc, iframe, teleportMenu)
  4789. {
  4790. let url = `https://${cc}.wikipedia.org/w/api.php`;
  4791. let widthRight = 325;
  4792. // console.log(cc);
  4793. // if (cc == "fr")
  4794. // {
  4795. // widthRight = 1200;
  4796. // }
  4797.  
  4798. let params = {
  4799. action: "query",
  4800. list: "geosearch",
  4801. gscoord: `${global_lat}|${global_lng}`,
  4802. gsradius: "10000",
  4803. gslimit: "1",
  4804. format: "json"
  4805. };
  4806.  
  4807. url = url + "?origin=*";
  4808. Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
  4809. let GOOGLE_MAPS_CANVAS = gCanvas();
  4810.  
  4811. fetch(url)
  4812. .then(function(response){return response.json();})
  4813. .then(function(response) {
  4814. // console.log(response)
  4815. var pages = response.query.geosearch;
  4816. if (pages.length !== 0)
  4817. {
  4818. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  4819. let pageId = pages[0].pageid;
  4820. iframe.src = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  4821. wikiUrl = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  4822. iframe.style.visibility = "";
  4823. iframe.style.right = `-${widthRight}px`;
  4824. iframe.style.width = (window.innerWidth + widthRight) + 'px';
  4825.  
  4826. // console.log(iframe.style.width);
  4827. // iframe.style.visibility = "";
  4828. }
  4829. else
  4830. {
  4831. GOOGLE_MAPS_CANVAS.style.visibility = "";
  4832. teleportMenu.google = true;
  4833. iframe.style.right = '0px';
  4834. iframe.style.width = window.innerWidth + 'px';
  4835. }
  4836. }).catch(function(error){console.log(error);});
  4837. }
  4838.  
  4839.  
  4840.  
  4841. function goToLocation(cond) {
  4842. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4843. console.log("Going to location");
  4844. console.log(nextPlayer);
  4845.  
  4846. if (nextPlayer !== "Planets" && (OverlayBtn.current.includes("Mars") || OverlayBtn.current.includes("Moon")))
  4847. {
  4848. document.getElementById("Earth").click();
  4849. }
  4850.  
  4851. if (nextPlayer === "Yandex") {
  4852. let options = {};
  4853. YandexPlayer.moveTo([global_lat, global_lng], options);
  4854. YandexPlayer.setDirection([0, 16]);
  4855. YandexPlayer.setSpan([10, 67]);
  4856. }
  4857. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft") {
  4858. if (document.getElementById("i_container") !== null)
  4859. {
  4860. let iframe = document.getElementById("i_container");
  4861.  
  4862. if (nextPlayer === "Baidu")
  4863. {
  4864. if (!isFirefox)
  4865. {
  4866. iframe.style.top = '-60px';
  4867. iframe.style.height = (window.innerHeight + 200) + 'px';
  4868. }
  4869. else
  4870. {
  4871. iframe.style.top = '-60px';
  4872. iframe.style.height = (window.innerHeight + 219) + 'px';
  4873. }
  4874.  
  4875. if (!isFirefox)
  4876. {
  4877. iframe.style.right = '-55px';
  4878. iframe.style.width = (window.innerWidth + 55) + 'px';
  4879. }
  4880. else
  4881. {
  4882. iframe.style.right = '-15px';
  4883. iframe.style.width = (window.innerWidth + 15) + 'px';
  4884. }
  4885. let urlStr2 = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  4886. 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;
  4887. // console.log(urlStr)
  4888. if (global_BDAh != null)
  4889. {
  4890. iframe.src = urlStr;
  4891. }
  4892. else
  4893. {
  4894. iframe.src = urlStr2;
  4895. }
  4896. iframe.style.visibility = "";
  4897. }
  4898. else if (nextPlayer === "Youtube")
  4899. {
  4900. document.getElementById("Youtube Button").style.visibility = "";
  4901. document.getElementById("Youtube Button").innerHTML = "Play video";
  4902. iframe.allow = "autoplay";
  4903. iframe.style.visibility = "hidden";
  4904. iframe.style.top = '-60px';
  4905. iframe.style.height = (window.innerHeight + 235) + 'px';
  4906. iframe.style.right = '0px';
  4907. iframe.style.width = window.innerWidth + 'px';
  4908. mainMenuBtn.innerHTML = "<font size=2>Unity<br><font size=1>v6.1.0</font>";
  4909. mainMenuBtn.style.width = "3em"
  4910. mainMenuBtn.style.backgroundPosition = "";
  4911. mainMenuBtn.backgroundColor = ""
  4912. }
  4913. else if (nextPlayer === "Image")
  4914. {
  4915. iframe.style.top = '0px';
  4916. iframe.style.height = (window.innerHeight) + 'px';
  4917. iframe.style.right = '0px';
  4918. iframe.style.width = window.innerWidth + 'px';
  4919. iframe.style.visibility = "";
  4920. iframe.src = iId;
  4921. }
  4922. else if (nextPlayer === "Wikipedia")
  4923. {
  4924. switchCovergeButton.style.visibility = "";
  4925. switchCovergeButton.disabled = false;
  4926. let wikiLocalLang = document.getElementById("local language")
  4927. wikiLocalLang.style.visibility = "";
  4928. switchCovergeButton.style.backgroundColor = "#ba55d3";
  4929. iframe.style.top = '0px';
  4930. iframe.style.height = (window.innerHeight) + 'px';
  4931. let fi = "en";
  4932. if (!wikiLocalLang.state && global_cc)
  4933. {
  4934. let cc = langDict[global_cc];
  4935. if (typeof cc !== typeof undefined)
  4936. {
  4937. fi = cc[Math.floor(Math.random() * cc.length)];
  4938. }
  4939. }
  4940. wiki(fi, iframe, teleportMenu);
  4941. }
  4942. else if (nextPlayer === "Minecraft")
  4943. {
  4944. iframe.style.top = '0px';
  4945. iframe.style.height = (window.innerHeight) + 'px';
  4946. iframe.style.right = '0px';
  4947. iframe.style.width = window.innerWidth + 'px';
  4948. iframe.style.visibility = "";
  4949. iframe.src = "https://classic.minecraft.net/?size=huge";
  4950. }
  4951. }
  4952.  
  4953. else
  4954. {
  4955. setTimeout(goToLocation(true), 250);
  4956. }
  4957. // let a = new BMap.Point(global_lng, global_lat);
  4958. // BaiduPlayer.setPov({ heading: -40, pitch: 6 });
  4959. // BaiduPlayer.setPosition(a);
  4960. }
  4961. else if (nextPlayer === "Kakao") {
  4962. var roadviewClient = new kakao.maps.RoadviewClient();
  4963. var position = new kakao.maps.LatLng(global_lat, global_lng);
  4964. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  4965. KakaoPlayer.setPanoId(panoId, position);
  4966. KakaoPlayer.setViewpoint({ pan: global_heading, tilt: global_pitch, zoom: -3 })
  4967. });
  4968. }
  4969. else if (nextPlayer === "Mapillary") {
  4970. MapillaryPlayer.resize()
  4971. MapillaryPlayer.moveTo(mmKey).then(
  4972. image => { //console.log(image);
  4973. },
  4974. error => { console.log(error); });
  4975. }
  4976. else if (nextPlayer === "Google" && !rtded) {
  4977. if (!bullseyeMapillary)
  4978. {
  4979. handleMapillary({lat: global_lat, lng: global_lng}, {meters: 500, limit: 500});
  4980. }
  4981. }
  4982. else if (nextPlayer === "Bing Streetside") {
  4983. let mTId = MSStreetPlayer.getMapTypeId();
  4984. if (mTId !== Microsoft.Maps.MapTypeId.streetside && mTId !== Microsoft.Maps.MapTypeId.road)
  4985. {
  4986. console.log("Reset Bing map type to Streetside")
  4987. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  4988. }
  4989. MSStreetPlayer.setOptions({disableStreetside: false});
  4990. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.streetside,
  4991. zoom: 18,
  4992. streetsideOptions: {
  4993. overviewMapMode: Microsoft.Maps.OverviewMapMode.hidden,
  4994. showCurrentAddress: false,
  4995. showProblemReporting: false,
  4996. showExitButton: false,
  4997. },
  4998. center: new Microsoft.Maps.Location(global_lat, global_lng),
  4999. heading: 90,
  5000. pitch: -30});
  5001. }
  5002. else if (nextPlayer === "Planets") {
  5003. // console.log("Bing Satellite Player")
  5004.  
  5005.  
  5006. let mTId = MSStreetPlayer.getMapTypeId();
  5007. if (mTId !== Microsoft.Maps.MapTypeId.aerial && mTId !== Microsoft.Maps.MapTypeId.road)
  5008. {
  5009. console.log("Reset Bing map type to Satellite")
  5010. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  5011. }
  5012. // MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  5013. let ctr = new Microsoft.Maps.Location(global_lat, global_lng)
  5014. let loc_centre = {lat: global_lat, lng: global_lng};
  5015. for (var i = MSStreetPlayer.entities.getLength() - 1; i >= 0; i--) {
  5016. var pushpin = MSStreetPlayer.entities.get(i);
  5017. if (pushpin instanceof Microsoft.Maps.Pushpin) {
  5018. MSStreetPlayer.entities.removeAt(i);
  5019. }
  5020. }
  5021. // console.log("Satellite radius: " + (ms_radius / 1000).toString() + "km");
  5022.  
  5023. let maxZoomNum = 6;
  5024. if (planetType == "Mars")
  5025. {
  5026. maxZoomNum = 5;
  5027. }
  5028.  
  5029. if (ms_radius < 1000000)
  5030. {
  5031. ms_radius = 1000000;
  5032. }
  5033.  
  5034. if (ms_radius > 6000000)
  5035. {
  5036. ms_radius = 6000000;
  5037. }
  5038.  
  5039. // console.log(ms_radius);
  5040.  
  5041. let latlngBounds = getBBox2(loc_centre, ms_radius);
  5042. // console.log(latlngBounds)
  5043. let bounds = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(latlngBounds[0], latlngBounds[1]), new Microsoft.Maps.Location(latlngBounds[2], latlngBounds[3]));
  5044.  
  5045. MSStreetPlayer.setOptions({maxBounds: bounds, maxZoom: maxZoomNum})
  5046.  
  5047. MSStreetPlayer.setOptions({disableStreetside: true});
  5048. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.mercator,
  5049. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  5050. center: ctr,
  5051. zoom: 1,
  5052. })
  5053. var weatherTileSource = new Microsoft.Maps.TileSource({
  5054. uriConstructor: getTMSTilePath
  5055. });
  5056. var weatherTileLayer = new Microsoft.Maps.TileLayer({
  5057. mercator: weatherTileSource,
  5058. });
  5059. if (planetType == "Moon")
  5060. {
  5061. document.getElementById("Moon (Labels)").click();
  5062. }
  5063. else if (planetType == "Mars")
  5064. {
  5065. document.getElementById("Mars (Labels)").click();
  5066. }
  5067. MSStreetPlayer.layers.insert(weatherTileLayer);
  5068.  
  5069. var pin = new Microsoft.Maps.Pushpin(ctr, {});
  5070. MSStreetPlayer.entities.push(pin);
  5071.  
  5072. // FixLink(); // DOM BASED SOLUTION
  5073. }
  5074. else if (nextPlayer === "Mapbox Satellite") {
  5075. // MapboxPlayer.resize();
  5076. let satelliteStyleBtn = document.getElementById("Satellite Style Button");
  5077. let satelliteTypeBtn = document.getElementById("Satellite Type Button");
  5078. function waitSky()
  5079. {
  5080. try
  5081. {
  5082. let l = [];
  5083. for (let element of MapboxPlayer.getStyle().layers)
  5084. {
  5085. l.push(element.id);
  5086. }
  5087. if (l.includes('sky'))
  5088. {
  5089. styleMapboxAll(satelliteTypeBtn.currentId, satelliteTypeBtn.currentDim, satelliteStyleBtn.current, satelliteTypeBtn.currentId, satelliteTypeBtn.currentDim, satelliteStyleBtn.current, true);
  5090. }
  5091. else
  5092. {
  5093. setTimeout(waitSky, 250);
  5094. }
  5095. }
  5096. catch(error)
  5097. {
  5098. console.log(error)
  5099. setTimeout(waitSky, 250);
  5100. }
  5101. }
  5102. waitSky();
  5103. }
  5104. if (nextPlayer === "Google" && fire1)
  5105. {
  5106. window.dispatchEvent(new Event('resize'));
  5107. if (rtded)
  5108. {
  5109. document.getElementById("Clear").click();
  5110. }
  5111. fire1 = false;
  5112. }
  5113.  
  5114. if (cond)
  5115. {
  5116. switchCovergeButton.lat = global_lat;
  5117. switchCovergeButton.lng = global_lng;
  5118. }
  5119.  
  5120. }
  5121.  
  5122.  
  5123. /**
  5124. * Handle undo using the location history of the current round
  5125. */
  5126.  
  5127. function goToUndoMove(data) {
  5128. /* console.log(global_lat);
  5129. console.log(global_lng); */
  5130. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  5131. let options = {};
  5132. let prevStep = null;
  5133. if (locHistory.length === 1) {
  5134. prevStep = locHistory[0];
  5135. }
  5136. else {
  5137. prevStep = locHistory.pop();
  5138. }
  5139. // console.log(prevStep);
  5140. // console.log(locHistory)
  5141. if (nextPlayer === "Yandex") {
  5142. defaultPanoIdChange = false;
  5143. YandexPlayer.moveTo([prevStep[0], prevStep[1]], options);
  5144. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  5145. YandexPlayer.setSpan([10, 67]);
  5146. switchCovergeButton.lat = prevStep[0];
  5147. switchCovergeButton.lng = prevStep[1];
  5148. }
  5149. else if (nextPlayer === "Kakao") {
  5150. let btn = document.querySelector("button[data-qa='undo-move']");
  5151. btn.disabled = false;
  5152. btn.classList.remove('styles_disabled__2YdHD');
  5153. defaultPanoIdChange = false;
  5154. let position = new kakao.maps.LatLng(prevStep[0], prevStep[1]);
  5155. KakaoPlayer.setPanoId(prevStep[2], position);
  5156. switchCovergeButton.lat = prevStep[0];
  5157. switchCovergeButton.lng = prevStep[1];
  5158. switchCovergeButton.useGoogle = false;
  5159. teleportMenu.google = false;
  5160. // console.log("Undo 1 step");
  5161. // console.log(locHistory);
  5162. }
  5163. else if (nextPlayer === "Mapillary" ) {
  5164. // console.log(prevStep[1]);
  5165.  
  5166. MapillaryPlayer.moveTo(prevStep[2]).then(
  5167. image => {
  5168. //console.log(image);
  5169. switchCovergeButton.lat = prevStep[1];
  5170. switchCovergeButton.lng = prevStep[0];
  5171. },
  5172. error => { console.log(error); });
  5173. }
  5174. else if (nextPlayer === "Bing Streetside") {
  5175. defaultPanoIdChange = false;
  5176. // console.log(locHistory);
  5177. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(prevStep[0], prevStep[1]),});
  5178. switchCovergeButton.lat = prevStep[0];
  5179. switchCovergeButton.lng = prevStep[1];
  5180. switchCovergeButton.heading = prevStep[2];
  5181. }
  5182.  
  5183. }
  5184.  
  5185. function handleTeleport()
  5186. {
  5187. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  5188. if (teleportMenu)
  5189. {
  5190. function tpt(direction)
  5191. {
  5192. if (!teleportMenu.google)
  5193. {
  5194. // console.log("non-Google Teleport");
  5195. function forwardReverse(heading)
  5196. {
  5197. if (direction)
  5198. {
  5199. return heading;
  5200. }
  5201. else
  5202. {
  5203. return (heading + 180) % 360;
  5204. }
  5205. }
  5206.  
  5207. let prevStep = null;
  5208. if (locHistory.length === 1) {
  5209. prevStep = locHistory[0];
  5210. }
  5211. else {
  5212. prevStep = locHistory[locHistory.length - 1];
  5213. }
  5214. // console.log(locHistory);
  5215.  
  5216. let options = {};
  5217. let place, position, pID;
  5218. if (nextPlayer === "Yandex") {
  5219.  
  5220. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  5221. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  5222. YandexPlayer.moveTo([place.lat, place.lng], options);
  5223. YandexPlayer.setSpan([10, 67]);
  5224. switchCovergeButton.lat = place.lat;
  5225. switchCovergeButton.lng = place.lng;
  5226. }
  5227. else if (nextPlayer === "Kakao") {
  5228. var roadviewClient = new kakao.maps.RoadviewClient();
  5229. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[3])), teleportMenu.distance * 0.001);
  5230. position = new kakao.maps.LatLng(place.lat, place.lng);
  5231. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  5232. KakaoPlayer.setPanoId(panoId, position);
  5233. });
  5234. switchCovergeButton.lat = place.lat;
  5235. switchCovergeButton.lng = place.lng;
  5236. }
  5237. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  5238. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  5239. handleMapillary(place, {meters: 500, limit: 500});
  5240. switchCovergeButton.lat = place.lat;
  5241. switchCovergeButton.lng = place.lng;
  5242. // locHistory.push([place.lat, place.lng, prevStep[2], prevStep[3]]);
  5243. }
  5244. else if (nextPlayer === "Bing Streetside") {
  5245. // console.log("teleport")
  5246. // console.log(prevStep);
  5247. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  5248. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(place.lat, place.lng), 1, 1);
  5249. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  5250. function onSuccess(panoramaInfo) {
  5251. // console.log("Coverage")
  5252. // console.log([panoramaInfo.la, panoramaInfo.lo])
  5253. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  5254. });
  5255. }
  5256. function onMissingCoverage() {
  5257. console.log("No Coverage")
  5258. }
  5259. }
  5260.  
  5261. if (teleportMenu.distance > 150)
  5262. {
  5263. teleportMenu.distance = 100;
  5264. teleportBtn.innerHTML = "Teleport " + teleportMenu.distance + " m";
  5265. }
  5266. }
  5267. }
  5268. teleportBtn.addEventListener("click", () => {
  5269. tpt(true);
  5270.  
  5271. });
  5272. teleportReverse.addEventListener("click", () => {
  5273. tpt(false);
  5274.  
  5275. });
  5276. }
  5277. }
  5278.  
  5279. function SyncListener()
  5280. {
  5281. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  5282. switchCovergeButton.addEventListener("click", () => {
  5283. if (switchCovergeButton.useGoogle == false) {
  5284. // switchCovergeButton.useGoogle = true;
  5285. console.log(nextPlayer)
  5286. if (nextPlayer === "Yandex") {
  5287. let options = {};
  5288. YandexPlayer.moveTo([switchCovergeButton.lat, switchCovergeButton.lng], options);
  5289. YandexPlayer.setDirection([switchCovergeButton.heading, 0]);
  5290.  
  5291. // nextPlayer = "Yandex";
  5292. }
  5293. else if (nextPlayer === "Kakao") {
  5294. let roadviewClient = new kakao.maps.RoadviewClient();
  5295. // console.log(switchCovergeButton.lat);
  5296. let position = new kakao.maps.LatLng(switchCovergeButton.lat, switchCovergeButton.lng);
  5297. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  5298. KakaoPlayer.setPanoId(panoId, position);
  5299. });
  5300. KakaoPlayer.setViewpoint({
  5301. pan: switchCovergeButton.heading,
  5302. tilt: 0,
  5303. zoom: -3
  5304. });
  5305. // nextPlayer = "Kakao";
  5306. }
  5307. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  5308. // nextPlayer = "Kakao";
  5309. handleMapillary({lat: switchCovergeButton.lat, lng: switchCovergeButton.lng}, {meters: 100, limit: 100});
  5310. }
  5311. else if (nextPlayer === "Bing Streetside") {
  5312. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(switchCovergeButton.lat, switchCovergeButton.lng), 0.01, 0.01);
  5313. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  5314. function onSuccess(panoramaInfo) {
  5315. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  5316. heading: switchCovergeButton.heading
  5317. });
  5318. }
  5319. function onMissingCoverage() {
  5320. console.log("No Coverage")
  5321. }
  5322. }
  5323. }
  5324. });
  5325.  
  5326. }
  5327.  
  5328. /**
  5329. * Gets the seed data for the current game
  5330. *
  5331. * @returns Promise with seed data as object
  5332. */
  5333. function getSeed() {
  5334. console.log("get seed");
  5335. // myHighlight("Get Seed");
  5336. return new Promise((resolve, reject) => {
  5337. let token = getToken();
  5338. let URL;
  5339. let cred = ""
  5340.  
  5341. const PATHNAME = window.location.pathname;
  5342.  
  5343. if (PATHNAME.startsWith("/game/")) {
  5344. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  5345. }
  5346. else if (PATHNAME.startsWith("/challenge/")) {
  5347. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  5348. }
  5349. else if (PATHNAME.startsWith("/battle-royale/")) {
  5350. URL = `https://game-server.geoguessr.com/api/battle-royale/${token}`;
  5351. }
  5352. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  5353. URL = `https://game-server.geoguessr.com/api/duels/${token}`;
  5354. }
  5355. else if (PATHNAME.startsWith("/bullseye/")) {
  5356. URL = `https://game-server.geoguessr.com/api/bullseye/${token}`;
  5357. }
  5358. else if (PATHNAME.startsWith("/live-challenge/")) {
  5359. URL = `https://game-server.geoguessr.com/api/live-challenge/${token}`;
  5360. }
  5361. if (isBattleRoyale) {
  5362. fetch(URL, {
  5363. // Include credentials to GET from the endpoint
  5364. credentials: 'include'
  5365. })
  5366. .then((response) => response.json())
  5367. .then((data) => {
  5368. resolve(data);
  5369. })
  5370. .catch((error) => {
  5371. reject(error);
  5372. });
  5373. }
  5374. else {
  5375. fetch(URL)
  5376. .then((response) => response.json())
  5377. .then((data) => {
  5378. resolve(data);
  5379. })
  5380. .catch((error) => {
  5381. reject(error);
  5382. });
  5383. }
  5384. });
  5385. }
  5386.  
  5387. /**
  5388. * Gets the token from the current URL
  5389. *
  5390. * @returns token
  5391. */
  5392. function getToken() {
  5393. const PATHNAME = window.location.pathname;
  5394. if (PATHNAME.startsWith("/game/")) {
  5395. return PATHNAME.replace("/game/", "");
  5396. }
  5397. else if (PATHNAME.startsWith("/challenge/")) {
  5398. return PATHNAME.replace("/challenge/", "");
  5399. }
  5400. else if (PATHNAME.startsWith("/battle-royale/")) {
  5401. return PATHNAME.replace("/battle-royale/", "");
  5402. }
  5403. else if (PATHNAME.startsWith("/duels/")) {
  5404. return PATHNAME.replace("/duels/", "");
  5405. }
  5406. else if (PATHNAME.startsWith("/team-duels/")) {
  5407. return PATHNAME.replace("/team-duels/", "");
  5408. }
  5409. else if (PATHNAME.startsWith("/bullseye/")) {
  5410. return PATHNAME.replace("/bullseye/", "");
  5411. }
  5412. else if (PATHNAME.startsWith("/live-challenge/")) {
  5413. return PATHNAME.replace("/live-challenge/", "");
  5414. }
  5415. }
  5416.  
  5417. /**
  5418. * Gets the round number from the ongoing game from the page itself
  5419. *
  5420. * @returns Round number
  5421. */
  5422. function getRoundFromPage() {
  5423. const roundData = document.querySelector("div[data-qa='round-number']");
  5424. if (roundData) {
  5425. let roundElement = roundData.querySelector("div:last-child");
  5426. if (roundElement) {
  5427. let round = parseInt(roundElement.innerText.charAt(0));
  5428. if (!isNaN(round) && round >= 1 && round <= 5) {
  5429. return round;
  5430. }
  5431. }
  5432. }
  5433. else {
  5434. return ROUND;
  5435. }
  5436. }
  5437.  
  5438.  
  5439. /**
  5440. * Injects Yandex Script
  5441. */
  5442. function injectYandexScript() {
  5443. return new Promise((resolve, reject) => {
  5444. if (!YANDEX_INJECTED) {
  5445. if (YANDEX_API_KEY === "") {
  5446. console.log("No Yandex Key")
  5447. reject();
  5448. }
  5449. else {
  5450. if (!partialCreateYandex)
  5451. {
  5452. const SCRIPT = document.createElement("script");
  5453. SCRIPT.type = "text/javascript";
  5454. SCRIPT.async = true;
  5455. SCRIPT.src = `https://api-maps.yandex.ru/2.1/?lang=en_US&apikey=${YANDEX_API_KEY}`;
  5456. document.body.appendChild(SCRIPT);
  5457. SCRIPT.onload = () => {
  5458. ymaps.ready(() => {
  5459. YANDEX_INJECTED = true;
  5460. myHighlight("Yandex API Loaded");
  5461. resolve();
  5462. });
  5463. }
  5464. }
  5465. else
  5466. {
  5467. YANDEX_INJECTED = true;
  5468. resolve();
  5469. }
  5470. }
  5471. }
  5472. else {
  5473. resolve();
  5474. }
  5475. });
  5476. }
  5477.  
  5478. /**
  5479. * Injects Yandex Player and calls handleReturnToStart
  5480. */
  5481. function injectYandexPlayer() {
  5482. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  5483. let lat = 41.321861;
  5484. let lng = 69.212920;
  5485.  
  5486. let options = {
  5487. "direction": [0, 16],
  5488. "span": [10, 67],
  5489. "controls": ["zoomControl"]
  5490. };
  5491. ymaps.panorama.createPlayer("player", [lat, lng], options)
  5492. .done((player) => {
  5493. YandexPlayer = player;
  5494. YandexPlayer.events.add("directionchange", (e) => {
  5495. updateCompass();
  5496. let pov = YandexPlayer.getDirection();
  5497. if (locHistory.length > 0 && nextPlayer == "Yandex") {
  5498. switchCovergeButton.heading = pov[0];
  5499. locHistory[locHistory.length - 1][2] = pov[0];
  5500. locHistory[locHistory.length - 1][3] = pov[1];
  5501. }
  5502. });
  5503. YandexPlayer.events.add("panoramachange", (e) => {
  5504. if (defaultPanoIdChange) {
  5505. let num = YandexPlayer.getPanorama().getPosition();
  5506. let pov = YandexPlayer.getDirection();
  5507. // console.log(num);
  5508. // console.log(pov);
  5509. if (nextPlayer == "Yandex")
  5510. {
  5511. locHistory.push([num[0], num[1], pov[0], pov[1]]);
  5512. switchCovergeButton.lat = num[0];
  5513. switchCovergeButton.lng = num[1];
  5514. }
  5515. let btn = document.querySelector("button[data-qa='undo-move']");
  5516. if (locHistory.length > 1) {
  5517. btn.disabled = false;
  5518. btn.classList.remove('styles_disabled__2YdHD');
  5519. }
  5520. // console.log(locHistory);
  5521. }
  5522. defaultPanoIdChange = true;
  5523.  
  5524. });
  5525. console.log("Yandex Player injected");
  5526. });
  5527.  
  5528. }
  5529.  
  5530.  
  5531. /**
  5532. * Injects Baidu script
  5533. */
  5534.  
  5535. function reportWindowSize() {
  5536. // console.log("report window size");
  5537. let iframeC = document.getElementById("i_container");
  5538. if (iframeC)
  5539. {
  5540. if (nextPlayer == "Baidu")
  5541. {
  5542. iframeC.style.top = '-60px';
  5543. iframeC.style.height = (window.innerHeight + 200) + 'px';
  5544. // TODO
  5545. iframeC.style.right = '-55px';
  5546. iframeC.style.width = (window.innerWidth + 55) + 'px';
  5547. }
  5548. else if (nextPlayer == "Youtube")
  5549. {
  5550. iframeC.style.top = '-60px';
  5551. iframeC.style.height = (window.innerHeight + 235) + 'px';
  5552. iframeC.style.right = '0px';
  5553. iframeC.style.width = (window.innerWidth) + 'px';
  5554. }
  5555. else if (nextPlayer == "Image" || nextPlayer === "Minecraft")
  5556. {
  5557. iframeC.style.top = '0px';
  5558. iframeC.style.height = (window.innerHeight) + 'px';
  5559. iframeC.style.right = '0px';
  5560. iframeC.style.width = (window.innerWidth) + 'px';
  5561. }
  5562. else if (nextPlayer === "Wikipedia")
  5563. {
  5564. iframeC.style.top = '0px';
  5565. iframeC.style.height = (window.innerHeight) + 'px';
  5566. iframeC.style.right = '-325px';
  5567. iframeC.style.width = (window.innerWidth + 325) + 'px';
  5568. }
  5569.  
  5570. }
  5571. }
  5572.  
  5573. window.onresize = reportWindowSize;
  5574.  
  5575.  
  5576.  
  5577. function injectContainer() {
  5578. myHighlight("iframe container loaded")
  5579. const iframe = document.createElement('iframe');
  5580. iframe.frameBorder = 0;
  5581. iframe.style.position = "absolute";
  5582. iframe.id = "i_container";
  5583. if (isBattleRoyale) {
  5584. if (isDuel)
  5585. {
  5586. iframe.className = "inactive";
  5587. }
  5588. else if (isBullseye)
  5589. {
  5590. iframe.className = "game-panorama_panorama__ncMwh";
  5591. }
  5592. else if (isLiveChallenge)
  5593. {
  5594. iframe.className = "game-panorama_panorama__Qpsxl";
  5595. }
  5596. else
  5597. {
  5598. iframe.className = "br-game-layout__panorama";
  5599. }
  5600. }
  5601. else {
  5602. iframe.className = "game-layout__panorama";
  5603. }
  5604. var div = document.getElementById("player");
  5605. if (div)
  5606. {
  5607. div.style.overflow = "hidden";
  5608. if (isBullseye || isLiveChallenge)
  5609. {
  5610. div.prepend(iframe);
  5611. }
  5612. else
  5613. {
  5614. div.appendChild(iframe);
  5615. }
  5616. }
  5617.  
  5618. }
  5619.  
  5620. /**
  5621. * Injects Kakao script
  5622. */
  5623.  
  5624. function injectKakaoScript() {
  5625. return new Promise((resolve, reject) => {
  5626. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  5627. if (!KAKAO_INJECTED) {
  5628. if (KAKAO_API_KEY === "") {
  5629. console.log("No Kakao Key")
  5630. }
  5631. else {
  5632.  
  5633. let canvas = document.createElement("kmap");
  5634. if (isBattleRoyale) {
  5635. if (isDuel)
  5636. {
  5637. canvas.innerHTML = `
  5638. <div id="roadview" class="inactive" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  5639. `;
  5640. }
  5641. else if (isBullseye)
  5642. {
  5643. canvas.innerHTML = `
  5644. <div id="roadview" class="game-panorama_panorama__ncMwh" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  5645. `;
  5646. }
  5647. else if (isLiveChallenge)
  5648. {
  5649. canvas.innerHTML = `
  5650. <div id="roadview" class="game-panorama_panorama__Qpsxl" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  5651. `;
  5652. }
  5653. else
  5654. {
  5655. canvas.innerHTML = `
  5656. <div id="roadview" class="br-game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  5657. `;
  5658. }
  5659. }
  5660. else {
  5661. canvas.innerHTML = `
  5662. <div id="roadview" class="game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  5663. `;
  5664. }
  5665.  
  5666.  
  5667. var div = document.getElementById("player");
  5668. if (isBullseye || isLiveChallenge)
  5669. {
  5670. div.prepend(canvas);
  5671. }
  5672. else
  5673. {
  5674. div.appendChild(canvas);
  5675. }
  5676.  
  5677. let SCRIPT;
  5678. if (!partialCreateKakao)
  5679. {
  5680. SCRIPT = document.createElement("script");
  5681. SCRIPT.async = true;
  5682. // SCRIPT.type = "text/javascript";
  5683. SCRIPT.src = `//dapi.kakao.com/v2/maps/sdk.js?appkey=${KAKAO_API_KEY}&autoload=false`;
  5684. document.body.appendChild(SCRIPT);
  5685. }
  5686.  
  5687. function drawmapKakao()
  5688. {
  5689. kakao.maps.load(function () {
  5690. var position = new kakao.maps.LatLng(33.450701, 126.560667);
  5691. let roadviewContainer = document.getElementById('roadview');
  5692. KakaoPlayer = new kakao.maps.Roadview(roadviewContainer);
  5693. var panoId = 1023434522;
  5694. KakaoPlayer.setPanoId(panoId, position);
  5695. KAKAO_INJECTED = true;
  5696. // Remove the compass from Kakao
  5697. kakao.maps.event.addListener(KakaoPlayer, 'init', () => {
  5698. const compassContainer = roadviewContainer.querySelector('div[id*="_box_util_"]');
  5699. if (compassContainer) compassContainer.style.display = 'none';
  5700. });
  5701. kakao.maps.event.addListener(KakaoPlayer, 'panoid_changed', function() {
  5702. if (defaultPanoIdChange && KakaoPlayer) {
  5703. let latlng = KakaoPlayer.getPosition();
  5704. let lat = latlng.getLat();
  5705. let lng = latlng.getLng();
  5706. let pID = KakaoPlayer.getViewpointWithPanoId();
  5707. if (nextPlayer == "Kakao" && lat != 33.45047613915499)
  5708. {
  5709. // console.log("push");
  5710. locHistory.push([lat, lng, pID.panoId, pID.pan]);
  5711. switchCovergeButton.lat = lat;
  5712. switchCovergeButton.lng = lng;
  5713. switchCovergeButton.heading = pID.pan;
  5714. }
  5715. let btn = document.querySelector("button[data-qa='undo-move']");
  5716. if (locHistory.length > 1 && (btn != null)) {
  5717. btn.disabled = false;
  5718. btn.classList.remove('styles_disabled__2YdHD');
  5719. }
  5720. // console.log(locHistory);
  5721. }
  5722. defaultPanoIdChange = true;
  5723. });
  5724. kakao.maps.event.addListener(KakaoPlayer, 'viewpoint_changed', function() {
  5725. // console.log("pov_listener attached");
  5726. let pID = KakaoPlayer.getViewpointWithPanoId();
  5727. if (locHistory.length > 0 && nextPlayer == "Kakao") {
  5728. switchCovergeButton.heading = pID.pan;
  5729. locHistory[locHistory.length - 1][3] = pID.pan;
  5730. }
  5731. if (GooglePlayer) {
  5732. const { heading, pitch } = GooglePlayer.getPov()
  5733. if ((!almostEqual(pID.pan, heading) || !almostEqual(pID.tilt, pitch)) && nextPlayer == "Kakao") {
  5734. // Updating the google street view POV will update the compass
  5735. GooglePlayer.setPov({ heading: pID.pan, pitch: pID.tilt })
  5736. }
  5737. }
  5738. // console.log(locHistory);
  5739. })
  5740. });
  5741. }
  5742.  
  5743. if (partialCreateKakao)
  5744. {
  5745. drawmapKakao();
  5746. }
  5747. else
  5748. {
  5749. SCRIPT.onload = () => {
  5750. drawmapKakao();
  5751. myHighlight("Kakao API Loaded");
  5752. resolve();
  5753. };
  5754. }
  5755.  
  5756. }
  5757. }
  5758. else {
  5759. resolve();
  5760. }
  5761. });
  5762. }
  5763.  
  5764. function getTMSTilePath(tile) {
  5765. var yN = Math.pow(2, tile.zoom) - tile.y - 1;
  5766. // console.log([tile.zoom,tile.x,yN]);
  5767. if (planetType == "Moon")
  5768. {
  5769. // document.getElementById("Moon (Labels)").click();
  5770. return "https://s3.amazonaws.com/opmbuilder/301_moon/tiles/w/hillshaded-albedo/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  5771. }
  5772. else if (planetType == "Mars")
  5773. {
  5774. // document.getElementById("Mars (Labels)").click();
  5775. return "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  5776. }
  5777. // else if (planetType == "GTAV")
  5778. // {
  5779. // return "https://tiles.mapgenie.io/games/gta5/los-santos/satellite/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  5780. // // https://tiles.mapgenie.io/games/gta5/los-santos/road/4/2/5.png
  5781. // }
  5782. // else if (planetType == "GTASA")
  5783. // {
  5784. // return "https://tiles.mapgenie.io/games/grand-theft-auto-san-andreas/san-andreas/satellite-v1/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  5785. // // "https://tiles.mapgenie.io/games/grand-theft-auto-san-andreas/san-andreas/atlas-v1/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  5786. // }
  5787. }
  5788.  
  5789. function injectMSPlayer() {
  5790. return new Promise((resolve, reject) => {
  5791. if (!MS_INJECTED) {
  5792. if (MS_API_KEY === "") {
  5793. let canvas = document.getElementById("player");
  5794. console.log("No MS Key")
  5795. }
  5796. else {
  5797.  
  5798. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  5799. let SCRIPT;
  5800. if (!partialCreateMS)
  5801. {
  5802. SCRIPT = document.createElement("script");
  5803. SCRIPT.type = "text/javascript";
  5804. SCRIPT.async = true;
  5805. SCRIPT.src = `https://www.bing.com/api/maps/mapcontrol?key=${MS_API_KEY}`;
  5806. document.body.appendChild(SCRIPT);
  5807. }
  5808. let canvas = document.createElement("msmap");
  5809. if (isBattleRoyale) {
  5810. if (isDuel)
  5811. {
  5812. canvas.innerHTML = `<div id="ms-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  5813. }
  5814. else if (isBullseye)
  5815. {
  5816. 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>`;
  5817. }
  5818. else if (isLiveChallenge)
  5819. {
  5820. canvas.innerHTML = `<div id="ms-player" class="game-panorama_panorama__Qpsxl" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  5821. }
  5822. else
  5823. {
  5824. 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>`;
  5825. }
  5826. }
  5827. else {
  5828. canvas.innerHTML = `<div id="ms-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  5829. }
  5830.  
  5831. var div = document.getElementById("player");
  5832. if (isBullseye || isLiveChallenge)
  5833. {
  5834. div.prepend(canvas);
  5835. }
  5836. else
  5837. {
  5838. div.appendChild(canvas);
  5839. }
  5840. function drawmapMS()
  5841. {
  5842. try
  5843. {
  5844. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  5845. MS_INJECTED = true;
  5846. // MSStreetPlayer.setOptions({
  5847. // minZoom: 13
  5848. // });
  5849. Microsoft.Maps.Events.addHandler(MSStreetPlayer, 'viewchangeend', function () { updateView(MSStreetPlayer); });
  5850. function updateView(map) {
  5851. let ctrm = map.getCenter();
  5852. if (nextPlayer == "Bing Streetside" && (switchCovergeButton.lat !== ctrm.latitude && switchCovergeButton.lng !== ctrm.longitude))
  5853. {
  5854. let heading2 = bearing(switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude)
  5855. // console.log("moved");
  5856. // console.log([switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude])
  5857. // console.log(heading2);
  5858. locHistory.push([ctrm.latitude, ctrm.longitude, heading2]);
  5859. switchCovergeButton.lat = ctrm.latitude;
  5860. switchCovergeButton.lng = ctrm.longitude;
  5861. switchCovergeButton.heading = heading2;
  5862. let btn = document.querySelector("button[data-qa='undo-move']");
  5863. if (locHistory.length > 1 && (btn != null)) {
  5864. btn.disabled = false;
  5865. btn.classList.remove('styles_disabled__2YdHD');
  5866. }
  5867. }
  5868. }
  5869. }
  5870. catch(error)
  5871. {
  5872. console.log(error);
  5873. // console.log("Retry MS");
  5874. // setTimeout(drawmapMS(), 1000);
  5875. }
  5876.  
  5877. }
  5878.  
  5879. if (partialCreateMS)
  5880. {
  5881. // drawmapMS();
  5882. if (isBullseye)
  5883. {
  5884. setTimeout(drawmapMS(), 1000);
  5885. }
  5886. else
  5887. {
  5888. drawmapMS();
  5889. }
  5890. resolve();
  5891. }
  5892. else
  5893. {
  5894. SCRIPT.addEventListener('load', () => {
  5895. myHighlight("Bing Maps API loaded");
  5896. let timeout = 0;
  5897. let interval = setInterval(() => {
  5898. // console.log(timeout);
  5899. if (timeout >= 40) {
  5900. reject();
  5901. clearInterval(interval);
  5902. }
  5903. if (document.getElementById('ms-player') !== null && Microsoft.Maps.Map !== typeof undefined) {
  5904. drawmapMS();
  5905. resolve();
  5906. clearInterval(interval);
  5907. }
  5908. timeout += 1;
  5909. }, 1000);
  5910. })
  5911. }
  5912. }
  5913. }
  5914. else {
  5915. resolve();
  5916. }
  5917. });
  5918. }
  5919.  
  5920.  
  5921.  
  5922. function injectMapillaryPlayer() {
  5923. return new Promise((resolve, reject) => {
  5924. if (!MAPILLARY_INJECTED) {
  5925. if (MAPILLARY_API_KEY === "") {
  5926. let canvas = document.getElementById("player");
  5927. console.log("No Mapillary Key")
  5928. }
  5929. else {
  5930. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  5931.  
  5932. let SCRIPT;
  5933. if (!partialCreateMapillary)
  5934. {
  5935. SCRIPT = document.createElement("script");
  5936. SCRIPT.type = "text/javascript";
  5937. SCRIPT.async = true;
  5938. SCRIPT.src = `https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.js`;
  5939. document.body.appendChild(SCRIPT);
  5940. document.querySelector('head').innerHTML += '<link href="https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.css" rel="stylesheet"/>';
  5941. }
  5942. let canvas = document.createElement("mmap");
  5943. if (isBattleRoyale) {
  5944. if (isDuel)
  5945. {
  5946.  
  5947. canvas.innerHTML = `<div id="mapillary-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  5948. }
  5949. else if (isBullseye)
  5950. {
  5951. 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>`;
  5952. }
  5953. else if (isLiveChallenge)
  5954. {
  5955. canvas.innerHTML = `<div id="mapillary-player" class="game-panorama_panorama__Qpsxl" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  5956. }
  5957. else
  5958. {
  5959. 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>`;
  5960. }
  5961. }
  5962. else {
  5963. canvas.innerHTML = `<div id="mapillary-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  5964. }
  5965.  
  5966. var div = document.getElementById("player");
  5967. if (isBullseye || isLiveChallenge)
  5968. {
  5969. div.prepend(canvas);
  5970. // setTimeout(drawmapMS(), 1000);
  5971. }
  5972. else
  5973. {
  5974. div.appendChild(canvas);
  5975. }
  5976.  
  5977. function drawMapML()
  5978. {
  5979. var {Viewer} = mapillary;
  5980.  
  5981. MapillaryPlayer = new Viewer({
  5982. accessToken: MAPILLARY_API_KEY,
  5983. container: 'mapillary-player', // the ID of our container defined in the HTML body
  5984. });
  5985.  
  5986. MapillaryPlayer.on('image', async (event) => {
  5987. // cnt = cnt + 1;
  5988. // console.log(cnt);
  5989. let image = event.image;
  5990. let pos = image.originalLngLat;
  5991. let cond = true;
  5992. for (const element of locHistory) {
  5993. if (element[2] == image.id)
  5994. {
  5995. cond = false;
  5996. }
  5997. }
  5998. if (cond)
  5999. {
  6000. switchCovergeButton.lat = pos.lat;
  6001. switchCovergeButton.lng = pos.lng;
  6002. switchCovergeButton.heading = image.compassAngle;
  6003. // console.log(pos);
  6004. locHistory.push([pos.lat, pos.lng, image.id, image.compassAngle]);
  6005. }
  6006. let btn = document.querySelector("button[data-qa='undo-move']");
  6007. if (btn !== null && locHistory.length > 1)
  6008. {
  6009. btn.disabled = false;
  6010. btn.classList.remove('styles_disabled__2YdHD');
  6011. }
  6012. });
  6013.  
  6014. MAPILLARY_INJECTED = true;
  6015. }
  6016. if (partialCreateMapillary)
  6017. {
  6018. drawMapML();
  6019. }
  6020. else
  6021. {
  6022.  
  6023. SCRIPT.addEventListener('load', () => {
  6024. myHighlight("Mapillary API Loaded");
  6025. // resolve(BMap);
  6026. drawMapML();
  6027. resolve();
  6028. })
  6029. }
  6030. }
  6031. }
  6032. else {
  6033. resolve();
  6034. }
  6035. });
  6036. }
  6037.  
  6038. function changeInnerHTML(canvas1, init)
  6039. {
  6040. canvas1.style.display = "";
  6041. var div = document.getElementById("player");
  6042. if (isBullseye || isLiveChallenge)
  6043. {
  6044. div.prepend(canvas1);
  6045. }
  6046. else
  6047. {
  6048. div.appendChild(canvas1);
  6049. }
  6050.  
  6051. let canvas;
  6052. if (init)
  6053. {
  6054. canvas = document.createElement("div");
  6055. canvas.id = "mapbox-player";
  6056. canvas.style = `zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'`;
  6057. canvas1.appendChild(canvas);
  6058. }
  6059. else
  6060. {
  6061. document.getElementById("mapbox-player").classList.remove("inactive", "game-panorama_panorama__ncMwh", "game-panorama_panorama__Qpsxl", "br-game-layout__panorama", "game-layout__panorama", "game-panorama_panorama__rdhFg");
  6062. }
  6063. canvas = document.getElementById("mapbox-player");
  6064. if (isBattleRoyale) {
  6065. if (isDuel)
  6066. {
  6067. canvas.classList.add("inactive");
  6068. }
  6069. else if (isBullseye)
  6070. {
  6071. canvas.classList.add("game-panorama_panorama__ncMwh");
  6072. }
  6073. else if (isLiveChallenge)
  6074. {
  6075. canvas.classList.add("game-panorama_panorama__Qpsxl");
  6076. }
  6077. else
  6078. {
  6079. canvas.classList.add("br-game-layout__panorama");
  6080. }
  6081. }
  6082. else {
  6083. canvas.classList.add("game-layout__panorama");
  6084. }
  6085. if (rainLayer)
  6086. {
  6087. MapboxPlayer.resize();
  6088. }
  6089. // console.log(canvas);
  6090.  
  6091. }
  6092.  
  6093. function updateSunPosition(sunPos) {
  6094. MapboxPlayer.setPaintProperty('sky', 'sky-atmosphere-sun', sunPos);
  6095. }
  6096.  
  6097. function getSunPosition(date) {
  6098. const center = MapboxPlayer.getCenter();
  6099. const sunPos = SunCalc.getPosition(
  6100. date || Date.now(),
  6101. center.lat,
  6102. center.lng
  6103. );
  6104. const sunAzimuth = 180 + (sunPos.azimuth * 180) / Math.PI;
  6105. const sunAltitude = 90 - (sunPos.altitude * 180) / Math.PI;
  6106. return [sunAzimuth, sunAltitude];
  6107. }
  6108.  
  6109. // function handleRainLayer()
  6110. // {
  6111. // if (typeof RainLayer !== typeof undefined)
  6112. // {
  6113.  
  6114. // MapboxPlayer.addLayer(rainLayer);
  6115.  
  6116. // console.log("Rain Layer loaded");
  6117. // }
  6118. // else
  6119. // {
  6120. // setTimeout(handleRainLayer, 1000);
  6121. // }
  6122. // }
  6123.  
  6124. function skyLayer(reset, time, style)
  6125. {
  6126. try
  6127. {
  6128. if (reset == "reset")
  6129. {
  6130. let tm = [360, 30];
  6131.  
  6132. MapboxPlayer.addLayer({
  6133. 'id': 'sky',
  6134. 'type': 'sky',
  6135. 'paint': {
  6136. 'sky-opacity': [
  6137. 'interpolate',
  6138. ['linear'],
  6139. ['zoom'],
  6140. 0,
  6141. 0,
  6142. 5,
  6143. 0.3,
  6144. 8,
  6145. 1
  6146. ],
  6147. // set up the sky layer for atmospheric scattering
  6148. 'sky-type': 'atmosphere',
  6149. // explicitly set the position of the sun rather than allowing the sun to be attached to the main light source
  6150. 'sky-atmosphere-sun': tm,
  6151. // set the intensity of the sun as a light source (0-100 with higher values corresponding to brighter skies)
  6152. 'sky-atmosphere-sun-intensity': 5
  6153. }
  6154. });
  6155. time = tm;
  6156. MapboxPlayer.addLayer(rainLayer)
  6157. // handleRainLayer();
  6158.  
  6159.  
  6160. // Reset Fog
  6161. }
  6162. let percentage;
  6163. // console.log(time);
  6164.  
  6165. if (time[1] <= 75)
  6166. {
  6167. percentage = 0;
  6168. }
  6169. else if (time[1] > 75 && time[1] <= 90)
  6170. {
  6171. percentage = (90 - time[1]) / 20;
  6172. }
  6173. else
  6174. {
  6175. percentage = 1;
  6176. }
  6177.  
  6178. // console.log(MapboxPlayer.getStyle());
  6179.  
  6180. if (style == "Satellite")
  6181. {
  6182. MapboxPlayer.setPaintProperty(
  6183. 'heatmap',
  6184. 'heatmap-opacity',
  6185. percentage * 0.35
  6186. );
  6187. MapboxPlayer.setPaintProperty(
  6188. 'satellite',
  6189. 'raster-brightness-max',
  6190. 0.25 + (1 - percentage) * 0.75
  6191. );
  6192. MapboxPlayer.setPaintProperty(
  6193. 'road-simple',
  6194. 'line-opacity',
  6195. percentage * 0.25
  6196. );
  6197. MapboxPlayer.setPaintProperty(
  6198. 'bridge-case-simple',
  6199. 'line-opacity',
  6200. percentage * 0.25
  6201. );
  6202. MapboxPlayer.setPaintProperty(
  6203. 'bridge-simple',
  6204. 'line-opacity',
  6205. percentage * 0.25
  6206. );
  6207. }
  6208. let fogVal = 100 - percentage * 100;
  6209. // console.log(`rgba(${parseInt(fogVal)}, ${parseInt(fogVal)}, ${parseInt(fogVal)}, 1.0)`)
  6210. let val = [0, 5, 0.1];
  6211. if (ms_radius < 10000)
  6212. {
  6213. val[1] = ms_radius / 10000 * 4 + 1;
  6214. }
  6215. MapboxPlayer.setFog({ 'color': `hsl(0, 0, ${fogVal}%)` , 'range': [val[0], val[1]],'horizon-blend': val[2]});
  6216. // console.log(MapboxPlayer.getStyle());
  6217. }
  6218. catch (error) {
  6219. console.error(error);
  6220. // expected output: ReferenceError: nonExistentFunction is not defined
  6221. // Note - error messages will vary depending on browser
  6222. }
  6223. }
  6224.  
  6225.  
  6226. // function fetchTime(lat, lng)
  6227. // {
  6228. // return new Promise((resolve, reject) => {
  6229. // fetch(`https://api.timezonedb.com/v2.1/get-time-zone?key=D95ISGQ041BQ&format=json&by=position&lat=${lat}&lng=${lng}`)
  6230. // .then((response) => {resolve(response.json())})
  6231. // .catch((error) => {console.log(error);});
  6232. // });
  6233. // }
  6234. // fetchTime(global_lat, global_lng).then((data) => {
  6235.  
  6236. function styleMapboxAll(initId, initDim, initStyle, endId, endDim, endStyle, resetDist)
  6237. {
  6238. let rtVal = false;
  6239. const sunPositions = SunCalc.getTimes(
  6240. Date.now(),
  6241. global_lat,
  6242. global_lng
  6243. );
  6244.  
  6245. if (resetDist)
  6246. {
  6247. let tempRadius;
  6248. if (endDim == "3D" || endDim == "2.5D")
  6249. {
  6250. tempRadius = ms_radius * 0.5;
  6251. }
  6252. else
  6253. {
  6254. tempRadius = ms_radius;
  6255. }
  6256. let loc_centre = {lat: global_lat, lng: global_lng};
  6257. let latlngBounds = getBBox2(loc_centre, tempRadius);
  6258. // console.log([latlngBounds[0], latlngBounds[1]], [latlngBounds[2], latlngBounds[3]])
  6259. let mpBounds = [
  6260. [latlngBounds[1], latlngBounds[2]], // Southwest coordinates
  6261. [latlngBounds[3], latlngBounds[0]] // Northeast coordinates
  6262. ];
  6263. MapboxPlayer.flyTo({center: [global_lng, global_lat], zoom: 9});
  6264. MapboxMarker.setLngLat([global_lng, global_lat]);
  6265. MapboxPlayer.setMaxBounds(mpBounds);
  6266.  
  6267.  
  6268.  
  6269. }
  6270. let sunPos = getSunPosition(sunPositions[endStyle]);
  6271. updateSunPosition(sunPos);
  6272.  
  6273. if (initId !== endId)
  6274. {
  6275. if (endId == "Satellite")
  6276. {
  6277. MapboxPlayer.setStyle("mapbox://styles/jupaoqq/cl0xjs63k003a15ml3essawbk");
  6278. }
  6279. else
  6280. {
  6281. MapboxPlayer.setStyle("mapbox://styles/jupaoqq/cl0ro0tm0001l14nyi17a91rs");
  6282. }
  6283. setTimeout(() => {
  6284. skyLayer("reset", sunPos, endId);
  6285. dimChange();
  6286. }, 1000);
  6287. rtVal = true;
  6288. }
  6289. else
  6290. {
  6291. skyLayer(endId, sunPos, endId);
  6292. dimChange();
  6293. }
  6294.  
  6295. function dimChange()
  6296. {
  6297. if (initDim !== endDim || initId !== endId)
  6298. {
  6299. if (endDim.includes("2D"))
  6300. {
  6301. MapboxPlayer.setPitch(0);
  6302. MapboxPlayer.dragRotate.disable();
  6303. MapboxPlayer.touchZoomRotate.disableRotation();
  6304. MapboxPlayer.setPaintProperty(
  6305. 'building-extrusion',
  6306. 'fill-extrusion-opacity',
  6307. 0
  6308. );
  6309. rainLayer.setMeshOpacity(0);
  6310. rainLayer.setRainColor("rgba(204, 204, 255, 0)");
  6311. }
  6312. else
  6313. {
  6314. MapboxPlayer.dragRotate.enable();
  6315. MapboxPlayer.touchZoomRotate.enableRotation();
  6316. if (endDim.includes("2.5D"))
  6317. {
  6318. MapboxPlayer.setPaintProperty(
  6319. 'building-extrusion',
  6320. 'fill-extrusion-opacity',
  6321. 0
  6322. );
  6323. }
  6324. else
  6325. {
  6326. MapboxPlayer.setPaintProperty(
  6327. 'building-extrusion',
  6328. 'fill-extrusion-opacity',
  6329. 0.8
  6330. );
  6331. }
  6332. rainLayer.setMeshOpacity(0.1);
  6333. rainLayer.setRainColor("rgba(204, 204, 255, 1)");
  6334. }
  6335. if (!MapboxPlayer.getSource('mapbox-dem')) {
  6336. MapboxPlayer.addSource('mapbox-dem', {
  6337. 'type': 'raster-dem',
  6338. 'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',
  6339. 'tileSize': 512,
  6340. 'maxzoom': 14
  6341. });
  6342. // add the DEM source as a terrain layer with exaggerated height
  6343. MapboxPlayer.setTerrain({ 'source': 'mapbox-dem', 'exaggeration': 1.5 });
  6344. }
  6345.  
  6346. }
  6347. }
  6348.  
  6349. return rtVal;
  6350.  
  6351. }
  6352.  
  6353. function injectMapboxPlayer() {
  6354. return new Promise((resolve, reject) => {
  6355. if (!MAPBOX_INJECTED) {
  6356. if (MAPBOX_API_KEY === "") {
  6357. let canvas = document.getElementById("player");
  6358. console.log("No Mapbox Key")
  6359. }
  6360. else {
  6361. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  6362.  
  6363.  
  6364. let canvas = document.createElement("sat-map");
  6365. canvas.id = "sat_map";
  6366. canvas.classList.add("sat_map");
  6367. changeInnerHTML(canvas, true);
  6368.  
  6369.  
  6370. // mapbox://styles/jupaoqq/cl0rnlwp9001914mz2vpinynt
  6371. // mapbox://styles/jupaoqq/cl0ro0tm0001l14nyi17a91rs
  6372.  
  6373. let SCRIPT;
  6374. if (!partialCreateMapbox)
  6375. {
  6376. const SCRIPT2 = document.createElement("script");
  6377. SCRIPT2.type = "text/javascript";
  6378. SCRIPT2.async = true;
  6379. SCRIPT2.src = `https://cdnjs.cloudflare.com/ajax/libs/suncalc/1.8.0/suncalc.min.js`;
  6380. document.body.appendChild(SCRIPT2);
  6381.  
  6382. SCRIPT = document.createElement("script");
  6383. SCRIPT.type = "text/javascript";
  6384. SCRIPT.async = true;
  6385. SCRIPT.src = `https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.js`;
  6386. document.body.appendChild(SCRIPT);
  6387. document.querySelector('head').innerHTML += '<link href="https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.css" rel="stylesheet"/>';
  6388. SCRIPT.addEventListener('load', () => {
  6389. const SCRIPT3 = document.createElement("script");
  6390. SCRIPT3.type = "text/javascript";
  6391. SCRIPT3.async = true;
  6392. SCRIPT3.src = `https://cdn.jsdelivr.net/npm/mapbox-gl-rain-layer@latest/dist/mapbox-gl-rain-layer.min.js`;
  6393. document.body.appendChild(SCRIPT3);
  6394. SCRIPT3.addEventListener('load', () => {
  6395. myHighlight("Mapbox API and Rainlayer Loaded");
  6396. // resolve(BMap);
  6397. mapboxgl.accessToken = MAPBOX_API_KEY;
  6398. MapboxPlayer = new mapboxgl.Map({
  6399. container: 'mapbox-player', // container ID
  6400. style: 'mapbox://styles/jupaoqq/cl0xjs63k003a15ml3essawbk', // style URL
  6401. center: [0, 0], // starting position [lng, lat]
  6402. zoom: 15, // starting zoom
  6403. pitch: 0
  6404. });
  6405. console.log("New Mapbox API Call");
  6406. MapboxMarker = new mapboxgl.Marker()
  6407. .setLngLat([0, 0])
  6408. .addTo(MapboxPlayer);
  6409. MapboxPlayer.addControl(new mapboxgl.NavigationControl(), 'top-left');
  6410. MapboxPlayer.addControl(new mapboxgl.ScaleControl({}));
  6411. MapboxPlayer.on('load', () => {
  6412. MapboxPlayer.addSource('mapbox-dem', {
  6413. 'type': 'raster-dem',
  6414. 'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',
  6415. 'tileSize': 512,
  6416. 'maxzoom': 14
  6417. });
  6418. // add the DEM source as a terrain layer with exaggerated height
  6419. MapboxPlayer.setTerrain({ 'source': 'mapbox-dem', 'exaggeration': 1.5 });
  6420. rainLayer = new RainLayer({
  6421. id: 'rain',
  6422. source: 'rainviewer',
  6423. scale: 'noaa'
  6424. });
  6425. // TODO
  6426. // MapboxPlayer.setFog({'range': [-1, 1.5], 'color': `rgba(255, 255, 255, 1.0)`,'horizon-blend': 0.1});
  6427. skyLayer("reset", "", "Satellite");
  6428.  
  6429.  
  6430. });
  6431.  
  6432. });
  6433. });
  6434.  
  6435.  
  6436. MAPBOX_INJECTED = true;
  6437. resolve();
  6438.  
  6439. }
  6440. else
  6441. {
  6442. resolve();
  6443. }
  6444. }
  6445. }
  6446. else {
  6447. resolve();
  6448. }
  6449. });
  6450. }
  6451.  
  6452.  
  6453.  
  6454. function handleMapillary(latlng, options)
  6455. {
  6456. console.log("handleMapillary")
  6457. handleMapillaryHelper(latlng, options).then((data) => {
  6458. //console.log(data.data)
  6459. let idToSet = 0;
  6460. let curDist = 100000000;
  6461. for (const element of data.data) {
  6462. // console.log(element)
  6463. if (element.hasOwnProperty("computed_geometry"))
  6464. {
  6465. try {
  6466. let rCord = element.computed_geometry["coordinates"];
  6467. let dist = distance(latlng.lat,latlng.lng,rCord[1],rCord[0])
  6468. if (dist < curDist)
  6469. {
  6470. idToSet = element.id;
  6471. curDist = dist
  6472. }
  6473. } catch (e) {
  6474. console.log("Error")
  6475. }
  6476. }
  6477. }
  6478. if (idToSet !== 0)
  6479. {
  6480. MapillaryPlayer.moveTo(idToSet).then(
  6481. image => { //console.log(image);
  6482. },
  6483. error => { console.log(error); });
  6484. }}).catch((error) => {
  6485. console.log(error);
  6486. });
  6487. }
  6488.  
  6489. function handleMapillaryHelper(latlng, options)
  6490. {
  6491. return new Promise((resolve, reject) => {
  6492. // console.log("1")
  6493. let bbox = getBBox(latlng, options.meters);
  6494. 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)
  6495. // console.log(URL)
  6496. fetch(URL)
  6497. .then((response) => {resolve(response.json())})
  6498. .catch((error) => {console.log(error);});
  6499. });
  6500. }
  6501.  
  6502.  
  6503. /**
  6504. * Minimap presets
  6505. */
  6506.  
  6507. let water_name_only =
  6508. [
  6509. {
  6510. "elementType": "geometry",
  6511. "stylers": [
  6512. {
  6513. "visibility": "off"
  6514. }
  6515. ]
  6516. },
  6517. {
  6518. "featureType": "administrative",
  6519. "stylers": [
  6520. {
  6521. "visibility": "off"
  6522. }
  6523. ]
  6524. },
  6525. {
  6526. "featureType": "landscape",
  6527. "stylers": [
  6528. {
  6529. "visibility": "off"
  6530. }
  6531. ]
  6532. },
  6533. {
  6534. "featureType": "poi",
  6535. "stylers": [
  6536. {
  6537. "visibility": "off"
  6538. }
  6539. ]
  6540. },
  6541. {
  6542. "featureType": "road",
  6543. "stylers": [
  6544. {
  6545. "visibility": "off"
  6546. }
  6547. ]
  6548. },
  6549. {
  6550. "featureType": "transit",
  6551. "stylers": [
  6552. {
  6553. "visibility": "off"
  6554. }
  6555. ]
  6556. }
  6557. ]
  6558. let country_name_only =
  6559. [
  6560. {
  6561. "elementType": "geometry",
  6562. "stylers": [
  6563. {
  6564. "visibility": "off"
  6565. }
  6566. ]
  6567. },
  6568. {
  6569. "featureType": "administrative",
  6570. "stylers": [
  6571. {
  6572. "visibility": "off"
  6573. }
  6574. ]
  6575. },
  6576. {
  6577. "featureType": "administrative.country",
  6578. "elementType": "labels",
  6579. "stylers": [
  6580. {
  6581. "visibility": "on"
  6582. }
  6583. ]
  6584. },
  6585. {
  6586. "featureType": "landscape",
  6587. "stylers": [
  6588. {
  6589. "visibility": "off"
  6590. }
  6591. ]
  6592. },
  6593. {
  6594. "featureType": "poi",
  6595. "stylers": [
  6596. {
  6597. "visibility": "off"
  6598. }
  6599. ]
  6600. },
  6601. {
  6602. "featureType": "road",
  6603. "stylers": [
  6604. {
  6605. "visibility": "off"
  6606. }
  6607. ]
  6608. },
  6609. {
  6610. "featureType": "transit",
  6611. "stylers": [
  6612. {
  6613. "visibility": "off"
  6614. }
  6615. ]
  6616. },
  6617. {
  6618. "featureType": "water",
  6619. "stylers": [
  6620. {
  6621. "visibility": "off"
  6622. }
  6623. ]
  6624. }
  6625. ]
  6626.  
  6627. let no_label_or_terrain =
  6628. [
  6629. {
  6630. "elementType": "geometry",
  6631. "stylers": [
  6632. {
  6633. "visibility": "off"
  6634. }
  6635. ]
  6636. },
  6637. {
  6638. "featureType": "administrative",
  6639. "stylers": [
  6640. {
  6641. "visibility": "off"
  6642. }
  6643. ]
  6644. },
  6645. {
  6646. "featureType": "landscape",
  6647. "stylers": [
  6648. {
  6649. "visibility": "off"
  6650. }
  6651. ]
  6652. },
  6653. {
  6654. "featureType": "poi",
  6655. "stylers": [
  6656. {
  6657. "visibility": "off"
  6658. }
  6659. ]
  6660. },
  6661. {
  6662. "featureType": "road",
  6663. "stylers": [
  6664. {
  6665. "visibility": "off"
  6666. }
  6667. ]
  6668. },
  6669. {
  6670. "featureType": "transit",
  6671. "stylers": [
  6672. {
  6673. "visibility": "off"
  6674. }
  6675. ]
  6676. },
  6677. {
  6678. "featureType": "water",
  6679. "stylers": [
  6680. {
  6681. "visibility": "on"
  6682. }
  6683. ]
  6684. },
  6685. {
  6686. "featureType": "water",
  6687. "elementType": "labels",
  6688. "stylers": [
  6689. {
  6690. "visibility": "off"
  6691. }
  6692. ]
  6693. }
  6694. ]
  6695.  
  6696. let no_label =
  6697. [
  6698. {
  6699. "elementType": "labels",
  6700. "stylers": [
  6701. {
  6702. "visibility": "off"
  6703. }
  6704. ]
  6705. },
  6706. {
  6707. "featureType": "administrative",
  6708. "stylers": [
  6709. {
  6710. "visibility": "off"
  6711. }
  6712. ]
  6713. }
  6714. ]
  6715.  
  6716. let blank =
  6717.  
  6718. [
  6719. {
  6720. "stylers": [
  6721. {
  6722. "visibility": "off"
  6723. }
  6724. ]
  6725. }
  6726. ]
  6727.  
  6728. let thick_border =
  6729.  
  6730. [
  6731. {
  6732. "featureType": "administrative.country",
  6733. "elementType": "geometry.stroke",
  6734. "stylers": [
  6735. {
  6736. "weight": 1.5
  6737. }
  6738. ]
  6739. },
  6740. {
  6741. "featureType": "administrative.province",
  6742. "elementType": "geometry.stroke",
  6743. "stylers": [
  6744. {
  6745. "weight": 3.5
  6746. }
  6747. ]
  6748. }
  6749. ]
  6750.  
  6751. let Indonesia =
  6752.  
  6753. [
  6754. {
  6755. "featureType": "administrative",
  6756. "stylers": [
  6757. {
  6758. "visibility": "off"
  6759. }
  6760. ]
  6761. },
  6762. {
  6763. "featureType": "landscape",
  6764. "elementType": "labels",
  6765. "stylers": [
  6766. {
  6767. "visibility": "off"
  6768. }
  6769. ]
  6770. },
  6771. {
  6772. "featureType": "poi.park",
  6773. "elementType": "labels",
  6774. "stylers": [
  6775. {
  6776. "visibility": "off"
  6777. }
  6778. ]
  6779. },
  6780. {
  6781. "featureType": "road",
  6782. "elementType": "labels",
  6783. "stylers": [
  6784. {
  6785. "visibility": "off"
  6786. }
  6787. ]
  6788. },
  6789. {
  6790. "featureType": "transit",
  6791. "elementType": "labels",
  6792. "stylers": [
  6793. {
  6794. "visibility": "off"
  6795. }
  6796. ]
  6797. },
  6798. {
  6799. "featureType": "water",
  6800. "elementType": "labels",
  6801. "stylers": [
  6802. {
  6803. "visibility": "off"
  6804. }
  6805. ]
  6806. }
  6807. ]
  6808.  
  6809. let dark = [
  6810. {
  6811. "elementType": "geometry",
  6812. "stylers": [
  6813. {
  6814. "color": "#212121"
  6815. }
  6816. ]
  6817. },
  6818. {
  6819. "elementType": "labels.icon",
  6820. "stylers": [
  6821. {
  6822. "visibility": "off"
  6823. }
  6824. ]
  6825. },
  6826. {
  6827. "elementType": "labels.text.fill",
  6828. "stylers": [
  6829. {
  6830. "color": "#757575"
  6831. }
  6832. ]
  6833. },
  6834. {
  6835. "elementType": "labels.text.stroke",
  6836. "stylers": [
  6837. {
  6838. "color": "#212121"
  6839. }
  6840. ]
  6841. },
  6842. {
  6843. "featureType": "administrative",
  6844. "elementType": "geometry",
  6845. "stylers": [
  6846. {
  6847. "color": "#757575"
  6848. }
  6849. ]
  6850. },
  6851. {
  6852. "featureType": "administrative.country",
  6853. "elementType": "labels.text.fill",
  6854. "stylers": [
  6855. {
  6856. "color": "#9e9e9e"
  6857. }
  6858. ]
  6859. },
  6860. {
  6861. "featureType": "administrative.land_parcel",
  6862. "stylers": [
  6863. {
  6864. "visibility": "off"
  6865. }
  6866. ]
  6867. },
  6868. {
  6869. "featureType": "administrative.locality",
  6870. "elementType": "labels.text.fill",
  6871. "stylers": [
  6872. {
  6873. "color": "#bdbdbd"
  6874. }
  6875. ]
  6876. },
  6877. {
  6878. "featureType": "poi",
  6879. "elementType": "labels.text.fill",
  6880. "stylers": [
  6881. {
  6882. "color": "#757575"
  6883. }
  6884. ]
  6885. },
  6886. {
  6887. "featureType": "poi.park",
  6888. "elementType": "geometry",
  6889. "stylers": [
  6890. {
  6891. "color": "#181818"
  6892. }
  6893. ]
  6894. },
  6895. {
  6896. "featureType": "poi.park",
  6897. "elementType": "labels.text.fill",
  6898. "stylers": [
  6899. {
  6900. "color": "#616161"
  6901. }
  6902. ]
  6903. },
  6904. {
  6905. "featureType": "poi.park",
  6906. "elementType": "labels.text.stroke",
  6907. "stylers": [
  6908. {
  6909. "color": "#1b1b1b"
  6910. }
  6911. ]
  6912. },
  6913. {
  6914. "featureType": "road",
  6915. "elementType": "geometry.fill",
  6916. "stylers": [
  6917. {
  6918. "color": "#2c2c2c"
  6919. }
  6920. ]
  6921. },
  6922. {
  6923. "featureType": "road",
  6924. "elementType": "labels.text.fill",
  6925. "stylers": [
  6926. {
  6927. "color": "#8a8a8a"
  6928. }
  6929. ]
  6930. },
  6931. {
  6932. "featureType": "road.arterial",
  6933. "elementType": "geometry",
  6934. "stylers": [
  6935. {
  6936. "color": "#373737"
  6937. }
  6938. ]
  6939. },
  6940. {
  6941. "featureType": "road.highway",
  6942. "elementType": "geometry",
  6943. "stylers": [
  6944. {
  6945. "color": "#3c3c3c"
  6946. }
  6947. ]
  6948. },
  6949. {
  6950. "featureType": "road.highway.controlled_access",
  6951. "elementType": "geometry",
  6952. "stylers": [
  6953. {
  6954. "color": "#4e4e4e"
  6955. }
  6956. ]
  6957. },
  6958. {
  6959. "featureType": "road.local",
  6960. "elementType": "labels.text.fill",
  6961. "stylers": [
  6962. {
  6963. "color": "#616161"
  6964. }
  6965. ]
  6966. },
  6967. {
  6968. "featureType": "transit",
  6969. "elementType": "labels.text.fill",
  6970. "stylers": [
  6971. {
  6972. "color": "#757575"
  6973. }
  6974. ]
  6975. },
  6976. {
  6977. "featureType": "water",
  6978. "elementType": "geometry",
  6979. "stylers": [
  6980. {
  6981. "color": "#000000"
  6982. }
  6983. ]
  6984. },
  6985. {
  6986. "featureType": "water",
  6987. "elementType": "labels.text.fill",
  6988. "stylers": [
  6989. {
  6990. "color": "#3d3d3d"
  6991. }
  6992. ]
  6993. }
  6994. ]
  6995.  
  6996. let default_preset = []
  6997.  
  6998. let presetMinimap = [[default_preset, "Default"],
  6999. [blank, "Blank"],
  7000. [water_name_only, "Oceanman"],
  7001. [country_name_only, "Impossible"],
  7002. [no_label_or_terrain, "Streaks"],
  7003. [no_label, "Easy 5K"],
  7004. [Indonesia, "POI only"],
  7005. [dark, "Dark Mode"],
  7006. [thick_border, "Borders"],
  7007. [default_preset, "Satellite"],
  7008. [default_preset, "Terrain"],
  7009. [default_preset, "Hybrid"],
  7010. [custom, "Custom", customMode]]
  7011.  
  7012. let GEOJSON_INVISIBLE =
  7013. {
  7014. strokeOpacity: 0,
  7015. fillOpacity: 0,
  7016. clickable: false,
  7017. }
  7018.  
  7019. let presetOverlay = [["Clear",""],
  7020. ["Coverage",""],
  7021. ["Official",""],
  7022. ["OSM",""],
  7023. ["City Lights",""],
  7024. ["Watercolor",""],
  7025. ["Toner",""],
  7026. ["Fire",""],
  7027. ["Longitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/lonl.json"],
  7028. ["Latitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/latl.json"],
  7029. ["US County","https://raw.githubusercontent.com/CodeForCary/CountyDataUSA5m/master/cb_2017_us_county_5m.json"],
  7030. ["France","https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements.geojson"],
  7031. ["Time Zone", "https://raw.githubusercontent.com/treyerl/timezones/master/timezones_wVVG8.geojson"],
  7032. ["UK Parliament", "https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/electoral/gb/wpc.json"],
  7033. ["Custom", YOUR_URL]]
  7034.  
  7035. let satType = [["Satellite","2.5D"],
  7036. ["Satellite","3D"],
  7037. ["Satellite","2D"],
  7038. ["Road", "3D"],
  7039. ["Road", "2D"]]
  7040.  
  7041. let satStyle = [["solarNoon","Noon"],
  7042. ["sunriseEnd","Sunrise"],
  7043. ["goldenHourEnd","Morning"],
  7044. ["goldenHour","Evening"],
  7045. ["sunsetStart","Sunset"],
  7046. ["nadir","Midnight"],
  7047. ["getlocal","Local Time"],
  7048. ];
  7049.  
  7050.  
  7051. // let spaceMainmap = [[default_preset, "Default"],
  7052. // ["Moon", "https://s3.amazonaws.com/opmbuilder/301_moon/tiles/w/hillshaded-albedo/"],
  7053. // ["Mars", "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/"]]
  7054.  
  7055. let spaceMinimap = [["Earth",""],
  7056. ["Moon", "https://s3.amazonaws.com/opmbuilder/301_moon/tiles/w/hillshaded-albedo/"],
  7057. ["Moon (Labels)", "https://cartocdn-gusc.global.ssl.fastly.net/opmbuilder/api/v1/map/named/opm-moon-basemap-v0-1/all/"],
  7058. ["Mars", "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/"],
  7059. ["Mars (Labels)", "https://cartocdn-gusc.global.ssl.fastly.net/opmbuilder/api/v1/map/named/opm-mars-basemap-v0-2/all/"],
  7060. ["Mars-Viking", "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/viking_mdim21_global/"],
  7061. ]
  7062.  
  7063. // ["5PM","Evening"],
  7064. // ["sunriseEnd","Sunrise"],
  7065.  
  7066. let langDict = {
  7067. "sn": ["fr"],
  7068. "za": ["af"],
  7069. "tn": ["ar"],
  7070. "bn": ["bn"],
  7071. "kh": ["km"],
  7072. "in": ["hi"],
  7073. "cn": ["zh"],
  7074. "hk": ["zh"],
  7075. "id": ["id"],
  7076. "il": ["he"],
  7077. "jp": ["ja"],
  7078. "jo": ["ar"],
  7079. "ky": ["ru", "ky"],
  7080. "la": ["lo"],
  7081. "my": ["ms"],
  7082. "mn": ["mn"],
  7083. "ru": ["ru"],
  7084. "sg": ["zh"],
  7085. "kr": ["ko"],
  7086. "lk": ["ta"],
  7087. "tw": ["zh"],
  7088. "th": ["th"],
  7089. "ae": ["ar"],
  7090. "vn": ["vi"],
  7091. "al": ["sq"],
  7092. "ad": ["es", "fr"],
  7093. "at": ["de"],
  7094. "be": ["nl", "fr"],
  7095. "bg": ["bg"],
  7096. "hr": ["hr"],
  7097. "cz": ["cs"],
  7098. "dk": ["da"],
  7099. "ee": ["et"],
  7100. "fo": ["fo"],
  7101. "fi": ["fi"],
  7102. "fr": ["fr"],
  7103. "de": ["de"],
  7104. "gr": ["el"],
  7105. "hu": ["hu"],
  7106. "is": ["is"],
  7107. "ie": ["ga"],
  7108. "it": ["it"],
  7109. "lv": ["lv"],
  7110. "lt": ["lt"],
  7111. "lu": ["lb", "fr", "de"],
  7112. "mc": ["fr"],
  7113. "nl": ["nl"],
  7114. "mk": ["mk"],
  7115. "no": ["no"],
  7116. "pl": ["pl"],
  7117. "pt": ["pt"],
  7118. "ro": ["ro"],
  7119. "sm": ["it"],
  7120. "rs": ["sr"],
  7121. "sk": ["sk"],
  7122. "si": ["sl"],
  7123. "es": ["es"],
  7124. "se": ["sv"],
  7125. "ch": ["de", "fr"],
  7126. "tr": ["tr"],
  7127. "ua": ["uk"],
  7128. "cw": ["nl"],
  7129. "do": ["es"],
  7130. "gt": ["es"],
  7131. "mx": ["es"],
  7132. "pr": ["es"],
  7133. "ar": ["es"],
  7134. "bo": ["es"],
  7135. "br": ["pt"],
  7136. "cl": ["es"],
  7137. "ec": ["es"],
  7138. "pe": ["es"],
  7139. "uy": ["es"]
  7140. };
  7141.  
  7142. // ch, lu, be, ad