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

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