Greasy Fork 支持简体中文。

Geoguessr Unity Script

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

目前為 2022-04-10 提交的版本,檢視 最新版本

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