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

As of 2022-05-04. See the latest version.

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