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-20 提交的版本。查看 最新版本

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