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

Verze ze dne 25. 06. 2022. Zobrazit nejnovější verzi.

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