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

  1. // ==UserScript==
  2. // @name Geoguessr Unity Script
  3. // @version 7.4.3
  4. // @author Jupaoqq
  5. // @match https://www.geoguessr.com/*
  6. // @run-at document-start
  7. // @license MIT
  8. // @icon https://raw.githubusercontent.com/echandler/test-geo-noob-script/refs/heads/main/misc/U-10-16-2024a%20(2).png
  9. // @grant none
  10. // @namespace https://gf.qytechs.cn/users/838374
  11. // @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
  12. // ==/UserScript==
  13.  
  14. Object.freeze(window.console);
  15.  
  16. const globalScriptVersion = "7.4.3";
  17.  
  18. let tempChangeScore = false; // delete soon used to test 5k country streak scores
  19. let tempLastLatLng = null; // delete soon used to test 5k country streak scores
  20.  
  21. let global_lat = 0;
  22. let global_lng = 0;
  23.  
  24. if (!window._unity_fetch_){
  25. // Added by EC
  26. window._unity_fetch_ = window.fetch;
  27.  
  28. window.fetch = (function(){
  29. return async function (...args){
  30. // console.log(args)
  31. // if (/lat|lng/.test(args[1]?.body)){
  32.  
  33. // +++++++ country streak 5k for correct country and 0 points for wrong country test +++++++++++++
  34. // console.log("-------------------------------------------------------------------------------------")
  35. // let body = JSON.parse(args[1].body);
  36. // if (tempChangeScore){
  37. // body.lat = global_lat + 0.0001;
  38. // body.lng = global_lng;
  39. // } else {
  40.  
  41. // debugger;
  42. // //body.lat = -84000.399864;
  43. // body.lat = global_lat > 0? -90: 90;
  44. // body.lng = 0; global_lng > 0? -180: 180
  45. // }
  46. // args[1].body = JSON.stringify(body);
  47. // let res = await window._unity_fetch_.apply(window, args);
  48. // let cloned = res.clone();
  49. // let ppp = await cloned.json().then( x => x);
  50. // if (ppp?.player?.guesses){
  51. // ppp.player.guesses[ppp.player.guesses.length - 1].lat = tempLastLatLng.lat;
  52. // ppp.player.guesses[ppp.player.guesses.length - 1].lng = tempLastLatLng.lng;
  53. // }
  54. // // console.log(ppp);
  55. // debugger;
  56. // res.json = function() {
  57. // return ppp;
  58. // return new Promise((res, rej)=>{
  59. // debugger;
  60. // return {
  61. // hi: "hi"
  62. // }
  63. // });
  64. // };
  65. // // return {
  66. // // text: function(){
  67. // // return new Promise((res, rej)=>{
  68. // // return JSON.stringify(ppp) ;
  69. // // } )
  70. // // }
  71. // // };
  72.  
  73. // return res;
  74. // +++++++ country streak 5k for correct country and 0 points for wrong country test +++++++++++++
  75. // }
  76. return window._unity_fetch_.apply(window, args);
  77. };
  78. })();
  79. }
  80.  
  81. setTimeout(()=>{
  82.  
  83. // Added by EC
  84. checkForRanomMapChallenge();
  85.  
  86. /**
  87. * Custom your YouTube Search here!
  88. * Replace " Tour Visit" with any keyword,
  89. * e.g. "Drone", to customize YouTube mode
  90. * search results.
  91. */
  92.  
  93. let customWord = " Tour Visit";
  94.  
  95. /**
  96. * Custom your minimap here!
  97. */
  98.  
  99. /**
  100. * 1: replace "roadmap" in the customMode field with any of the options below:
  101. * "roadmap" displays the default road map view. This is the default map type.
  102. * "satellite" displays Google Earth satellite images.
  103. * "hybrid" displays a mixture of normal and satellite views.
  104. * "terrain" displays a physical map based on terrain information.
  105. */
  106.  
  107. let customMode = "roadmap";
  108.  
  109. /**
  110. * 2: Go to https://mapstyle.withgoogle.com/ first click "No thanks, take me to the old style wizard"
  111. * then click "MORE OPTIONS" to hide or reveal certain features.
  112. * When you are done, click "FINISH", then "COPY JSON", and replace my settings in custom with your settings below.
  113. */
  114.  
  115. let custom =
  116.  
  117. [
  118. {
  119. "featureType": "administrative",
  120. "stylers": [
  121. {
  122. "visibility": "off"
  123. }
  124. ]
  125. },
  126. {
  127. "featureType": "landscape",
  128. "stylers": [
  129. {
  130. "visibility": "off"
  131. }
  132. ]
  133. },
  134. {
  135. "featureType": "poi.park",
  136. "stylers": [
  137. {
  138. "visibility": "off"
  139. }
  140. ]
  141. },
  142. {
  143. "featureType": "road",
  144. "elementType": "labels",
  145. "stylers": [
  146. {
  147. "visibility": "off"
  148. }
  149. ]
  150. },
  151. {
  152. "featureType": "transit",
  153. "stylers": [
  154. {
  155. "visibility": "off"
  156. }
  157. ]
  158. }
  159. ]
  160.  
  161. /**
  162. * End of Minimap customization instruction section
  163. */
  164.  
  165. /**
  166. * Overlay anything on the minimap here!
  167. * 1. overlay an GeoJSON object
  168. * 2. overlay a custom image
  169. */
  170.  
  171. /**
  172. * Overlay an GeoJSON object:
  173. */
  174.  
  175. // change the GeoJson display style.
  176. // strokeOpacity, strokeWeight, fillOpacity takes a value between 0 and 1.
  177. // strokeColor and fillColor supports Hexadecimal color (#00FF00 is green)
  178. // If clickable is set to true, you would not be able to make a guess within the shape
  179.  
  180. let GEOJSON_STYLE =
  181. {
  182. strokeColor: "black",
  183. strokeOpacity: 1,
  184. strokeWeight: 0.2,
  185. fillColor: "#00FF00",
  186. fillOpacity: 0,
  187. clickable: false,
  188. }
  189.  
  190. // replace the URL with your desired link
  191. // For example, search "Germany GeoJson" on Github, find this link (https://github.com/isellsoap/deutschlandGeoJSON/blob/main/4_kreise/4_niedrig.geo.json)
  192. // Then click "Download" to get the raw.githubusercontent.com link (https://raw.githubusercontent.com/isellsoap/deutschlandGeoJSON/main/4_kreise/4_niedrig.geo.json)
  193. // and replace the URL below with that URL.
  194. // State zipcode: see this site https://github.com/OpenDataDE/State-zip-code-GeoJSON
  195.  
  196. let YOUR_URL = "https://raw.githubusercontent.com/severinlandolt/map-switzerland/main/02%20GeoJSON/CH_Kantonsgrenzen_100_geo.json"
  197.  
  198. // set it to true to add your custom GeoJSON by copy it to the code below (this is for
  199.  
  200. let GeoJsonCustomUser = true; //false
  201.  
  202. // replace with your custom GeoJson, go to https://geojson.io/ to customize it then copy the Json to here
  203.  
  204. let CUSTOM_GEOJSON = null;
  205.  
  206. CUSTOM_GEOJSON =
  207.  
  208. {
  209. "type": "FeatureCollection",
  210. "features": [
  211. {
  212. "type": "Feature",
  213. "properties": {},
  214. "geometry": {
  215. "type": "LineString",
  216. "coordinates": [
  217. [
  218. 2.493896484375,
  219. 52.7163309360463
  220. ],
  221. [
  222. 2.4609375,
  223. 53.15994678846807
  224. ],
  225. [
  226. 3.2025146484375,
  227. 53.179703893605385
  228. ],
  229. [
  230. 3.2080078125,
  231. 52.96518371955126
  232. ],
  233. [
  234. 2.48291015625,
  235. 52.948637884883205
  236. ]
  237. ]
  238. }
  239. },
  240. {
  241. "type": "Feature",
  242. "properties": {},
  243. "geometry": {
  244. "type": "LineString",
  245. "coordinates": [
  246. [
  247. 3.218994140625,
  248. 52.05586831074774
  249. ],
  250. [
  251. 3.218994140625,
  252. 52.13685974852633
  253. ],
  254. [
  255. 2.515869140625,
  256. 52.1267438596429
  257. ],
  258. [
  259. 2.515869140625,
  260. 51.77803705914517
  261. ],
  262. [
  263. 3.2354736328125,
  264. 51.78993084774129
  265. ],
  266. [
  267. 3.228607177734375,
  268. 51.96119237712624
  269. ],
  270. [
  271. 2.8571319580078125,
  272. 51.95230623740452
  273. ]
  274. ]
  275. }
  276. },
  277. {
  278. "type": "Feature",
  279. "properties": {
  280. "stroke": "#555555",
  281. "stroke-width": 2,
  282. "stroke-opacity": 1
  283. },
  284. "geometry": {
  285. "type": "LineString",
  286. "coordinates": [
  287. [
  288. 2.5048828125,
  289. 52.619725272670266
  290. ],
  291. [
  292. 2.5103759765625,
  293. 52.274880130680536
  294. ],
  295. [
  296. 2.867431640625,
  297. 52.284962354465726
  298. ],
  299. [
  300. 3.2299804687499996,
  301. 52.29504228453735
  302. ],
  303. [
  304. 3.2135009765625,
  305. 52.63973017532399
  306. ],
  307. [
  308. 2.5096893310546875,
  309. 52.621392697207625
  310. ]
  311. ]
  312. }
  313. }
  314. ]
  315. }
  316. /**
  317. * Overlay a custom image:
  318. */
  319.  
  320. // set it to true to add your image overlay
  321.  
  322. let OverlayCustom = false;
  323.  
  324. // replace the URL with your desired link
  325.  
  326. let OVERLAY_URL = "https://www.battleface.com/blog/wp-content/uploads/2020/10/patreon-profile-tom-geowizard.jpg"
  327.  
  328. // set the bounds for the image - latitude (North and South), longitude (North and South)
  329.  
  330. let OVERLAY_BOUNDS =
  331. {
  332. north: 53,
  333. west: -3,
  334. south: 51,
  335. east: 1,
  336. };
  337.  
  338. // change the image overlay display style.
  339.  
  340. let OVERLAY_STYLE =
  341. {
  342. fillOpacity: 0.2,
  343. clickable: false,
  344. }
  345.  
  346. /**
  347. * End of Minimap Overlay instruction section
  348. */
  349.  
  350. // API Keys
  351.  
  352. var MS_API_KEY = "Ap2DwDDitzY7jJuYeIJF6YyfqDkYt-QxIBjeQ6SDEJelSfb6ghAVb-V4I-G3om-s";
  353. var YANDEX_API_KEY = "b704b5a9-3d67-4d19-b702-ec7807cecfc6";
  354. var KAKAO_API_KEY = "cbacbe41e3a223d794f321de4f3e247b";
  355. var MAPBOX_API_KEY = "pk.eyJ1IjoianVwYW9xcSIsImEiOiJjbDB2dTBnbngweWIzM2NtdWR5NXZ1dncyIn0.bJixk3kN5Mmedw_C3vQmmw";
  356. const MAPS_API_URL = "https://maps.googleapis.com/maps/api/js"; // removed "?" from the link
  357. var MAPILLARY_API_KEY_LIST =
  358. ["MLY|6723031704435203|5afd537469b114cf814881137ad74b7c",
  359. "MLY|6691659414239148|b45e7e82cde126044cbc2cf5d4a7c9b1",
  360. "MLY|5074369465929308|f7ad2802cbaf26c63f88046a292df68b",
  361. "MLY|7451643761528219|6477f2db0e3928b51e45ec9311983936",
  362. "MLY|4855256237866198|6d0464771831c8a4bf2be095e1e1aabc",
  363. "MLY|4772941976102161|8458d4f08d2e1970cdfe0a4e242c04ff",
  364. "MLY|4492067214235489|94c44703942362ad6f6b70b5d32c3a45",
  365. "MLY|4618251611628426|0cef71d6ec8b997a5ec06ecdeabf11ec",
  366. "MLY|4096846270415982|fa2ce29641503e6ef665f17459633570",
  367. "MLY|4231415756962414|fe353880fd246e8a4a6ae32152f7dbb0",]
  368.  
  369. var MAPILLARY_API_KEY = MAPILLARY_API_KEY_LIST[Math.floor(Math.random() * MAPILLARY_API_KEY_LIST.length)];
  370. var MAPY_API_KEY = "placeholder";
  371.  
  372. console.log(`Geoguessr Unity Script v${globalScriptVersion} by Jupaoqq`);
  373.  
  374.  
  375. // Store each player instance
  376.  
  377. let YandexPlayer, KakaoPlayer, GooglePlayer, MapillaryPlayer, MSStreetPlayer, MapboxPlayer, MapboxMarker, MapyPlayer;
  378. let YANDEX_INJECTED = false;
  379. let BAIDU_INJECTED = false;
  380. let KAKAO_INJECTED = false;
  381. let MAPILLARY_INJECTED = false;
  382. let MS_INJECTED = false;
  383. let MAPBOX_INJECTED = false;
  384. let MAPY_INJECTED = false;
  385. let rainLayer;
  386.  
  387. let GoogleMapsObj = null;
  388.  
  389. // Game mode detection
  390.  
  391. let isBattleRoyale = false;
  392. let isDuel = false;
  393. let isBullseye = false;
  394. let isLiveChallenge = false;
  395. let isPlayAlong = false;
  396.  
  397. // Player detection and coordinate conversion
  398.  
  399. let nextPlayer = "Google";
  400. let nextPlayer_save = "Google";
  401. let global_data = {};
  402. let global_bounds = {max : {lat: 50.387397, lng: 57.412767}, min : {lat: 50.181227, lng: 57.077273}};
  403. let global_cc = null;
  404. let global_panoID = null;
  405. let global_BDID, global_BDAh, global_BDBh;
  406. let yId, yTime, yEnd, iId;
  407. let global_heading = null;
  408. let global_pitch = null;
  409.  
  410. let krCoordinates = [38.75292321084364, 124.2804539232574, 33.18509676203202, 129.597381999198]
  411. let global_radi = 100
  412.  
  413. // Callback variables
  414.  
  415. let eventListenerAttached = false;
  416. let povListenerAttached = false;
  417. let playerLoaded = false;
  418. let teleportLoaded = false;
  419. let syncLoaded = false;
  420.  
  421. // Minimize Yandex API use
  422.  
  423. let yandex_map = false;
  424. let Kakao_map = false;
  425. let Wikipedia_map = false;
  426. let WikiXplore_map = false; // Added by EC.
  427. let randomMapChallenge_map = false;// Added by EC.
  428. let Minecraft_map = false;
  429. let Youtube_map = false;
  430. let bing_map = false;
  431. let Mapy_map = false;
  432.  
  433. // Mapillary Image Key
  434.  
  435. let mmKey = 0;
  436.  
  437. // Handle Yandex compass
  438.  
  439. let COMPASS = null;
  440.  
  441. // Handle undo
  442.  
  443. let locHistory = [];
  444. let defaultPanoIdChange = true;
  445.  
  446. // Round check
  447.  
  448. let ROUND = 0;
  449. let CURRENT_ROUND_DATA = null;
  450.  
  451. let switch_call = true;
  452. let one_reset = false;
  453. // let cnt = 0;
  454.  
  455. var isFirefox = typeof InstallTrigger !== 'undefined';
  456.  
  457. let linksList = []
  458. let fire1 = true;
  459. let allowDetect = false;
  460. let planetType = "None";
  461.  
  462. // Satellite Map Radius (in Meters)
  463. let ms_radius = 15000;
  464. //let sat_choice = false;
  465. const ls_sat_choice = localStorage['unity_sat_choice']; // Added by EC
  466. let sat_choice = !(ls_sat_choice === undefined || ls_sat_choice === "false"); // Added by EC
  467.  
  468. // Create the Maps, but not reload API
  469. let partialCreateYandex = false;
  470. let partialCreateKakao = false;
  471. let partialCreateMapillary = false;
  472. let partialCreateMS = false;
  473. let partialCreateMapbox = false;
  474. let partialCreateMapy = false;
  475.  
  476. // let NEW_ROUND_LOADED = false;
  477.  
  478. // Geoguessr Canvas String Names
  479.  
  480. let GENERAL_LAYOUT = `[class*="game_canvas"]`;//`[aria-label="Street View"] > canvas`;//".game-layout__canvas";
  481. let GENERAL_CANVAS = `[data-qa*="panorama-canvas"]`; //".game-layout__panorama-canvas";
  482. let BR_CANVAS = ".br-game-layout__panorama-canvas";
  483. let BR_WRAPPER = ".br-game-layout__panorama-wrapper";
  484. let BR_LAYOUT = ".br-game-layout";
  485. let FAIL_TO_LOAD_CANVAS = ".game-layout__panorama-message";
  486. let DUEL_LAYOUT = ".game_layout__TO_jf";
  487. let DUELS_CANVAS = ".game-panorama_panorama__rdhFg";
  488. let DUELS_CANVAS2 = ".game-panorama_panoramaCanvas__PNKve";
  489. let BULLSEYE_CANVAS = ".game-panorama_panorama__ncMwh";
  490. let BULLSEYE_CANVAS2 = ".game-panorama_panoramaCanvas__r_5ea";
  491. let LIVE_CANVAS = ".game-panorama_panorama__IuPsO";
  492. let LIVE_CANVAS2 = ".game-panorama_panoramaCanvas__HbDig";
  493. let DUELS_POPUP = ".overlay_overlay__AR02x";
  494. let BR_POPUP = ".popup__content";
  495.  
  496. let BR_LOAD_KAKAO = false;
  497. let BR_LOAD_YANDEX = false;
  498. let BR_LOAD_MS = false;
  499. let BR_LOAD_MP = false;
  500. let BR_LOAD_MAPILLARY = false;
  501. let BR_LOAD_MAPY = false;
  502.  
  503. let ms_sat_map = false;
  504. let rtded = false;
  505. let NM = false;
  506. let NP = false;
  507. let NZ = false;
  508.  
  509. let initBing = false;
  510.  
  511. let menuLocCounter = 0;
  512. let wikiUrl = "";
  513. let bullseyeMapillary = false;
  514. let randomPlanets = false;
  515.  
  516. let corsString = "https://nameless-bastion-28139.herokuapp.com/"
  517. // Additional: https://cors.eu.org/
  518. let carteCity = ""
  519.  
  520. let youtubeIndex = -1;
  521. let youtubeList = [];
  522.  
  523. let GAME_CANVAS = "";
  524. let DUEL_CANVAS = "";
  525.  
  526. let skySpecial = false;
  527. let soilSpecial = false;
  528. let skewedSpecial = false;
  529. let zoomSpecial = false;
  530. let randomSpecial = false;
  531. let nmpzSpecial = false;
  532.  
  533. let mosaicPre = false;
  534. let restrictMovement = false;
  535.  
  536. var Weather = false;
  537.  
  538. const ls_Dimension_choice = localStorage['Satallite_2D_3D_setting']; // Added by EC
  539. let Dimension = ls_Dimension_choice == undefined ? true /* Default = true 3D*/: (ls_Dimension_choice == "3D"? true/*3D*/: false /*2D*/); // Added by EC
  540.  
  541. var mapSty = true;
  542. var Building = false;
  543.  
  544. setTimeout(function createWindowFunctions(){
  545. // Made by EC
  546. // Trying to make this script load faster, by delaying unnecessary stuff.
  547.  
  548. window.toggleSatellite = (e) => {
  549. if (e.checked) {
  550. sat_choice = true;
  551. document.getElementById('tgs').style.display = "";
  552. }
  553. else {
  554. sat_choice = false;
  555. document.getElementById('tgs').style.display = "none";
  556. }
  557. localStorage['unity_sat_choice'] = sat_choice;
  558. }
  559.  
  560. window.toggleWeather = (e) => {
  561. Weather = e.checked ? true : false;
  562. }
  563.  
  564. window.toggleBuildings = (e) => {
  565. Building = e.checked ? true : false;
  566. }
  567.  
  568. window.toggle3D = (e) => {
  569. Dimension = e.checked ? true : false;
  570. }
  571.  
  572. window.toggleSky = (e) => {
  573. skySpecial = e.checked ? true : false;
  574. }
  575.  
  576. window.toggleSoil = (e) => {
  577. soilSpecial = e.checked ? true : false;
  578. }
  579.  
  580. window.toggleSkewed = (e) => {
  581. skewedSpecial = e.checked ? true : false;
  582. }
  583.  
  584. window.toggleMaxZoom = (e) => {
  585. zoomSpecial = e.checked ? true : false;
  586. }
  587.  
  588. window.toggleRdn = (e) => {
  589. randomSpecial = e.checked ? true : false;
  590. }
  591.  
  592. window.toggleNMPZSpecial = (e) => {
  593. nmpzSpecial = e.checked ? true : false;
  594. }
  595.  
  596. window.toggleMosaic = (e) => {
  597. mosaicPre = e.checked ? true : false;
  598. }
  599.  
  600. window.toggleRestrictMovement = (e) => {
  601. restrictMovement = e.checked ? true : false;
  602. }
  603.  
  604. window.toggleRandomMapChallenge = (_this) => {
  605. if (_this.id === 'toggleRandomMapChallenge') {
  606. initRandomMapChallenge();
  607. return;
  608. }
  609. if (_this.id === 'toggleRandomMapChallengeOnHomePage') {
  610. if (_this.checked) {
  611. localStorage["RandomMapChallenge_onHomePage"] = true;
  612. showRandomMapChallengeBtnOnHomePage(true);
  613. } else {
  614. delete localStorage["RandomMapChallenge_onHomePage"];
  615. showRandomMapChallengeBtnOnHomePage(false);
  616. }
  617. }
  618. }
  619. }, 100);
  620.  
  621. function getPathName(){
  622. // Hopefully this fixes most issues with localization.
  623. // Thanks to Destroy666x for bringing this to our attention.
  624. // https://github.com/echandler/Geoguessr-Unity-Script-Fork/issues/1
  625. return location.pathname.replace(/^\/[a-z]{2}\//i, "/");
  626. }
  627.  
  628. function getLocalizationFromPathName(){
  629. const pathname = location.pathname;
  630. const local = /^\/[a-z]{2}\//.test(pathname)? pathname[1] + pathname[2] : "en";
  631.  
  632. return local;
  633. }
  634.  
  635. let guiEnabled = true;
  636.  
  637. function guiHTML(){
  638. const sectionHeader = document.querySelector('div[class*="section_sectionHeader"]');
  639. //const standardGameModeSettings = document.querySelector('div[class*="start-standard-game_settings"]');
  640. const standardGameModeSettings = document.querySelector('div[class*="-game_settings_"]');
  641. const barsRoot = document.querySelector('div[class*="bars_root"]');
  642. const barsBefore = document.querySelector('div[class*="bars_before"]');
  643. const barsContent = document.querySelector('[class*="bars_content"]');
  644. const barsAfter = document.querySelector('div[class*="bars_after"]');
  645. const optionsLabel = `color:#fecd19; margin: 0; padding-right: 6px; font-size: 1rem; text-transform: uppercase; font-style:italic; font-size: 700;`;//document.querySelector('div[class*="label_label"]');//
  646. const bodyText = {};//document.querySelector('div[class*="body-text_bodyText"]');
  647. const toggle = {className: "toggle"};//document.querySelector('input[class*="toggle_toggle"]');
  648.  
  649. document.head.insertAdjacentHTML(
  650. // EC: Styles for toggle copied from the streaks page before it was changed to new style.
  651. "beforeend",
  652. `<style id='unity_guiHTML_styles'>
  653. .toggle:checked {
  654. background: var(--ds-color-purple-50);
  655. }
  656. .toggle {
  657. -webkit-appearance: none;
  658. -moz-appearance: none;
  659. appearance: none;
  660. background: var(--ds-color-white-10);
  661. border: 0;
  662. border-radius: 2rem;
  663. cursor: pointer;
  664. display: inline-block;
  665. height: 1.25rem;
  666. position: relative;
  667. transition: background-color .2s ease;
  668. width: 2.5rem;
  669. }
  670. input {
  671. border: .0625rem solid #ddd;
  672. box-sizing: border-box;
  673. outline: none;
  674. padding: .625rem
  675. }
  676. .toggle:before {
  677. background: var(--ds-color-purple-50);
  678. content: "";
  679. height: 100%;
  680. left: 0;
  681. opacity: 0;
  682. position: absolute;
  683. top: 0;
  684. transition: opacity .3s ease;
  685. width: 100%;
  686. }
  687. .toggle:after {
  688. background: var(--ds-color-white);
  689. border-radius: 100%;
  690. content: "";
  691. height: 1rem;
  692. left: 0;
  693. margin: 0.125rem;
  694. opacity: .1;
  695. position: absolute;
  696. top: 0;
  697. transition: transform .1s ease, opacity .1s ease;
  698. width: 1rem;
  699. }
  700. .toggle:checked:after {
  701. opacity: 1;
  702. transform: translateX(125%);
  703. }
  704. </style>`);
  705.  
  706. return `
  707. <div id="Unity Start Menu" style="margin: 0px auto; text-align: center; color: grey; padding: 1rem; backdrop-filter: blur(1000px); border-radius: 10px; --hlColor: #a19bd9; --hlTextColor: var(--hlColor);">
  708. <div class="${sectionHeader?.className}">
  709. <div class="${barsRoot?.className}" style="display:flex; align-items: center; margin-bottom: 1rem;">
  710. <div class="${barsBefore?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  711. <span class="${barsContent?.className}" style="font-style: italic; padding: 0px 1rem; color: var(--hlTextColor);"> <h3>Satellite Mode (Unity Script)</h3> </span>
  712. <div class="${barsAfter?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  713. </div>
  714. </div>
  715. <div class="${standardGameModeSettings?.className}">
  716. <div style="display: flex; justify-content: space-around;">
  717. <div style="display: flex; align-items: center;">
  718.  
  719. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  720. <span class="${optionsLabel?.className}" style="${optionsLabel}">Enabled</span>
  721. <input type="checkbox" id="toggleSatellite" onclick="toggleSatellite(this)" class="${toggle?.className}">
  722. </label>
  723.  
  724. </div>
  725. </div>
  726. <p class="${bodyText?.className}" style="margin-top: 1rem;margin-bottom: 1rem;${bodyText?.style?.cssText}">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>
  727. </div>
  728. <div class="${standardGameModeSettings?.className}" id="tgs" style="display:none">
  729. <div style="display: flex; justify-content: space-around;">
  730. <div style="display: flex; align-items: center;">
  731.  
  732. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  733. <span class="${optionsLabel?.className}" style="${optionsLabel}">Live Weather</span>
  734. <input type="checkbox" id="toggleWeather" onclick="toggleWeather(this)" class="${toggle?.className}">
  735. </label>
  736.  
  737. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  738. <span class="${optionsLabel?.className}" style="${optionsLabel}">Buildings</span>
  739. <input type="checkbox" id="toggleBuildings" onclick="toggleBuildings(this)" class="${toggle?.className}">
  740. </label>
  741.  
  742. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  743. <span class="${optionsLabel?.className}" style="${optionsLabel}">3D</span>
  744. <input type="checkbox" id="toggle3D" onclick="toggle3D(this)" class="${toggle?.className}">
  745. </label>
  746. </div>
  747. </div>
  748. <p class="${bodyText?.className}" style="margin-top: 1rem;margin-bottom: 1rem;${bodyText?.style?.cssText}">If "3D" is toggled, right click and drag for 3D View.</p>
  749. </div>
  750.  
  751. <!-- Section -->
  752.  
  753. <!-- Random Map Challenge by Alok -->
  754.  
  755. <div class="${sectionHeader?.className}">
  756. <div class="${barsRoot?.className}"style="display:flex; align-items: center; margin-bottom: 1rem;">
  757. <div class="${barsBefore?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  758. <span class="${barsContent?.className}" style="font-style: italic; padding: 0px 1rem; color: var(--hlTextColor);" title="Invented by Alok!"><h3>Alok's Radical Random Map Challenge Mode (Unity Script)</h3></span>
  759. <div class="${barsAfter?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);" ></div>
  760. </div>
  761. </div>
  762. <div class="${standardGameModeSettings?.className}">
  763. <div style="display: flex; justify-content: space-around;">
  764. <div style="display: flex; align-items: center;">
  765.  
  766. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  767. <span class="${optionsLabel?.className}" style="${optionsLabel}">Enabled</span>
  768. <input type="checkbox" id="toggleRandomMapChallenge" onclick="toggleRandomMapChallenge(this)" class="${toggle?.className}">
  769. </label>
  770.  
  771. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  772. <span class="${optionsLabel?.className}" style="${optionsLabel}">Show on homepage?</span>
  773. <input type="checkbox" id="toggleRandomMapChallengeOnHomePage" onclick="toggleRandomMapChallenge(this)" class="${toggle?.className}">
  774. </label>
  775. </div>
  776. </div>
  777. <!--
  778. <div style="display: flex; justify-content: space-around;">
  779. <div style="display: flex; align-items: center;">
  780. <span class="${optionsLabel?.className}" style="${optionsLabel}">Show on homepage?</span>
  781. <input type="checkbox" id="toggleRandomMapChallengeOnHomePage" onclick="toggleRandomMapChallenge(this)" class="${toggle?.className}">
  782. </div>
  783. </div>
  784. -->
  785. <p class="${bodyText?.className}" style="margin-top: 1rem;margin-bottom: 1rem;">Inspired by Trackmania, how many random maps can you play in a set amount of time?</p>
  786. </div>
  787.  
  788. <!-- Section -->
  789.  
  790. <div class="${sectionHeader?.className}">
  791. <div class="${barsRoot?.className}" style="display:flex; align-items: center; margin-bottom: 1rem;">
  792. <div class="${barsBefore?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  793. <span class="${barsContent?.className}" style="font-style: italic; padding: 0px 1rem; color: var(--hlTextColor);"><h3>Mosaic & Peek Mode (Unity Script)</h3></span>
  794. <div class="${barsAfter?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  795. </div>
  796. </div>
  797. <div class="${standardGameModeSettings?.className}">
  798. <div style="display: flex; justify-content: space-around;">
  799. <div style="display: flex; align-items: center;">
  800. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  801. <span class="${optionsLabel?.className}" style="${optionsLabel}">Enabled</span>
  802. <input type="checkbox" id="toggleMosaic" onclick="toggleMosaic(this)" class="${toggle?.className}">
  803. </label>
  804. </div>
  805. </div>
  806. <p class="${bodyText?.className}" style="margin-top: 1rem;margin-bottom: 1rem;">Default mosaic grid: 5x5.</p>
  807. </div>
  808.  
  809. <!-- Section -->
  810.  
  811. <div class="${sectionHeader?.className}">
  812. <div class="${barsRoot?.className}" style="display:flex; align-items: center; margin-bottom: 1rem;">
  813. <div class="${barsBefore?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  814. <span class="${barsContent?.className}" style="font-style: italic; padding: 0px 1rem; color: var(--hlTextColor);"><h3>No Escape Mode (Unity Script)</h3></span>
  815. <div class="${barsAfter?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  816. </div>
  817. </div>
  818. <div class="${standardGameModeSettings?.className}">
  819. <div style="display: flex; justify-content: space-around;">
  820. <div style="display: flex; align-items: center;">
  821. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  822. <span class="${optionsLabel?.className}" style="${optionsLabel}">Enabled</span>
  823. <input type="checkbox" id="toggleRestrictMovement" onclick="toggleRestrictMovement(this)" class="${toggle?.className}">
  824. </labe>
  825. </div>
  826. </div>
  827. <p class="${bodyText?.className}" style="margin-top: 1rem;margin-bottom: 1rem;">Please make sure the "Move" option in Game Settings is allowed. Default radius: 250m.</p>
  828. </div>
  829.  
  830. <!-- Section -->
  831.  
  832. <div class="${sectionHeader?.className}">
  833. <div class="${barsRoot?.className}" style="display:flex; align-items: center; margin-bottom: 1rem;">
  834. <div class="${barsBefore?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  835. <span class="${barsContent?.className}" style="font-style: italic; padding: 0px 1rem; color: var(--hlTextColor);"><h3>Circus Mode (Unity Script)</h3></span>
  836. <div class="${barsAfter?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  837. </div>
  838. </div>
  839. <div class="${standardGameModeSettings?.className}">
  840. <div style="display: flex; justify-content: space-around;">
  841. <div style="display: flex; align-items: center;">
  842. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  843. <span class="${optionsLabel?.className}" style="${optionsLabel}">Sky</span>
  844. <input type="checkbox" id="toggleSky" onclick="toggleSky(this)" class="${toggle?.className}">
  845. </label>
  846. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  847. <span class="${optionsLabel?.className}" style="${optionsLabel}">Soiled</span>
  848. <input type="checkbox" id="toggleSoil" onclick="toggleSoil(this)" class="${toggle?.className}">
  849. </label>
  850. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  851. <span class="${optionsLabel?.className}" style="${optionsLabel}">Skewed</span>
  852. <input type="checkbox" id="toggleSkewed" onclick="toggleSkewed(this)" class="${toggle?.className}">
  853. </label>
  854. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  855. <span class="${optionsLabel?.className}" style="${optionsLabel}">Max Zoom</span>
  856. <input type="checkbox" id="toggleMaxZoom" onclick="toggleMaxZoom(this)" class="${toggle?.className}">
  857. </label>
  858. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  859. <span class="${optionsLabel?.className}" style="${optionsLabel}">Random</span>
  860. <input type="checkbox" id="toggleRdn" onclick="toggleRdn(this)" class="${toggle?.className}">
  861. </label>
  862. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  863. <span class="${optionsLabel?.className}" style="${optionsLabel}">NMPZ</span>
  864. <input type="checkbox" id="toggleNMPZSpecial" onclick="toggleNMPZSpecial(this)" class="${toggle?.className}">
  865. </label>
  866. </div>
  867. </div>
  868. <p class="${bodyText?.className}" style="margin-top: 1rem;margin-bottom: 1rem;${bodyText?.style?.cssText}">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>
  869. </div>
  870. </div>
  871. `;
  872. }
  873.  
  874.  
  875. const checkInsertGui = () => {
  876. if (document.querySelector(`div[class*="map-block_root"]`) && document.getElementById('toggleSky') === null){
  877.  
  878. document.querySelector(`div[class*="map-block_root"]`).lastChild.remove();
  879. document.querySelector(`div[class*="map-block_root"]`).insertAdjacentHTML('beforeend', guiHTML());
  880.  
  881. if (sat_choice) {
  882. document.getElementById('toggleSatellite').checked = true;
  883. document.getElementById('tgs').style.display = "";
  884. }
  885. if (Weather)
  886. {
  887. document.getElementById('toggleWeather').checked = true;
  888. }
  889. if (Building)
  890. {
  891. document.getElementById('toggleBuildings').checked = true;
  892. }
  893. if (Dimension)
  894. {
  895. document.getElementById('toggle3D').checked = true;
  896. }
  897. if (skySpecial) {
  898. document.getElementById('toggleSky').checked = true;
  899. }
  900. if (soilSpecial) {
  901. document.getElementById('toggleSoil').checked = true;
  902. }
  903. if (skewedSpecial) {
  904. document.getElementById('toggleSkewed').checked = true;
  905. }
  906. if (zoomSpecial) {
  907. document.getElementById('toggleMaxZoom').checked = true;
  908. }
  909. if (randomSpecial) {
  910. document.getElementById('toggleRdn').checked = true;
  911. }
  912. if (nmpzSpecial)
  913. {
  914. document.getElementById('toggleNMPZSpecial').checked = true;
  915. }
  916. if (mosaicPre)
  917. {
  918. document.getElementById('toggleMosaic').checked = true;
  919. }
  920. if (restrictMovement)
  921. {
  922. document.getElementById('toggleRestrictMovement').checked = true;
  923. }
  924. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  925. if ((rmcMenuBtn && rmcMenuBtn.style.display !== "none") || localStorage["RandomMapChallenge"])
  926. {
  927. // Added by EC
  928. document.getElementById('toggleRandomMapChallenge').checked = true;
  929. }
  930. if (localStorage["RandomMapChallenge_onHomePage"]){
  931. // Added by EC
  932. document.getElementById('toggleRandomMapChallengeOnHomePage').checked = true;
  933. }
  934. }
  935. }
  936.  
  937. let observerNew = new MutationObserver((mutations) => {
  938. // Inserts Menu on map options screen.
  939. if (guiEnabled) {
  940. checkInsertGui();
  941. }
  942. if (document.getElementById('Unity Start Menu'))
  943. {
  944. if (document.querySelector('div[class*="map-selector_root"]'))
  945. {
  946. document.getElementById('Unity Start Menu').style.display = "";
  947. }
  948. else
  949. {
  950. document.getElementById('Unity Start Menu').style.display = "none";
  951. }
  952. }
  953. });
  954.  
  955. observerNew.observe(document.body, {
  956. characterDataOldValue: false,
  957. subtree: true,
  958. childList: true,
  959. characterData: false
  960. });
  961.  
  962. function sleep(milliseconds) {
  963. var start = new Date().getTime();
  964. for (var i = 0; i < 1e7; i++) {
  965. if ((new Date().getTime() - start) > milliseconds){
  966. break;
  967. }
  968. }
  969. }
  970.  
  971. // window.addEventListener('popstate', function(event) {
  972. // var photo = document.getElementById("sat_map");
  973. // console.log(photo);
  974. // document.body.appendChild(photo);
  975. // }, false);
  976.  
  977.  
  978.  
  979. /**
  980. * Helper Functions
  981. */
  982.  
  983. // Highlight API Load Message
  984.  
  985. function myHighlight(...args) {
  986. console.log(`%c${[...args]}`, "color: dodgerblue; font-size: 24px;");
  987. }
  988.  
  989. // Hex to number conversion for Baidu coordinate conversion
  990.  
  991. function hex2a(hexx) {
  992. var hex = hexx.toString();
  993. var str = '';
  994. for (var i = 0; i < hex.length; i += 2)
  995. {
  996. str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
  997. }
  998. return str;
  999. }
  1000. window._hex2a = hex2a;
  1001.  
  1002. // Coordinate computation given heading, distance and current coordinates for teleport
  1003.  
  1004. function FindPointAtDistanceFrom(lat, lng, initialBearingRadians, distanceKilometres) {
  1005. const radiusEarthKilometres = 6371.01;
  1006. var distRatio = distanceKilometres / radiusEarthKilometres;
  1007. var distRatioSine = Math.sin(distRatio);
  1008. var distRatioCosine = Math.cos(distRatio);
  1009.  
  1010. var startLatRad = DegreesToRadians(lat);
  1011. var startLonRad = DegreesToRadians(lng);
  1012.  
  1013. var startLatCos = Math.cos(startLatRad);
  1014. var startLatSin = Math.sin(startLatRad);
  1015.  
  1016. var endLatRads = Math.asin((startLatSin * distRatioCosine) + (startLatCos * distRatioSine * Math.cos(initialBearingRadians)));
  1017.  
  1018. var endLonRads = startLonRad
  1019. + Math.atan2(
  1020. Math.sin(initialBearingRadians) * distRatioSine * startLatCos,
  1021. distRatioCosine - startLatSin * Math.sin(endLatRads));
  1022.  
  1023. return { lat: RadiansToDegrees(endLatRads), lng: RadiansToDegrees(endLonRads) };
  1024. }
  1025.  
  1026. function DegreesToRadians(degrees) {
  1027. const degToRadFactor = Math.PI / 180;
  1028. return degrees * degToRadFactor;
  1029. }
  1030.  
  1031. function RadiansToDegrees(radians) {
  1032. const radToDegFactor = 180 / Math.PI;
  1033. return radians * radToDegFactor;
  1034. }
  1035.  
  1036. function toRadians(degrees) {
  1037. return degrees * Math.PI / 180;
  1038. };
  1039.  
  1040. // Converts from radians to degrees.
  1041. function toDegrees(radians) {
  1042. return radians * 180 / Math.PI;
  1043. }
  1044.  
  1045. function bearing(start_latitude, start_longitude, stop_latitude, stop_longitude){
  1046. let y = Math.sin(stop_longitude-start_longitude) * Math.cos(stop_latitude);
  1047. let x = Math.cos(start_latitude)*Math.sin(stop_latitude) -
  1048. Math.sin(start_latitude)*Math.cos(stop_latitude)*Math.cos(stop_longitude-start_longitude);
  1049. let brng = Math.atan2(y, x) * 180 / Math.PI;
  1050. return brng
  1051. }
  1052.  
  1053. // Check if two floating point numbers are really really really really close to each other (to 10 decimal points)
  1054. function almostEqual (a, b) {
  1055. return a.toFixed(10) === b.toFixed(10)
  1056. }
  1057.  
  1058. function almostEqual2 (a, b) {
  1059. return a.toFixed(3) === b.toFixed(3)
  1060. }
  1061.  
  1062. function moveFrom(coords, angle, distance){
  1063. const R_EARTH = 6378.137;
  1064. const M = (1 / ((2 * Math.PI / 360) * R_EARTH)) / 1000;
  1065. let radianAngle = -angle * Math.PI / 180;
  1066. let x = 0 + (distance * Math.cos(radianAngle));
  1067. let y = 0 + (distance * Math.sin(radianAngle));
  1068.  
  1069. let newLat = coords.lat + (y * M);
  1070. let newLng = coords.lng + (x * M) / Math.cos(coords.lat * (Math.PI / 180));
  1071. return { lat: newLat, lng: newLng };
  1072. }
  1073.  
  1074. function getBBox(coordinates, meters){
  1075. let SW = moveFrom(coordinates, 135, meters);
  1076. let NE = moveFrom(coordinates, 315, meters);
  1077. return `${SW.lng},${SW.lat},${NE.lng},${NE.lat}`;
  1078. }
  1079.  
  1080. // function getBBox2(coordinates, meters){
  1081. // let SW = moveFrom(coordinates, 135, meters * 1.44);
  1082. // let NE = moveFrom(coordinates, 315, meters * 1.44);
  1083. // return [NE.lat,SW.lng,SW.lat,NE.lng];
  1084. // }
  1085.  
  1086. function getBBox2(coordinates, meters){
  1087. let SW = moveFrom(coordinates, 135, meters * 1.44);
  1088. let NE = moveFrom(coordinates, 315, meters * 1.44);
  1089. if (NE.lat > 90)
  1090. {
  1091. SW.lat -= (NE.lat - 90);
  1092. NE.lat = 90;
  1093. }
  1094. if (SW.lat < -90)
  1095. {
  1096. NE.lat += (-90 - SW.lat);
  1097. SW.lat = -90;
  1098. }
  1099. if (SW.lng < -180)
  1100. {
  1101. NE.lng += (-180 - SW.lng);
  1102. SW.lng = -180;
  1103. }
  1104. if (NE.lng > 180)
  1105. {
  1106. SW.lng -= (NE.lng - 180);
  1107. NE.lng = 180;
  1108. }
  1109. return [NE.lat,SW.lng,SW.lat,NE.lng];
  1110. }
  1111.  
  1112. function distance(lat1, lon1, lat2, lon2) {
  1113. var p = 0.017453292519943295; // Math.PI / 180
  1114. var c = Math.cos;
  1115. var a = 0.5 - c((lat2 - lat1) * p)/2 +
  1116. c(lat1 * p) * c(lat2 * p) *
  1117. (1 - c((lon2 - lon1) * p))/2;
  1118.  
  1119. return 1000 * 12742 * Math.asin(Math.sqrt(a)); // 2 * R; R = 6371 km
  1120. }
  1121.  
  1122. function convertMMSS(input) {
  1123. var parts = input.split(':'),
  1124. minutes = +parts[0],
  1125. seconds = +parts[1];
  1126. return (minutes * 60 + seconds).toFixed(3);
  1127. }
  1128.  
  1129. function handleBtwRoundsClear()
  1130. {
  1131. youtubeIndex = -1;
  1132. youtubeList = [];
  1133. locHistory = [];
  1134. wikiUrl = "";
  1135. one_reset = false;
  1136. // let iframe = document.getElementById("i_container");
  1137. // if (iframe && nextPlayer !== "Image")
  1138. // {
  1139. // iframe.src = "";
  1140. // }
  1141. }
  1142.  
  1143. // Script injection, extracted from extenssr:
  1144. // https://gitlab.com/nonreviad/extenssr/-/blob/main/src/injected_scripts/maps_api_injecter.ts
  1145.  
  1146. function overrideOnLoad(googleScript, observer, overrider) {
  1147. const oldOnload = googleScript.onload
  1148. if (window.google){
  1149. // Delete this before uploading.
  1150. // alert('window google')
  1151. }
  1152. googleScript.onload = (event) => {
  1153. const google = window.google
  1154. if (google) {
  1155. observer.disconnect()
  1156. overrider(google)
  1157. }
  1158. if (oldOnload) {
  1159. oldOnload.call(googleScript, event)
  1160. }
  1161. }
  1162. }
  1163.  
  1164. function grabGoogleScript(mutations) {
  1165. for (const mutation of mutations) {
  1166. for (const newNode of mutation.addedNodes) {
  1167. const asScript = newNode
  1168. if (asScript && asScript.src && asScript.src.startsWith('https://maps.googleapis.com/')) {
  1169. //asScript.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyDqRTXlnHXELLKn7645Q1L_5oc4CswKZK4&v=3&libraries=places,drawing&language=ja&region=JP"
  1170. return asScript
  1171. }
  1172. }
  1173. }
  1174. return null
  1175. }
  1176.  
  1177. function injecter(overrider) {
  1178. if (document.documentElement)
  1179. {
  1180. injecterCallback(overrider);
  1181. }
  1182. else
  1183. {
  1184. alert("Script didn't load, refresh to try loading the script");
  1185. }
  1186. }
  1187.  
  1188.  
  1189. function injecterCallback(overrider)
  1190. {
  1191. new MutationObserver((mutations, observer) => {
  1192. const googleScript = grabGoogleScript(mutations)
  1193. if (googleScript) {
  1194. overrideOnLoad(googleScript, observer, overrider)
  1195. }
  1196. }).observe(document.documentElement, { childList: true, subtree: true })
  1197. }
  1198.  
  1199. function magic_formula(boundary)
  1200. {
  1201. let area = Math.abs((boundary[0] - boundary[2]) * (boundary[1] - boundary[3]))
  1202. // console.log(boundary);
  1203. // console.log(area);
  1204. let dist = Math.pow((area / 50000), 0.25) * 20000
  1205. if (dist < 250) dist = 250
  1206. return dist
  1207. }
  1208.  
  1209. function formatDist()
  1210. {
  1211. if (ms_radius > 999)
  1212. {
  1213. let d = ms_radius / 1000.0;
  1214. return parseFloat(d.toPrecision(2)).toString() + "km";
  1215. }
  1216. else
  1217. {
  1218. let d = ms_radius;
  1219. return parseFloat(d.toPrecision(3)).toString() + "m";
  1220. }
  1221. }
  1222.  
  1223. // Getter function for the button elements
  1224.  
  1225. function setButtons()
  1226. {
  1227. return [document.getElementById("Teleport Forward"), document.getElementById("Teleport Reverse"), document.getElementById("Teleport Button"), document.getElementById("plus"), document.getElementById("minus"),
  1228. document.getElementById("reset"), document.getElementById("switch"), document.getElementById("Show Buttons"),
  1229. document.getElementById("Date Button"), document.getElementById("minus year"), document.getElementById("plus year"),
  1230. document.getElementById("Teleport Options Button"), document.getElementById("Satellite Switch"),
  1231. document.getElementById("Restrict Bounds Main"),
  1232. document.getElementById("Restrict Distance"), document.getElementById("Increase Restrict Distance"),
  1233. document.getElementById("Decrease Restrict Distance"), document.getElementById("Restrict Bounds Enable"),
  1234. document.getElementById("Restrict Distance Reset")];
  1235. }
  1236.  
  1237. function setButtons2()
  1238. {
  1239. return [document.getElementById("Show Buttons"),
  1240. document.getElementById("Youtube Button"),
  1241. document.getElementById("Info Menu"),
  1242. document.getElementById("Teleport Menu"),
  1243. document.getElementById("Satellite Menu"),
  1244. document.getElementById("Mosaic Menu"),
  1245. document.getElementById("Minimap Menu Button"),
  1246. document.getElementById("Space Menu Button"),
  1247. document.getElementById("Time Machine Button"),
  1248. document.getElementById("Circus Menu"),
  1249. ];
  1250. }
  1251.  
  1252. function setButtons3()
  1253. {
  1254. // Added by EC - same as setButtons2 but with out youtube button.
  1255. return [document.getElementById("Show Buttons"),
  1256. document.getElementById("Info Menu"),
  1257. document.getElementById("Teleport Menu"),
  1258. document.getElementById("Satellite Menu"),
  1259. document.getElementById("Mosaic Menu"),
  1260. document.getElementById("Minimap Menu Button"),
  1261. document.getElementById("Space Menu Button"),
  1262. document.getElementById("Time Machine Button"),
  1263. document.getElementById("Circus Menu"),
  1264. ];
  1265. }
  1266.  
  1267. // Store default position for the button elements
  1268.  
  1269. function btnPosFinal(element)
  1270. {
  1271. if (element.id !== "Show Buttons")
  1272. {
  1273. if (element.classList.contains("menu-btn"))
  1274. {
  1275. element.style.right = "0.5em";
  1276. }
  1277.  
  1278. if (element.classList.contains("full") || element.classList.contains("extra-full"))
  1279. {
  1280. element.style.right = "4em";
  1281. }
  1282. else if (element.classList.contains("half"))
  1283. {
  1284. if (element.classList.contains("horizontal-1"))
  1285. {
  1286. element.style.right = "4em";
  1287. }
  1288. else if (element.classList.contains("horizontal-2"))
  1289. {
  1290. element.style.right = "11.75em";
  1291. }
  1292. else if (element.classList.contains("horizontal-3"))
  1293. {
  1294. element.style.right = "19.5em";
  1295. }
  1296. }
  1297. else if (element.classList.contains("small"))
  1298. {
  1299. if (element.classList.contains("horizontal-1"))
  1300. {
  1301. element.style.right = "17em";
  1302. }
  1303. else if (element.classList.contains("horizontal-3"))
  1304. {
  1305. element.style.right = "4em";
  1306. }
  1307. else if (element.classList.contains("horizontal-sp"))
  1308. {
  1309. element.style.right = "14.5em";
  1310. }
  1311. }
  1312. else if (element.classList.contains("large"))
  1313. {
  1314. element.style.right = "6.5em";
  1315. }
  1316. else if (element.classList.contains("lgMinus"))
  1317. {
  1318. element.style.right = "6.5em";
  1319. }
  1320.  
  1321. if (element.classList.contains("vertical-0"))
  1322. {
  1323. element.style.top = "6em";
  1324. }
  1325. else if (element.classList.contains("vertical-1"))
  1326. {
  1327. element.style.top = "9.5em";
  1328. }
  1329. else if (element.classList.contains("vertical-2"))
  1330. {
  1331. element.style.top = "12em";
  1332. }
  1333. else if (element.classList.contains("vertical-3"))
  1334. {
  1335. element.style.top = "14.5em";
  1336. }
  1337. else if (element.classList.contains("vertical-4"))
  1338. {
  1339. element.style.top = "17em";
  1340. }
  1341. else if (element.classList.contains("vertical-5"))
  1342. {
  1343. element.style.top = "19.5em";
  1344. }
  1345. else if (element.classList.contains("vertical-6"))
  1346. {
  1347. element.style.top = "22em";
  1348. }
  1349. else if (element.classList.contains("vertical-7"))
  1350. {
  1351. element.style.top = "24.5em";
  1352. }
  1353. }
  1354. }
  1355.  
  1356. function handleDropdown()
  1357. {
  1358. function dropdownHelper1(nm, val)
  1359. {
  1360. let hC = 0
  1361. for (let mapDiv of document.getElementsByClassName(nm)){
  1362. mapDiv.style.top = (val + (hC * 1.65)).toString() + "em";
  1363. hC++;
  1364. }
  1365. }
  1366.  
  1367. // let classN = ["preset-minimap", "overlay-minimap", "space-mainmap", "space-minimap"]
  1368. let classN = ["preset-minimap", "overlay-minimap", "space-minimap", "space-2minimap", "space-3minimap"]
  1369. for (let x of classN)
  1370. {
  1371. dropdownHelper1(x, 11.85);
  1372. }
  1373. let classN2 = ["grid-size", "grid-opt", "satellite-style", "satellite-type"];
  1374. for (let x of classN2)
  1375. {
  1376. dropdownHelper1(x, 14.1);
  1377. }
  1378. allowDetect = true;
  1379. }
  1380.  
  1381. function resetBtnPos()
  1382. {
  1383. let [
  1384. mainMenuBtn,
  1385. YoutubeBtn,
  1386. infoMenu,
  1387. teleportMenu,
  1388. satelliteMenu,
  1389. mosaicMenu,
  1390. MinimapMenuBtn,
  1391. SpaceMenuBtn,
  1392. ClockMenuBtn,
  1393. SpecialMapMenuBtn
  1394. ] = setButtons2();
  1395.  
  1396. // Manu Buttons
  1397.  
  1398. mainMenuBtn.style.top = "6em";
  1399. YoutubeBtn.style.top = "6em";
  1400. infoMenu.style.top = "9.5em";
  1401. teleportMenu.style.top = "12.5em";
  1402. MinimapMenuBtn.style.top = "15.5em";
  1403. satelliteMenu.style.top = "18.5em";
  1404. SpaceMenuBtn.style.top = "21.5em";
  1405. mosaicMenu.style.top = "24.5em";
  1406. ClockMenuBtn.style.top = "27.5em";
  1407. SpecialMapMenuBtn.style.top = "30.5em";
  1408.  
  1409. mainMenuBtn.style.right = "0.5em";
  1410. mainMenuBtn.style.width = "3em";
  1411.  
  1412. for (let element of document.getElementsByClassName("unity-btn")){
  1413. btnPosFinal(element);
  1414. }
  1415. handleDropdown();
  1416.  
  1417. }
  1418.  
  1419. // Adjust Buttons for different game modes
  1420.  
  1421. function AdjustBtnPos(top, right, arg)
  1422. {
  1423. if (arg)
  1424. {
  1425. resetBtnPos();
  1426. }
  1427. for (let element of document.getElementsByClassName("unity-btn")){
  1428. let eTop = element.style.top;
  1429. let eRight = element.style.right;
  1430. element.style.top = "calc(" + top.toString() + " + " + eTop + ")";
  1431. element.style.right = "calc(" + right.toString() + " + " + eRight + ")";
  1432. // console.log(element.style.top)
  1433. }
  1434. }
  1435.  
  1436. function handleStyles()
  1437. {
  1438. let unityCSS =
  1439. `visibility:hidden;
  1440. border-radius: 25px;
  1441. height:2em;
  1442. position:fixed;
  1443. z-index:99990;
  1444. background-color: #ba55d3cc;
  1445. box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
  1446. border: none;
  1447. color: white;
  1448. padding: none;
  1449. text-align: center;
  1450. vertical-align: text-top;
  1451. text-decoration: none;
  1452. display: inline-block;
  1453. font-size: 16px;`;
  1454.  
  1455. for (let element of document.getElementsByClassName("unity-btn")){
  1456. if (element.id !== "Show Buttons")
  1457. {
  1458. element.style = unityCSS;
  1459. // const classNames = ["preset-minimap", "overlay-minimap", "satellite-style", "satellite-type", "space-mainmap", "space-minimap"]
  1460. const classNames = ["preset-minimap", "overlay-minimap", "satellite-style", "satellite-type", "space-minimap","space-2minimap","space-3minimap", "grid-size", "grid-opt"]
  1461. if (classNames.some(className => element.classList.contains(className)))
  1462. {
  1463. element.style.height = "1.5em";
  1464. element.style.background = "#ff69b4cc";
  1465. if (["Clear", "Default", "Earth", "Grid 0"].includes(element.id))
  1466. {
  1467. if (element.id == "Clear")
  1468. {
  1469. element.loaded = true;
  1470. }
  1471. element.style.background = "#ff1493cc";
  1472. }
  1473. }
  1474.  
  1475. if (element.classList.contains("menu-btn"))
  1476. {
  1477. element.style.width = "3em";
  1478. element.style.height = "2.5em";
  1479. // element.style.borderStyle = "solid";
  1480. // element.style.borderWidth = "0.1px"
  1481. // element.style.borderColor = "black";
  1482.  
  1483. }
  1484.  
  1485. if (element.classList.contains("special-map-btn") && !element.classList.contains("full"))
  1486. {
  1487. element.style.background = "#ff69b4cc";
  1488. }
  1489.  
  1490. if (element.classList.contains("extra-height"))
  1491. {
  1492. element.style.height = "4.5em";
  1493. }
  1494.  
  1495. if (element.classList.contains("extra-full"))
  1496. {
  1497. element.style.width = "22.75em";
  1498. }
  1499. else if (element.classList.contains("full"))
  1500. {
  1501. element.style.width = "15em";
  1502. }
  1503. else if (element.classList.contains("half"))
  1504. {
  1505. element.style.width = "7.25em";
  1506. }
  1507. else if (element.classList.contains("small"))
  1508. {
  1509. element.style.width = "2em";
  1510. }
  1511. else if (element.classList.contains("large"))
  1512. {
  1513. element.style.width = "10em";
  1514. }
  1515. else if (element.classList.contains("lgMinus"))
  1516. {
  1517. element.style.width = "7.5em";
  1518. }
  1519. btnPosFinal(element);
  1520. }
  1521. }
  1522.  
  1523. let dict = {
  1524. 'Info Menu': ["url(https://www.svgrepo.com/show/299161/big-data.svg)", "#ff9999"],
  1525. 'Teleport Menu': ["url(https://www.svgrepo.com/show/12767/car.svg)", "#ffcba4"],
  1526. "Time Machine Button": ["url(https://www.svgrepo.com/show/38630/clock.svg)", "#D8BFD8"],
  1527. 'Minimap Menu Button': ["url(https://www.svgrepo.com/show/116365/map.svg)", "#faf0be"],
  1528. 'Mosaic Menu': ["url(https://www.svgrepo.com/show/77240/map.svg)", "#E6E6FA"],
  1529. 'Satellite Menu': ["url(https://www.svgrepo.com/show/29288/satellite.svg)", "#e8f48c"],
  1530. 'Space Menu Button': ["url(https://www.svgrepo.com/show/120980/saturn.svg)", "#e0ffff"],
  1531. 'Circus Menu': ["url(https://www.svgrepo.com/show/296852/circus.svg)", "#ff99c2"],
  1532. };
  1533.  
  1534. for (let element of document.getElementsByClassName("menu-btn"))
  1535. {
  1536. element.style.backgroundImage = dict[element.id][0];
  1537. element.style.backgroundColor = dict[element.id][1];
  1538. element.style.backgroundRepeat = "no-repeat";
  1539. element.style.backgroundOrigin = "content-box";
  1540. element.style.backgroundSize = "50%";
  1541. element.style.backgroundPositionX = "50%";
  1542. element.style.backgroundPositionY = "50%";
  1543. element.style.visibility = "";
  1544. }
  1545.  
  1546. handleDropdown();
  1547. }
  1548.  
  1549. /**
  1550. * Creates Unity buttons
  1551. *
  1552. * @returns Promise
  1553. */
  1554.  
  1555. function hideOtherBtn()
  1556. {
  1557. for (let element of document.getElementsByClassName("unity-btn")){
  1558. if (element.id !== "Show Buttons")
  1559. {
  1560. if (!element.styleTop){
  1561. element.styleTop = element.style.top;
  1562. }
  1563. clearTimeout(element._timer);
  1564.  
  1565. element.style.transition = "0.2s top ease";
  1566. element.style.top = "calc(6em)";
  1567. element._timer = setTimeout(()=>{
  1568. element.style.visibility = "hidden";
  1569. element.style.transition = "";
  1570. }, 950)
  1571.  
  1572. if (!element.classList.contains("menu-btn")) { element.style.visibility = "hidden"; }
  1573. }
  1574. if (nextPlayer == "Youtube" && element.classList.contains("youtube-btn"))
  1575. {
  1576. element.style.visibility = "";
  1577. }
  1578. if (nextPlayer == "Wikipedia" && (element.id == "local language" || element.id == "wikiXplore_btn"))
  1579. {
  1580. element.style.visibility = "";
  1581. }
  1582. }
  1583. }
  1584.  
  1585. function switchBtn(arg)
  1586. {
  1587. for (let element of document.getElementsByClassName("unity-btn")){
  1588. if (element.id !== "Show Buttons" && !element.classList.contains("menu-btn") && !element.classList.contains(arg))
  1589. {
  1590. element.style.visibility = "hidden";
  1591. }
  1592. if (nextPlayer == "Youtube" && element.classList.contains("youtube-btn"))
  1593. {
  1594. element.style.visibility = "";
  1595. }
  1596. if (nextPlayer == "Wikipedia" && (element.id == "local language" || element.id == "wikiXplore_btn"))
  1597. {
  1598. element.style.visibility = "";
  1599. }
  1600. }
  1601. }
  1602.  
  1603. function getVar(argm)
  1604. {
  1605. if (argm == "Weather")
  1606. {
  1607. return Weather;
  1608. }
  1609. else if (argm == "Building")
  1610. {
  1611. return Building;
  1612. }
  1613. else if (argm == "Dimension")
  1614. {
  1615. return Dimension;
  1616. }
  1617. else if (argm == "mapSty")
  1618. {
  1619. return mapSty;
  1620. }
  1621. else
  1622. {
  1623. return false;
  1624. }
  1625. }
  1626.  
  1627. function setVar(argm)
  1628. {
  1629. if (argm == "Weather")
  1630. {
  1631. Weather = !Weather;
  1632. }
  1633. else if (argm == "Building")
  1634. {
  1635. Building = !Building;
  1636. }
  1637. else if (argm == "Dimension")
  1638. {
  1639. Dimension = !Dimension;
  1640.  
  1641. // Added by EC
  1642. localStorage["Satallite_2D_3D_setting"] = Dimension === true? "3D" : "2D";
  1643. }
  1644. else if (argm == "mapSty")
  1645. {
  1646. mapSty = !mapSty;
  1647. }
  1648. }
  1649.  
  1650. function handleSatColor(cond1, cond2)
  1651. {
  1652. // Added by EC: Button innerHTML and background color is added in this function.
  1653.  
  1654. let sC = document.getElementById("Satellite Type Button");
  1655. if (cond1)
  1656. {
  1657. for (let element of satType)
  1658. {
  1659. let ele0 = document.getElementById(element[0]);
  1660. let strNmHere;
  1661. if (ele0.id !== "SunPos")
  1662. {
  1663. strNmHere = getVar(ele0.id);
  1664. }
  1665. else
  1666. {
  1667. strNmHere = ele0.id;
  1668. }
  1669. if (strNmHere)
  1670. {
  1671. ele0.innerHTML = element[1];
  1672. ele0.style.background = "#ff1493cc";
  1673. }
  1674. else
  1675. {
  1676. ele0.innerHTML = element[2];
  1677. ele0.style.background = "#ff69b4cc";
  1678. }
  1679. }
  1680. }
  1681. if (cond2)
  1682. {
  1683. for (let element of document.getElementsByClassName("satellite-style")){
  1684. if (element.id == sC.currentTime)
  1685. {
  1686. element.style.background = "#ff1493cc";
  1687. }
  1688. else
  1689. {
  1690. element.style.background = "#ff69b4cc";
  1691. }
  1692. }
  1693. }
  1694. }
  1695.  
  1696. function enterChaosMode(heading)
  1697. {
  1698. if (heading === -999)
  1699. {
  1700. try
  1701. {
  1702. heading = GooglePlayer.getPhotographerPov().heading;
  1703. }
  1704. catch (e) {
  1705. heading = 0;
  1706. }
  1707. }
  1708. setTimeout(
  1709. function()
  1710. {
  1711. let hdn = heading;
  1712. let pch = GooglePlayer.getPhotographerPov().pitch;
  1713. if (randomSpecial)
  1714. {
  1715. hdn = Math.random() * 360;
  1716. }
  1717. else if (skewedSpecial)
  1718. {
  1719.  
  1720. hdn = (GooglePlayer.getPhotographerPov().heading + 90) % 360;
  1721. }
  1722.  
  1723. if (randomSpecial)
  1724. {
  1725. pch = Math.random() * 180 - 90;
  1726. }
  1727. else if (soilSpecial)
  1728. {
  1729. pch = -60;
  1730. }
  1731. else if (skySpecial)
  1732. {
  1733. pch = 90;
  1734. }
  1735. GooglePlayer.setPov({ heading: hdn, pitch: pch});
  1736. }
  1737. , 300);
  1738. setTimeout(function() {
  1739. let zmn = 0;
  1740. if (randomSpecial)
  1741. {
  1742. zmn = Math.random() * 3;
  1743. }
  1744. else if (zoomSpecial)
  1745. {
  1746. zmn = 4;
  1747. }
  1748. GooglePlayer.setZoom(zmn);
  1749. }, 300);
  1750. }
  1751.  
  1752. function UnityInitiate() {
  1753. const google = window.google;
  1754. let curPosition;
  1755. let kakao_enabled = true;
  1756.  
  1757. ZoomControls();
  1758.  
  1759. function svCheck(data, status) {
  1760. if (status === 'OK') {
  1761. // console.log("STATUS OK");
  1762. let l = data.location.latLng.toString().split(',');
  1763. let lat = l[0].replaceAll('(', '');
  1764. let lng = l[1].replaceAll(')', '');
  1765. if (lat == curPosition.lat && lng == curPosition.lng && !switch_call)
  1766. {
  1767. console.log("Trying more distance");
  1768. teleportMain.distance += 100;
  1769. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1770. }
  1771. else
  1772. {
  1773. // console.log("Teleport Success");
  1774. let hd = 0;
  1775. if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Bing Streetside" || nextPlayer === "Mapy")
  1776. {
  1777. hd = switchCovergeButton.heading;
  1778. }
  1779. GooglePlayer.setPosition(data.location.latLng);
  1780. if (hd !== 0)
  1781. {
  1782. GooglePlayer.setPov({
  1783. heading: hd,
  1784. pitch: 0,
  1785. })
  1786. }
  1787. else
  1788. {
  1789. GooglePlayer.setPov({
  1790. heading: switchCovergeButton.heading,
  1791. pitch: 0,
  1792. })
  1793. }
  1794. if (teleportMain.distance > 150)
  1795. {
  1796. teleportMain.distance = 100;
  1797. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1798. }
  1799. }
  1800. switch_call = false;
  1801. }
  1802. else {
  1803. console.log("STATUS NOT OK");
  1804. teleportMain.distance += 100;
  1805. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1806. }
  1807. }
  1808.  
  1809. google.maps.Map = class extends google.maps.Map {
  1810. constructor(...args) {
  1811. super(...args);
  1812.  
  1813. GoogleMapsObj = this;
  1814.  
  1815. if (GeoJsonCustomUser)
  1816. {
  1817. if (GeoJsonCustomUser)
  1818. {
  1819. this.data.addGeoJson(CUSTOM_GEOJSON);
  1820. }
  1821. this.data.setStyle(function(feature) {
  1822. return GEOJSON_STYLE
  1823. });
  1824. }
  1825. if (OverlayCustom)
  1826. {
  1827. let customOverlay = new google.maps.GroundOverlay(OVERLAY_URL, OVERLAY_BOUNDS, OVERLAY_STYLE);
  1828. customOverlay.setMap(this);
  1829. }
  1830.  
  1831. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  1832. google.maps.event.addDomListener(mapDiv, "click", () => {
  1833. // Create click handler for mini-map buttons.
  1834. this.unity_is_blocking_style_changes = false;
  1835. MinimapBtn.current = mapDiv.id;
  1836. if (mapDiv.id == "Hybrid")
  1837. {
  1838. this.setMapTypeId('hybrid');
  1839. }
  1840. else if (mapDiv.id == "Terrain")
  1841. {
  1842. this.setMapTypeId('terrain');
  1843. }
  1844. else if (mapDiv.id == "Satellite")
  1845. {
  1846. this.setMapTypeId('satellite');
  1847. }
  1848. else if (mapDiv.id == "Custom")
  1849. {
  1850. this.setMapTypeId(customMode);
  1851. }
  1852. else if (mapDiv.id == "Country Streak")
  1853. {
  1854. // Created by EC.
  1855. initCountryStreakCounter();
  1856. }
  1857. else if (mapDiv.id == "RMC")
  1858. {
  1859. // Created by EC.
  1860. initRandomMapChallenge();
  1861. }
  1862. else
  1863. {
  1864. this.setMapTypeId('roadmap');
  1865. }
  1866.  
  1867. // this.setTilt(45);
  1868. for (let ar of presetMinimap)
  1869. {
  1870. if (ar[1] == mapDiv.id)
  1871. {
  1872.  
  1873. if (!this.set.alreadySet){
  1874.  
  1875. this.set.alreadySet = true;
  1876. let p = this.set;
  1877. this.set = function(...args){
  1878. // Total hack by EC, because I can't be bothered with this
  1879. // unpaid "job".
  1880. // Prevents map style from changing once set by this script.
  1881. // So if map style is set to "Easy 5k", it won't change.
  1882. if ((args[0] === 'styles' || args[0] === "mapTypeId")){
  1883. if (args[2] !== "unity" && this.unity_is_blocking_style_changes){
  1884. return;
  1885. }
  1886. }
  1887. p.apply(this, args);
  1888. }
  1889. }
  1890.  
  1891. this.unity_is_blocking_style_changes = ar[1] === 'Default'? false: true;
  1892.  
  1893. this.set('styles', ar[0], "unity");
  1894. }
  1895. }
  1896. for (let element of document.getElementsByClassName("preset-minimap")){
  1897. if (element.id == MinimapBtn.current)
  1898. {
  1899. element.style.background = "#ff1493cc";
  1900. }
  1901. else
  1902. {
  1903. element.style.background = "#ff69b4cc";
  1904. }
  1905. if (rtded || nextPlayer == "Planets") {
  1906. if (["Borders", "Satellite", "Terrain", "Hybrid", "Custom"].includes(element.id))
  1907. {
  1908. element.style.backgroundColor = "red";
  1909. element.disabled = true;
  1910. }
  1911. }
  1912. }
  1913. });
  1914. }
  1915.  
  1916. for (let mapDiv of document.getElementsByClassName("overlay-minimap")){
  1917. google.maps.event.addDomListener(mapDiv, "click", () => {
  1918. OverlayBtn.current = mapDiv.id;
  1919. // console.log(mapDiv.url)
  1920. // console.log(mapDiv.id)
  1921. // console.log(mapDiv.loaded)
  1922. if (!mapDiv.loaded)
  1923. {
  1924. this.data.loadGeoJson(mapDiv.url, {
  1925. id: mapDiv.id
  1926. });
  1927. mapDiv.loaded = true;
  1928. }
  1929. if (mapDiv.id == "Clear")
  1930. {
  1931. this.overlayMapTypes.clear();
  1932. this.data.setStyle(function(feature) {
  1933. return GEOJSON_INVISIBLE
  1934. });
  1935. for (let element of document.getElementsByClassName("overlay-minimap")){
  1936. if (element.id === "Clear")
  1937. {
  1938. element.style.background = "#ff1493cc";
  1939. }
  1940. else
  1941. {
  1942. element.style.background = "#ff69b4cc";
  1943. if (["Coverage", "Official", "OSM"].includes(element.id))
  1944. {
  1945. if (rtded || nextPlayer == "Planets")
  1946. {
  1947. element.style.background = "red";
  1948. }
  1949. }
  1950. if (["Coverage", "Official", "City Lights", "OSM", "Watercolor", "Toner", "Fire", "Choekaas.no"].includes(element.id))
  1951. {
  1952. element.loaded = false;
  1953. }
  1954. }
  1955. }
  1956. }
  1957. else
  1958. {
  1959. if (["Coverage", "Official", "City Lights", "OSM", "Watercolor", "Toner", "Fire", "Choekaas.no"].includes(mapDiv.id))
  1960. {
  1961. this.overlayMapTypes.clear();
  1962. const coverageLayer = new google.maps.ImageMapType({
  1963. getTileUrl ({ x, y }, z) {
  1964.  
  1965. // Omits photospheres
  1966. // return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:apiv3&style=5,8&x=${x}&y=${y}&z=${z}`
  1967.  
  1968. // Omits unofficial and trekker, but also half of mongolia
  1969.  
  1970. if (mapDiv.id == "Official") {
  1971. return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:app&style=5,8&x=${x}&y=${y}&z=${z}`
  1972. } else if (mapDiv.id == "OSM") {
  1973. return `https://tile.openstreetmap.org/${z}/${x}/${y}.png`
  1974. } else if (mapDiv.id == "City Lights") {
  1975. return `https://map1.vis.earthdata.nasa.gov/wmts-webmerc/VIIRS_CityLights_2012/default/{time}/GoogleMapsCompatible_Level8/${z}/${y}/${x}.jpg`
  1976. } else if (mapDiv.id == "Watercolor") {
  1977. return `https://tiles.stadiamaps.com/tiles/stamen_watercolor/${z}/${x}/${y}.jpg`
  1978. //return `https://stamen-tiles.a.ssl.fastly.net/watercolor/${z}/${x}/${y}.jpg`
  1979. } else if (mapDiv.id == "Toner") {
  1980. return `https://stamen-tiles.a.ssl.fastly.net/toner/${z}/${x}/${y}.png`
  1981. } else if (mapDiv.id == "Fire") {
  1982. return `https://tile.thunderforest.com/spinal-map/${z}/${x}/${y}.png?apikey=1360c6d2440c4202bf725238d1b9c761`
  1983. }
  1984. // 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`
  1985.  
  1986. // Includes everything
  1987. else if (mapDiv.id == "Coverage") {
  1988. 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`
  1989. }
  1990. },
  1991. maxZoom: 20,
  1992. tileSize: new google.maps.Size(256, 256),
  1993. })
  1994. this.overlayMapTypes.push(coverageLayer);
  1995.  
  1996. // let other = "Official";
  1997. // if (mapDiv.id == "Official")
  1998. // {
  1999. // other = "Coverage";
  2000. // }
  2001.  
  2002. for (let element of document.getElementsByClassName("overlay-minimap")){
  2003. if (["Clear", "City Lights", "Watercolor", "Toner", "Fire", "Choekaas.no"].includes(element.id))
  2004. {
  2005. element.style.background = "#ff69b4cc";
  2006. element.loaded = false;
  2007. }
  2008. if (["Coverage", "Official", "OSM"].includes(element.id))
  2009. {
  2010. if (!rtded && nextPlayer !== "Planets")
  2011. {
  2012. element.style.background = "#ff69b4cc";
  2013. element.loaded = false;
  2014. }
  2015. }
  2016. }
  2017. mapDiv.style.background = "#ff1493cc";
  2018. mapDiv.loaded = true;
  2019. }
  2020. else
  2021. {
  2022. this.data.setStyle(function(feature) {
  2023. return GEOJSON_STYLE
  2024. });
  2025. for (let element of document.getElementsByClassName("overlay-minimap")){
  2026. if (element.id !== "Clear" && element.loaded)
  2027. {
  2028. element.style.background = "#ff1493cc";
  2029. }
  2030. else
  2031. {
  2032. element.style.background = "#ff69b4cc";
  2033. }
  2034. if (["Coverage", "Official", "OSM"].includes(element.id))
  2035. {
  2036. if (rtded || nextPlayer == "Planets")
  2037. {
  2038. element.style.background = "red";
  2039. }
  2040. }
  2041.  
  2042. }
  2043. }
  2044. }
  2045. });
  2046. }
  2047.  
  2048. for (let spMini of document.getElementsByClassName("spaceMM")) {
  2049. google.maps.event.addDomListener(spMini, "click", () => {
  2050. OverlayBtn.current = spMini.id;
  2051. setMapstylePlanet(planetType);
  2052. if (spMini.id == "Earth") {
  2053. this.overlayMapTypes.clear();
  2054. this.setMapTypeId('roadmap');
  2055. this.set('styles', default_preset);
  2056. // for (let element of document.getElementsByClassName("space-minimap")) {
  2057. // if (element.id === spMini.id) {
  2058. // element.style.background = "#ff1493cc";
  2059. // }
  2060. // else {
  2061. // element.style.background = "#ff69b4cc";
  2062. // }
  2063. // }
  2064. }
  2065. else
  2066. {
  2067. this.set('styles', blank);
  2068. setTimeout(this.set('styles', blank), 1000)
  2069. this.overlayMapTypes.clear();
  2070. const coverageLayer = new google.maps.ImageMapType({
  2071. getTileUrl({ x, y }, z) {
  2072. if (spMini.id.includes("Moon") || spMini.id.includes("Mars"))
  2073. {
  2074. if (spMini.id.includes("Label")) {
  2075. return spMini.url + z + "/" + x + "/" + y + ".png";
  2076. }
  2077. else
  2078. {
  2079. y = Math.pow(2, z) - y - 1;
  2080. return spMini.url + z + "/" + x + "/" + y + ".png";;
  2081. }
  2082. }
  2083. else
  2084. {
  2085. return handleSpURL(spMini.url, x, y, z);;
  2086. }
  2087. },
  2088. maxZoom: 20,
  2089. tileSize: new google.maps.Size(256, 256),
  2090. })
  2091.  
  2092. this.overlayMapTypes.push(coverageLayer);
  2093.  
  2094. if (spMini.id == ("Mars (Labels)"))
  2095. {
  2096. const coverageLayer2 = new google.maps.ImageMapType({
  2097. getTileUrl({ x, y }, z) {
  2098. y = Math.pow(2, z) - y - 1;
  2099. return `http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/${z}/${x}/${y}.png`;
  2100. },
  2101. maxZoom: 20,
  2102. tileSize: new google.maps.Size(256, 256),
  2103. opacity: 0.5
  2104. })
  2105. this.overlayMapTypes.push(coverageLayer2);
  2106. }
  2107. }
  2108. for (let element of document.getElementsByClassName("spaceMM")) {
  2109. if (element.id === spMini.id) {
  2110. element.style.background = "#ff1493cc";
  2111. }
  2112. else if (element.id.includes(planetType)) {
  2113. element.style.background = "#ff69b4cc";
  2114. }
  2115. }
  2116. });
  2117. }
  2118.  
  2119.  
  2120. }
  2121.  
  2122. }
  2123.  
  2124. const svService = new google.maps.StreetViewService();
  2125. google.maps.StreetViewPanorama = class extends google.maps.StreetViewPanorama {
  2126. constructor(...args) {
  2127. super(...args);
  2128.  
  2129. GooglePlayer = this;
  2130.  
  2131. const path = getPathName();
  2132. const isGamePage = () => path.startsWith("/challenge/") || path.startsWith("/results/") ||
  2133. path.startsWith("/game/")|| path.startsWith("/battle-royale/") ||
  2134. path.startsWith("/duels/") || path.startsWith("/team-duels/") || path.startsWith("/bullseye/")
  2135. || path.startsWith("/live-challenge/");
  2136.  
  2137. // const isGamePage = () => location.pathname.startsWith("/challenge/") || location.pathname.startsWith("/results/") ||
  2138. // location.pathname.startsWith("/game/")|| location.pathname.startsWith("/battle-royale/") ||
  2139. // location.pathname.startsWith("/duels/") || location.pathname.startsWith("/team-duels/") || location.pathname.startsWith("/bullseye/")
  2140. // || location.pathname.startsWith("/live-challenge/");
  2141.  
  2142. this.addListener('position_changed', () => {
  2143. // Maybe this could be used to update the position in the other players
  2144. // so that they are always in sync
  2145.  
  2146. try {
  2147. if (!isGamePage()) return;
  2148. // timeMachineBtn.panoId = GooglePlayer.pano;
  2149. // timeMachineBtn.index = -1;
  2150. const lat = this.getPosition().lat();
  2151. const lng = this.getPosition().lng();
  2152. const { heading, pitch } = this.getPov();
  2153.  
  2154. if (skySpecial || soilSpecial || skewedSpecial || zoomSpecial || randomSpecial)
  2155. {
  2156. enterChaosMode(heading);
  2157. }
  2158.  
  2159. curPosition = { lat, lng, heading };
  2160.  
  2161. if (switchCovergeButton.useGoogle)
  2162. {
  2163. switchCovergeButton.lng = lng;
  2164. switchCovergeButton.lat = lat;
  2165. switchCovergeButton.heading = heading;
  2166. if (!timeMachineBtn.list.some(row => row.includes(GooglePlayer.pano)))
  2167. {
  2168. timeMachineBtn.innerHTML = "Time Machine";
  2169. timeMachineBtn.panoId = GooglePlayer.pano;
  2170. timeMachineBtn.index = -1;
  2171. timeMachineBtn.plusminusLock = true;
  2172. timeMachineNewerBtn.style.backgroundColor = "red";
  2173. timeMachineNewerBtn.disabled = true;
  2174. timeMachineOlderBtn.style.backgroundColor = "red";
  2175. timeMachineOlderBtn.disabled = true;
  2176. }
  2177. }
  2178. // switchCovergeButton.useGoogle = true;
  2179. teleportMain.google = true;
  2180.  
  2181.  
  2182. if (restrictMovement)
  2183. {
  2184. let dist = distance(lat, lng , global_lat, global_lng);
  2185. if (dist > RestrictBoundsBtn.maxDist)
  2186. {
  2187. let prevD = distance(RestrictBoundsBtn.lat, RestrictBoundsBtn.lng, global_lat, global_lng);
  2188. if (prevD > RestrictBoundsBtn.maxDist)
  2189. {
  2190. svService.getPanorama({ location: { lat: global_lat, lng: global_lng }, radius: 1000 }, svCheck);
  2191. RestrictBoundsBtn.lng = global_lng;
  2192. RestrictBoundsBtn.lat = global_lat;
  2193. }
  2194. else
  2195. {
  2196. svService.getPanorama({ location: { lat: RestrictBoundsBtn.lat, lng: RestrictBoundsBtn.lng }, radius: 1000 }, svCheck);
  2197. }
  2198. }
  2199. else
  2200. {
  2201. RestrictBoundsBtn.lng = lng;
  2202. RestrictBoundsBtn.lat = lat;
  2203. }
  2204. let d = Math.round(distance(RestrictBoundsBtn.lat, RestrictBoundsBtn.lng , global_lat, global_lng));
  2205. let pct = Math.round((d / RestrictBoundsBtn.maxDist*100));
  2206. RestrictBoundsBtn.innerHTML = "<font size=2>Straight Line Distance: " + d + "m (" + pct + "%)</font>";
  2207. }
  2208. }
  2209. catch (e) {
  2210. console.error("Error:", e);
  2211. }
  2212. });
  2213.  
  2214. this.addListener('pov_changed', () => {
  2215. const { heading, pitch } = this.getPov();
  2216. if (KakaoPlayer) {
  2217. if (typeof KakaoPlayer !== 'string' )
  2218. {
  2219. const vp = KakaoPlayer.getViewpoint();
  2220. // Prevent a recursive loop: only update kakao's viewpoint if it got out of sync with google's
  2221. if ((!almostEqual(vp.pan, heading) || !almostEqual(vp.tilt, pitch)) && nextPlayer == "Kakao") {
  2222. KakaoPlayer.setViewpoint({ pan: heading, tilt: pitch, zoom: vp.zoom });
  2223. }
  2224. }
  2225. }
  2226. });
  2227. }
  2228. };
  2229.  
  2230. document.head.insertAdjacentHTML(
  2231. // Added by EC. Can't do hover effects with out style sheet.
  2232. "beforeend",
  2233. `<style>
  2234. .unity-btn:not([class*="nonclickable"]):hover { scale: 0.95; } , "unity-btn-nonclickable"
  2235. </style>`);
  2236.  
  2237. var mainMenuBtn = document.createElement("Button");
  2238. mainMenuBtn.classList.add("unity-btn", "main-btn");
  2239. mainMenuBtn.id = "Show Buttons";
  2240. mainMenuBtn.hide = false;
  2241. mainMenuBtn.menuBtnCache = true;
  2242. mainMenuBtn.innerHTML = "<font size=2>Unity<br><font size=1 id='unity_version'>v7.4.2EC</font></font>";
  2243. mainMenuBtn.style =
  2244. "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;";
  2245. // document.querySelector(".game-layout__status").appendChild(mainMenuBtn)
  2246. document.body.appendChild(mainMenuBtn);
  2247. mainMenuBtn.addEventListener("click", () => {
  2248. if (mainMenuBtn.hide) {
  2249. for (let element of document.getElementsByClassName("unity-btn")){
  2250.  
  2251. if (!element.styleTop){
  2252. if (element.classList.contains("menu-btn")) { element.style.visibility = "";}
  2253. //element.styleTop = element.style.top;
  2254. continue;
  2255. }
  2256. clearTimeout(element._timer);
  2257.  
  2258. if (element.classList.contains("menu-btn")) { element.style.visibility = "";}
  2259.  
  2260. element.style.transition = "0.2s all ease";
  2261. element.style.top = element.styleTop;
  2262.  
  2263. element._timer = setTimeout(()=>{
  2264. element.style.transition = "";
  2265. }, 950)
  2266. }
  2267.  
  2268. mainMenuBtn.menuBtnCache = true;
  2269. mainMenuBtn.hide = false;
  2270. }
  2271. else {
  2272. hideOtherBtn();
  2273. mainMenuBtn.menuBtnCache = false;
  2274. mainMenuBtn.hide = true;
  2275. }
  2276. });
  2277.  
  2278. var infoBtn = document.createElement("Button");
  2279. infoBtn.classList.add("unity-btn", "info-btn", "full", "vertical-1", "extra-height", "unity-button-nonclickable");
  2280. infoBtn.id = "Info Button";
  2281. infoBtn.innerHTML = `Geoguessr Unity Script<font size=1><br>&#169; Jupaoqq | v${globalScriptVersion}</font>`;
  2282. document.body.appendChild(infoBtn);
  2283. // infoBtn.addEventListener("click", () => {
  2284. // window.open('https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing');
  2285. // });
  2286.  
  2287. var HelpBtn = document.createElement("Button");
  2288. HelpBtn.classList.add("unity-btn", "info-btn", "half", "horizontal-1", "vertical-3");
  2289. HelpBtn.id = "Help Button";
  2290. HelpBtn.innerHTML = "Help & Credits";
  2291. document.body.appendChild(HelpBtn);
  2292. HelpBtn.addEventListener("click", () => {
  2293. window.open('https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing');
  2294. });
  2295.  
  2296. var UpdateBtn = document.createElement("Button");
  2297. UpdateBtn.classList.add("unity-btn", "info-btn", "half", "horizontal-2", "vertical-3");
  2298. UpdateBtn.id = "Update Button";
  2299. UpdateBtn.innerHTML = "Check Update";
  2300.  
  2301. document.body.appendChild(UpdateBtn);
  2302. UpdateBtn.addEventListener("click", () => {
  2303. window.open('https://gf.qytechs.cn/en/scripts/436813-geoguessr-unity-script');
  2304. });
  2305.  
  2306. var menuResetBtn = document.createElement("Button");
  2307. menuResetBtn.classList.add("unity-btn", "info-btn", "large", "vertical-4", "unity-btn-nonclickable");
  2308. menuResetBtn.id = "Menu Reset";
  2309. menuResetBtn.innerHTML = "Menu Position";
  2310. document.body.appendChild(menuResetBtn);
  2311. menuResetBtn.addEventListener("click", () => {
  2312. menuLocCounter = 0;
  2313. btnAll();
  2314. });
  2315.  
  2316. var menuUpBtn = document.createElement("Button");
  2317. menuUpBtn.classList.add("unity-btn", "info-btn", "small", "horizontal-1", "vertical-4");
  2318. menuUpBtn.id = "Menu Up";
  2319. menuUpBtn.innerHTML = "↑";
  2320. document.body.appendChild(menuUpBtn);
  2321. menuUpBtn.addEventListener("click", () => {
  2322. AdjustBtnPos("-2em", "0em", false);
  2323. menuLocCounter++;
  2324. });
  2325.  
  2326. var menuDownBtn = document.createElement("Button");
  2327. menuDownBtn.classList.add("unity-btn", "info-btn", "small", "horizontal-3", "vertical-4");
  2328. menuDownBtn.id = "Menu down";
  2329. menuDownBtn.innerHTML = "↓";
  2330. document.body.appendChild(menuDownBtn);
  2331. menuDownBtn.addEventListener("click", () => {
  2332. AdjustBtnPos("2em", "0em", false);
  2333. menuLocCounter--;
  2334. });
  2335.  
  2336. var unity_alert = document.createElement("Button");
  2337. unity_alert.classList.add("unity-btn", "unity_alert", "extra-full", "vertical-0");
  2338. unity_alert.id = "Unhackable Button";
  2339. unity_alert.innerHTML = `Unity Alert Message`;
  2340. document.body.appendChild(unity_alert);
  2341. unity_alert.addEventListener("click", unhackableAnsswersShowPrompt);
  2342.  
  2343. function unhackableAnsswersShowPrompt() {
  2344. // TODO EC
  2345. }
  2346.  
  2347. document.body.addEventListener('keydown', function(e){
  2348. if (e.altKey && e.key === 'u'){
  2349. unhackableAnsswersShowPrompt();
  2350. }
  2351. });
  2352.  
  2353. var infoMenu = document.createElement("Button");
  2354. infoMenu.classList.add("unity-btn", "menu-btn");
  2355. infoMenu.classList.add();
  2356. infoMenu.id = "Info Menu";
  2357. // infoMenu.innerHTML = "In";
  2358. document.body.appendChild(infoMenu);
  2359. infoMenu.addEventListener("click", () => {
  2360. switchBtn("info-btn");
  2361. if (menuDownBtn.style.visibility == "hidden")
  2362. {
  2363. for (let element of document.getElementsByClassName("info-btn"))
  2364. {
  2365. element.style.visibility = "";
  2366. }
  2367. }
  2368. else
  2369. {
  2370. for (let element of document.getElementsByClassName("info-btn"))
  2371. {
  2372. element.style.visibility = "hidden";
  2373. }
  2374. }
  2375. });
  2376.  
  2377. function handleCountries(locStr)
  2378. {
  2379. let locStr2 = "";
  2380.  
  2381. let hardCode = {"Finland": 3, "United Kingdom": 3, "France": 3, "Czech": 3, "Slovakia": 3};
  2382. if (["Finland", "United Kingdom", "France", "Czech", "Slovakia"].some(v => locStr.includes(v)))
  2383. {
  2384. let ll = locStr.split(",");
  2385. for (let [key, value] of Object.entries(hardCode)) {
  2386. if (locStr.includes(key))
  2387. {
  2388. for (let ct = 0; ct < value; ct++)
  2389. {
  2390. if (ct < ll.length)
  2391. {
  2392. locStr2 = locStr2 + ll[ct] + " ";
  2393. }
  2394. }
  2395. }
  2396. }
  2397. }
  2398. else if (["Poland", "Brazil", "Denmark"].some(v => locStr.includes(v)))
  2399. {
  2400. let ll = locStr.split(",");
  2401. // console.log(ll);
  2402. for (let ct = 0; ct < ll.length; ct++)
  2403. {
  2404. if (!["gmina", "Region"].some(v => ll[ct].includes(v)))
  2405. {
  2406. locStr2 = locStr2 + ll[ct] + " ";
  2407. }
  2408. }
  2409. }
  2410. else if (["Russia"].some(v => locStr.includes(v)))
  2411. {
  2412. let ll = locStr.split(",");
  2413. let index = 0;
  2414. for (let ct1 = ll.length - 1; ct1 >= 0; ct1--)
  2415. {
  2416. if (["District", "district", "Oblast", "Krai", "Municipality", "Urban Okrug"].some(v => ll[ct1].includes(v)) && !["Federal District"].some(v => ll[ct1].includes(v)))
  2417. {
  2418. index = ct1;
  2419. }
  2420. }
  2421. if (locStr.includes("Amur"))
  2422. {
  2423. index = 0;
  2424. }
  2425. for (let ct = index; ct < ll.length; ct++)
  2426. {
  2427. if (!["Federal District"].some(v => ll[ct].includes(v)))
  2428. {
  2429. locStr2 = locStr2 + ll[ct] + " ";
  2430. }
  2431. }
  2432. }
  2433. else
  2434. {
  2435. locStr2 = locStr;
  2436. }
  2437.  
  2438. const toStrip = ["Região Geográfica Intermediária de", "Região Geográfica Imediata de", "Região Imediata de", "Região Metropolitana de",
  2439. "Voivodeship", "okres", "kraj", "Oblast", "Krai", "Urban Okrug", "Hromada", "Urban Hromada", "Raion", "Settlement",
  2440. "Metropolitan Municipality", "Municipality", "Municipal", "Administrative", "District", "Subdistrict", "Province", "Regional", "Council", "Township", "Department", "Local",
  2441. "Département de", "Arrondissement de", "Communauté rurale de",
  2442. "Municipio de", "Municipio", "Departamento", "Provincia de", "Provincia", " of"];
  2443. toStrip.forEach(x => {
  2444. locStr2 = locStr2.replaceAll(x, '');
  2445. });
  2446.  
  2447. if (!locStr2.includes("United States"))
  2448. {
  2449. locStr2 = locStr2.replaceAll("County", '');
  2450. }
  2451.  
  2452. if (!locStr2.includes("Botswana"))
  2453. {
  2454. locStr2 = locStr2.replaceAll("Region", '');
  2455. }
  2456.  
  2457. if (playYoutubeBtn.travel)
  2458. {
  2459. console.log("travel video")
  2460. locStr2 += customWord;
  2461. }
  2462. else
  2463. {
  2464. console.log("Any video")
  2465. }
  2466.  
  2467. return locStr2;
  2468. }
  2469.  
  2470. function moduleHandleYoutube()
  2471. {
  2472. // console.log(youtubeList);
  2473. let iframe = document.getElementById("i_container");
  2474. if (youtubeIndex !== -1)
  2475. {
  2476. yId = youtubeList[youtubeIndex];
  2477. }
  2478.  
  2479. let srcString = "https://www.youtube.com/embed/" + yId + "?&playlist=" + yId + "&autoplay=1&modestbranding=1&controls=0";
  2480.  
  2481. if (yTime !== "0")
  2482. {
  2483. srcString += "&start=" + yTime;
  2484. }
  2485. if (yEnd)
  2486. {
  2487. if (yEnd !== "0")
  2488. {
  2489. srcString += "&end=" + yEnd;
  2490. }
  2491. }
  2492. iframe.src = srcString;
  2493. iframe.style.visibility = "";
  2494. playYoutubeBtn.innerHTML = `Check | [${youtubeIndex + 1}]`;
  2495. }
  2496.  
  2497. var youtubeResetBtn = document.createElement("Button");
  2498. youtubeResetBtn.classList.add("unity-btn", "youtube-btn", "small", "horizontal-1", "vertical-0");
  2499. youtubeResetBtn.id = "Youtube Reset";
  2500. youtubeResetBtn.innerHTML = "&#8635;";
  2501. document.body.appendChild(youtubeResetBtn);
  2502. youtubeResetBtn.addEventListener("click", () => {
  2503. if (youtubeIndex !== -1 && youtubeIndex < youtubeList.length - 1)
  2504. {
  2505. moduleHandleYoutube();
  2506. }
  2507. });
  2508.  
  2509. var youtubeRandomBtn = document.createElement("Button");
  2510. youtubeRandomBtn.classList.add("unity-btn", "youtube-btn", "small", "horizontal-sp", "vertical-0");
  2511. youtubeRandomBtn.id = "Youtube Random";
  2512. youtubeRandomBtn.innerHTML = "&#8677;";
  2513. document.body.appendChild(youtubeRandomBtn);
  2514. youtubeRandomBtn.addEventListener("click", () => {
  2515. if (youtubeIndex !== -1 && youtubeIndex < youtubeList.length - 1)
  2516. {
  2517. youtubeIndex++;
  2518. moduleHandleYoutube();
  2519. }
  2520. });
  2521.  
  2522. var youtubeTravelBtn = document.createElement("Button");
  2523. youtubeTravelBtn.classList.add("unity-btn", "youtube-btn", "small", "horizontal-3", "vertical-0");
  2524. youtubeTravelBtn.id = "Youtube Travel";
  2525. youtubeTravelBtn.innerHTML = "<font size=2>Trip</font>";
  2526. document.body.appendChild(youtubeTravelBtn);
  2527. youtubeTravelBtn.addEventListener("click", () => {
  2528. if (playYoutubeBtn.travel)
  2529. {
  2530. playYoutubeBtn.travel = false;
  2531. youtubeTravelBtn.innerHTML = "<font size=2>Any</font>";
  2532. }
  2533. else
  2534. {
  2535. playYoutubeBtn.travel = true;
  2536. youtubeTravelBtn.innerHTML = "<font size=2>Trip</font>";
  2537. }
  2538. playYoutubeBtn.innerHTML = "Check YouTube";
  2539.  
  2540. });
  2541.  
  2542. var playYoutubeBtn = document.createElement("Button");
  2543. playYoutubeBtn.classList.add("unity-btn", "lgMinus", "youtube-btn", "vertical-0");
  2544. playYoutubeBtn.id = "Youtube Button";
  2545. playYoutubeBtn.travel = true;
  2546. playYoutubeBtn.innerHTML = "Check YouTube";
  2547. document.body.appendChild(playYoutubeBtn);
  2548. playYoutubeBtn.addEventListener("click", () => {
  2549. let iframe = document.getElementById("i_container");
  2550. iframe.style.position = "absolute";
  2551. iframe.allow = "autoplay";
  2552.  
  2553. if (!yEnd)
  2554. {
  2555. let url = `https://nominatim.openstreetmap.org/reverse?format=jsonv2&zoom=10&lat=${global_lat}&lon=${global_lng}`
  2556. fetch(url).then(function(response) {
  2557. return response.json();
  2558. }).then(function(data) {
  2559. // console.log(data)
  2560. youtubeList = [];
  2561. youtubeIndex = -1;
  2562. let locStr = data.display_name.replaceAll(/[\u3400-\u9FBF]/g, "").replace(/[0-9]/g, '');;
  2563. // console.log(locStr);
  2564. let locStr2 = handleCountries(locStr)
  2565. // console.log(locStr2);
  2566. let url2 = corsString + `https://youtube-scrape.herokuapp.com/api/search?q=${locStr2}`
  2567. fetch(url2).then(function(response) {
  2568. return response.json();
  2569. }).then(function(data) {
  2570. // console.log(data.results);
  2571. for (let vid of data.results)
  2572. {
  2573. if (vid.hasOwnProperty("video"))
  2574. {
  2575. let vidLen = convertMMSS(vid.video.duration);
  2576. if (vidLen > 120)
  2577. {
  2578. // console.log(vid.video.title);
  2579. youtubeList.push(vid.video.id);
  2580. }
  2581. }
  2582. }
  2583. if (youtubeList.length > 0)
  2584. {
  2585. youtubeIndex = 0;
  2586. }
  2587. yTime = 20;
  2588. moduleHandleYoutube();
  2589. }).catch(function() {
  2590. console.log("youtube scrappe failure");
  2591. });
  2592. }).catch(function() {
  2593. console.log("nominatim failure");
  2594. });
  2595. }
  2596. else
  2597. {
  2598. moduleHandleYoutube();
  2599. }
  2600. });
  2601.  
  2602. // Teleport Module Buttons
  2603. // Class: teleport-btn
  2604. // Button: teleportMenu
  2605. // Buttons: teleportForward, teleportReverse, teleportMain, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, TeleportArisBtn
  2606.  
  2607. function teleportModule(dir)
  2608. {
  2609. // Added by EC - Victheturtle said that someone was using teleport in nm duels games.
  2610. const PATH = getPathName();
  2611. if (PATH.startsWith("/duels/")) return;
  2612.  
  2613. if (switchCovergeButton.init)
  2614. {
  2615. // console.log("run");
  2616. switchCovergeButton.init = false;
  2617. if (teleportMain.google)
  2618. {
  2619. switchCovergeButton.useGoogle = true;
  2620. teleportMain.google = true;
  2621. }
  2622. else
  2623. {
  2624. switchCovergeButton.useGoogle = false;
  2625. teleportMain.google = false;
  2626. }
  2627. }
  2628. else
  2629. {
  2630. // console.log(teleportMenu.google)
  2631. if (teleportMain.google && GooglePlayer != null)
  2632. {
  2633. let heading = GooglePlayer.getPov().heading;
  2634. if (!dir)
  2635. {
  2636. heading = (heading + 180) % 360;
  2637. }
  2638. let place = FindPointAtDistanceFrom(curPosition.lat, curPosition.lng , DegreesToRadians(heading), teleportMain.distance * 0.001)
  2639. svService.getPanorama({ location: place, radius: 1000, source: teleportMain.teleType}, svCheck);
  2640. }
  2641. }
  2642. }
  2643.  
  2644. var teleportForward = document.createElement("Button");
  2645. teleportForward.classList.add("unity-btn", "teleport-btn", "half", "horizontal-1", "vertical-1");
  2646. teleportForward.id = "Teleport Forward";
  2647. teleportForward.innerHTML = "↑ Forward";
  2648. document.body.appendChild(teleportForward);
  2649.  
  2650. teleportForward.addEventListener("click", () => {
  2651. teleportModule(true);
  2652. });
  2653.  
  2654. var teleportReverse = document.createElement("Button");
  2655. teleportReverse.classList.add("unity-btn", "teleport-btn", "half", "horizontal-2", "vertical-1");
  2656. teleportReverse.id = "Teleport Reverse";
  2657. teleportReverse.innerHTML = "↓ Reverse";
  2658. document.body.appendChild(teleportReverse);
  2659.  
  2660. teleportReverse.addEventListener("click", () => {
  2661. teleportModule(false);
  2662. });
  2663.  
  2664. var teleportMain = document.createElement("Button");
  2665. teleportMain.classList.add("unity-btn", "teleport-btn", "large", "vertical-2");
  2666. teleportMain.teleType = "default";
  2667. teleportMain.id = "Teleport Button";
  2668. teleportMain.distance = 100;
  2669. teleportMain.google = true;
  2670. teleportMain.innerHTML = "Teleport: 100m";
  2671. document.body.appendChild(teleportMain);
  2672.  
  2673. var teleportMoreBtn = document.createElement("Button");
  2674. teleportMoreBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-3", "vertical-2");
  2675. teleportMoreBtn.id = "plus"
  2676. teleportMoreBtn.innerHTML = "+";
  2677. document.body.appendChild(teleportMoreBtn);
  2678. teleportMoreBtn.addEventListener("click", () => {
  2679. if (teleportMain.distance > 21 && teleportMain.distance < 149) {
  2680. teleportMain.distance = teleportMain.distance + 25;
  2681. }
  2682. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  2683. });
  2684.  
  2685. var teleportLessBtn = document.createElement("Button");
  2686. teleportLessBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-1", "vertical-2");
  2687. teleportLessBtn.id = "minus"
  2688. teleportLessBtn.innerHTML = "-";
  2689. document.body.appendChild(teleportLessBtn);
  2690. teleportLessBtn.addEventListener("click", () => {
  2691. if (teleportMain.distance > 26) {
  2692. teleportMain.distance = teleportMain.distance - 25;
  2693. }
  2694. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  2695. });
  2696.  
  2697. var teleportDistResetBtn = document.createElement("Button");
  2698. teleportDistResetBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-1", "vertical-3");
  2699. teleportDistResetBtn.id = "reset"
  2700. teleportDistResetBtn.innerHTML = "Reset Teleport";
  2701. document.body.appendChild(teleportDistResetBtn);
  2702. teleportDistResetBtn.addEventListener("click", () => {
  2703. teleportMain.distance = 100;
  2704. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  2705. });
  2706.  
  2707. var TeleportArisBtn = document.createElement("Button");
  2708. TeleportArisBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-2", "vertical-3");
  2709. TeleportArisBtn.id = "Teleport Options Button";
  2710. TeleportArisBtn.innerHTML = "+ Unofficial";
  2711. document.body.appendChild(TeleportArisBtn);
  2712. TeleportArisBtn.addEventListener("click", () => {
  2713. if (teleportMain.teleType == "default")
  2714. {
  2715. teleportMain.teleType = "outdoor"
  2716. TeleportArisBtn.innerHTML = "No Unofficial";
  2717. }
  2718. else
  2719. {
  2720. teleportMain.teleType = "default"
  2721. TeleportArisBtn.innerHTML = "+ Unofficial";
  2722. }
  2723. });
  2724.  
  2725.  
  2726. var RestrictBoundsBtn = document.createElement("Button");
  2727. RestrictBoundsBtn.classList.add("unity-btn", "teleport-btn", "full", "horizontal-1", "vertical-4");
  2728. RestrictBoundsBtn.id = "Restrict Bounds Main";
  2729. RestrictBoundsBtn.innerHTML = "No Escape Mode Disabled";
  2730. RestrictBoundsBtn.lat = 0;
  2731. RestrictBoundsBtn.lng = 0;
  2732. RestrictBoundsBtn.maxDist = 250;
  2733. document.body.appendChild(RestrictBoundsBtn);
  2734.  
  2735.  
  2736. var RestrictBoundsDistBtn = document.createElement("Button");
  2737. RestrictBoundsDistBtn.classList.add("unity-btn", "teleport-btn", "large", "vertical-5");
  2738. RestrictBoundsDistBtn.id = "Restrict Distance";
  2739. RestrictBoundsDistBtn.innerHTML = "Limit: 250m";
  2740. document.body.appendChild(RestrictBoundsDistBtn);
  2741.  
  2742. var RestrictMoreBtn = document.createElement("Button");
  2743. RestrictMoreBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-3", "vertical-5");
  2744. RestrictMoreBtn.id = "Increase Restrict Distance";
  2745. RestrictMoreBtn.innerHTML = "+";
  2746. document.body.appendChild(RestrictMoreBtn);
  2747. RestrictMoreBtn.addEventListener("click", () => {
  2748. if (RestrictBoundsBtn.maxDist > 49 && RestrictBoundsBtn.maxDist < 249) {
  2749. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist + 50;
  2750. }
  2751. else if (RestrictBoundsBtn.maxDist > 249 && RestrictBoundsBtn.maxDist < 999) {
  2752. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist + 250;
  2753. }
  2754. else if (RestrictBoundsBtn.maxDist > 999 && RestrictBoundsBtn.maxDist < 9999) {
  2755. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist + 1000;
  2756. }
  2757. else if (RestrictBoundsBtn.maxDist > 9999) {
  2758. RestrictBoundsBtn.maxDist = 100000000;
  2759. }
  2760. if (RestrictBoundsBtn.maxDist < 10001)
  2761. {
  2762. RestrictBoundsDistBtn.innerHTML = "Limit: " + RestrictBoundsBtn.maxDist + "m";
  2763. }
  2764. else
  2765. {
  2766. RestrictBoundsDistBtn.innerHTML = "Limit: &#8734;";
  2767. }
  2768. });
  2769.  
  2770. var RestrictLessBtn = document.createElement("Button");
  2771. RestrictLessBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-1", "vertical-5");
  2772. RestrictLessBtn.id = "Decrease Restrict Distance";
  2773. RestrictLessBtn.innerHTML = "-";
  2774. document.body.appendChild(RestrictLessBtn);
  2775. RestrictLessBtn.addEventListener("click", () => {
  2776. if (RestrictBoundsBtn.maxDist > 51 && RestrictBoundsBtn.maxDist < 251) {
  2777. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist - 50;
  2778. }
  2779. else if (RestrictBoundsBtn.maxDist > 251 && RestrictBoundsBtn.maxDist < 1001) {
  2780. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist - 250;
  2781. }
  2782. else if (RestrictBoundsBtn.maxDist > 1001 && RestrictBoundsBtn.maxDist < 10001) {
  2783. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist - 1000;
  2784. }
  2785. else if (RestrictBoundsBtn.maxDist > 10001) {
  2786. RestrictBoundsBtn.maxDist = 10000;
  2787. }
  2788. if (RestrictBoundsBtn.maxDist < 10001)
  2789. {
  2790. RestrictBoundsDistBtn.innerHTML = "Limit: " + RestrictBoundsBtn.maxDist + "m";
  2791. }
  2792. else
  2793. {
  2794. RestrictBoundsDistBtn.innerHTML = "Limit: &#8734;";
  2795. }
  2796. });
  2797.  
  2798. var RestrictBoundsEnableBtn = document.createElement("Button");
  2799. RestrictBoundsEnableBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-2", "vertical-6");
  2800. RestrictBoundsEnableBtn.id = "Restrict Bounds Enable";
  2801. RestrictBoundsEnableBtn.innerHTML = "Enable Limit";
  2802. document.body.appendChild(RestrictBoundsEnableBtn);
  2803. RestrictBoundsEnableBtn.addEventListener("click", () => {
  2804. if (restrictMovement)
  2805. {
  2806. restrictMovement = false;
  2807. RestrictBoundsEnableBtn.innerHTML = "Enable Limit";
  2808. RestrictBoundsBtn.innerHTML = "No Escape Mode Disabled";
  2809. }
  2810. else
  2811. {
  2812. restrictMovement = true;
  2813. RestrictBoundsEnableBtn.innerHTML = "Disable Limit";
  2814. RestrictBoundsBtn.innerHTML = "No Escape Mode Enabled";
  2815. }
  2816. });
  2817.  
  2818. var RestrictResetBtn = document.createElement("Button");
  2819. RestrictResetBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-1", "vertical-6");
  2820. RestrictResetBtn.id = "Restrict Distance Reset";
  2821. RestrictResetBtn.innerHTML = "Reset Limit";
  2822. document.body.appendChild(RestrictResetBtn);
  2823. RestrictResetBtn.addEventListener("click", () => {
  2824. RestrictBoundsBtn.maxDist = 250;
  2825. RestrictBoundsDistBtn.innerHTML = "Limit: " + RestrictBoundsBtn.maxDist + "m";
  2826. });
  2827.  
  2828.  
  2829.  
  2830. // Switch Coverage Module
  2831.  
  2832. var switchCovergeButton = document.createElement("Button");
  2833. switchCovergeButton.classList.add("unity-btn", "timemachine-btn", "full", "vertical-1");
  2834. switchCovergeButton.sat = false;
  2835. switchCovergeButton.id = "switch";
  2836. switchCovergeButton.init = false;
  2837. switchCovergeButton.useGoogle = false;
  2838. switchCovergeButton.lng = 0
  2839. switchCovergeButton.lat = 0
  2840. switchCovergeButton.heading = 0
  2841. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  2842. document.body.appendChild(switchCovergeButton);
  2843. switchCovergeButton.addEventListener("click", () => {
  2844. nextPlayer = nextPlayer_save;
  2845. let GOOGLE_MAPS_CANVAS1 = document.querySelector(GENERAL_CANVAS);
  2846. let GOOGLE_MAPS_CANVAS2 = document.querySelector(BR_CANVAS);
  2847. let GOOGLE_MAPS_CANVAS3 = document.querySelector(".inactive");
  2848. let GOOGLE_MAPS_CANVAS4 = document.querySelector(BULLSEYE_CANVAS2);
  2849. let GOOGLE_MAPS_CANVAS5 = document.querySelector(LIVE_CANVAS2);
  2850. let duel = false;
  2851.  
  2852. let GOOGLE_MAPS_CANVAS = null;
  2853. if (GOOGLE_MAPS_CANVAS1 !== null)
  2854. {
  2855. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS1;
  2856. }
  2857. else if (GOOGLE_MAPS_CANVAS2 !== null)
  2858. {
  2859. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS2;
  2860. }
  2861. else if (GOOGLE_MAPS_CANVAS4 !== null)
  2862. {
  2863. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS4;
  2864. }
  2865. else if (GOOGLE_MAPS_CANVAS5 !== null)
  2866. {
  2867. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS5;
  2868. }
  2869. if (GOOGLE_MAPS_CANVAS3 !== null)
  2870. {
  2871. duel = true;
  2872. }
  2873.  
  2874. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  2875. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  2876. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player")
  2877. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  2878. let MS_MAPS_CANVAS = document.getElementById("ms-player");
  2879. let MAPBOX_MAPS_CANVAS = document.getElementById("sat_map");
  2880. let MAPY_MAPS_CANVAS = document.getElementById("mapy-player");
  2881. // if (nextPlayer !== "Baidu") {
  2882. if (switchCovergeButton.useGoogle == false) {
  2883. if (duel)
  2884. {
  2885.  
  2886. if (nextPlayer == "Kakao")
  2887. {
  2888. KAKAO_MAPS_CANVAS.className = "inactive";
  2889. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  2890. }
  2891. else if (nextPlayer == "Bing Streetside")
  2892. {
  2893. MS_MAPS_CANVAS.className = "inactive";
  2894. MS_MAPS_CANVAS.style.visibility = "hidden";
  2895. }
  2896. else if (nextPlayer == "Mapbox Satellite")
  2897. {
  2898. MAPBOX_MAPS_CANVAS.className = "inactive";
  2899. MAPBOX_MAPS_CANVAS.style.visibility = "hidden";
  2900. }
  2901. else if (nextPlayer == "Yandex")
  2902. {
  2903. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  2904. YANDEX_MAPS_CANVAS.style.zIndex = "none";
  2905. }
  2906. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte")
  2907. {
  2908. BAIDU_MAPS_CANVAS.className = "inactive";
  2909. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  2910. }
  2911. else if (nextPlayer == "Mapy")
  2912. {
  2913. MAPY_MAPS_CANVAS.className = "inactive";
  2914. MAPY_MAPS_CANVAS.style.visibility = "hidden";
  2915. }
  2916. else
  2917. {
  2918. MAPILLARY_MAPS_CANVAS.className = "inactive";
  2919. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  2920. }
  2921. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  2922. document.getElementById("default_player").style.visibility = "";
  2923. window.dispatchEvent(new Event('resize'));
  2924. }
  2925. else
  2926. {
  2927. GOOGLE_MAPS_CANVAS.style.visibility = "";
  2928. if (nextPlayer == "Kakao")
  2929. {
  2930. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  2931. }
  2932. else if (nextPlayer == "Yandex")
  2933. {
  2934. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  2935. }
  2936. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte")
  2937. {
  2938. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  2939. }
  2940. else if (nextPlayer == "Mapillary" || nextPlayer == "Google")
  2941. {
  2942. //MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  2943. }
  2944. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  2945. {
  2946. MS_MAPS_CANVAS.style.visibility = "hidden";
  2947. }
  2948. else if (nextPlayer == "Mapbox Satellite")
  2949. {
  2950. MAPBOX_MAPS_CANVAS.style.visibility = "hidden";
  2951. }
  2952. else if (nextPlayer == "Mapy")
  2953. {
  2954. MAPY_MAPS_CANVAS.style.visibility = "hidden";
  2955. }
  2956. }
  2957. const lat = GooglePlayer.getPosition().lat();
  2958. const lng = GooglePlayer.getPosition().lng();
  2959. switch_call = true;
  2960. if ((!almostEqual2(lat, switchCovergeButton.lat) || !almostEqual2(lat, switchCovergeButton.lng)) && !(NM || NP || NZ)) {
  2961. svService.getPanorama({ location: { lat: switchCovergeButton.lat, lng: switchCovergeButton.lng }, radius: 1000 }, svCheck);
  2962. }
  2963. switchCovergeButton.useGoogle = true;
  2964. teleportMain.google = true;
  2965. switchCovergeButton.init = false;
  2966.  
  2967. console.log("use Google");
  2968. }
  2969. else {
  2970. // if (MS_MAPS_CANVAS)
  2971. // {
  2972. // MS_MAPS_CANVAS.style.visibility = "hidden";
  2973. // }
  2974.  
  2975. if (duel)
  2976. {
  2977. document.getElementById("default_player").className = "inactive";
  2978. document.getElementById("default_player").style.visibility = "hidden";
  2979. if (nextPlayer == "Kakao")
  2980. {
  2981. KAKAO_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  2982. KAKAO_MAPS_CANVAS.style.visibility = "";
  2983. }
  2984. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  2985. {
  2986. MS_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  2987. MS_MAPS_CANVAS.style.visibility = "";
  2988. }
  2989. else if (nextPlayer == "Mapbox Satellite")
  2990. {
  2991. MAPBOX_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  2992. MAPBOX_MAPS_CANVAS.style.visibility = "";
  2993. }
  2994. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte")
  2995. {
  2996. BAIDU_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  2997. BAIDU_MAPS_CANVAS.style.visibility = "";
  2998. }
  2999. else if (nextPlayer == "Yandex")
  3000. {
  3001. YANDEX_MAPS_CANVAS.style.visibility = "";
  3002. YANDEX_MAPS_CANVAS.style.zIndex = "1";
  3003. }
  3004. else if (nextPlayer == "Mapy")
  3005. {
  3006. MAPY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3007. MAPY_MAPS_CANVAS.style.visibility = "";
  3008. }
  3009. else
  3010. {
  3011. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3012. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  3013. MapillaryPlayer.resize();
  3014. //window.dispatchEvent(new Event('resize'));
  3015. // document.querySelector(".mapillary-canvas").style.;
  3016. // mapillary-canvas
  3017. }
  3018.  
  3019. }
  3020. else
  3021. {
  3022. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  3023. if (nextPlayer == "Kakao")
  3024. {
  3025. KAKAO_MAPS_CANVAS.style.visibility = "";
  3026. }
  3027. else if (nextPlayer == "Yandex")
  3028. {
  3029. YANDEX_MAPS_CANVAS.style.visibility = "";
  3030. }
  3031. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft"|| nextPlayer === "Carte")
  3032. {
  3033. BAIDU_MAPS_CANVAS.style.visibility = "";
  3034. }
  3035. else if (nextPlayer == "Mapillary" || nextPlayer == "Google" )
  3036. {
  3037. //MAPILLARY_MAPS_CANVAS.style.visibility = "";
  3038. }
  3039. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  3040. {
  3041. MS_MAPS_CANVAS.style.visibility = "";
  3042. }
  3043. else if (nextPlayer == "Mapbox Satellite")
  3044. {
  3045. MAPBOX_MAPS_CANVAS.style.visibility = "";
  3046. }
  3047. else if (nextPlayer == "Mapy")
  3048. {
  3049. MAPY_MAPS_CANVAS.style.visibility = "";
  3050. }
  3051. }
  3052. switchCovergeButton.useGoogle = false;
  3053. teleportMain.google = false;
  3054. switchCovergeButton.init = true;
  3055. console.log("use Others");
  3056. }
  3057. if (switchCovergeButton.useGoogle)
  3058. {
  3059. if (nextPlayer == "Google")
  3060. {
  3061. switchCovergeButton.innerHTML = "Switch to Mapillary";
  3062. satelliteSwitchButton.disabled = false;
  3063. satelliteSwitchButton.style.background = "#ba55d3cc";
  3064. }
  3065. else
  3066. {
  3067. switchCovergeButton.innerHTML = "Switch to " + nextPlayer;
  3068. satelliteSwitchButton.disabled = true;
  3069. satelliteSwitchButton.style.background = "red";
  3070. }
  3071. }
  3072. else
  3073. {
  3074. if (nextPlayer == "Google" || nextPlayer == "Baidu")
  3075. {
  3076. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  3077. satelliteSwitchButton.disabled = true;
  3078. satelliteSwitchButton.style.background = "red";
  3079. }
  3080. else
  3081. {
  3082. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  3083. satelliteSwitchButton.disabled = false;
  3084. satelliteSwitchButton.style.background = "#ba55d3cc";
  3085. }
  3086. }
  3087. });
  3088.  
  3089.  
  3090. var timeMachineNewerBtn = document.createElement("Button");
  3091. timeMachineNewerBtn.classList.add("unity-btn", "timemachine-btn", "small", "horizontal-3", "vertical-2");
  3092. timeMachineNewerBtn.id = "plus year"
  3093. timeMachineNewerBtn.innerHTML = "+";
  3094. document.body.appendChild(timeMachineNewerBtn);
  3095. timeMachineNewerBtn.addEventListener("click", () => {
  3096. if (timeMachineBtn.index < timeMachineBtn.list.length - 1 && !timeMachineBtn.plusminusLock) {
  3097. timeMachineBtn.index = timeMachineBtn.index + 1;
  3098. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  3099. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  3100. // console.log(timeMachineBtn.index)
  3101. }
  3102. GenBtnColor();
  3103.  
  3104. });
  3105.  
  3106. var timeMachineOlderBtn = document.createElement("Button");
  3107. timeMachineOlderBtn.classList.add("unity-btn", "timemachine-btn", "small", "horizontal-1", "vertical-2");
  3108. timeMachineOlderBtn.id = "minus year"
  3109. timeMachineOlderBtn.innerHTML = "-";
  3110. document.body.appendChild(timeMachineOlderBtn);
  3111. timeMachineOlderBtn.addEventListener("click", () => {
  3112. if (timeMachineBtn.index > 0 && !timeMachineBtn.plusminusLock) {
  3113. timeMachineBtn.index = timeMachineBtn.index - 1;
  3114. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  3115. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  3116. // console.log(timeMachineBtn.index)
  3117. }
  3118. GenBtnColor();
  3119. });
  3120.  
  3121. function svCheck2(data, status) {
  3122. let l = []
  3123. if (status === 'OK') {
  3124. // console.log("OK for " + data.location.latLng + " at ID " + data.location.pano);
  3125. // console.log(data.time)
  3126. for (const alt of data.time) {
  3127. let date = Object.values(alt).find((value) => value instanceof Date)
  3128.  
  3129. l.push([alt.pano, date.toDateString()]);
  3130. }
  3131. // console.log(l);
  3132. timeMachineBtn.list = l
  3133. timeMachineBtn.index = l.length - 1;
  3134. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  3135. GenBtnColor();
  3136. timeMachineBtn.plusminusLock = false;
  3137. // timeMachineOlderBtn.click()
  3138. // timeMachineBtn.innerHTML = "Default Date";
  3139. }
  3140. }
  3141.  
  3142. function waitPopulate()
  3143. {
  3144. // console.log(timeMachineBtn.list);
  3145. if (timeMachineBtn.list.length !== 0)
  3146. {
  3147. timeMachineBtn.index = timeMachineBtn.list.length - 1;
  3148. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  3149. }
  3150. else
  3151. {
  3152. setTimeout(waitPopulate, 250);
  3153. }
  3154. }
  3155.  
  3156. var timeMachineBtn = document.createElement("Button");
  3157. timeMachineBtn.classList.add("unity-btn", "timemachine-btn", "large", "vertical-2");
  3158. timeMachineBtn.id = "Date Button";
  3159. timeMachineBtn.plusminusLock = true;
  3160. timeMachineBtn.panoId = 0;
  3161. timeMachineBtn.index = -1;
  3162. timeMachineBtn.list = [];
  3163. timeMachineBtn.innerHTML = "Time Machine";
  3164. document.body.appendChild(timeMachineBtn);
  3165. timeMachineBtn.addEventListener("click", () => {
  3166. // console.log(timeMachineBtn.index)
  3167. if (timeMachineBtn.panoId != 0)
  3168. {
  3169. if(timeMachineBtn.index == -1)
  3170. {
  3171. timeMachineBtn.list = [];
  3172. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  3173. waitPopulate();
  3174. }
  3175. else
  3176. {
  3177. waitPopulate();
  3178. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  3179. GenBtnColor();
  3180. }
  3181. }
  3182. else
  3183. {
  3184. timeMachineBtn.panoId = GooglePlayer.pano;
  3185. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  3186. waitPopulate();
  3187. }
  3188. });
  3189.  
  3190.  
  3191. var timeMachineMenu = document.createElement("Button");
  3192. timeMachineMenu.classList.add("unity-btn", "menu-btn");
  3193. timeMachineMenu.id = "Time Machine Button";
  3194. document.body.appendChild(timeMachineMenu);
  3195. timeMachineMenu.addEventListener("click", () => {
  3196. switchBtn("timemachine-btn");
  3197. if (timeMachineBtn.style.visibility == "hidden")
  3198. {
  3199. for (let element of document.getElementsByClassName("timemachine-btn"))
  3200. {
  3201. element.style.visibility = "";
  3202. }
  3203. }
  3204. else
  3205. {
  3206. for (let element of document.getElementsByClassName("timemachine-btn"))
  3207. {
  3208. element.style.visibility = "hidden";
  3209. }
  3210. }
  3211. });
  3212.  
  3213.  
  3214. var teleportMenu = document.createElement("Button");
  3215. teleportMenu.classList.add("unity-btn", "menu-btn");
  3216. teleportMenu.id = "Teleport Menu";
  3217. document.body.appendChild(teleportMenu);
  3218. teleportMenu.addEventListener("click", () => {
  3219. switchBtn("teleport-btn");
  3220. if (teleportForward.style.visibility == "hidden")
  3221. {
  3222. for (let element of document.getElementsByClassName("teleport-btn"))
  3223. {
  3224. element.style.visibility = "";
  3225. }
  3226. }
  3227. else
  3228. {
  3229. for (let element of document.getElementsByClassName("teleport-btn"))
  3230. {
  3231. element.style.visibility = "hidden";
  3232. }
  3233. }
  3234. });
  3235.  
  3236. // Satellite Module Buttons
  3237. // Class: satelliteSwitchButton, satellite-menu
  3238. // subclass 1: satellite-btn-type
  3239. // subclass 2: satellite-btn-style
  3240. // Buttons: satelliteRadius, satelliteType, satelliteStyle
  3241. // satelliteDefault, satelliteNight, satelliteClassic, roadDefault, roadClassic
  3242. // skyDefault, skyCurrent, skyLocal
  3243.  
  3244. var satelliteTypeBtn = document.createElement("Button");
  3245. satelliteTypeBtn.classList.add("unity-btn", "satellite-btn", "half", "horizontal-1", "vertical-2", "unity-btn-nonclickable");
  3246. satelliteTypeBtn.id = "Satellite Type Button";
  3247. satelliteTypeBtn.innerHTML = "Map Style";
  3248. satelliteTypeBtn.currentTime = "solarNoon";
  3249. document.body.appendChild(satelliteTypeBtn);
  3250.  
  3251.  
  3252. var satelliteStyleBtn = document.createElement("Button");
  3253. satelliteStyleBtn.classList.add("unity-btn", "satellite-btn", "half", "horizontal-2", "vertical-2", "unity-btn-nonclickable");
  3254. satelliteStyleBtn.id = "Satellite Style Button";
  3255. satelliteStyleBtn.innerHTML = "Time";
  3256.  
  3257. document.body.appendChild(satelliteStyleBtn);
  3258.  
  3259.  
  3260. for (let satT of satType)
  3261. {
  3262. let satTButton = document.createElement("Button");
  3263. satTButton.id = satT[0];
  3264. satTButton.classList.add("unity-btn", "satellite-btn", "satellite-type", "half", "horizontal-1");
  3265. satTButton.addEventListener("click", () => {
  3266. // let sB = document.getElementById("Satellite Type Button");
  3267. let strNm = satTButton.id;
  3268. let val = getVar(strNm);
  3269. styleMapboxAll(strNm, !val);
  3270. setVar(strNm);
  3271. handleSatColor(true, false);
  3272. })
  3273. document.body.appendChild(satTButton);
  3274.  
  3275. if (satT[0] === "Dimension"){
  3276. satTButton.title = "In 3D mode, radius is 50%; tilt map to see full radius.";
  3277. }
  3278. }
  3279.  
  3280.  
  3281.  
  3282. for (let satS of satStyle)
  3283. {
  3284. let satSButton = document.createElement("Button");
  3285. satSButton.id = satS[0];
  3286. satSButton.classList.add("unity-btn", "satellite-btn", "satellite-style", "half", "horizontal-2");
  3287. satSButton.innerHTML = satS[1];
  3288. satSButton.addEventListener("click", () => {
  3289. styleMapboxAll("SunPos", satSButton.id);
  3290. satelliteTypeBtn.currentTime = satSButton.id;
  3291. handleSatColor(false, true);
  3292. })
  3293. document.body.appendChild(satSButton);
  3294. }
  3295.  
  3296.  
  3297.  
  3298. function handleSatMenu(cond)
  3299. {
  3300. let transition = true;
  3301. if (cond)
  3302. {
  3303. transition = (satelliteSwitchButton.innerHTML == "Streetview mode");
  3304. }
  3305. else
  3306. {
  3307. transition = (satelliteSwitchButton.innerHTML !== "Streetview mode");
  3308. }
  3309. if (transition)
  3310. {
  3311. for (let element of document.getElementsByClassName("satellite-btn"))
  3312. {
  3313. if (element.id !== "Satellite Switch")
  3314. {
  3315. element.style.visibility = "hidden";
  3316. }
  3317. }
  3318. }
  3319. else
  3320. {
  3321. for (let element of document.getElementsByClassName("satellite-btn"))
  3322. {
  3323. if (element.id !== "Satellite Switch")
  3324. {
  3325. element.style.visibility = "";
  3326. }
  3327. }
  3328. }
  3329. }
  3330.  
  3331. var satelliteSwitchButton = document.createElement("Button");
  3332. satelliteSwitchButton.classList.add("unity-btn", "satellite-btn", "full", "vertical-1");
  3333. satelliteSwitchButton.id = "Satellite Switch";
  3334. satelliteSwitchButton.state = false;
  3335. satelliteSwitchButton.innerHTML = "Streetview mode";
  3336. document.body.appendChild(satelliteSwitchButton);
  3337. satelliteSwitchButton.addEventListener("click", () => {
  3338. handleSatMenu(false);
  3339. if (!initBing)
  3340. {
  3341. let di = formatDist();
  3342. // satelliteRadius.innerHTML = `Satellite (${di})`;
  3343. satelliteSwitchButton.innerHTML = `Satellite (${di})`;
  3344.  
  3345. initBing = true;
  3346. MAPBOX_INJECTED = false;
  3347. BR_LOAD_MP = true;
  3348.  
  3349. let canvas = document.getElementById("sat_map");
  3350. if (!canvas)
  3351. {
  3352. injectMapboxPlayer();
  3353. }
  3354. else
  3355. {
  3356. changeInnerHTML(canvas, false);
  3357. MAPBOX_INJECTED = true;
  3358. }
  3359. nextPlayer = "Mapbox Satellite";
  3360. injectCanvas();
  3361. satCallback();
  3362.  
  3363. sat_choice = true;
  3364. console.log("Load Mapbox Satellite API")
  3365. //
  3366. }
  3367. else
  3368. {
  3369. if (!satelliteSwitchButton.innerHTML.includes("Satellite"))
  3370. {
  3371. // console.log("true!!")
  3372. let di2 = formatDist();
  3373. satelliteSwitchButton.innerHTML = `Satellite (${di2})`;
  3374.  
  3375. nextPlayer = "Mapbox Satellite";
  3376. injectCanvas();
  3377. satCallback();
  3378. nextPlayer = nextPlayer_save;
  3379.  
  3380. sat_choice = true;
  3381. // console.log("hello")
  3382. }
  3383. else
  3384. {
  3385. satelliteSwitchButton.innerHTML = "Streetview mode";
  3386. if (nextPlayer_save == "Mapbox Satellite")
  3387. {
  3388. nextPlayer = "Google";
  3389. }
  3390. else
  3391. {
  3392. nextPlayer = nextPlayer_save;
  3393. }
  3394.  
  3395. injectCanvas();
  3396. if (sat_choice)
  3397. {
  3398. if (nextPlayer !== "Google")
  3399. {
  3400. goToLocation(true);
  3401. }
  3402. handleButtons();
  3403. }
  3404. sat_choice = false;
  3405. }
  3406. if (satelliteSwitchButton.innerHTML !== "Streetview mode" || nextPlayer == "Baidu")
  3407. {
  3408. switchCovergeButton.disabled = true;
  3409. switchCovergeButton.style.background = "red";
  3410. }
  3411. else
  3412. {
  3413. switchCovergeButton.disabled = false;
  3414. switchCovergeButton.style.background = "#ba55d3cc";
  3415. }
  3416. }
  3417. localStorage['unity_sat_choice'] = sat_choice; // Added by EC
  3418. });
  3419.  
  3420. var satelliteMenu = document.createElement("Button");
  3421. satelliteMenu.classList.add("unity-btn", "menu-btn");
  3422. satelliteMenu.id = "Satellite Menu";
  3423. document.body.appendChild(satelliteMenu);
  3424. satelliteMenu.addEventListener("click", () => {
  3425. switchBtn("satellite-btn");
  3426. if (satelliteSwitchButton.style.visibility == "hidden")
  3427. {
  3428. satelliteSwitchButton.style.visibility = "";
  3429. handleSatMenu(true);
  3430. }
  3431. else
  3432. {
  3433. for (let element of document.getElementsByClassName("satellite-btn"))
  3434. {
  3435. element.style.visibility = "hidden";
  3436. }
  3437. }
  3438.  
  3439. });
  3440.  
  3441.  
  3442. // Mosaic Module Buttons
  3443.  
  3444. var mosaicMain = document.createElement("Button");
  3445. mosaicMain.classList.add("unity-btn", "mosaic-btn", "full", "vertical-1");
  3446. mosaicMain.id = "Mosaic Enable";
  3447. mosaicMain.grid = 0;
  3448. // mosaicMain.random = false;
  3449. mosaicMain.color = false;
  3450. mosaicMain.label = true;
  3451. // mosaicMain.blink = false;
  3452. mosaicMain.innerHTML = "Mosaic Mode";
  3453. document.body.appendChild(mosaicMain);
  3454.  
  3455. var mosaicGridSize = document.createElement("Button");
  3456. mosaicGridSize.classList.add("unity-btn", "mosaic-btn", "half", "horizontal-2", "vertical-2");
  3457. mosaicGridSize.id = "Mosaic Grid";
  3458. mosaicGridSize.innerHTML = "Grid Size";
  3459. document.body.appendChild(mosaicGridSize);
  3460.  
  3461. let gridWidth = [0, 3, 5, 7, 10, 20, 50, 100];
  3462. for (let i = 0; i < gridWidth.length; i++)
  3463. {
  3464. let gridButton = document.createElement("Button");
  3465. gridButton.id = `Grid ${gridWidth[i]}`;
  3466. gridButton.classList.add("unity-btn", "mosaic-btn", "grid-size", "half", "horizontal-2");
  3467. if (i !== 0)
  3468. {
  3469. gridButton.innerHTML = `${gridWidth[i]} x ${gridWidth[i]}`;
  3470. }
  3471. else
  3472. {
  3473. gridButton.innerHTML = `No Grid`;
  3474. }
  3475. document.body.appendChild(gridButton);
  3476. gridButton.addEventListener("click", () => {
  3477. mosaicMain.color = false;
  3478. mosaicMain.label = true;
  3479. loadGridBtn(gridWidth[i]);
  3480. });
  3481. }
  3482.  
  3483. var mosaicGridOpt = document.createElement("Button");
  3484. mosaicGridOpt.classList.add("unity-btn", "mosaic-btn", "half", "horizontal-1", "vertical-2");
  3485. mosaicGridOpt.id = "Mosaic Options";
  3486. mosaicGridOpt.innerHTML = "Options";
  3487. document.body.appendChild(mosaicGridOpt);
  3488.  
  3489. // ["Blink Mode"]
  3490. 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"];
  3491. for (let i = 0; i < gridOpt.length; i++)
  3492. {
  3493. let gridButton = document.createElement("Button");
  3494. gridButton.id = `Grid ${gridOpt[i]}`;
  3495. gridButton.classList.add("unity-btn", "mosaic-btn", "grid-opt", "half", "horizontal-1");
  3496. gridButton.innerHTML = `${gridOpt[i]}`;
  3497. document.body.appendChild(gridButton);
  3498. if (gridOpt[i] == "Reveal All")
  3499. {
  3500. gridButton.addEventListener("click", () => {
  3501. let gridCanvas = document.getElementById("grid");
  3502. if (gridCanvas)
  3503. {
  3504. gridCanvas.style.visibility = "hidden";
  3505. }
  3506. });
  3507. }
  3508. else if (gridOpt[i].includes("Peek"))
  3509. {
  3510. gridButton.addEventListener("click", () => {
  3511. let gridCanvas = document.getElementById("grid");
  3512. if (gridCanvas)
  3513. {
  3514. gridCanvas.style.visibility = "hidden";
  3515. let time = 500;
  3516. if (gridOpt[i].includes("0.01s"))
  3517. {
  3518. time = 10;
  3519. }
  3520. else if (gridOpt[i].includes("0.1s"))
  3521. {
  3522. time = 100;
  3523. }
  3524. else if (gridOpt[i].includes("0.25s"))
  3525. {
  3526. time = 250;
  3527. }
  3528. else if (gridOpt[i].includes("0.5s"))
  3529. {
  3530. time = 500;
  3531. }
  3532. else if (gridOpt[i].includes("1s"))
  3533. {
  3534. time = 1000;
  3535. }
  3536. else if (gridOpt[i].includes("3s"))
  3537. {
  3538. time = 3000;
  3539. }
  3540. setTimeout(function() {gridCanvas.style.visibility = "";}, time);
  3541. }
  3542. });
  3543. }
  3544. else if (gridOpt[i] == "Reveal 5%")
  3545. {
  3546. gridButton.addEventListener("click", () => {
  3547. for (let grid of document.getElementsByClassName("grid-btn"))
  3548. {
  3549. let num = Math.random();
  3550. if (num > 0.95)
  3551. {
  3552. grid.style.visibility = "hidden";
  3553. }
  3554. }
  3555. });
  3556. }
  3557. else if (gridOpt[i] == "Add Color")
  3558. {
  3559. gridButton.addEventListener("click", () => {
  3560. mosaicMain.color = true;
  3561. for (let grid of document.getElementsByClassName("grid-btn"))
  3562. {
  3563. grid.style.background = '#' + (Math.random() * 0xFFFFFF<<0).toString(16);
  3564. }
  3565. });
  3566. }
  3567. else if (gridOpt[i] == "Remove Label")
  3568. {
  3569. gridButton.addEventListener("click", () => {
  3570. mosaicMain.label = false;
  3571. for (let grid of document.getElementsByClassName("grid-btn"))
  3572. {
  3573. grid.innerHTML = "";
  3574. }
  3575. });
  3576. }
  3577. }
  3578.  
  3579. var mosaicMenu = document.createElement("Button");
  3580. mosaicMenu.classList.add("unity-btn", "menu-btn");
  3581. mosaicMenu.id = "Mosaic Menu";
  3582. document.body.appendChild(mosaicMenu);
  3583. mosaicMenu.addEventListener("click", () => {
  3584. switchBtn("mosaic-btn");
  3585. if (mosaicMain.style.visibility == "hidden")
  3586. {
  3587. for (let element of document.getElementsByClassName("mosaic-btn"))
  3588. {
  3589. element.style.visibility = "";
  3590. }
  3591. }
  3592. else
  3593. {
  3594. for (let element of document.getElementsByClassName("mosaic-btn"))
  3595. {
  3596. element.style.visibility = "hidden";
  3597. }
  3598. }
  3599. });
  3600.  
  3601.  
  3602.  
  3603. // Minimap Module
  3604.  
  3605. var MinimapBtn = document.createElement("Button");
  3606. MinimapBtn.classList.add("unity-btn", "minimap-btn", "half", "horizontal-2", "vertical-1");
  3607. MinimapBtn.id = "Minimap Button";
  3608. MinimapBtn.innerHTML = "Minimap Style";
  3609. MinimapBtn.current = "Default";
  3610. // MinimapBtn.childVisible = false;
  3611. document.body.appendChild(MinimapBtn);
  3612.  
  3613. for (let a of presetMinimap)
  3614. {
  3615. let aButton = document.createElement("Button");
  3616. aButton.id = a[1];
  3617. aButton.classList.add("unity-btn", "minimap-btn", "preset-minimap", "half", "horizontal-2");
  3618. aButton.innerHTML = a[1];
  3619. document.body.appendChild(aButton);
  3620. }
  3621.  
  3622. var OverlayBtn = document.createElement("Button");
  3623. OverlayBtn.classList.add("unity-btn", "minimap-btn", "half", "horizontal-1", "vertical-1");
  3624. OverlayBtn.id = "Overlay Button";
  3625. OverlayBtn.innerHTML = "Overlay";
  3626. OverlayBtn.current = "Clear";
  3627. // OverlayBtn.childVisible = false;
  3628. document.body.appendChild(OverlayBtn);
  3629.  
  3630. for (let b of presetOverlay)
  3631. {
  3632. let bButton = document.createElement("Button");
  3633. bButton.id = b[0];
  3634. bButton.url = b[1];
  3635. bButton.loaded = false;
  3636. bButton.classList.add("unity-btn", "minimap-btn", "overlay-minimap", "half", "horizontal-1");
  3637. bButton.innerHTML = b[0];
  3638. document.body.appendChild(bButton);
  3639. }
  3640.  
  3641. var MinimapMenuBtn = document.createElement("Button");
  3642. MinimapMenuBtn.classList.add("unity-btn", "menu-btn");
  3643. MinimapMenuBtn.id = "Minimap Menu Button";
  3644. document.body.appendChild(MinimapMenuBtn);
  3645. MinimapMenuBtn.addEventListener("click", () => {
  3646. switchBtn("minimap-btn");
  3647. if (OverlayBtn.style.visibility !== "hidden")
  3648. {
  3649. for (let element of document.getElementsByClassName("minimap-btn")){
  3650. element.style.visibility="hidden";
  3651. }
  3652. }
  3653. else
  3654. {
  3655. for (let element of document.getElementsByClassName("minimap-btn")){
  3656. element.style.visibility="";
  3657. }
  3658. }
  3659. });
  3660.  
  3661.  
  3662. // Space Buttons Module
  3663.  
  3664. // var SpaceMainmapBtn = document.createElement("Button");
  3665. // SpaceMainmapBtn.classList.add("unity-btn", "space-btn", "half", "horizontal-2", "vertical-1");
  3666. // SpaceMainmapBtn.id = "SpMini Button";
  3667. // SpaceMainmapBtn.innerHTML = "Minimap Style";
  3668. // SpaceMainmapBtn.current = "Default";
  3669. // // SpaceMainmapBtn.childVisible = false;
  3670. // document.body.appendChild(SpaceMainmapBtn);
  3671.  
  3672. // for (let a of spaceMainmap)
  3673. // {
  3674. // let saButton = document.createElement("Button");
  3675. // saButton.id = a[0];
  3676. // saButton.url = a[1];
  3677. // saButton.classList.add("unity-btn", "space-btn", "space-mainmap", "half", "horizontal-2");
  3678. // saButton.innerHTML = a[0];
  3679. // document.body.appendChild(saButton);
  3680. // }
  3681.  
  3682. var SpaceOverlayBtn = document.createElement("Button");
  3683. SpaceOverlayBtn.classList.add("unity-btn", "space-btn", "extra-full", "horizontal-1", "vertical-1");
  3684. SpaceOverlayBtn.id = "SpOver Button";
  3685. SpaceOverlayBtn.innerHTML = "Space";
  3686. SpaceOverlayBtn.current = "Clear";
  3687. // SpaceOverlayBtn.childVisible = false;
  3688. document.body.appendChild(SpaceOverlayBtn);
  3689.  
  3690. for (let b of spaceMinimap)
  3691. {
  3692. let sbButton = document.createElement("Button");
  3693. sbButton.id = b[0];
  3694. sbButton.url = b[1];
  3695. sbButton.classList.add("unity-btn", "space-btn", "spaceMM", "space-minimap", "half", "horizontal-1");
  3696. sbButton.innerHTML = b[0];
  3697. document.body.appendChild(sbButton);
  3698. }
  3699.  
  3700. for (let c of spaceMinimap2)
  3701. {
  3702. let scButton = document.createElement("Button");
  3703. scButton.id = c[0];
  3704. scButton.url = c[1];
  3705. scButton.classList.add("unity-btn", "space-btn", "spaceMM", "space-2minimap", "half", "horizontal-2");
  3706. scButton.innerHTML = c[0];
  3707. document.body.appendChild(scButton);
  3708. }
  3709.  
  3710. for (let d of spaceMinimap3)
  3711. {
  3712. let sdButton = document.createElement("Button");
  3713. sdButton.id = d[0];
  3714. sdButton.url = d[1];
  3715. sdButton.classList.add("unity-btn", "space-btn", "spaceMM", "space-3minimap", "half", "horizontal-3");
  3716. sdButton.innerHTML = d[0];
  3717. document.body.appendChild(sdButton);
  3718. }
  3719.  
  3720.  
  3721. var SpaceMenuBtn = document.createElement("Button");
  3722. SpaceMenuBtn.classList.add("unity-btn", "menu-btn");
  3723. SpaceMenuBtn.id = "Space Menu Button";
  3724. document.body.appendChild(SpaceMenuBtn);
  3725. SpaceMenuBtn.addEventListener("click", () => {
  3726. switchBtn("space-btn");
  3727. if (document.getElementById("Ceres").style.visibility !== "hidden")
  3728. {
  3729. for (let element of document.getElementsByClassName("space-btn")){
  3730. element.style.visibility = "hidden";
  3731. }
  3732. }
  3733. else
  3734. {
  3735. for (let element of document.getElementsByClassName("space-btn")){
  3736. element.style.visibility = "";
  3737. }
  3738. }
  3739. });
  3740.  
  3741. var wikiLocalLang = document.createElement("Button");
  3742. wikiLocalLang.classList.add("unity-btn", "full", "horizontal-1", "vertical-0");
  3743. wikiLocalLang.id = "local language";
  3744. wikiLocalLang.state = true;
  3745. wikiLocalLang.innerHTML = "Switch to Local Language";
  3746. document.body.appendChild(wikiLocalLang);
  3747. wikiLocalLang.addEventListener("click", () => {
  3748. if (wikiLocalLang.state && global_cc)
  3749. {
  3750. let cc = langDict[global_cc];
  3751. let fi = "en";
  3752. if (typeof cc !== typeof undefined)
  3753. {
  3754. fi = cc[Math.floor(Math.random() * cc.length)];
  3755. }
  3756. wiki(fi, document.getElementById("i_container"), teleportMenu);
  3757. wikiLocalLang.innerHTML = "Switch to English";
  3758. wikiLocalLang.state = false;
  3759. }
  3760. else if (wikiLocalLang.innerHTML == "Switch to English")
  3761. {
  3762. wiki("en", document.getElementById("i_container"), teleportMenu);
  3763. if (getLocalizationFromPathName() == "en"){
  3764. wikiLocalLang.innerHTML = "Switch to Local Language";
  3765. wikiLocalLang.state = true;
  3766. } else {
  3767. wikiLocalLang.innerHTML = "Switch to your language.";
  3768. }
  3769. } else {
  3770. wiki(getLocalizationFromPathName(), document.getElementById("i_container"), teleportMenu);
  3771. wikiLocalLang.innerHTML = "Switch to Local Language";
  3772. wikiLocalLang.state = true;
  3773. }
  3774. });
  3775.  
  3776. var specialMapMain = document.createElement("Button");
  3777. specialMapMain.classList.add("unity-btn", "special-map-btn", "full", "vertical-1");
  3778. specialMapMain.id = "Circus Main";
  3779. specialMapMain.innerHTML = "Circus Mode";
  3780. document.body.appendChild(specialMapMain);
  3781.  
  3782. var specialMapSky = document.createElement("Button");
  3783. specialMapSky.classList.add("unity-btn", "special-map-btn", "half", "horizontal-1", "vertical-2");
  3784. specialMapSky.id = "Circus Sky";
  3785. specialMapSky.innerHTML = "Sky";
  3786. document.body.appendChild(specialMapSky);
  3787. specialMapSky.addEventListener("click", () => {
  3788. skySpecial = !skySpecial;
  3789. if (skySpecial)
  3790. {
  3791. enterChaosMode(-999);
  3792. }
  3793. handleSpecialColor();
  3794. });
  3795.  
  3796. var specialMapSkewed = document.createElement("Button");
  3797. specialMapSkewed.classList.add("unity-btn", "special-map-btn", "half", "horizontal-2", "vertical-2");
  3798. specialMapSkewed.id = "Circus Skewed";
  3799. specialMapSkewed.innerHTML = "Skewed";
  3800. document.body.appendChild(specialMapSkewed);
  3801. specialMapSkewed.addEventListener("click", () => {
  3802. skewedSpecial = !skewedSpecial;
  3803. if (skewedSpecial)
  3804. {
  3805. enterChaosMode(-999);
  3806. }
  3807. handleSpecialColor();
  3808. });
  3809.  
  3810. var specialMapSoil = document.createElement("Button");
  3811. specialMapSoil.classList.add("unity-btn", "special-map-btn", "half", "horizontal-1", "vertical-3");
  3812. specialMapSoil.id = "Circus Soil";
  3813. specialMapSoil.innerHTML = "Soiled";
  3814. document.body.appendChild(specialMapSoil);
  3815. specialMapSoil.addEventListener("click", () => {
  3816. soilSpecial = !soilSpecial;
  3817. if (soilSpecial)
  3818. {
  3819. enterChaosMode(-999);
  3820. }
  3821. handleSpecialColor();
  3822. });
  3823.  
  3824. var specialMapZoom = document.createElement("Button");
  3825. specialMapZoom.classList.add("unity-btn", "special-map-btn", "half", "horizontal-2", "vertical-3");
  3826. specialMapZoom.id = "Circus Zoom";
  3827. specialMapZoom.innerHTML = "Max Zoom";
  3828. document.body.appendChild(specialMapZoom);
  3829. specialMapZoom.addEventListener("click", () => {
  3830. zoomSpecial = !zoomSpecial;
  3831. if (zoomSpecial)
  3832. {
  3833. enterChaosMode(-999);
  3834. }
  3835. handleSpecialColor();
  3836. });
  3837.  
  3838. var specialMapRandom = document.createElement("Button");
  3839. specialMapRandom.classList.add("unity-btn", "special-map-btn", "half", "horizontal-2", "vertical-4");
  3840. specialMapRandom.id = "Circus Random";
  3841. specialMapRandom.innerHTML = "Random";
  3842. document.body.appendChild(specialMapRandom);
  3843. specialMapRandom.addEventListener("click", () => {
  3844. randomSpecial = !randomSpecial;
  3845. if (randomSpecial)
  3846. {
  3847. enterChaosMode(-999);
  3848. }
  3849. handleSpecialColor();
  3850. });
  3851.  
  3852. var specialMapNMPZ = document.createElement("Button");
  3853. specialMapNMPZ.classList.add("unity-btn", "special-map-btn", "half", "horizontal-1", "vertical-4");
  3854. specialMapNMPZ.id = "Circus NMPZ";
  3855. specialMapNMPZ.innerHTML = "Force NMPZ";
  3856. document.body.appendChild(specialMapNMPZ);
  3857. specialMapNMPZ.addEventListener("click", () => {
  3858. if (!document.getElementById("specialNMPZ"))
  3859. {
  3860. loadNMPZ();
  3861. }
  3862. else
  3863. {
  3864. if (nmpzSpecial)
  3865. {
  3866. document.getElementById("specialNMPZ").style.visibility = "hidden";
  3867. }
  3868. else
  3869. {
  3870. document.getElementById("specialNMPZ").style.visibility = "";
  3871. }
  3872. nmpzSpecial = !nmpzSpecial;
  3873. }
  3874. handleSpecialColor();
  3875. });
  3876.  
  3877.  
  3878.  
  3879. var specialMapClear = document.createElement("Button");
  3880. specialMapClear.classList.add("unity-btn", "special-map-btn", "half", "horizontal-2", "vertical-5");
  3881. specialMapClear.id = "Circus Clear";
  3882. specialMapClear.innerHTML = "Clear All";
  3883. document.body.appendChild(specialMapClear);
  3884. specialMapClear.addEventListener("click", () => {
  3885. skySpecial = false;
  3886. skewedSpecial = false;
  3887. soilSpecial = false;
  3888. zoomSpecial = false;
  3889. randomSpecial = false;
  3890. enterChaosMode(-999);
  3891. handleSpecialColor();
  3892. });
  3893.  
  3894.  
  3895. var specialMapMenu = document.createElement("Button");
  3896. specialMapMenu.classList.add("unity-btn", "menu-btn");
  3897. specialMapMenu.id = "Circus Menu";
  3898. document.body.appendChild(specialMapMenu);
  3899. specialMapMenu.addEventListener("click", () => {
  3900. switchBtn("special-map-btn");
  3901. if (specialMapMain.style.visibility == "hidden")
  3902. {
  3903. for (let element of document.getElementsByClassName("special-map-btn"))
  3904. {
  3905. element.style.visibility = "";
  3906. }
  3907. }
  3908. else
  3909. {
  3910. for (let element of document.getElementsByClassName("special-map-btn"))
  3911. {
  3912. element.style.visibility = "hidden";
  3913. }
  3914. }
  3915. });
  3916.  
  3917. handleStyles();
  3918.  
  3919. if (sat_choice){
  3920. // Added by EC
  3921. const svCanvas = document.body.querySelector(GENERAL_CANVAS);
  3922. if (svCanvas) svCanvas.style.visibility = "hidden";
  3923. }
  3924.  
  3925. console.log("Script buttons Loaded");
  3926. UnityInitiate.callbacks.forEach( cb => cb() );
  3927. }// End UntityInitiate();
  3928.  
  3929. UnityInitiate.callbacks = [];
  3930. UnityInitiate.removeCallback = function(cb){
  3931. for (let n = 0; n < UnityInitiate.callbacks.length;n++){
  3932. if (UnityInitiate.callbacks[n] == cb){
  3933. UnityInitiate.callbacks.splice(n, 1);
  3934. return;
  3935. }
  3936. }
  3937. }
  3938.  
  3939. function loadNMPZ()
  3940. {
  3941. let gridBtn = document.createElement("div");
  3942. gridBtn.id = "specialNMPZ";
  3943. // visibility: hidden;
  3944. gridBtn.style =
  3945. `
  3946. display: grid;
  3947. gap: 0px;
  3948. top: 0px;
  3949. left: 0px;
  3950. position: absolute;
  3951. width: 100%;
  3952. height: 100%;
  3953. z-index: 1;
  3954. `;
  3955. GAME_CANVAS.appendChild(gridBtn);
  3956. }
  3957.  
  3958. // Handle Grid Mode
  3959.  
  3960. function loadGridBtn(num)
  3961. {
  3962. let gridCanvas = document.getElementById("grid");
  3963. let reload = false;
  3964. if (!gridCanvas && num !== 0)
  3965. {
  3966. let gridBtn = document.createElement("div");
  3967. gridBtn.id = "grid";
  3968. // visibility: hidden;
  3969. gridBtn.style =
  3970. `
  3971. display: grid;
  3972. gap: 0px;
  3973. top: 0px;
  3974. left: 0px;
  3975. position: absolute;
  3976. width: 100%;
  3977. height: 100%;
  3978. z-index: 1;
  3979. `;
  3980. GAME_CANVAS.appendChild(gridBtn);
  3981. gridCanvas = gridBtn;
  3982. reload = true;
  3983. }
  3984.  
  3985. if (gridCanvas)
  3986. {
  3987. let mosaicMenu = document.getElementById("Mosaic Enable");
  3988. if (num !== mosaicMenu.grid || reload)
  3989. {
  3990. console.log("Generate Mosaic tiles");
  3991. gridCanvas.innerHTML = "";
  3992. mosaicMenu.grid = num;
  3993. // cond = true;
  3994. if (num !== 0)
  3995. {
  3996. gridCanvas.style.visibility = "";
  3997. for (let i = 1; i < num+1; i++)
  3998. {
  3999. for (let ii = 1; ii < num+1; ii++)
  4000. {
  4001. let btn1 = document.createElement("Button");
  4002. btn1.style =
  4003. `grid-column: ${ii};
  4004. grid-row: ${i};
  4005. `;
  4006. btn1.classList.add("grid-btn");
  4007. if (num < 21 && mosaicMenu.label)
  4008. {
  4009. btn1.innerHTML = `(${ii}, ${i})`;
  4010. }
  4011. btn1.addEventListener("click", () => {
  4012. btn1.style.visibility = "hidden";
  4013. });
  4014. if (mosaicMenu.color)
  4015. {
  4016. btn1.style.background = '#' + (Math.random() * 0xFFFFFF<<0).toString(16);
  4017. }
  4018. gridCanvas.appendChild(btn1);
  4019. }
  4020. }
  4021. mosaicMenu.grid = num;
  4022. }
  4023. else
  4024. {
  4025. gridCanvas.style.visibility = "hidden";
  4026.  
  4027. }
  4028.  
  4029. for (let grid2 of document.getElementsByClassName("grid-size"))
  4030. {
  4031. grid2.style.background = "#ff69b4cc";
  4032. if (parseInt(grid2.id.replace(/\D/g,'')) == mosaicMenu.grid)
  4033. {
  4034. grid2.style.background = "#ff1493cc";
  4035. }
  4036. }
  4037. }
  4038.  
  4039. if (num !== 0)
  4040. {
  4041. gridCanvas.style.visibility = "";
  4042. for (let grid1 of document.getElementsByClassName("grid-btn"))
  4043. {
  4044. grid1.style.visibility = "";
  4045. }
  4046. mosaicPre = true;
  4047. }
  4048. else
  4049. {
  4050. mosaicPre = false;
  4051. }
  4052. }
  4053. }
  4054.  
  4055.  
  4056. function GenBtnColor()
  4057. {
  4058. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4059. let timeMachineOlderBtn = document.getElementById("minus year");
  4060. let timeMachineNewerBtn = document.getElementById("plus year");
  4061. let timeMachineBtn = document.getElementById("Date Button");
  4062. if (timeMachineBtn.index == timeMachineBtn.list.length - 1)
  4063. {
  4064. timeMachineNewerBtn.style.backgroundColor = "red";
  4065. timeMachineNewerBtn.disabled = true;
  4066. }
  4067. else
  4068. {
  4069. timeMachineNewerBtn.style.backgroundColor = "#ba55d3cc";
  4070. timeMachineNewerBtn.disabled = false;
  4071. }
  4072. if (timeMachineBtn.index == 0)
  4073. {
  4074. timeMachineOlderBtn.style.backgroundColor = "red";
  4075. timeMachineOlderBtn.disabled = true;
  4076. }
  4077. else
  4078. {
  4079. timeMachineOlderBtn.style.backgroundColor = "#ba55d3cc";
  4080. timeMachineOlderBtn.disabled = false;
  4081. }
  4082. }
  4083.  
  4084. /**
  4085. * Handle Keyboard inputs
  4086. */
  4087.  
  4088. function kBoard()
  4089. {
  4090. document.addEventListener('keydown', logKey);
  4091. }
  4092.  
  4093. function logKey(e) {
  4094. // console.log(e.code);
  4095. let isGamePage2 = ["challenge", "results", "game", "battle-royale", "duels", "team-duels", "bullseye"].some(v => window.location.pathname.includes(v));
  4096. if (isGamePage2)
  4097. {
  4098. let mainMenuBtn = document.getElementById("Show Buttons");
  4099. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4100. if (e.code == "Space")
  4101. {
  4102. setHidden(true);
  4103. }
  4104. if (e.code == "Digit4")
  4105. {
  4106. // Got a DM from Mika and this appeared to be causeing people to jump forward in nm duels.
  4107. // I can't duplicate it on my computer, but I don't think this is a feature that will be missed.
  4108. }
  4109. if (e.code == "Digit3")
  4110. {
  4111. // Got a DM from Mika and this appeared to be causeing people to jump forward in nm duels.
  4112. // I can't duplicate it on my computer, but I don't think this is a feature that will be missed.
  4113. }
  4114. else if (e.code == "Digit5")
  4115. {
  4116. document.getElementById("minus year").click();
  4117. }
  4118. else if (e.code == "Digit6")
  4119. {
  4120. document.getElementById("Date Button").click();
  4121. }
  4122. else if (e.code == "Digit7")
  4123. {
  4124. document.getElementById("plus year").click();
  4125. }
  4126. else if (e.code == "Digit8")
  4127. {
  4128. if (mainMenuBtn.style.visibility == "hidden")
  4129. {
  4130. mainMenuBtn.style.visibility = "";
  4131. }
  4132. else
  4133. {
  4134. mainMenuBtn.style.visibility = "hidden";
  4135. }
  4136. }
  4137. else if (e.code == "Digit9")
  4138. {
  4139. document.getElementById("Restrict Bounds Main").maxDist = 100000000;
  4140. document.getElementById("Increase Restrict Distance").click();
  4141. if (!document.getElementById("Restrict Bounds Main").enabled)
  4142. {
  4143. document.getElementById("Restrict Bounds Enable").click();
  4144. }
  4145. }
  4146. }
  4147. }
  4148.  
  4149.  
  4150. /**
  4151. * Hide or reveal the buttons, and disable buttons if such feature is not available
  4152. */
  4153.  
  4154. function setHidden(cond)
  4155. {
  4156. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4157. let teleportBtn = document.getElementById("Teleport Forward");
  4158. let mainMenuBtn = document.getElementById("Show Buttons");
  4159. if (mainMenuBtn != null)
  4160. {
  4161. mainMenuBtn.style.visibility = "";
  4162. // mainMenuBtn.hide = cond;
  4163. // console.log(["cache", mainMenuBtn.menuBtnCache]);
  4164. if (cond)
  4165. {
  4166. if (teleportBtn != null)
  4167. {
  4168. for (let element of document.getElementsByClassName("unity-btn")){
  4169. element.style.visibility = "hidden";
  4170. }
  4171. }
  4172. let iframe = document.getElementById("i_container");
  4173. if (iframe != null)
  4174. {
  4175. if (!isBattleRoyale)
  4176. {
  4177. iframe.src = ""
  4178. }
  4179. }
  4180. }
  4181. else
  4182. {
  4183. for (let element of document.getElementsByClassName("unity-btn")){
  4184. if (element.id !== "Show Buttons" && !element.classList.contains("menu-btn"))
  4185. {
  4186. element.style.visibility = "hidden";
  4187. }
  4188. }
  4189. }
  4190. }
  4191. }
  4192.  
  4193. function setMenuBtnsUnhidden(){
  4194. // Added by EC
  4195. let mainMenuBtn = document.getElementById("Show Buttons");
  4196. let btns= setButtons3();
  4197. for (let element of btns){
  4198. if (element == mainMenuBtn){
  4199. element.style.visibility = "";
  4200. }
  4201. if (!mainMenuBtn.hide){
  4202. element.style.visibility = "";
  4203. }
  4204. }
  4205. }
  4206.  
  4207. function setDisable(cond) {
  4208. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4209. let btnList = [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ];
  4210.  
  4211. function setAll(cond1, cond2)
  4212. {
  4213. for (let btn of btnList)
  4214. {
  4215. btn.style.backgroundColor = cond1;
  4216. btn.disabled = cond2;
  4217. }
  4218. }
  4219.  
  4220. function setMapstyle(cond1, cond2)
  4221. {
  4222. for (let mapDiv of document.getElementsByClassName("preset-minimap"))
  4223. {
  4224. if (["Borders", "Satellite", "Terrain", "Hybrid", "Custom"].includes(mapDiv.id))
  4225. {
  4226. mapDiv.style.backgroundColor = cond1;
  4227. mapDiv.disabled = cond2;
  4228. }
  4229. }
  4230. for (let mapDiv2 of document.getElementsByClassName("overlay-minimap"))
  4231. {
  4232. if (["Coverage", "Official", "OSM"].includes(mapDiv2.id))
  4233. {
  4234. mapDiv2.style.backgroundColor = cond1;
  4235. mapDiv2.disabled = cond2;
  4236. }
  4237. }
  4238. }
  4239.  
  4240. if (teleportBtn != null) {
  4241. setMapstylePlanet("None");
  4242. if (rtded) {
  4243. setAll("red", true);
  4244. setMapstyle("red", true);
  4245. }
  4246. else
  4247. {
  4248. setMapstyle("#ff69b4cc", false)
  4249. if (cond === "NMPZ") {
  4250. setAll("red", true);
  4251. if (nextPlayer !== "Baidu")
  4252. {
  4253. satelliteSwitchButton.style.backgroundColor = "#ba55d3cc";
  4254. satelliteSwitchButton.disabled = false;
  4255. }
  4256. if (nextPlayer !== "Google")
  4257. {
  4258. switchCovergeButton.style.backgroundColor = "#ba55d3cc";
  4259. switchCovergeButton.disabled = false;
  4260. }
  4261. if (NZ)
  4262. {
  4263. if (ms_radius > 5000)
  4264. {
  4265. ms_radius = 5000;
  4266. }
  4267. }
  4268. if (NM)
  4269. {
  4270. if (ms_radius > 2000)
  4271. {
  4272. ms_radius = 2000;
  4273. }
  4274. }
  4275. if (NM && NP && NZ)
  4276. {
  4277. if (ms_radius > 1000)
  4278. {
  4279. ms_radius = 1000;
  4280. }
  4281. }
  4282. }
  4283. else if (nextPlayer == "Google" || nextPlayer === "Wikipedia" || nextPlayer === "Youtube") {
  4284. setAll("#ba55d3cc", false);
  4285. if (bullseyeMapillary && nextPlayer === "Google")
  4286. {
  4287. switchCovergeButton.style.backgroundColor = "red";
  4288. switchCovergeButton.disabled = true;
  4289. }
  4290. }
  4291. else if (nextPlayer === "Baidu" || nextPlayer === "Image" || nextPlayer === "Minecraft" || nextPlayer === "Carte") {
  4292. setAll("red", true);
  4293. switchCovergeButton.style.backgroundColor = "#ba55d3cc";
  4294. switchCovergeButton.disabled = false;
  4295. if (nextPlayer !== "Baidu")
  4296. {
  4297. satelliteSwitchButton.style.backgroundColor = "#ba55d3cc";
  4298. satelliteSwitchButton.disabled = false;
  4299. }
  4300. }
  4301. else if (nextPlayer == "Kakao" || nextPlayer == "Yandex" || nextPlayer == "Mapillary" || nextPlayer == "Bing Streetside" || nextPlayer == "Mapy") {
  4302. setAll("#ba55d3cc", false);
  4303. timeMachineBtn.style.backgroundColor = "red";
  4304. timeMachineBtn.disabled = true;
  4305. let li = [RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn]
  4306. for (let btns of li)
  4307. {
  4308. btns.style.backgroundColor = "red";
  4309. btns.disabled = true;
  4310. }
  4311.  
  4312. }
  4313. else if (nextPlayer == "Mapbox Satellite") {
  4314. setAll("#ba55d3cc", false);
  4315. timeMachineBtn.style.backgroundColor = "red";
  4316. timeMachineBtn.disabled = true;
  4317. for (let btns of document.getElementsByClassName("teleport-btn"))
  4318. {
  4319. btns.style.backgroundColor = "red";
  4320. btns.disabled = true;
  4321. }
  4322. }
  4323. else if (nextPlayer == "Planets") {
  4324. setAll("red", true);
  4325. console.log("setting map style");
  4326. setMapstyle("red", true);
  4327. setMapstylePlanet(planetType);
  4328. }
  4329. }
  4330. timeMachineNewerBtn.style.backgroundColor = "red";
  4331. timeMachineNewerBtn.disabled = true;
  4332. timeMachineOlderBtn.style.backgroundColor = "red";
  4333. timeMachineOlderBtn.disabled = true;
  4334.  
  4335. }
  4336. }
  4337.  
  4338. function setMapstylePlanet(cond)
  4339. {
  4340. for (let mapDiv of document.getElementsByClassName("spaceMM"))
  4341. {
  4342. if (cond == "None" && mapDiv.id.includes("Earth"))
  4343. {
  4344. mapDiv.style.backgroundColor = "#ff1493cc";
  4345. mapDiv.disabled = false;
  4346. }
  4347. else if (mapDiv.id.includes(cond) || mapDiv.id.includes("Earth"))
  4348. {
  4349. mapDiv.style.backgroundColor = "#ff69b4cc";
  4350. mapDiv.disabled = false;
  4351. }
  4352. else
  4353. {
  4354. mapDiv.style.backgroundColor = "red";
  4355. mapDiv.disabled = true;
  4356. }
  4357. }
  4358. }
  4359.  
  4360.  
  4361. /**
  4362. * This observer stays alive while the script is running
  4363. */
  4364.  
  4365. let alreadyLaunchedObserver = false;
  4366. function launchObserver() {
  4367. if (alreadyLaunchedObserver) return;
  4368. alreadyLaunchedObserver = true;
  4369.  
  4370. //let sat4 = document.body.querySelector(".fullscreen-spinner_square__mwMfl");
  4371. let sat4 = document.body.querySelector(`div[class*="spinner"]`);
  4372. if (sat4) {
  4373. // Added by EC.
  4374. const svCanvas = document.body.querySelector(GENERAL_CANVAS);
  4375. if (svCanvas) svCanvas.style.visibility = "hidden";
  4376. }
  4377.  
  4378. UnityInitiate();
  4379. handleTeleport();
  4380. SyncListener();
  4381. kBoard();
  4382.  
  4383. console.log("Unity Main Observer");
  4384. // const OBSERVER = new MutationObserver((mutations, observer) => {
  4385. // detectGamePage();
  4386. // });
  4387. // OBSERVER.observe(document.head, { attributes: true, childList: true, subtree: true });
  4388. let observer3 = new MutationObserver((mutations) => {
  4389. mutations.forEach((mutation) => {
  4390. if (oldHref != document.location.href && allowDetect) {
  4391. oldHref = document.location.href;
  4392. }
  4393. if (mutation.removedNodes)
  4394. {
  4395. for (let m of mutation.removedNodes) {
  4396. if (m.classList)
  4397. {
  4398. // Comment added by EC: Recycle old sat-map by catching it before it gets deleted, saving it, then re-appending it later.
  4399. // TODO EC: Is recycling the mini map necessary?
  4400.  
  4401. let sat = m.getElementsByTagName('sat-map');
  4402. let sat0 = null;
  4403. // let minimap = m.querySelector('.game_guessMap__MTlQ_');
  4404.  
  4405. if (sat.length !== 0)
  4406. {
  4407. console.log("Recycling the satellite map.");
  4408.  
  4409. sat0 = sat[0];
  4410.  
  4411. sat0.style.display = "none";
  4412. //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")
  4413. document.body.appendChild(sat0);
  4414. //document.body.appendChild(minimap);
  4415.  
  4416. let t = setInterval(()=>{
  4417.  
  4418. let GAME_CANVAS = document.querySelector(GENERAL_LAYOUT);
  4419. if (!GAME_CANVAS) return;
  4420.  
  4421. clearInterval(t);
  4422.  
  4423. GAME_CANVAS.id = "player";
  4424. GAME_CANVAS.appendChild(sat0)
  4425.  
  4426. // GAME_CANVAS.appendChild(minimap)
  4427.  
  4428. sat0.style.display = "";
  4429.  
  4430. detectGamePage();
  4431.  
  4432. }, 100);
  4433. }
  4434.  
  4435.  
  4436. }
  4437. }
  4438. }
  4439. if (mutation.addedNodes)
  4440. {
  4441. for (let m of mutation.addedNodes) {
  4442. // console.log(m);
  4443. if (m.classList)
  4444. {
  4445. // console.log(m)
  4446. // let sat3 = m.getElementsByClassName("tooltip_tooltip__CHe2s");
  4447. let PATHNAME = getPathName();
  4448. let spinner = document.querySelector('div[class*="spinner"]');//(m.getElementsByClassName('fullscreen-spinner_square__NGIgc'));
  4449. //let sat4 = m.getElementsByClassName('fullscreen-spinner_square__mwMfl');
  4450. // console.log(m.classList.contains('round-starting_wrapper__1G_FC'));
  4451.  
  4452. //if (m.classList.contains("game-layout__panorama-message"))
  4453. // if (document.body.querySelector(`[class*="game_panoramaMessage"]`))
  4454. if (checkFailedToLoadRoundMsg())
  4455. {
  4456. console.log("Fail to load canvas message - observer3")
  4457. if (allowDetect)
  4458. {
  4459. detectGamePage();
  4460. }
  4461. }
  4462. else if (m.getElementsByClassName("tooltip_tooltip__CHe2s").length !== 0)
  4463. {
  4464. // console.log("detect setting")
  4465. let mainMenuBtn = document.getElementById("Show Buttons");
  4466. if (mainMenuBtn != null)
  4467. {
  4468. // console.log("try to show show buttons")
  4469. mainMenuBtn.style.visibility = "";
  4470. if (mainMenuBtn.menuBtnCache)
  4471. {
  4472. for (let element of document.getElementsByClassName("menu-btn"))
  4473. {
  4474. element.style.visibility = "";
  4475. }
  4476. }
  4477. }
  4478. detectGamePage();
  4479. }
  4480. else if ((PATHNAME.startsWith("/challenge/") ||PATHNAME.startsWith("/results/") ||
  4481. PATHNAME.startsWith("/game/")|| PATHNAME.startsWith("/battle-royale/") ||
  4482. PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/") ||
  4483. PATHNAME.startsWith("/bullseye/")) && spinner)
  4484. {
  4485. // console.log("detect spinner")
  4486. if (allowDetect)
  4487. {
  4488. // obeserver detect
  4489. console.log('Main observer detect')
  4490. detectGamePage();
  4491. }
  4492. }
  4493. else if (!isPlayAlong && PATHNAME.startsWith("/play-along/")){
  4494. console.log("unity main observer detected play-along")
  4495.  
  4496. isPlayAlong = true;
  4497.  
  4498. if (allowDetect)
  4499. {
  4500. //detectGamePage();
  4501. setTimeout(()=>{
  4502. btnAll();
  4503. setMenuBtnsUnhidden();
  4504. }, 2000);
  4505. playAlongWebSocketInit();
  4506. }
  4507.  
  4508. }
  4509. else if ((PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/play-along/")) && (m.classList.contains('new-round_roundInfo__UlMCc')))
  4510. {
  4511. // console.log("detect duel")
  4512. if (allowDetect)
  4513. {
  4514. detectGamePage();
  4515. }
  4516. }
  4517. else if (PATHNAME.startsWith("/live-challenge/") && (m.classList.contains('round-starting_wrapper__1G_FC')))
  4518. {
  4519. // console.log("detect live challie")
  4520. if (allowDetect)
  4521. {
  4522. detectGamePage();
  4523. }
  4524. }
  4525.  
  4526. let sat = m.getElementsByClassName('result-layout_bottom__qLPd2');
  4527.  
  4528. // if (m.querySelectorAll('div[class*="result-layout_bottom"]').length !== 0)
  4529. // {
  4530. // // console.log("Round middle Callback");
  4531. // // EC : This puts links at the bottom of the next round button for say satellite mode or something.
  4532. // // I'm not sure if this is necessary.
  4533. // nextButtonCallback();
  4534. // }
  4535.  
  4536. let sat2 = m.getElementsByClassName('guess-map__canvas-container');
  4537. if (sat2.length !== 0)
  4538. {
  4539. // console.log("Minimap Callback");
  4540. handleMinimapCallback();
  4541. return;
  4542. }
  4543.  
  4544. if (PATHNAME.startsWith("/results/")){
  4545. // Made by EC for UAC
  4546. let mapsAnchor = document.querySelector('a[href^="/maps/"]');
  4547. if (mapsAnchor){
  4548. fetchOnce(`https://www.geoguessr.com/api/${mapsAnchor.href.replace(/.*(maps.*)/, "$1")}`, 5000)
  4549. .then((res) => res.json())
  4550. .then((json)=> {
  4551. // TODO EC: Do something here.
  4552. if (!/UAC/.test(json.name)){
  4553. return;
  4554. }
  4555.  
  4556. if (!json?.description){
  4557. showUACAnswerBtn(null);
  4558. return;
  4559. }
  4560.  
  4561. const answerHref = json.description?.replace(/\[\[(http.*?)\]\]/, "$1");
  4562. let t = fetch(answerHref)
  4563. .then((res) => res.json())
  4564. .then((json) => {
  4565. showUACAnswerBtn(JSON.stringify(json));
  4566. //unhackableAnswers(JSON.stringify(json));
  4567. }).catch(()=>{
  4568. showUACAnswerBtn(null);
  4569. });
  4570. })
  4571. .catch(function(e){ console.warn("FetchOnce called more than once.")});
  4572. }
  4573. }
  4574. }
  4575. }
  4576. }
  4577. })
  4578. })
  4579. observer3.observe(document.body, {childList: true, subtree: true, attributes: false, characterData: false})
  4580. }
  4581.  
  4582. let fetchOnce = function(){
  4583. // Made by EC
  4584. let obj = {};
  4585. return function(url, timeToWait){
  4586. if (obj[url]) return new Promise((res, rej) =>{ rej(); });
  4587. obj[url] = true;
  4588. return fetch(url);
  4589. }
  4590. }();
  4591.  
  4592. /**
  4593. * Once the Google Maps API was loaded we can do more stuff
  4594. */
  4595.  
  4596. var oldHref = document.location.href;
  4597.  
  4598. const immediateLoad = localStorage['unity_immediate_load']; // EC
  4599. const _pathName = getPathName();
  4600. if (_pathName.startsWith("/play-along/") || _pathName.startsWith("/challenge/") || _pathName.startsWith("/game/") || _pathName.startsWith("/results/") || immediateLoad === "true"){
  4601. // EC made this to fix not loading during game.
  4602. injecter(() => {
  4603. launchObserver();
  4604. })
  4605. localStorage['unity_immediate_load'] = false;
  4606. }
  4607.  
  4608. window.addEventListener('DOMContentLoaded', (event) => {
  4609. // Added by EC
  4610. doInitScript();
  4611. });
  4612.  
  4613. window.addEventListener('load', (event) => {
  4614. // Added by EC
  4615. doInitScript();
  4616. });
  4617.  
  4618. function doInitScript(){
  4619. // doInitScript added by EC.
  4620. if (sat_choice){
  4621. // Added by EC
  4622. const svCanvas = document.body.querySelector(GENERAL_CANVAS);
  4623. if (svCanvas) svCanvas.style.visibility = "hidden";
  4624. }
  4625. if (!document.getElementById("Show Buttons"))
  4626. {
  4627. console.log('dom content loaded')
  4628. injecter(() => {
  4629. launchObserver();
  4630. })
  4631. }
  4632.  
  4633. }
  4634.  
  4635. const base62 = {
  4636. charset: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  4637. .split(''),
  4638. encode: integer => {
  4639. if (integer === 0) {
  4640. return 0;
  4641. }
  4642. let s = [];
  4643. while (integer > 0) {
  4644. s = [base62.charset[integer % 62], ...s];
  4645. integer = Math.floor(integer / 62);
  4646. }
  4647. return s.join('');
  4648. },
  4649. decode: chars => chars.split('').reverse().reduce((prev, curr, i) =>
  4650. prev + (base62.charset.indexOf(curr) * (62 ** i)), 0)
  4651. };
  4652.  
  4653.  
  4654. /**
  4655. * Check whether the current page is a game, if so which game mode
  4656. */
  4657.  
  4658. function detectGamePage() {
  4659. // console.log("detect game change");
  4660. if (document.querySelector(FAIL_TO_LOAD_CANVAS) !== null && !one_reset)
  4661. {
  4662. one_reset = true;
  4663. console.log("Hide fail to load panorama canvas");
  4664. document.querySelector(FAIL_TO_LOAD_CANVAS).style.visibility = "hidden";
  4665. }
  4666. function loadModule()
  4667. {
  4668. // console.log("load module")
  4669. if (toLoad) {
  4670. // console.log("initializeCanvas")
  4671. initializeCanvas();
  4672. }
  4673. waitLoad();
  4674. }
  4675.  
  4676. let toLoad = !playerLoaded && !isPlayAlong && !YANDEX_INJECTED && !KAKAO_INJECTED && !MAPILLARY_INJECTED && !MS_INJECTED && !MAPBOX_INJECTED && !MAPY_INJECTED;
  4677. const PATHNAME = getPathName();
  4678. if (PATHNAME.startsWith("/game/") || PATHNAME.startsWith("/challenge/") || PATHNAME.startsWith("/play-along/")) {
  4679. // console.log("Game page");
  4680. isBattleRoyale = false;
  4681. isDuel = false;
  4682. loadModule();
  4683. }
  4684. else if (PATHNAME.startsWith("/battle-royale/")) {
  4685. if (document.querySelector(BR_LAYOUT) == null) {
  4686. // console.log("Battle Royale Lobby");
  4687. rstValues();
  4688. }
  4689. else {
  4690. // console.log("Battle Royale");
  4691. isBattleRoyale = true;
  4692. isDuel = false;
  4693. loadModule();
  4694. }
  4695. }
  4696. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  4697. if (document.querySelector(DUEL_LAYOUT) == null) {
  4698. // console.log("Battle Royale Lobby");
  4699. rstValues();
  4700. }
  4701. else {
  4702. // console.log("Duels");
  4703. isBattleRoyale = true;
  4704. isDuel = true;
  4705. loadModule();
  4706. }
  4707. }
  4708. else if (PATHNAME.startsWith("/bullseye/")) {
  4709. if (document.querySelector(".game_layout__0vAWj") == null) {
  4710. // console.log("Battle Royale Lobby");
  4711. rstValues();
  4712. }
  4713. else {
  4714. // console.log("bullseye");
  4715. isBattleRoyale = true;
  4716. isBullseye = true;
  4717. // console.log(document.getElementById("player"));
  4718. if (document.getElementById("player") == null)
  4719. {
  4720. loadModule();
  4721. }
  4722. }
  4723. }
  4724. else if (PATHNAME.startsWith("/live-challenge/")) {
  4725. if (document.querySelector(".panorama-question_layout__wSP7g") == null) {
  4726. // console.log("Battle Royale Lobby");
  4727. rstValues();
  4728. }
  4729. else {
  4730. // console.log("bullseye");
  4731. isLiveChallenge = true;
  4732. isBattleRoyale = true;
  4733. loadModule();
  4734. }
  4735. }
  4736. else {
  4737. rstValues();
  4738. // console.log("Not a Game page");
  4739. }
  4740. }
  4741.  
  4742. function rstValues()
  4743. {
  4744. ROUND = 0;
  4745. YandexPlayer = null;
  4746. KakaoPlayer = null;
  4747. MapillaryPlayer = null;
  4748. MSStreetPlayer = null;
  4749. MapyPlayer = null;
  4750.  
  4751. // MapboxPlayer = null;
  4752. // MapboxMarker = null;
  4753.  
  4754. BAIDU_INJECTED = false;
  4755. YANDEX_INJECTED = false;
  4756. KAKAO_INJECTED = false;
  4757. MAPILLARY_INJECTED = false;
  4758. MS_INJECTED = false;
  4759. MAPBOX_INJECTED = false;
  4760. MAPY_INJECTED = false;
  4761.  
  4762. nextPlayer = "Google";
  4763. nextPlayer_save = "Google";
  4764.  
  4765. global_data = {};
  4766. global_lat = 0;
  4767. global_lng = 0;
  4768. global_bounds = {max : {lat: 50.387397, lng: 57.412767}, min : {lat: 50.181227, lng: 57.077273}};
  4769. global_panoID = null;
  4770. global_cc = null;
  4771. global_BDAh = null;
  4772. global_BDBh = null;
  4773. global_BDID = null;
  4774. yId = null;
  4775. yTime = null;
  4776. yEnd = null;
  4777. iId = null;
  4778.  
  4779. COMPASS = null;
  4780. eventListenerAttached = false;
  4781. povListenerAttached = false;
  4782. playerLoaded = false;
  4783. handleBtwRoundsClear();
  4784. setHidden(true);
  4785. yandex_map = false;
  4786. Kakao_map = false;
  4787. Wikipedia_map = false;
  4788. Minecraft_map = false;
  4789. Youtube_map = false;
  4790. bing_map = false;
  4791. Mapy_map = false;
  4792. mmKey = 0;
  4793. CURRENT_ROUND_DATA = null;
  4794. ms_radius = 15000;
  4795.  
  4796. isDuel = false;
  4797. isBattleRoyale = false;
  4798. isBullseye = false;
  4799. isLiveChallenge = false;
  4800.  
  4801. BR_LOAD_KAKAO = false;
  4802. BR_LOAD_YANDEX = false;
  4803. BR_LOAD_MS = false;
  4804. BR_LOAD_MP = false;
  4805. BR_LOAD_MAPILLARY = false;
  4806. BR_LOAD_MAPY = false;
  4807.  
  4808. ms_sat_map = false;
  4809. rtded = false;
  4810.  
  4811. linksList = [];
  4812.  
  4813. NM = false;
  4814. NP = false;
  4815. NZ = false;
  4816. initBing = false;
  4817.  
  4818. planetType = "None";
  4819. bullseyeMapillary = false;
  4820.  
  4821. GAME_CANVAS = "";
  4822. DUEL_CANVAS = "";
  4823. randomPlanets = false;
  4824.  
  4825. // let RestrictBoundsBtn = document.getElementById("Restrict Bounds Main");
  4826. // let RestrictBoundsEnableBtn = document.getElementById("Restrict Bounds Enable");
  4827. // if (RestrictBoundsBtn && RestrictBoundsEnableBtn)
  4828. // {
  4829. // RestrictBoundsBtn.innerHTML = "No Escape Mode Disabled";
  4830. // RestrictBoundsBtn.enabled = false;
  4831. // RestrictBoundsEnableBtn.innerHTML = "Enable Limit";
  4832. // }
  4833. }
  4834.  
  4835. /**
  4836. * Wait for various players to load
  4837. */
  4838.  
  4839. function btnAll()
  4840. {
  4841. // console.log([document.querySelector(BULLSEYE_CANVAS), "???"])
  4842. if (document.querySelector(".ticket-bar_root__H8RcX") != null)
  4843. {
  4844. if (document.querySelector(BR_CANVAS) != null)
  4845. {
  4846. AdjustBtnPos("-2em + 2px", "300px", true);
  4847. }
  4848. else if (document.querySelector(DUELS_CANVAS) != null)
  4849. {
  4850. AdjustBtnPos("6em", "0em", true);
  4851. }
  4852. else if (document.querySelector(BULLSEYE_CANVAS) != null)
  4853. {
  4854. AdjustBtnPos("5em", "18.5em", true);
  4855. }
  4856. else if (document.querySelector(LIVE_CANVAS) != null)
  4857. {
  4858. AdjustBtnPos("4em", "0em", true);
  4859. }
  4860. else
  4861. {
  4862. AdjustBtnPos("4em", "0em", true);
  4863. }
  4864. }
  4865. else
  4866. {
  4867. if (document.querySelector(BR_CANVAS) != null)
  4868. {
  4869. AdjustBtnPos("-6em + 2px", "300px", true);
  4870. }
  4871. else if (document.querySelector(DUELS_CANVAS) != null)
  4872. {
  4873. AdjustBtnPos("2em", "0em", true);
  4874. }
  4875. else if (document.querySelector(BULLSEYE_CANVAS) != null)
  4876. {
  4877. AdjustBtnPos("1em", "18.5em", true);
  4878. }
  4879. else if (document.querySelector(LIVE_CANVAS) != null)
  4880. {
  4881. AdjustBtnPos("0em", "0em", true);
  4882. }
  4883. else
  4884. {
  4885. AdjustBtnPos("0em", "0em", true);
  4886. }
  4887. }
  4888. if (menuLocCounter > 0)
  4889. {
  4890. for (let i = 0; i < menuLocCounter; i++) {
  4891. AdjustBtnPos("-2em", "0em", false);
  4892. }
  4893. }
  4894. else if (menuLocCounter < 0)
  4895. {
  4896. for (let i = 0; i < -menuLocCounter; i++) {
  4897. AdjustBtnPos("2em", "0em", false);
  4898. }
  4899. }
  4900. }
  4901.  
  4902. function waitLoad() {
  4903. //if (!YandexPlayer || !KakaoPlayer || !MapillaryPlayer || !MSStreetPlayer || !MapboxPlayer || !MapyPlayer || !document.getElementById("i_container") || !YANDEX_INJECTED || !KAKAO_INJECTED || !MAPILLARY_INJECTED || !MS_INJECTED || !MAPBOX_INJECTED || !MAPY_INJECTED) {
  4904. if (isPlayAlong) return;
  4905. if (!YandexPlayer || !KakaoPlayer || !MapillaryPlayer || !MSStreetPlayer || !MapboxPlayer || !MapyPlayer /*|| !document.getElementById("i_container")*/ || !YANDEX_INJECTED || !KAKAO_INJECTED || !MAPILLARY_INJECTED || !MS_INJECTED || !MAPBOX_INJECTED || !MAPY_INJECTED) {
  4906. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4907.  
  4908. if ((isBullseye || isLiveChallenge) && (document.getElementById("player") == null))
  4909. {
  4910. BAIDU_INJECTED = false;
  4911. YANDEX_INJECTED = false;
  4912. KAKAO_INJECTED = false;
  4913. MAPILLARY_INJECTED = false;
  4914. MS_INJECTED = false;
  4915. MAPBOX_INJECTED = false;
  4916. MAPY_INJECTED = false;
  4917. initializeCanvas();
  4918. // document.querySelector(BULLSEYE_CANVAS).id = "player";
  4919. // injectContainer();
  4920. }
  4921. btnAll();
  4922. // console.log("wait");
  4923. // console.log([!YandexPlayer, !KakaoPlayer,!MapillaryPlayer,!MSStreetPlayer,!MapboxPlayer,!MapyPlayer,!document.getElementById("i_container"),!YANDEX_INJECTED,!KAKAO_INJECTED,!MAPILLARY_INJECTED,!MS_INJECTED,!MAPBOX_INJECTED,!MAPY_INJECTED])
  4924. setTimeout(waitLoad, 250);
  4925. } else {
  4926. checkRound();
  4927. }
  4928. }
  4929.  
  4930. /**
  4931. * Checks for round changes
  4932. */
  4933.  
  4934. function checkRound() {
  4935. // console.log("Check Round");
  4936. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4937. let switchCovergeButton = document.getElementById("switch");
  4938. if (!isBattleRoyale) {
  4939. // console.log("Check Round");
  4940. let currentRound = getRoundFromPage();
  4941. if (ROUND != currentRound) {
  4942. // fire1 = true;
  4943. switchCovergeButton.init = true;
  4944. console.log("New round");
  4945. ROUND = currentRound;
  4946. // NEW_ROUND_LOADED = true;
  4947. COMPASS = null;
  4948. handleBtwRoundsClear();
  4949. getMapData();
  4950. // nextButtonCallback();
  4951. }
  4952. }
  4953. else {
  4954. getMapData();
  4955. }
  4956. }
  4957.  
  4958. /**
  4959. * Add listeners if buttons have been created
  4960. */
  4961.  
  4962. function finalDetail()
  4963. {
  4964. let target = document.querySelector("a[data-qa='play-same-map']");
  4965. if (target)
  4966. {
  4967. var div = document.createElement("div");
  4968. div.classList.add("buttons_buttons__0B3SB")
  4969. document.querySelector('.result-layout_content__jAHfP').appendChild(div);
  4970. for (var rd of linksList)
  4971. {
  4972. let str;
  4973. if (rd[1] == "Mapbox Satellite")
  4974. {
  4975. str = "Google Maps";
  4976. }
  4977. else
  4978. {
  4979. str = rd[1];
  4980. }
  4981. // console.log(rd)
  4982. let cl = target.cloneNode( true );
  4983. let tx = "View R" + rd[0] + " in " + str;
  4984. cl.querySelector('.button_label__kpJrA').innerHTML = tx;
  4985. cl.removeAttribute('data-qa');
  4986. cl.removeAttribute('href');
  4987. cl.urlStr = rd[2];
  4988. cl.addEventListener("click", (e) => {
  4989. window.open(cl.urlStr);
  4990. })
  4991. cl.style = "top:10px;right:-10px;";
  4992. div.appendChild(cl);
  4993. }
  4994. }
  4995. else
  4996. {
  4997. setTimeout(finalDetail, 500);
  4998. }
  4999. }
  5000.  
  5001. function nextButtonCallback()
  5002. {
  5003. let nextButton = document.querySelector("button[data-qa='close-round-result']");
  5004. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5005. // if (nextButton != null && fire1)
  5006. // {
  5007. // fire1 = false;
  5008. nextButton.addEventListener("click", (e) => {
  5009.  
  5010. if (ROUND == 5)
  5011. {
  5012. console.log("Game Finished")
  5013. if (linksList)
  5014. {
  5015. finalDetail();
  5016. }
  5017. }
  5018. })
  5019. let urlStr = ""
  5020.  
  5021. if (nextPlayer !== "Google" && nextPlayer !== "Planets")
  5022. {
  5023. // console.log("Clone buttons");
  5024.  
  5025. let clone = document.querySelector("button[data-qa='close-round-result']").cloneNode( true );
  5026. let tx;
  5027. if (nextPlayer == "Mapbox Satellite")
  5028. {
  5029. tx = "View Location in Google Maps";
  5030. }
  5031. else
  5032. {
  5033. tx = "View Location in " + nextPlayer;
  5034. }
  5035. clone.querySelector('[class*="button_label"]').innerHTML = tx;
  5036. clone.setAttribute('id', "LinkBtn");
  5037. clone.removeAttribute('data-qa');
  5038. if (nextPlayer == "Baidu")
  5039. {
  5040. urlStr = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  5041. }
  5042. else if (nextPlayer == "Youtube")
  5043. {
  5044. urlStr = "https://www.youtube.com/watch?v=" + yId;
  5045. }
  5046. else if (nextPlayer == "Image")
  5047. {
  5048. urlStr = iId;
  5049. }
  5050. else if (nextPlayer == "Kakao")
  5051. {
  5052. urlStr = "https://map.kakao.com/link/roadview/" + global_lat + "," + global_lng;
  5053. }
  5054. else if (nextPlayer == "Mapillary")
  5055. {
  5056. urlStr = "https://www.mapillary.com/app/?pKey=" + mmKey + "&focus=photo";
  5057. }
  5058. else if (nextPlayer == "Yandex")
  5059. {
  5060. urlStr = "https://yandex.com/maps/?&panorama%5Bdirection%5D=16%2C0&panorama%5Bpoint%5D=" + global_lng + "%2C" + global_lat;
  5061. }
  5062. else if (nextPlayer == "Bing Streetside")
  5063. {
  5064. urlStr = "https://bing.com/maps/default.aspx?cp=" + global_lat + "~" + global_lng + "&lvl=20&style=r";
  5065. }
  5066. else if (nextPlayer == "Mapbox Satellite")
  5067. {
  5068. urlStr = `http://www.google.com/maps/place/${global_lat},${global_lng}`;
  5069. }
  5070. else if (nextPlayer == "Wikipedia")
  5071. {
  5072. urlStr = wikiUrl;
  5073. }
  5074. else if (nextPlayer == "Carte")
  5075. {
  5076. urlStr = carteCity;
  5077. }
  5078. // IMPLEMENT WIKIPEDIA
  5079. clone.addEventListener("click", (e) => {
  5080. window.open(urlStr);
  5081. })
  5082. if (ROUND == 5)
  5083. {
  5084. clone.style = "top:10px;";
  5085. }
  5086. else
  5087. {
  5088. clone.style = "right:-10px;";
  5089. }
  5090. linksList.push([ROUND, nextPlayer, urlStr]);
  5091. document.querySelector('[class*="round-result_actions"]').appendChild(clone);
  5092. }
  5093. // }
  5094. // else
  5095. // {
  5096. // setTimeout(nextButtonCallback, 1000);
  5097. // }
  5098. }
  5099.  
  5100. function guessButtonCallback()
  5101. {
  5102. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5103. let guessButton = document.querySelector("button[data-qa='perform-guess']");
  5104. let mainMenuBtn = document.getElementById("Show Buttons");
  5105. if (guessButton != null)
  5106. {
  5107.  
  5108. guessButton.addEventListener("click", (e) => {
  5109. if (mainMenuBtn != null)
  5110. {
  5111. console.log("try to hide show buttons")
  5112. mainMenuBtn.style.visibility = "hidden";
  5113. setHidden(true);
  5114. guessButtonCallback.callbacks.forEach((cb) => cb());
  5115. }
  5116. })
  5117. }
  5118. else
  5119. {
  5120. setTimeout(guessButtonCallback, 1000);
  5121. }
  5122. }
  5123. guessButtonCallback.callbacks = [];
  5124. guessButtonCallback.removeCallback = function(cb){
  5125. for (let n = 0; n < guessButtonCallback.callbacks.length;n++){
  5126. if (guessButtonCallback.callbacks[n] == cb){
  5127. guessButtonCallback.callbacks.splice(n, 1);
  5128. return;
  5129. }
  5130. }
  5131. }
  5132.  
  5133. /**
  5134. * Load different streetview players
  5135. */
  5136.  
  5137. function loaderChecker(map_name, map_description)
  5138. {
  5139. console.log('load checker')
  5140. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5141. let substrings = ["Yangle", "Goodex", "Yandex", "Bing Streetside", "Kakao", "Mapbox", "Bing Satellite", "Planets"]
  5142. bullseyeMapillary = ((isBullseye || isLiveChallenge) && !["Mapillary", "A United World", "A Unity World", "Unity Test","Unity Special Edition"].some(v => map_name.includes(v)));
  5143. if (substrings.some(v => map_name.includes(v)) || rtded || bullseyeMapillary)
  5144. {
  5145. MapillaryPlayer = "MA";
  5146. MAPILLARY_INJECTED = true;
  5147.  
  5148. console.log("Not loading Mapillary");
  5149. }
  5150. else
  5151. {
  5152. BR_LOAD_MAPILLARY = true;
  5153. injectMapillaryPlayer();
  5154. }
  5155.  
  5156. const unityNerd = /unity nerd/i.test(map_name);
  5157. const unityNoob = /unity noob/i.test(map_name);
  5158.  
  5159. if (!unityNerd){
  5160. deactivateUnityNerd();
  5161. } else {
  5162. activateUnityNerd();
  5163. }
  5164.  
  5165. if (!unityNoob){
  5166. deactivateUnityNoob();
  5167. } else {
  5168. activateUnityNoob();
  5169. }
  5170.  
  5171. if (map_name.includes("A United World") || map_name.includes("A Unity World") || map_name.includes("Unity Test") || map_name.includes("Unity Special Edition"))
  5172. {
  5173. console.log("Complete Map");
  5174. map_name = "Yandex Bing Streetside Kakao Mapbox Mapy";
  5175. }
  5176.  
  5177. if (map_name.includes("Yandex") || map_name.includes('Goodex') || map_name.includes('Yangle'))
  5178. {
  5179. console.log("Yandex Map or Goodex Map or Yangle Map");
  5180. if (map_name == "Yandex Bing Streetside Kakao Mapbox Mapy")
  5181. {
  5182. yandex_map = false;
  5183. }
  5184. else
  5185. {
  5186. yandex_map = true;
  5187. }
  5188.  
  5189. injectYandexScript().then(() => {
  5190. console.log("Ready to inject Yandex player");
  5191. injectYandexPlayer();
  5192. }).catch((error) => {
  5193. console.log(error);
  5194. });
  5195. BR_LOAD_YANDEX = true;
  5196. }
  5197. else
  5198. {
  5199. // console.log("Not Yandex map");
  5200. YANDEX_INJECTED = true;
  5201. YandexPlayer = "YD";
  5202. }
  5203.  
  5204. if (map_name.includes("Bing Streetside") || map_name.includes("Planets"))
  5205. {
  5206. console.log("Bing Map");
  5207. if (map_name.includes("Planets"))
  5208. {
  5209. let tempRad2;
  5210. tempRad2 = map_name.split("Planets")[1];
  5211. if (/\d/.test(tempRad2))
  5212. {
  5213. ms_radius = parseInt(tempRad2.replace(/\D/g,'')) * 1000;
  5214. }
  5215. bing_map = true;
  5216.  
  5217. for (let pl of spaceList)
  5218. {
  5219. if (map_name.includes(pl))
  5220. {
  5221. planetType = pl;
  5222. }
  5223. }
  5224. if (planetType == "Solar System")
  5225. {
  5226. randomPlanets = true;
  5227. }
  5228. console.log(planetType)
  5229. // else if (map_name.includes("GTA V"))
  5230. // {
  5231. // planetType = "GTAV";
  5232. // }
  5233. // else if (map_name.includes("GTA San Andreas"))
  5234. // {
  5235. // planetType = "GTASA";
  5236. // }
  5237.  
  5238. }
  5239. if (map_name == "Yandex Bing Streetside Kakao Mapbox Mapy")
  5240. {
  5241. bing_map = false;
  5242. }
  5243. injectMSPlayer();
  5244. // initBing = true;
  5245. BR_LOAD_MS = true;
  5246. }
  5247. else
  5248. {
  5249. // console.log("Not Bing map");
  5250. MS_INJECTED = true;
  5251. MSStreetPlayer = "MS";
  5252. }
  5253.  
  5254.  
  5255. let canvas = document.getElementById("sat_map");
  5256. if (/🛰️|🛰/.test(map_name) || map_name.includes("Bing Satellite") || map_name.includes("Mapbox") || map_name.includes("Unity Satellite") || (sat_choice && !rtded))
  5257. {
  5258. if (map_name == "Yandex Bing Streetside Kakao Mapbox Mapy")
  5259. {
  5260. ms_sat_map = false;
  5261. }
  5262. else
  5263. {
  5264. ms_sat_map = true;
  5265. }
  5266. let tempRad;
  5267. if (map_name.includes("Bing Satellite"))
  5268. {
  5269. tempRad = map_name.split("Bing Satellite")[1];
  5270. }
  5271. else if (map_name.includes("Mapbox"))
  5272. {
  5273. tempRad = map_name.split("Mapbox")[1];
  5274. }
  5275. else if (map_name.includes("Unity Satellite"))
  5276. {
  5277. tempRad = map_name.split("Unity Satellite")[1];
  5278. }
  5279. else if (/🛰️|🛰/.test(map_name))
  5280. {
  5281. tempRad = map_name.replace(/(🛰️|🛰)(\d+)(🛰️|🛰)/, '$2');
  5282. }
  5283.  
  5284. if (/\d/.test(tempRad))
  5285. {
  5286. ms_radius = parseInt(tempRad.replace(/\D/g,'')) * 1000;
  5287. }
  5288. console.log("Mapbox Satellite Map");
  5289. // console.log(canvas)
  5290.  
  5291. if (!canvas)
  5292. {
  5293. injectMapboxPlayer();
  5294. }
  5295. else
  5296. {
  5297. changeInnerHTML(canvas, false);
  5298. MAPBOX_INJECTED = true;
  5299. }
  5300. initBing = true;
  5301. BR_LOAD_MP = true;
  5302. }
  5303. else
  5304. {
  5305. if (canvas == null)
  5306. {
  5307. MapboxPlayer = "MP";
  5308. }
  5309. MAPBOX_INJECTED = true;
  5310. // console.log("Not Mapbox Satellite map");
  5311.  
  5312. }
  5313.  
  5314. if (map_name.includes("Kakao"))
  5315. {
  5316. console.log("Kakao Map");
  5317. if (map_name == "Yandex Bing Streetside Kakao Mapbox Mapy")
  5318. {
  5319. Kakao_map = false;
  5320. }
  5321. else
  5322. {
  5323. Kakao_map = true;
  5324. }
  5325. injectKakaoScript().then(() => {
  5326. console.log("Ready to inject Kakao player");
  5327. }).catch((error) => {
  5328. console.log(error);
  5329. });
  5330. BR_LOAD_KAKAO = true;
  5331. }
  5332. else{
  5333. KAKAO_INJECTED = true;
  5334. KakaoPlayer = "KK";
  5335. // console.log("Not Kakao map");
  5336. }
  5337.  
  5338. if (map_name.includes("Mapy") || map_name.includes("mapy"))
  5339. {
  5340. console.log("Mapy Map");
  5341. if (map_name == "Yandex Bing Streetside Kakao Mapbox Mapy")
  5342. {
  5343. Mapy_map = false;
  5344. }
  5345. else
  5346. {
  5347. Mapy_map = true;
  5348. }
  5349. injectMapyPlayer();
  5350. BR_LOAD_MAPY = true;
  5351. }
  5352. else{
  5353. MAPY_INJECTED = true;
  5354. MapyPlayer = "MPP";
  5355. // console.log("Not Kakao map");
  5356. }
  5357.  
  5358. if (map_name.includes("Wikipedia"))
  5359. {
  5360. console.log("Wikipedia Map");
  5361. Wikipedia_map = true;
  5362.  
  5363. }
  5364. else{
  5365. // console.log("Not Wikipedia map");
  5366. }
  5367.  
  5368. if (map_name.includes("WikiXplore"))
  5369. {
  5370. console.log("Wikipedia Map");
  5371. Wikipedia_map = true;
  5372. WikiXplore_map = true;
  5373. }
  5374. else{
  5375. // console.log("Not Wikipedia map");
  5376. }
  5377.  
  5378. if (map_name.includes("[RMC]"))
  5379. {
  5380. console.log("is Random map challenge");
  5381. randomMapChallenge_map = true;
  5382. randomMapChallenge_map_init(map_description);
  5383. }
  5384. else{
  5385. // console.log("Not Wikipedia map");
  5386. }
  5387. if (map_name.includes("Minecraft"))
  5388. {
  5389. console.log("Minecraft Map");
  5390. Minecraft_map = true;
  5391.  
  5392. }
  5393. else{
  5394. // console.log("Not Minecraft map");
  5395. }
  5396.  
  5397. if (map_name.includes("Youtube") || map_name.includes("YouTube"))
  5398. {
  5399. console.log("Youtube Map");
  5400. Youtube_map = true;
  5401.  
  5402. }
  5403. else{
  5404. // console.log("Not Minecraft map");
  5405. }
  5406.  
  5407. setHidden(false);
  5408.  
  5409. if (map_name.includes("China Tips for each province"))
  5410. {
  5411. guaranteeUI();
  5412. AdjustBtnPos("0em", "22em", true);
  5413. console.log("AdjustBtnPos");
  5414. }
  5415. }
  5416.  
  5417. function loadPlayers() {
  5418. let mapBounds;
  5419.  
  5420. playerLoaded = true;
  5421. injectContainer();
  5422. getSeed().then((data) => {
  5423. console.log('get seed', data)
  5424. let map_name = "Default"
  5425.  
  5426. if (typeof data.isRated !== 'undefined')
  5427. {
  5428. rtded = data.isRated;
  5429. }
  5430.  
  5431. if (typeof data.options !== 'undefined')
  5432. {
  5433. if (typeof data.options.isRated !== 'undefined')
  5434. {
  5435. rtded = data.options.isRated;
  5436. }
  5437. }
  5438.  
  5439. if (rtded)
  5440. {
  5441. map_name = "Public Game";
  5442. }
  5443. else
  5444. {
  5445. if (!isBattleRoyale)
  5446. {
  5447. mapBounds = [data.bounds.max.lat, data.bounds.max.lng, data.bounds.min.lat, data.bounds.min.lng];
  5448. map_name = data.mapName;
  5449. }
  5450. else
  5451. {
  5452. if (isBullseye)
  5453. {
  5454. mapBounds = [data.boundingBox.max.lat, data.boundingBox.max.lng, data.boundingBox.min.lat, data.boundingBox.min.lng];
  5455. map_name = data.mapName;
  5456. }
  5457. else if (isDuel)
  5458. {
  5459. mapBounds = [data.mapBounds.max.lat, data.mapBounds.max.lng, data.mapBounds.min.lat, data.mapBounds.min.lng];
  5460. map_name = data.options.map.name;
  5461. }
  5462. else if (isLiveChallenge)
  5463. {
  5464. mapBounds = [data.rounds[0].question.panoramaQuestionPayload.mapBounds.max.lat, data.rounds[0].question.panoramaQuestionPayload.mapBounds.max.lng,
  5465. data.rounds[0].question.panoramaQuestionPayload.mapBounds.min.lat, data.rounds[0].question.panoramaQuestionPayload.mapBounds.min.lng];
  5466. map_name = data.rounds[0].question.panoramaQuestionPayload.mapName;
  5467. }
  5468. else
  5469. {
  5470. map_name = "Unity Test";
  5471. }
  5472. }
  5473. }
  5474.  
  5475. if (mapBounds)
  5476. {
  5477. ms_radius = magic_formula(mapBounds);
  5478. // console.log(ms_radius / 1000)
  5479. }
  5480.  
  5481. loaderChecker(map_name, data)
  5482.  
  5483. }).catch((error) => {
  5484. console.log(error);
  5485. });
  5486. }
  5487.  
  5488. function guaranteeUI()
  5489. {
  5490. // console.log("UI")
  5491. if (document.getElementById("GH-ui") !== null)
  5492. {
  5493. document.getElementById("GH-ui").style.display = "block";
  5494. }
  5495. else
  5496. {
  5497. setTimeout(guaranteeUI, 500);
  5498. }
  5499. }
  5500.  
  5501. /**
  5502. * Handles Return to start and undo
  5503. */
  5504.  
  5505. function handleReturnToStart() {
  5506. let rtsButton = document.querySelector("button[data-qa='return-to-start']");
  5507. // console.log("Handle Return to start");
  5508. rtsButton.addEventListener("click", (e) => {
  5509. if (nextPlayer !== "Baidu")
  5510. {
  5511. goToLocation(true);
  5512. }
  5513. else
  5514. {
  5515. document.getElementById("i_container").src = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  5516. }
  5517. const elementClicked = e.target;
  5518. elementClicked.setAttribute('listener', 'true');
  5519. console.log("Return to start");
  5520. });
  5521. guessButtonCallback();
  5522. // setTimeout(function () {goToLocation();}, 1000);
  5523. }
  5524.  
  5525. function handleUndo() {
  5526. let undoButton = document.querySelector("button[data-qa='undo-move']");
  5527. // console.log("Handle undo");
  5528. undoButton.addEventListener("click", (e) => {
  5529. if (locHistory.length > 0) {
  5530. goToUndoMove();
  5531. console.log("Undo Move");
  5532. }
  5533. })
  5534. }
  5535.  
  5536. /**
  5537. * Load game information
  5538. */
  5539.  
  5540. function satCallback()
  5541. {
  5542. if (typeof MapboxPlayer.flyTo !== typeof undefined)
  5543. {
  5544. goToLocation(false);
  5545. }
  5546. else
  5547. {
  5548. setTimeout(satCallback, 250);
  5549. }
  5550. }
  5551.  
  5552. function kakaoCallback()
  5553. {
  5554. console.log("Kakao callback")
  5555. if (typeof kakao.maps !== typeof undefined)
  5556. {
  5557. goToLocation(true);
  5558. setTimeout(function () {goToLocation(true);}, 3000);
  5559. }
  5560. else
  5561. {
  5562. setTimeout(kakaoCallback, 250);
  5563. }
  5564. }
  5565.  
  5566.  
  5567. function modularget(data)
  5568. {
  5569. if (data)
  5570. {
  5571. locationCheck(data);
  5572. if (nextPlayer == "Kakao")
  5573. {
  5574. kakaoCallback();
  5575. }
  5576. else
  5577. {
  5578. goToLocation(true);
  5579. }
  5580. // handleMinimapCallback();
  5581. handleButtons();
  5582. }
  5583. }
  5584.  
  5585. function getMapData() {
  5586. // myHighlight("Seed data");
  5587.  
  5588. getSeed().then((data) => {
  5589. let switchCovergeButton = document.getElementById("switch");
  5590. let mainMenuBtn = document.getElementById("Show Buttons")
  5591. if (isBattleRoyale) {
  5592. if (data.status == "Finished" || typeof data.gameId == typeof undefined) {
  5593. // console.log("Battle Royale Lobby");
  5594. }
  5595. else
  5596. {
  5597. let origin = false;
  5598. if (!CURRENT_ROUND_DATA) {
  5599. CURRENT_ROUND_DATA = data
  5600. origin = true;
  5601. }
  5602.  
  5603. if (origin || !(data.currentRoundNumber === CURRENT_ROUND_DATA.currentRoundNumber)) {
  5604. // myHighlight("Battle Royale New round");
  5605. switchCovergeButton.init = true;
  5606. // NEW_ROUND_LOADED = true;
  5607. COMPASS = null;
  5608. handleBtwRoundsClear();
  5609. setHidden(false);
  5610. if (!origin) {
  5611. CURRENT_ROUND_DATA = data;
  5612. }
  5613. modularget(data);
  5614. }
  5615. }
  5616. }
  5617. else {
  5618. modularget(data);
  5619. }
  5620.  
  5621. }).catch((error) => {
  5622. console.log(error);
  5623. });
  5624. }
  5625.  
  5626. function handleMinimapCallback()
  5627. {
  5628. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5629. let MinimapBtn = document.getElementById("Minimap Button");
  5630. if (MinimapBtn)
  5631. {
  5632. let cur = MinimapBtn.current;
  5633. // console.log(cur)
  5634. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  5635. if (cur == mapDiv.id)
  5636. {
  5637. setTimeout(function () {mapDiv.click();}, 500);
  5638. setTimeout(function () {mapDiv.click();}, 1000);
  5639. setTimeout(function () {mapDiv.click();}, 3000);
  5640. }
  5641. }
  5642. }
  5643. else
  5644. {
  5645. setTimeout(handleMinimapCallback, 1000);
  5646. }
  5647. }
  5648.  
  5649. /**
  5650. * Hide unnecessary buttons for non-Google coverages
  5651. */
  5652.  
  5653. function handleButtons() {
  5654. let CHECKPOINT = document.querySelector("button[data-qa='set-checkpoint']");
  5655. let ZOOM_IN = document.querySelector("button[data-qa='pano-zoom-in']");
  5656. let ZOOM_OUT = document.querySelector("button[data-qa='pano-zoom-out']");
  5657. let UNDO_MOVE = document.querySelector("button[data-qa='undo-move']");
  5658. //let DEFAULT_COMPASS = document.querySelector(".compass");
  5659. let DEFAULT_COMPASS = document.querySelector("[title*='Compass' i]");
  5660. let NEW_COMPASS = document.querySelector(".panorama-compass_compassContainer__MEnh0");
  5661. let RETURN_TO_START = document.querySelector("button[data-qa='return-to-start']");
  5662.  
  5663. let C1 = (CHECKPOINT !== null);
  5664. let C2 = (ZOOM_IN !== null);
  5665. let C3 = (ZOOM_OUT !== null);
  5666. let C4 = (UNDO_MOVE !== null);
  5667. let C5 = (DEFAULT_COMPASS !== null);
  5668. let C6 = (NEW_COMPASS !== null);
  5669. let C7 = (RETURN_TO_START !== null);
  5670.  
  5671. let waitCond = C5 || C6;
  5672. let cpCond = true;
  5673. let comCond = true;
  5674. if (!NM)
  5675. {
  5676. cpCond = C1 && C4 && C7;
  5677. }
  5678. if (!NZ)
  5679. {
  5680. comCond = C2 && C3;
  5681. }
  5682.  
  5683. function moduleButtons(cond)
  5684. {
  5685.  
  5686. if (!NM)
  5687. {
  5688. CHECKPOINT.style.visibility = cond;
  5689. UNDO_MOVE.style.visibility = cond;
  5690. }
  5691. if (!NZ)
  5692. {
  5693. ZOOM_IN.style.visibility = cond;
  5694. ZOOM_OUT.style.visibility = cond;
  5695. }
  5696. if (C5)
  5697. {
  5698. DEFAULT_COMPASS.style.visibility = cond;
  5699. }
  5700. if (C6)
  5701. {
  5702. NEW_COMPASS.style.visibility = cond;
  5703. }
  5704. }
  5705.  
  5706. if (waitCond && cpCond && comCond)
  5707. {
  5708. // console.log("Handle Buttons");
  5709. if (nextPlayer === "Google" || nextPlayer === "Wikipedia" || nextPlayer === "Youtube") {
  5710. moduleButtons("");
  5711. }
  5712. else if (nextPlayer === "Baidu" || nextPlayer === "Image" || nextPlayer === "Mapbox Satellite" || nextPlayer === "Minecraft" || nextPlayer === "Planets" || nextPlayer === "Carte")
  5713. {
  5714. moduleButtons("hidden");
  5715. }
  5716. else if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Mapillary" || nextPlayer === "Bing Streetside" || nextPlayer === "Mapy")
  5717. {
  5718. moduleButtons("hidden");
  5719. if (nextPlayer === "Yandex" || nextPlayer === "Kakao")
  5720. {
  5721. if (C5)
  5722. {
  5723. DEFAULT_COMPASS.style.visibility = "";
  5724. }
  5725. if (C6)
  5726. {
  5727. NEW_COMPASS.style.visibility = "";
  5728. }
  5729. }
  5730. if (!NM)
  5731. {
  5732. UNDO_MOVE.style.visibility = "";
  5733. handleUndo();
  5734. }
  5735. }
  5736. if (!NM)
  5737. {
  5738. handleReturnToStart();
  5739. }
  5740. }
  5741. else
  5742. {
  5743. setTimeout(handleButtons, 250);
  5744. }
  5745. }
  5746.  
  5747. /**
  5748. * Check which player to use for the next location
  5749. */
  5750.  
  5751. function locationCheck(data) {
  5752. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5753. console.log(data)
  5754. let curRound = data.rounds[data.rounds.length -1];
  5755.  
  5756.  
  5757. let round;
  5758. let switchCovergeButton = document.getElementById("switch");
  5759. let satelliteSwitchButton = document.getElementById("Satellite Switch");
  5760. // console.log(data)
  5761.  
  5762. if (isBattleRoyale) {
  5763. if (isDuel || isBullseye)
  5764. {
  5765. round = data.rounds[data.currentRoundNumber - 1].panorama;
  5766. global_cc = round.countryCode;
  5767. }
  5768. else if (isLiveChallenge)
  5769. {
  5770. round = data.rounds[data.currentRoundNumber - 1].question.panoramaQuestionPayload.panorama;
  5771. global_cc = round.countryCode;
  5772. }
  5773. else
  5774. {
  5775. round = data.rounds[data.currentRoundNumber - 1];
  5776. global_cc = "us"; // No field available
  5777. }
  5778.  
  5779. }
  5780. else {
  5781. round = data.rounds[data.round - 1];
  5782. global_cc = round.streakLocationCode;
  5783. }
  5784.  
  5785. global_data = data;
  5786. global_lat = round.lat;
  5787. global_lng = round.lng;
  5788. global_panoID = round.panoId;
  5789. global_bounds = data.bounds;
  5790.  
  5791. global_heading = round.heading;
  5792. global_pitch = round.pitch;
  5793.  
  5794. nextPlayer = "Google";
  5795. //
  5796. // Start of Unity Nerd stuff
  5797. //
  5798. unityNerdFn(data);
  5799. //
  5800. // End of Unity Nerd stuff
  5801. //
  5802.  
  5803. function runCheck()
  5804. {
  5805. if (Kakao_map)
  5806. {
  5807. nextPlayer = "Kakao";
  5808. }
  5809. else if (yandex_map)
  5810. {
  5811. nextPlayer = "Yandex";
  5812. }
  5813. else if (Wikipedia_map)
  5814. {
  5815. nextPlayer = "Wikipedia";
  5816. }
  5817. else if (Minecraft_map)
  5818. {
  5819. nextPlayer = "Minecraft";
  5820. }
  5821. else if (Youtube_map)
  5822. {
  5823. nextPlayer = "Youtube";
  5824. }
  5825. else if (bing_map)
  5826. {
  5827. nextPlayer = "Planets";
  5828. }
  5829. else if (Mapy_map)
  5830. {
  5831. nextPlayer = "Mapy";
  5832. }
  5833. else
  5834. {
  5835. nextPlayer = "Google";
  5836. }
  5837. }
  5838.  
  5839. if (global_panoID) {
  5840. let locInfo;
  5841. if (isBullseye)
  5842. {
  5843. locInfo = global_panoID;
  5844. }
  5845. else
  5846. {
  5847. locInfo = hex2a(global_panoID);
  5848. }
  5849. // console.log(locInfo)
  5850. if (locInfo.substring(0, 3) == "YTB")
  5851. {
  5852. nextPlayer = "Youtube";
  5853. let lengths = [3, 11, 4, 4];
  5854. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  5855. let fullID = locInfo.substring(3).split('START');
  5856. yId = toPiece[1];
  5857. yTime = Number(toPiece[2]);
  5858. yEnd = Number(toPiece[3]);
  5859. }
  5860. else
  5861. {
  5862. let mapType = locInfo.substring(0, 5);
  5863.  
  5864. // panoId unchanged
  5865.  
  5866. if (mapType === "YDMAP" ) {
  5867. nextPlayer = "Yandex";
  5868. }
  5869. else if (mapType === "KKMAP" ) {
  5870. nextPlayer = "Kakao";
  5871. }
  5872.  
  5873. // New panoId formats
  5874.  
  5875. else if (mapType === "BAIDU" ) {
  5876. nextPlayer = "Baidu";
  5877. let lengths = [5, 7, 7, 3];
  5878. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  5879. let panoId1 = base62.decode(toPiece[1]).toString().substring(1);
  5880. let panoId2 = base62.decode(toPiece[2]).toString().substring(1);
  5881. global_BDID = panoId1 + panoId2 + toPiece[3]
  5882. }
  5883. else if (mapType === "MAPIL")
  5884. {
  5885. nextPlayer = "Mapillary";
  5886. mmKey = locInfo.substring(5).replace(/\D/g,'');
  5887. }
  5888. else if (mapType === "IMAGE")
  5889. {
  5890. nextPlayer = "Image";
  5891. let lengths = [5, 4, 4, 7, 2];
  5892. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  5893. iId = "https://i.ibb.co/" + toPiece[3] + "/" + toPiece[1] + "." + toPiece[2].replace(/[^0-9a-z]/gi, '')
  5894. }
  5895. else if (mapType.includes("BING")) {
  5896. if (mapType === "BINGM")
  5897. {
  5898. nextPlayer = "Bing Streetside";
  5899. }
  5900. else
  5901. {
  5902. nextPlayer = "Planets";
  5903. let num = mapType.slice(-1).charCodeAt(0) - 65;
  5904. planetType = spaceList[num];
  5905.  
  5906. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  5907. }
  5908. }
  5909. else if (mapType === "SATEL" ) {
  5910. nextPlayer = "Mapbox Satellite";
  5911. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  5912. }
  5913. else if (mapType === "MINEC" ) {
  5914. nextPlayer = "Minecraft";
  5915. }
  5916. else if (mapType === "WIKIP" ) {
  5917. nextPlayer = "Wikipedia";
  5918. }
  5919. else if (mapType === "CARTE")
  5920. {
  5921. nextPlayer = "Carte";
  5922. let cityCode = locInfo.substring(5, 7);
  5923. let panoNum = locInfo.substring(7).replace(/\D/g,'');
  5924. console.log(cityCode);
  5925. carteCity = "http://" + carteDict[cityCode] + ".carte.ma/view/" + carteDict[cityCode] + ".php?sv=" + panoNum;
  5926. }
  5927. else if (mapType === "YOUTU")
  5928. {
  5929. nextPlayer = "Youtube";
  5930. }
  5931. else if (mapType === "MAPYC")
  5932. {
  5933. nextPlayer = "Mapy";
  5934. global_BDID = "";
  5935. }
  5936. else if (mapType === "MAPCZ")
  5937. {
  5938. nextPlayer = "Mapy";
  5939. global_BDID = locInfo.substring(5, 13);
  5940. }
  5941. else
  5942. {
  5943. runCheck();
  5944. }
  5945. }
  5946. }
  5947. else
  5948. {
  5949. runCheck();
  5950. }
  5951.  
  5952. // Disable buttons if NM, NMPZ
  5953.  
  5954. if(!isBattleRoyale)
  5955. {
  5956. NM = data.forbidMoving;
  5957. NP = data.forbidRotating;
  5958. NZ = data.forbidZooming;
  5959. }
  5960. else
  5961. {
  5962. // console.log(data)
  5963. if (isBullseye || isLiveChallenge)
  5964. {
  5965. NM = data.options.movementOptions.forbidMoving;
  5966. NP = data.options.movementOptions.forbidRotating;
  5967. NZ = data.options.movementOptions.forbidZooming;
  5968. }
  5969. else
  5970. {
  5971. NM = data.movementOptions.forbidMoving;
  5972. NP = data.movementOptions.forbidRotating;
  5973. NZ = data.movementOptions.forbidZooming;
  5974. let canvas = document.getElementById("sat_map");
  5975. if (!canvas)
  5976. {
  5977. injectMapboxPlayer();
  5978. }
  5979. else
  5980. {
  5981. changeInnerHTML(canvas, false);
  5982. MAPBOX_INJECTED = true;
  5983. }
  5984. nextPlayer = "Mapbox Satellite";
  5985. }
  5986. }
  5987. if (NM || NP || NZ)
  5988. {
  5989. // EC: Why disable the time machine feature for nm or np or nz?
  5990. //setDisable("NMPZ");
  5991. }
  5992. else
  5993. {
  5994. setDisable(nextPlayer);
  5995. }
  5996.  
  5997. if (nextPlayer == "Google")
  5998. {
  5999. switchCovergeButton.innerHTML = "Switch to Mapillary";
  6000. }
  6001. else
  6002. {
  6003. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  6004. }
  6005. nextPlayer_save = nextPlayer;
  6006.  
  6007.  
  6008. // console.log("??")
  6009. // console.log(sessionStorage.getItem('Satellite') == "T")
  6010. // console.log(ms_sat_map)
  6011. if (ms_sat_map || (sat_choice && nextPlayer !== "Baidu" && !rtded))
  6012. {
  6013. nextPlayer = "Mapbox Satellite";
  6014. }
  6015.  
  6016. if (nextPlayer == "Mapbox Satellite")
  6017. {
  6018. let di3 = formatDist();
  6019. satelliteSwitchButton.innerHTML = `Satellite (${di3})`;
  6020. }
  6021. else
  6022. {
  6023. satelliteSwitchButton.innerHTML = "Streetview mode";
  6024. }
  6025. console.log(nextPlayer_save + "," + nextPlayer);
  6026. if (!rtded)
  6027. {
  6028. injectCanvas();
  6029. }
  6030. else
  6031. {
  6032. console.log("rated game, no canvas injection");
  6033. }
  6034. }
  6035.  
  6036.  
  6037. /**
  6038. * setID for canvas
  6039. */
  6040.  
  6041. function initializeCanvas() {
  6042. GAME_CANVAS = "";
  6043. DUEL_CANVAS = "";
  6044. //console.log("Is duels");
  6045. //console.log(duels);
  6046.  
  6047. if (isBattleRoyale) {
  6048. if (isDuel) {
  6049. GAME_CANVAS = document.querySelector(DUELS_CANVAS);
  6050. DUEL_CANVAS = document.querySelector(DUELS_CANVAS2);
  6051. }
  6052. else if (isBullseye) {
  6053. GAME_CANVAS = document.querySelector(BULLSEYE_CANVAS);
  6054. DUEL_CANVAS = "dummy";
  6055. }
  6056. else if (isLiveChallenge)
  6057. {
  6058. GAME_CANVAS = document.querySelector(LIVE_CANVAS);
  6059. DUEL_CANVAS = "dummy";
  6060. }
  6061. else
  6062. {
  6063. GAME_CANVAS = document.querySelector(BR_WRAPPER);
  6064. DUEL_CANVAS = "dummy";
  6065. }
  6066. }
  6067. else {
  6068. GAME_CANVAS = document.querySelector(GENERAL_LAYOUT);
  6069. DUEL_CANVAS = "dummy";
  6070. }
  6071. if (GAME_CANVAS && DUEL_CANVAS)
  6072. {
  6073. console.log("Canvas injected");
  6074. GAME_CANVAS.id = "player";
  6075.  
  6076. if (isDuel) {
  6077. DUEL_CANVAS.id = "default_player";
  6078. }
  6079.  
  6080. let mosaicBtn = document.getElementById("Mosaic Enable");
  6081. if (mosaicPre)
  6082. {
  6083. loadGridBtn(mosaicBtn.grid);
  6084. }
  6085.  
  6086. partialCreateMapillary = (typeof mapillary !== typeof undefined)
  6087. partialCreateYandex = (typeof ymaps !== typeof undefined)
  6088. partialCreateKakao = (typeof kakao !== typeof undefined)
  6089. partialCreateMS = (typeof Microsoft !== typeof undefined);
  6090. partialCreateMapbox = (typeof mapboxgl !== typeof undefined);
  6091. partialCreateMapy = (typeof SMap !== typeof undefined);
  6092. loadPlayers();
  6093. }
  6094. else
  6095. {
  6096. setTimeout(initializeCanvas, 250);
  6097. }
  6098.  
  6099. }
  6100.  
  6101. /**
  6102. * Hide or show players based on where the next location is
  6103. */
  6104.  
  6105. function injectCanvas() {
  6106. if (isDuel)
  6107. {
  6108. if (!rtded)
  6109. {
  6110. canvasSwitch();
  6111. }
  6112. }
  6113. else
  6114. {
  6115. Google();
  6116. Baidu();
  6117. if (BR_LOAD_KAKAO)
  6118. {
  6119. Kakao();
  6120. }
  6121. if (BR_LOAD_YANDEX)
  6122. {
  6123. Yandex();
  6124. }
  6125. if (BR_LOAD_MS)
  6126. {
  6127. // console.log("Yes")
  6128. Bing();
  6129. }
  6130. if (BR_LOAD_MP)
  6131. {
  6132. // console.log("Yes")
  6133. Mapbox();
  6134. }
  6135. if (BR_LOAD_MAPILLARY)
  6136. {
  6137. Mapillary();
  6138. }
  6139. if (BR_LOAD_MAPY)
  6140. {
  6141. Mapy();
  6142. }
  6143. }
  6144.  
  6145. }
  6146.  
  6147. // for duels (class ID change)
  6148.  
  6149. function canvasSwitch()
  6150. {
  6151.  
  6152. // console.log("canvas switch")
  6153. // let cond = true;
  6154. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6155. let teleportMenu = document.getElementById("Teleport Button");
  6156. let switchCovergeButton = document.getElementById("switch");
  6157.  
  6158. let GOOGLE_MAPS_CANVAS = document.querySelector(DUELS_CANVAS);
  6159. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  6160. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  6161. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  6162. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  6163. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  6164. let MAPBOX_MAPS_CANVAS = document.getElementById("mapbox-player");
  6165. let MAPY_MAPS_CANVAS = document.getElementById("mapy-player");
  6166. // 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])
  6167.  
  6168. if (GOOGLE_MAPS_CANVAS && BAIDU_MAPS_CANVAS && (!BR_LOAD_MAPILLARY || MAPILLARY_MAPS_CANVAS) && (!BR_LOAD_KAKAO || KAKAO_MAPS_CANVAS) &&
  6169. (!BR_LOAD_MS || BING_MAPS_CANVAS) && (!BR_LOAD_YANDEX || YANDEX_MAPS_CANVAS) && (!BR_LOAD_MP || MAPBOX_MAPS_CANVAS) && (!BR_LOAD_MAPY || MAPY_MAPS_CANVAS))
  6170. {
  6171. document.getElementById("default_player").style.position = "absolute";
  6172. document.getElementById("default_player").className = "inactive";
  6173. BAIDU_MAPS_CANVAS.style.position = "absolute";
  6174. BAIDU_MAPS_CANVAS.className = "inactive";
  6175. BAIDU_MAPS_CANVAS.visibility = "hidden";
  6176.  
  6177. if (BR_LOAD_MAPILLARY)
  6178. {
  6179. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  6180. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  6181. MAPILLARY_MAPS_CANVAS.className = "inactive";
  6182. }
  6183.  
  6184. if (BR_LOAD_KAKAO)
  6185. {
  6186. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  6187. KAKAO_MAPS_CANVAS.style.position = "absolute";
  6188. KAKAO_MAPS_CANVAS.className = "inactive";
  6189. }
  6190. if (BR_LOAD_YANDEX)
  6191. {
  6192. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  6193. YANDEX_MAPS_CANVAS.style.position = "absolute";
  6194. }
  6195. if (BR_LOAD_MS)
  6196. {
  6197. BING_MAPS_CANVAS.style.visibility = "hidden";
  6198. BING_MAPS_CANVAS.style.position = "absolute";
  6199. BING_MAPS_CANVAS.className = "inactive";
  6200. }
  6201.  
  6202. if (BR_LOAD_MP)
  6203. {
  6204. MAPBOX_MAPS_CANVAS.style.visibility = "hidden";
  6205. MAPBOX_MAPS_CANVAS.style.position = "absolute";
  6206. MAPBOX_MAPS_CANVAS.classList.remove("game-panorama_panorama__rdhFg")
  6207. MAPBOX_MAPS_CANVAS.classList.add("inactive");
  6208. }
  6209.  
  6210. if (BR_LOAD_MAPY)
  6211. {
  6212. MAPY_MAPS_CANVAS.style.visibility = "hidden";
  6213. MAPY_MAPS_CANVAS.style.position = "absolute";
  6214. MAPY_MAPS_CANVAS.className = "inactive";
  6215. }
  6216.  
  6217. teleportMenu.google = false;
  6218. switchCovergeButton.useGoogle = false;
  6219.  
  6220. if (nextPlayer === "Google") {
  6221. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  6222. if (BR_LOAD_KAKAO)
  6223. {
  6224. //console.log("doing")
  6225. window.dispatchEvent(new Event('resize'));
  6226. }
  6227. document.getElementById("default_player").style.visibility = "";
  6228. teleportMenu.google = true;
  6229. switchCovergeButton.useGoogle = true;
  6230. console.log("Google Duel Canvas loaded");
  6231. }
  6232. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte")
  6233. {
  6234. BAIDU_MAPS_CANVAS.style.visibility = "";
  6235. BAIDU_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  6236. console.log("Container Duel Canvas loaded");
  6237. }
  6238. else if (nextPlayer === "Kakao")
  6239. {
  6240. if (BR_LOAD_KAKAO)
  6241. {
  6242. KAKAO_MAPS_CANVAS.style.visibility = "";
  6243. KAKAO_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  6244. }
  6245. console.log("Kakao Duel Canvas loaded");
  6246. }
  6247. else if (nextPlayer === "Yandex")
  6248. {
  6249. if (BR_LOAD_YANDEX)
  6250. {
  6251. YANDEX_MAPS_CANVAS.style.visibility = "";
  6252. }
  6253. console.log("Yandex Duel Canvas loaded");
  6254. }
  6255. else if (nextPlayer === "Mapillary")
  6256. {
  6257. if (BR_LOAD_MAPILLARY)
  6258. {
  6259. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  6260. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  6261. MapillaryPlayer.resize();
  6262. }
  6263. //
  6264. console.log("Mapillary Duel Canvas loaded");
  6265. }
  6266. else if (nextPlayer === "Bing Streetside" || nextPlayer === "Planets")
  6267. {
  6268. if (BR_LOAD_MS)
  6269. {
  6270. BING_MAPS_CANVAS.style.visibility = "";
  6271. BING_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  6272. }
  6273. console.log("MS Duel Canvas loaded");
  6274. }
  6275. else if (nextPlayer === "Mapbox Satellite")
  6276. {
  6277. if (BR_LOAD_MP)
  6278. {
  6279. MAPBOX_MAPS_CANVAS.style.visibility = "";
  6280. MAPBOX_MAPS_CANVAS.classList.remove("inactive");
  6281. MAPBOX_MAPS_CANVAS.classList.add("game-panorama_panorama__rdhFg");
  6282. try
  6283. {
  6284. MapboxPlayer.resize();
  6285. }
  6286. catch (e)
  6287. {
  6288. console.error("MapboxPlayer resize failed", e);
  6289. }
  6290. }
  6291. console.log("Mapbox Satellite Duel Canvas loaded");
  6292. }
  6293. else if (nextPlayer === "Mapy")
  6294. {
  6295. if (BR_LOAD_MAPY)
  6296. {
  6297. MAPY_MAPS_CANVAS.style.visibility = "";
  6298. MAPY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  6299. }
  6300. console.log("Mapy Duel Canvas loaded");
  6301. }
  6302. }
  6303. else
  6304. {
  6305. setTimeout(canvasSwitch(), 1000);
  6306. }
  6307. }
  6308.  
  6309. // for Battle Royale and classic (change visibility)
  6310.  
  6311. function gCanvas()
  6312. {
  6313. let GOOGLE_MAPS_CANVAS = ""
  6314. if (isBattleRoyale) {
  6315. if (isBullseye)
  6316. {
  6317. GOOGLE_MAPS_CANVAS = document.querySelector(BULLSEYE_CANVAS2);
  6318. }
  6319. else if (isLiveChallenge)
  6320. {
  6321. GOOGLE_MAPS_CANVAS = document.querySelector(LIVE_CANVAS2);
  6322. }
  6323. else if (isDuel)
  6324. {
  6325. GOOGLE_MAPS_CANVAS = document.getElementById("default_player");
  6326. }
  6327. else
  6328. {
  6329. GOOGLE_MAPS_CANVAS = document.querySelector(BR_CANVAS);
  6330. }
  6331. }
  6332. else {
  6333. GOOGLE_MAPS_CANVAS = document.querySelector(GENERAL_CANVAS);
  6334. }
  6335. return GOOGLE_MAPS_CANVAS;
  6336. }
  6337.  
  6338. function Google() {
  6339. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6340. let teleportMenu = document.getElementById("Teleport Button");
  6341. let switchCovergeButton = document.getElementById("switch");
  6342.  
  6343. let GOOGLE_MAPS_CANVAS = gCanvas();
  6344. if (GOOGLE_MAPS_CANVAS !== null)
  6345. {
  6346. if (nextPlayer === "Google") {
  6347. GOOGLE_MAPS_CANVAS.style.visibility = "";
  6348. teleportMenu.google = true;
  6349. switchCovergeButton.useGoogle = true;
  6350. }
  6351. else {
  6352. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  6353. teleportMenu.google = false;
  6354. }
  6355. }
  6356. else
  6357. {
  6358. setTimeout(Google, 250);
  6359. }
  6360. }
  6361.  
  6362. function Baidu() {
  6363. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  6364. let switchCovergeButton = document.getElementById("switch");
  6365. // console.log("Baidu canvas");
  6366. if (BAIDU_MAPS_CANVAS !== null)
  6367. {
  6368. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6369. BAIDU_MAPS_CANVAS.style.position = "absolute";
  6370. if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte") {
  6371. BAIDU_MAPS_CANVAS.style.visibility = "";
  6372. switchCovergeButton.useGoogle = false;
  6373. console.log("Container Canvas loaded");
  6374. }
  6375. else {
  6376. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  6377. // console.log("Container Canvas hidden");
  6378. }
  6379. }
  6380. else
  6381. {
  6382. setTimeout(Baidu, 250);
  6383. }
  6384.  
  6385. }
  6386.  
  6387. function Kakao() {
  6388. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  6389. let switchCovergeButton = document.getElementById("switch");
  6390. // console.log("Kakao canvas");
  6391. if (KAKAO_MAPS_CANVAS != null)
  6392. {
  6393. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6394. KAKAO_MAPS_CANVAS.style.position = "absolute";
  6395. if (nextPlayer === "Kakao") {
  6396. KAKAO_MAPS_CANVAS.style.visibility = "";
  6397. switchCovergeButton.useGoogle = false;
  6398. console.log("Kakao Canvas loaded");
  6399. }
  6400. else {
  6401. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  6402. // console.log("Kakao Canvas hidden");
  6403. }
  6404. }
  6405. else
  6406. {
  6407. setTimeout(Kakao, 250);
  6408. }
  6409.  
  6410. }
  6411.  
  6412. function Yandex() {
  6413. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  6414. let switchCovergeButton = document.getElementById("switch");
  6415. if (YANDEX_MAPS_CANVAS != null)
  6416. {
  6417. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6418. if (isBullseye)
  6419. {
  6420. let div = document.getElementById("player");
  6421. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__ncMwh");
  6422. div.prepend(YANDEX_MAPS_CANVAS);
  6423. }
  6424. if (isLiveChallenge)
  6425. {
  6426. let div = document.getElementById("player");
  6427. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__IuPsO");
  6428. div.prepend(YANDEX_MAPS_CANVAS);
  6429. }
  6430. // console.log("Yandex canvas");
  6431. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  6432. // console.log("Yandex canvas");
  6433. /* console.log(YANDEX_MAPS_CANVAS); */
  6434. if (nextPlayer === "Yandex") {
  6435. // Make google street view visible so it doesn't blink.
  6436. gCanvas().style.visibility = "";
  6437.  
  6438. YANDEX_MAPS_CANVAS.style.visibility = "";
  6439. switchCovergeButton.useGoogle = false;
  6440. console.log("Yandex Canvas loaded");
  6441. }
  6442. else {
  6443. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  6444. console.log("Yandex Canvas hidden");
  6445. }
  6446. }
  6447. else
  6448. {
  6449. setTimeout(Yandex, 250);
  6450. }
  6451.  
  6452. }
  6453.  
  6454. function Mapillary()
  6455. {
  6456. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  6457. let switchCovergeButton = document.getElementById("switch");
  6458. if (MAPILLARY_MAPS_CANVAS != null)
  6459. {
  6460. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6461. // console.log("Mapillary canvas");
  6462. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  6463. if (nextPlayer === "Mapillary") {
  6464. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  6465. switchCovergeButton.useGoogle = false;
  6466. console.log("Mapillary Canvas loaded");
  6467.  
  6468. }
  6469. else {
  6470. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  6471. // console.log("Mapillary Canvas hidden");
  6472. }
  6473. }
  6474. else
  6475. {
  6476. setTimeout(Mapillary, 250);
  6477. }
  6478.  
  6479. }
  6480.  
  6481. function Bing() {
  6482. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  6483. let switchCovergeButton = document.getElementById("switch");
  6484. // console.log("stuck")
  6485. if (BING_MAPS_CANVAS != null)
  6486. {
  6487. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6488. // console.log("Mapillary canvas");
  6489. BING_MAPS_CANVAS.style.position = "absolute";
  6490. if (nextPlayer === "Bing Streetside" || nextPlayer === "Planets") {
  6491. BING_MAPS_CANVAS.style.visibility = "";
  6492. switchCovergeButton.useGoogle = false;
  6493. console.log("Bing Canvas loaded");
  6494. }
  6495. else {
  6496. BING_MAPS_CANVAS.style.visibility = "hidden";
  6497. console.log("Bing Canvas hidden");
  6498. }
  6499. }
  6500. else
  6501. {
  6502. setTimeout(Bing, 500)
  6503. }
  6504. }
  6505.  
  6506. function Mapbox()
  6507. {
  6508. let MAPBOX_CANVAS = document.querySelector("sat-map");
  6509. //let MAPBOX_CANVAS = document.getElementById("mapbox-player");
  6510. let switchCovergeButton = document.getElementById("switch");
  6511. if (MAPBOX_CANVAS != null)
  6512. {
  6513. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6514. // console.log("Mapillary canvas");
  6515. MAPBOX_CANVAS.style.position = "absolute";
  6516. if (nextPlayer === "Mapbox Satellite") {
  6517. MAPBOX_CANVAS.style.visibility = "";
  6518. switchCovergeButton.useGoogle = false;
  6519. console.log("Mapbox Satellite Canvas loaded");
  6520.  
  6521. }
  6522. else {
  6523. MAPBOX_CANVAS.style.visibility = "hidden";
  6524. // console.log("Mapillary Canvas hidden");
  6525. }
  6526. }
  6527. else
  6528. {
  6529. setTimeout(Mapbox, 250);
  6530. }
  6531.  
  6532. }
  6533.  
  6534. function Mapy() {
  6535. let MAPY_MAPS_CANVAS = document.getElementById("mapy-player");
  6536. let switchCovergeButton = document.getElementById("switch");
  6537. // console.log("Kakao canvas");
  6538. if (MAPY_MAPS_CANVAS != null)
  6539. {
  6540. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6541. MAPY_MAPS_CANVAS.style.position = "absolute";
  6542. if (nextPlayer === "Mapy") {
  6543. MAPY_MAPS_CANVAS.style.visibility = "";
  6544. switchCovergeButton.useGoogle = false;
  6545. console.log("Mapy Canvas loaded");
  6546. }
  6547. else {
  6548. MAPY_MAPS_CANVAS.style.visibility = "hidden";
  6549. // console.log("Kakao Canvas hidden");
  6550. }
  6551. }
  6552. else
  6553. {
  6554. setTimeout(Mapy, 250);
  6555. }
  6556.  
  6557. }
  6558.  
  6559.  
  6560. /**
  6561. * Adjust button placement
  6562. */
  6563.  
  6564. function ZoomControls() {
  6565. let style = `
  6566. .ymaps-2-1-79-panorama-gotoymaps {display: none !important;}
  6567. .ymaps-2-1-79-panorama-control__zoom {top: 2rem !important; left: 2rem !important; z-Index: 0}
  6568. .mapillary-bearing-indicator-container {top: 2rem !important; left: 2rem !important;}
  6569. .mapillary-zoom-container {top: 6rem !important; left: 2.20rem !important;}
  6570. .NavBar_MapTypeButtonContainerWrapper {visibility: hidden !important;}
  6571. .bm_LocateMeControl {visibility: hidden !important;}
  6572. .NavBar_Container {top: -6rem !important; left: 2rem !important;}
  6573. .streetsideToolPanel {top: 4rem !important; left: 2rem !important;}
  6574. .NavBarButton_Container {visibility: hidden !important;}
  6575. .mapboxgl-ctrl-top-left {z-Index: 999}
  6576. `;
  6577.  
  6578. // let nav = document.querySelector('.NavBar_MapTypeButtonContainerWrapper');
  6579. // let locate = document.getElementById("LocateMeButton");
  6580. // let navAll = document.getElementById("MicrosoftNav");
  6581. // if (nav)
  6582. // {
  6583. // nav.style.visibility = "hidden";
  6584. // }
  6585. // if (locate)
  6586. // {
  6587. // locate.style.visibility = "hidden";
  6588. // }
  6589. // if (navAll)
  6590. // {
  6591. // navAll.style.top = "15em"
  6592. // }
  6593.  
  6594. let style_element = document.createElement("style");
  6595. style_element.innerHTML = style;
  6596. document.body.appendChild(style_element);
  6597. // document.getElementById("mapillary-bearing-indicator-container").style.top = "20em"
  6598. }
  6599.  
  6600. /**
  6601. * Updates the compass to match Yandex Panorama facing
  6602. */
  6603. function updateCompass() {
  6604. let direction = YandexPlayer.getDirection()[0] * -1;
  6605. if (!COMPASS) {
  6606. //let compass = document.querySelector("img.compass__indicator");
  6607. let compass = document.querySelector('[alt="compass" i]'); // EC made this
  6608. if (compass != null) {
  6609. COMPASS = compass;
  6610. // let direction = YandexPlayer.getDirection()[0] * -1;
  6611. // COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  6612. COMPASS.style.transform = `rotate(${direction}deg)`;
  6613. return;
  6614. }
  6615. setTimeout(function(){
  6616. addCustomYandexCompass();
  6617. updateCompass();
  6618. }, 2000);
  6619. }
  6620. else {
  6621. // let direction = YandexPlayer.getDirection()[0] * -1;
  6622. // COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  6623. COMPASS.style.transform = `rotate(${direction}deg)`;
  6624. }
  6625. }
  6626.  
  6627. function addCustomYandexCompass(){
  6628. if (COMPASS || document.querySelector('[alt="compass" i]')){
  6629. return;
  6630. }
  6631.  
  6632. let arrow = document.createElement('img');
  6633. arrow.src = 'https://www.geoguessr.com/_next/static/media/compass.f79e0d30.svg';
  6634. arrow.style.cssText = "position: absolute; bottom: 22%; left: 3%; height: 3rem; width: 0.75rem;";
  6635. arrow.setAttribute('alt', "Compass");
  6636. arrow.title = "Custom Yandex compass.";
  6637.  
  6638. let arrowBackground = document.createElement('img');
  6639. arrowBackground.src = "https://cdn.discordapp.com/attachments/1087972736485298276/1206196948965793882/Base2.png?ex=65db2172&is=65c8ac72&hm=9b05e064ed56c17b5d5c56ecaf8f41c91a72b711d6125e544339bc4b4290e728&";
  6640. arrowBackground.style.cssText = "position: absolute; bottom: 22%; left: 3%; width: calc(0.75rem * 5); translate: calc(-0.75rem *2) calc(0.4rem);";
  6641.  
  6642. let ymaps = document.querySelector('ymaps');
  6643.  
  6644. ymaps.parentElement.appendChild(arrowBackground)
  6645. ymaps.parentElement.appendChild(arrow)
  6646. }
  6647. /**
  6648. * Open next location in streetview player given next player and next coordinate
  6649. */
  6650.  
  6651. function wiki(cc, iframe, teleportMenu)
  6652. {
  6653. if (WikiXplore_map) {
  6654. wikiXplore(cc, iframe, teleportMenu, true);
  6655. return;
  6656. }
  6657.  
  6658. let url = `https://${cc}.wikipedia.org/w/api.php`;
  6659. let widthRight = 325;
  6660. // console.log(cc);
  6661. // if (cc == "fr")
  6662. // {
  6663. // widthRight = 1200;
  6664. // }
  6665.  
  6666. let params = {
  6667. action: "query",
  6668. list: "geosearch",
  6669. gscoord: `${global_lat}|${global_lng}`,
  6670. gsradius: "10000",
  6671. gslimit: "1",
  6672. format: "json"
  6673. };
  6674.  
  6675. url = url + "?origin=*";
  6676. Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
  6677. let GOOGLE_MAPS_CANVAS = gCanvas();
  6678.  
  6679. fetch(url)
  6680. .then(function(response){return response.json();})
  6681. .then(function(response) {
  6682. // console.log(response)
  6683. var pages = response.query.geosearch;
  6684. if (pages.length !== 0)
  6685. {
  6686. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  6687. let pageId = pages[0].pageid;
  6688. iframe.src = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  6689. wikiUrl = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  6690. iframe.style.visibility = "";
  6691. iframe.style.right = `-${widthRight}px`;
  6692. iframe.style.width = (window.innerWidth + widthRight) + 'px';
  6693. // console.log(iframe.style.width);
  6694. // iframe.style.visibility = "";
  6695. }
  6696. else
  6697. {
  6698. GOOGLE_MAPS_CANVAS.style.visibility = "";
  6699. teleportMenu.google = true;
  6700. iframe.style.right = '0px';
  6701. iframe.style.width = window.innerWidth + 'px';
  6702. }
  6703. }).catch(function(error){console.log(error);});
  6704. }
  6705.  
  6706. function wikiXplore(cc, iframe, teleportMenu, newLocation){
  6707. // Mode suggested by Alok.
  6708. // Created by EC.
  6709. const lc = localStorage["unity_wikiXplore_active"] || "false";
  6710.  
  6711. let wikiXplore_btn = document.getElementById("wikiXplore_btn");
  6712.  
  6713. let GOOGLE_MAPS_CANVAS = gCanvas();
  6714. GOOGLE_MAPS_CANVAS.style.visibility = "";
  6715.  
  6716. if (!wikiXplore_btn){
  6717. const wikiImgOpened = "https://upload.wikimedia.org/wikipedia/commons/6/63/Wikipedia-logo.png";
  6718. const wikiImgClosed = "https://upload.wikimedia.org/wikipedia/commons/d/de/Wikipedia-logo_%28inverse%29.png";
  6719.  
  6720. wikiXplore_btn = document.createElement("Button");
  6721. wikiXplore_btn.classList.add("unity-btn", "full", "horizontal-1", "vertical-2");
  6722. wikiXplore_btn.style.cssText = "border-radius: 25px; height: 2em; position: fixed; z-index: 99970; background-color: rgba(186, 85, 211, 0.8); box-shadow: rgba(0, 0, 0, 0.1) 0px 8px 15px; border: none; color: white; text-align: center; vertical-align: text-top; text-decoration: none; display: inline-block; font-size: 16px; width: 3em; right: calc(4em); top: calc(9.5em);";
  6723. wikiXplore_btn.id = "wikiXplore_btn";
  6724. wikiXplore_btn.title = "Open or close Wikipedia article.";
  6725. wikiXplore_btn.state = lc === 'true'? true: false;
  6726. wikiXplore_btn.lang = cc;
  6727.  
  6728. wikiXplore_btn.innerHTML = `<img style="width: 1.7em; margin-top: 4px;" src="${lc === 'true'? wikiImgOpened: wikiImgClosed}" alt="Wiki logo" >`;
  6729.  
  6730. wikiXplore_btn.addEventListener("click", () => {
  6731. const wikiLocalLang = document.getElementById("local language")
  6732. GOOGLE_MAPS_CANVAS.style.visibility = "";
  6733.  
  6734. if (wikiXplore_btn.state === false){
  6735. wikiLocalLang.style.visibility = "";
  6736.  
  6737. wikiXplore_btn.state = true;
  6738. wikiXplore_btn.innerHTML = `<img style="width: 1.7em; margin-top: 2px;" src="${wikiImgOpened}" alt="Wiki logo" >`;
  6739.  
  6740. GOOGLE_MAPS_CANVAS.style.left = "calc(100vw * 0.25)";
  6741. GOOGLE_MAPS_CANVAS.style.width = "75vw";
  6742.  
  6743. localStorage["unity_wikiXplore_active"] = "true";
  6744.  
  6745. setIframe();
  6746. } else {
  6747. iframe.style.visibility = "hidden";
  6748. iframe.style.width = '0px';
  6749.  
  6750. wikiLocalLang.style.visibility = "hidden";
  6751.  
  6752. wikiXplore_btn.state = false;
  6753. wikiXplore_btn.innerHTML = `<img style="width: 1.7em; margin-top: 4px;" src="${wikiImgClosed}" alt="Wiki logo" >`;
  6754.  
  6755. GOOGLE_MAPS_CANVAS.style.left = "";
  6756. GOOGLE_MAPS_CANVAS.style.width = "";
  6757.  
  6758. localStorage["unity_wikiXplore_active"] = "false";
  6759. }
  6760. });
  6761.  
  6762. document.body.appendChild(wikiXplore_btn);
  6763. let inter = setInterval(()=>{
  6764. // Deal with menu buttons being hidden and unhidden.
  6765.  
  6766. const mainMenuBtn = document.getElementById("Show Buttons");
  6767.  
  6768. if (!mainMenuBtn) return;
  6769. if (mainMenuBtn.wikXplore) return;
  6770.  
  6771. mainMenuBtn.wikXplore = true;
  6772.  
  6773. mainMenuBtn.addEventListener('click', ()=>{
  6774. // Listen for mainMenuBtn click which will hide or unhide the buttons.
  6775. setTimeout(()=>{
  6776. if (mainMenuBtn.hide === true) return;
  6777.  
  6778. wikiXplore_btn.style.visibility = "";
  6779.  
  6780. if (wikiXplore_btn.state === true){
  6781. let wikiLocalLang = document.getElementById("local language")
  6782. wikiLocalLang.style.visibility = "";
  6783. };
  6784. }, 500);
  6785. });
  6786. }, 2000);
  6787.  
  6788. }
  6789.  
  6790. const mainMenuBtn = document.getElementById("Show Buttons");
  6791. if (mainMenuBtn && mainMenuBtn.hide === true) {
  6792. wikiXplore_btn.style.visibility = "hidden";
  6793. } else {
  6794. wikiXplore_btn.style.visibility = "";
  6795. }
  6796. if (wikiXplore_btn.lang !== cc || newLocation || lc === "true"){
  6797. if (wikiXplore_btn.state == false) return;
  6798.  
  6799. let wikiLocalLang = document.getElementById("local language")
  6800. wikiLocalLang.style.visibility = "";
  6801.  
  6802. iframe.style.right = ``;
  6803. iframe.style.width = "calc(100vw * 0.25)";
  6804.  
  6805. wikiXplore_btn.lang = cc;
  6806.  
  6807. GOOGLE_MAPS_CANVAS.style.left = "calc(100vw * 0.25)";
  6808. GOOGLE_MAPS_CANVAS.style.width = "75vw";
  6809.  
  6810. setIframe();
  6811. }
  6812.  
  6813. function setIframe(){
  6814. let url = `https://${cc}.wikipedia.org/w/api.php`;
  6815. let widthRight = 325;
  6816.  
  6817. let params = {
  6818. action: "query",
  6819. list: "geosearch",
  6820. gscoord: `${global_lat}|${global_lng}`,
  6821. gsradius: "10000",
  6822. gslimit: "1",
  6823. format: "json"
  6824. };
  6825.  
  6826. url = url + "?origin=*";
  6827. Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
  6828. let GOOGLE_MAPS_CANVAS = gCanvas();
  6829.  
  6830. fetch(url)
  6831. .then(function(response){return response.json();})
  6832. .then(function(json) {
  6833.  
  6834. let pages = json.query.geosearch;
  6835.  
  6836. if (pages.length !== 0) {
  6837. let pageId = pages[0].pageid;
  6838.  
  6839. iframe.src = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  6840. wikiUrl = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  6841.  
  6842. iframe.style.visibility = "";
  6843. iframe.style.right = ``;
  6844. iframe.style.width = "calc(100vw * 0.25)";
  6845. } else {
  6846. GOOGLE_MAPS_CANVAS.style.visibility = "";
  6847.  
  6848. teleportMenu.google = true;
  6849.  
  6850. iframe.style.right = '0px';
  6851. iframe.style.width = window.innerWidth + 'px';
  6852. }
  6853.  
  6854. }).catch(function(error){console.log(error);});
  6855. }
  6856. }
  6857.  
  6858. function handleSpecialColor()
  6859. {
  6860. document.getElementById("Circus Sky").style.background = skySpecial ? "#ff1493cc" : "#ff69b4cc";
  6861. document.getElementById("Circus Soil").style.background = soilSpecial ? "#ff1493cc" : "#ff69b4cc";
  6862. document.getElementById("Circus Skewed").style.background = skewedSpecial ? "#ff1493cc" : "#ff69b4cc";
  6863. document.getElementById("Circus Zoom").style.background = zoomSpecial ? "#ff1493cc" : "#ff69b4cc";
  6864. document.getElementById("Circus Random").style.background = randomSpecial ? "#ff1493cc" : "#ff69b4cc";
  6865. document.getElementById("Circus NMPZ").style.background = nmpzSpecial ? "#ff1493cc" : "#ff69b4cc";
  6866. }
  6867.  
  6868. let yandexIntervalFailedToLoadMessage = null;
  6869. let __t = 0;
  6870. let goToLocationTimerHack = Date.now();
  6871.  
  6872. async function goToLocation(cond) {
  6873. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6874. console.log("Going to location");
  6875. console.log(nextPlayer);
  6876.  
  6877. // Added by EC - I can't figure out how to show unity buttons on new round.
  6878. setMenuBtnsUnhidden();
  6879.  
  6880. // if (nextPlayer === "Yandex" && !document.querySelector("ymaps")){
  6881. // // Hack by EC to fix yandex not showing when starting a new game.
  6882. // location.reload();
  6883. // }
  6884.  
  6885. let mosaicBtn = document.getElementById("Mosaic Enable");
  6886. if (mosaicPre)
  6887. {
  6888. if (mosaicPre && mosaicBtn.grid == 0)
  6889. {
  6890. mosaicBtn.grid = 5;
  6891. document.getElementById("Mosaic Menu").click();
  6892. }
  6893. else if (mosaicBtn.grid !== 0)
  6894. {
  6895. document.getElementById("Mosaic Menu").click();
  6896. }
  6897. loadGridBtn(mosaicBtn.grid);
  6898. }
  6899.  
  6900. if (restrictMovement)
  6901. {
  6902. // if (teleportMenu.style.visibility == "hidden")
  6903. // {
  6904. // document.getElementById("Teleport Menu").click();
  6905. // }
  6906. RestrictBoundsEnableBtn.innerHTML = "Disable Limit";
  6907. if (RestrictBoundsBtn.innerHTML == "No Escape Mode Disabled")
  6908. {
  6909. RestrictBoundsBtn.innerHTML = "No Escape Mode Enabled";
  6910. }
  6911. }
  6912.  
  6913. if (skySpecial || soilSpecial || skewedSpecial || zoomSpecial || randomSpecial || nmpzSpecial)
  6914. {
  6915. if (nmpzSpecial && !document.getElementById("specialNMPZ"))
  6916. {
  6917. loadNMPZ();
  6918. }
  6919. handleSpecialColor();
  6920. }
  6921.  
  6922. let OverlayBtn = document.getElementById("Overlay Button");
  6923. if (nextPlayer !== "Planets" && (spaceList.some(className => OverlayBtn.current.includes(className))))
  6924. {
  6925. document.getElementById("Earth").click();
  6926. }
  6927.  
  6928. if (nextPlayer === "Yandex") {
  6929. // Everything between these curly braces is just stupid.
  6930.  
  6931. const _ymaps = document.querySelector("ymaps");
  6932. console.log("yandex 1")
  6933. if (!document.querySelector("ymaps")){
  6934. // Hack by EC to fix yandex not showing when starting a new game.
  6935. location.reload();
  6936. return;
  6937. }
  6938.  
  6939. clearInterval(yandexIntervalFailedToLoadMessage);
  6940. __t = 100;// For a wierd bug.
  6941.  
  6942. const map_name = global_data.mapName;
  6943. let panosAtThisLocation = null;
  6944.  
  6945. if (map_name.includes('Goodex') || map_name.includes('Yangle')){
  6946. // Apparently if the panoid is not length 22 then it isn't official?
  6947. console.log('includes goodex')
  6948. let pano = GooglePlayer.getPano();
  6949.  
  6950. // TODO EC: check if global_data pano is same as GooglePlayer.getPano().
  6951. pano = !checkFailedToLoadRoundMsg() ? pano : "Failed Pano message";
  6952.  
  6953.  
  6954. let unofficial = pano? pano.length !== 22 : true;
  6955. panosAtThisLocation = await ymaps.panorama.locate([global_lat, global_lng]).then(ret => ret);
  6956.  
  6957. if (!unofficial || panosAtThisLocation.length == 0){
  6958.  
  6959. if (panosAtThisLocation.length === 0){
  6960. console.log("No yandex panos, panos == 0")
  6961. //let spacey = document.getElementById('SpOver Button');
  6962. let unityAlert = document.querySelector('.unity_alert');
  6963. let _unityAlert = unityAlert.innerHTML;
  6964. unityAlert.innerHTML = "Couldn't find any panoramas for Yandex here!";
  6965. unityAlert.style.visibility = 'visible';
  6966. setTimeout(()=> {
  6967. unityAlert.style.visibility = 'hidden';
  6968. unityAlert.innerHTML = _unityAlert;
  6969. }, 5000);
  6970. }
  6971.  
  6972. console.log("official coverage or no yandex, resorting back to google sv - ", pano, pano?.length)
  6973. const GOOGLE_MAPS_CANVAS = gCanvas();
  6974. GOOGLE_MAPS_CANVAS.style.visibility = "visible";
  6975.  
  6976. _ymaps.style.display = "none";
  6977.  
  6978. return;
  6979. }
  6980. }
  6981.  
  6982. console.log("here is yandex")
  6983.  
  6984. const showYmapsTimer = setTimeout(function(){
  6985. const pano = GooglePlayer.getPano();
  6986. let unofficial = pano? pano.length !== 22 : true;
  6987. let failedToLoadRoundMsg = checkFailedToLoadRoundMsg();
  6988. console.log("showYmapsTimer: Checking if official coverage or failed round before hidding ymaps")
  6989. console.log("showYmapsTimer:", unofficial, failedToLoadRoundMsg, panosAtThisLocation?.length);
  6990. if (!failedToLoadRoundMsg && !unofficial && panosAtThisLocation?.length) return;
  6991. console.log("show maps timer hidden")
  6992.  
  6993. _ymaps.style.display = "";
  6994. // Hide google streetview that was un-hidden so it wouldn't blink,
  6995. // but now can be hidden again.
  6996. gCanvas().style.visibility = "hidden";
  6997.  
  6998. }, 750);
  6999.  
  7000. let options = {};
  7001. YandexPlayer.moveTo([global_lat, global_lng], options);
  7002. //YandexPlayer.setDirection([0, 16]);
  7003. //YandexPlayer.setDirection([-55, 0]); // Hopefully points down the road.
  7004. YandexPlayer.setDirection("auto"); // Hopefully points down the road.
  7005. // YandexPlayer.setSpan([10, 67]);
  7006. YandexPlayer.setSpan([-10, 67]);
  7007. console.log("yandex moveto location", [global_lat, global_lng])
  7008.  
  7009. __t = 0;
  7010. clearInterval(yandexIntervalFailedToLoadMessage); // Double make sure it's cleared
  7011. yandexIntervalFailedToLoadMessage = setInterval(async function(){
  7012. console.log("yandex interval", __t)
  7013. if (__t++ > 50) {
  7014. clearInterval(yandexIntervalFailedToLoadMessage);
  7015. return;
  7016. }
  7017.  
  7018. let failedToLoadRoundMsg = checkFailedToLoadRoundMsg();
  7019. if(failedToLoadRoundMsg){
  7020. clearInterval(yandexIntervalFailedToLoadMessage);
  7021.  
  7022. let panosAtThisLocation = await ymaps.panorama.locate([global_lat, global_lng]).then(ret => ret);
  7023. if (panosAtThisLocation.length == 0){
  7024. let spacey = document.getElementById('SpOver Button');
  7025. let _spacey = spacey.innerHTML;
  7026. spacey.innerHTML = "Couldn't find any panoramas for Yandex here spacey!";
  7027. spacey.style.visibility = 'visible';
  7028. setTimeout(()=> {
  7029. spacey.style.visibility = 'hidden';
  7030. spacey.innerHTML = _spacey;
  7031. }, 5000);
  7032.  
  7033. clearTimeout(showYmapsTimer);
  7034.  
  7035. _ymaps.style.display = "none";
  7036.  
  7037. return;
  7038. }
  7039.  
  7040. failedToLoadRoundMsg.style.display = 'none';
  7041. console.log("failed to load display none");
  7042. makeGuessMapHack({
  7043. markerIcon: {
  7044. // Path is just a filler for a 0 opacity marker.
  7045. path: "M49.07 0c.524.405.262.88.095 1.333l-6.643 18.095-8.047 22.12a4.21 4.21 0 0 0-.262 1.429v19.81c0 1.2-.024 1.2-1.214 1.2-1.238 0-2.476-.048-3.714.024-.786.024-1.07-.238-1.048-1.024l.024-7.333V42.928c0-.5-.07-1.048-.262-1.524L14.976 7.333c-.095-.262-.238-.476-.357-.714v-.5c.38-.12.762-.3 1.143-.3l4.12-.024s1.357 0 1.81 1.286l9.7 27.31.405.976.333-1.095 1.905-6.976 8.5-26.31c.12-.333.405-.62.62-.93L49.07 0z",
  7046. fillColor: "#e52620",
  7047. scale: 0.5,
  7048. fillOpacity: 1,
  7049. strokeColor: "#e52620",
  7050. strokeOpacity: 1,
  7051. anchor: new google.maps.Point(31, 64),
  7052. },
  7053. guessBtnText:"Yandex Guess Button",
  7054. mapContainer: document.querySelector('ymaps'),
  7055. locationUrl: "https://yandex.com/maps/?&panorama%5Bdirection%5D=16%2C0&panorama%5Bpoint%5D=" + global_lng + "%2C" + global_lat
  7056. });
  7057. }
  7058. }, 500);
  7059. }
  7060. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte") {
  7061. if (document.getElementById("i_container") !== null)
  7062. {
  7063. let iframe = document.getElementById("i_container");
  7064.  
  7065. if (nextPlayer === "Baidu")
  7066. {
  7067. if (!isFirefox)
  7068. {
  7069. iframe.style.top = '-60px';
  7070. iframe.style.height = (window.innerHeight + 200) + 'px';
  7071. }
  7072. else
  7073. {
  7074. iframe.style.top = '-60px';
  7075. iframe.style.height = (window.innerHeight + 219) + 'px';
  7076. }
  7077.  
  7078. if (!isFirefox)
  7079. {
  7080. iframe.style.right = '-55px';
  7081. iframe.style.width = (window.innerWidth + 55) + 'px';
  7082. }
  7083. else
  7084. {
  7085. iframe.style.right = '-15px';
  7086. iframe.style.width = (window.innerWidth + 15) + 'px';
  7087. }
  7088.  
  7089. let urlStr2 = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  7090. 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;
  7091.  
  7092. // Hack to change status bar z index
  7093. const statusBar = document.querySelector(`[class*="game_status"]`);
  7094. statusBar.style.zIndex = 3;
  7095.  
  7096. makeGuessMapHack({
  7097. guessBtnText:"Baidu Guess Button",
  7098. mapContainer: document.getElementById("i_container"),
  7099. locationUrl: urlStr2,
  7100. });
  7101.  
  7102. // console.log(urlStr)
  7103. if (global_BDAh != null)
  7104. {
  7105. iframe.src = urlStr;
  7106. }
  7107. else
  7108. {
  7109. iframe.src = urlStr2;
  7110. }
  7111. iframe.style.visibility = "";
  7112. }
  7113. else if (nextPlayer === "Youtube")
  7114. {
  7115. iframe.src = "";
  7116. if (!document.getElementById("mapbox-player"))
  7117. {
  7118. switchCovergeButton.style.visibility = "";
  7119. }
  7120. for (let yBtn of document.getElementsByClassName("youtube-btn")){
  7121. yBtn.style.visibility = "";
  7122. if (yBtn.id === "Youtube Button")
  7123. {
  7124. yBtn.innerHTML = "Check YouTube";
  7125. }
  7126. }
  7127. iframe.allow = "autoplay";
  7128. iframe.style.visibility = "hidden";
  7129. iframe.style.top = '-250px';
  7130. iframe.style.bottom = '250px';
  7131. iframe.style.height = (window.innerHeight + 500) + 'px';
  7132. iframe.style.right = '0px';
  7133. iframe.style.width = window.innerWidth + 'px';
  7134. }
  7135. else if (nextPlayer === "Image")
  7136. {
  7137. iframe.style.top = '0px';
  7138. iframe.style.height = (window.innerHeight) + 'px';
  7139. iframe.style.right = '0px';
  7140. iframe.style.width = window.innerWidth + 'px';
  7141. iframe.style.visibility = "";
  7142. iframe.src = iId;
  7143. }
  7144. else if (randomMapChallenge_map){
  7145. console.log("IS RANDOM")
  7146. }
  7147. else if (WikiXplore_map){
  7148. iframe.style.top = '0px';
  7149. iframe.style.height = (window.innerHeight) + 'px';
  7150. let fi = getLocalizationFromPathName();
  7151. wikiXplore(fi, iframe, teleportMenu, true);
  7152. }
  7153. else if (nextPlayer === "Wikipedia")
  7154. {
  7155. if (!WikiXplore_map && !document.getElementById("mapbox-player"))
  7156. {
  7157. switchCovergeButton.style.visibility = "";
  7158. }
  7159. let wikiLocalLang = document.getElementById("local language")
  7160. wikiLocalLang.style.visibility = "";
  7161. iframe.style.top = '0px';
  7162. iframe.style.height = (window.innerHeight) + 'px';
  7163. //let fi = "en";
  7164. let fi = getLocalizationFromPathName();
  7165. if (!wikiLocalLang.state && global_cc)
  7166. {
  7167. let cc = langDict[global_cc];
  7168. if (typeof cc !== typeof undefined)
  7169. {
  7170. fi = cc[Math.floor(Math.random() * cc.length)];
  7171. }
  7172. }
  7173. wiki(fi, iframe, teleportMenu);
  7174. }
  7175. else if (nextPlayer === "Minecraft")
  7176. {
  7177. iframe.style.top = '0px';
  7178. iframe.style.height = (window.innerHeight) + 'px';
  7179. iframe.style.right = '0px';
  7180. iframe.style.width = window.innerWidth + 'px';
  7181. iframe.style.visibility = "";
  7182. iframe.src = "https://classic.minecraft.net/?size=huge";
  7183. }
  7184. else if (nextPlayer === "Carte")
  7185. {
  7186. iframe.style.bottom = '190px';
  7187. if ((1.14 * window.innerHeight) >= window.innerWidth)
  7188. {
  7189. iframe.style.top = '-100px';
  7190. iframe.style.height = (window.innerHeight + 290) + 'px';
  7191. }
  7192. else
  7193. {
  7194. iframe.style.top = '-60px';
  7195. iframe.style.height = (window.innerHeight + 250) + 'px';
  7196. }
  7197. iframe.style.left = '-20px';
  7198. iframe.style.right = '20px';
  7199. iframe.style.width = (window.innerWidth + 40) + 'px';
  7200. iframe.style.visibility = "";
  7201. iframe.src = corsString + carteCity;
  7202. }
  7203. }
  7204.  
  7205. else
  7206. {
  7207.  
  7208. if ((Date.now() - goToLocationTimerHack) > 2000){
  7209. goToLocationTimerHack = Date.now();
  7210. localStorage['unity_reload_to_fix_error_attempt'] = 'false';
  7211. setTimeout(()=> goToLocation(true), 250);
  7212. } else {
  7213.  
  7214. if (localStorage['unity_reload_to_fix_error_attempt'] === "true"){
  7215. alert(`Attempted to reload page to fix error with Unity script but it didn't work.`);
  7216. localStorage['unity_reload_to_fix_error_attempt'] = 'false';
  7217. return;
  7218. }
  7219. localStorage['unity_reload_to_fix_error_attempt'] = 'true';
  7220. location.reload();
  7221. }
  7222. }
  7223. // let a = new BMap.Point(global_lng, global_lat);
  7224. // BaiduPlayer.setPov({ heading: -40, pitch: 6 });
  7225. // BaiduPlayer.setPosition(a);
  7226. }
  7227. else if (nextPlayer === "Kakao") {
  7228. var roadviewClient = new kakao.maps.RoadviewClient();
  7229. var position = new kakao.maps.LatLng(global_lat, global_lng);
  7230. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  7231. KakaoPlayer.setPanoId(panoId, position);
  7232. KakaoPlayer.setViewpoint({ pan: global_heading, tilt: global_pitch, zoom: -3 })
  7233. });
  7234. }
  7235. else if (nextPlayer === "Mapillary") {
  7236. MapillaryPlayer.resize()
  7237. MapillaryPlayer.moveTo(mmKey).then(
  7238. image => { //console.log(image);
  7239. },
  7240. error => { console.log(error); });
  7241. }
  7242. else if (nextPlayer === "Google" && !rtded) {
  7243. if (!bullseyeMapillary)
  7244. {
  7245. handleMapillary({lat: global_lat, lng: global_lng}, {meters: 500, limit: 500});
  7246. }
  7247. }
  7248. else if (nextPlayer === "Bing Streetside") {
  7249. let mTId = MSStreetPlayer.getMapTypeId();
  7250. if (mTId !== Microsoft.Maps.MapTypeId.streetside && mTId !== Microsoft.Maps.MapTypeId.road)
  7251. {
  7252. console.log("Reset Bing map type to Streetside")
  7253. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  7254. }
  7255. MSStreetPlayer.setOptions({disableStreetside: false});
  7256. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.streetside,
  7257. zoom: 18,
  7258. streetsideOptions: {
  7259. overviewMapMode: Microsoft.Maps.OverviewMapMode.hidden,
  7260. showCurrentAddress: false,
  7261. showProblemReporting: false,
  7262. showExitButton: false,
  7263. },
  7264. center: new Microsoft.Maps.Location(global_lat, global_lng),
  7265. heading: 90,
  7266. pitch: -30});
  7267. }
  7268. else if (nextPlayer === "Planets") {
  7269. // console.log("Bing Satellite Player")
  7270.  
  7271. if (randomPlanets)
  7272. {
  7273. let tempSL = spaceList.slice(0, -1);
  7274. planetType = tempSL[Math.floor(Math.random() * tempSL.length)];
  7275. setMapstylePlanet(planetType);
  7276. }
  7277.  
  7278. let mTId = MSStreetPlayer.getMapTypeId();
  7279. if (mTId !== Microsoft.Maps.MapTypeId.aerial && mTId !== Microsoft.Maps.MapTypeId.road)
  7280. {
  7281. console.log("Reset Bing map type to Satellite")
  7282. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  7283. }
  7284. // MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  7285. let ctr = new Microsoft.Maps.Location(global_lat, global_lng)
  7286. let loc_centre = {lat: global_lat, lng: global_lng};
  7287. for (var i = MSStreetPlayer.entities.getLength() - 1; i >= 0; i--) {
  7288. var pushpin = MSStreetPlayer.entities.get(i);
  7289. if (pushpin instanceof Microsoft.Maps.Pushpin) {
  7290. MSStreetPlayer.entities.removeAt(i);
  7291. }
  7292. }
  7293. // console.log("Satellite radius: " + (ms_radius / 1000).toString() + "km");
  7294.  
  7295. let maxZoomNum = 20;
  7296. if (planetType == "Mars")
  7297. {
  7298. maxZoomNum = 5;
  7299. }
  7300. else if (planetType == "Moon")
  7301. {
  7302. maxZoomNum = 6;
  7303. }
  7304.  
  7305. if (ms_radius < 1500000)
  7306. {
  7307. ms_radius = 1500000;
  7308. }
  7309.  
  7310. if (ms_radius > 6000000)
  7311. {
  7312. ms_radius = 6000000;
  7313. }
  7314.  
  7315. // console.log(ms_radius);
  7316.  
  7317. let latlngBounds = getBBox2(loc_centre, ms_radius);
  7318. // console.log(latlngBounds)
  7319. let bounds = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(latlngBounds[0], latlngBounds[1]), new Microsoft.Maps.Location(latlngBounds[2], latlngBounds[3]));
  7320. MSStreetPlayer.setOptions({maxBounds: bounds, maxZoom: maxZoomNum})
  7321.  
  7322. MSStreetPlayer.setOptions({disableStreetside: true});
  7323. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.mercator,
  7324. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  7325. center: ctr,
  7326. zoom: 1,
  7327. })
  7328. var weatherTileSource = new Microsoft.Maps.TileSource({
  7329. uriConstructor: getTMSTilePath
  7330. });
  7331. var weatherTileLayer = new Microsoft.Maps.TileLayer({
  7332. mercator: weatherTileSource,
  7333. });
  7334. if (planetType == "Moon")
  7335. {
  7336. document.getElementById("Moon (Labels)").click();
  7337. }
  7338. else if (planetType == "Mars")
  7339. {
  7340. document.getElementById("Mars (Labels)").click();
  7341. }
  7342. else
  7343. {
  7344. // console.log(planetType);
  7345. // console.log(document.getElementById(planetType));
  7346. document.getElementById(planetType).click();
  7347. }
  7348. MSStreetPlayer.layers.insert(weatherTileLayer);
  7349.  
  7350. var pin = new Microsoft.Maps.Pushpin(ctr, {});
  7351. MSStreetPlayer.entities.push(pin);
  7352.  
  7353. // FixLink(); // DOM BASED SOLUTION
  7354. }
  7355. else if (nextPlayer === "Mapbox Satellite") {
  7356. console.log("goToLocation: Mapbox Satellite");
  7357. // MapboxPlayer.resize();
  7358. let satelliteStyleBtn = document.getElementById("Satellite Style Button");
  7359. let satelliteTypeBtn = document.getElementById("Satellite Type Button");
  7360. function waitSky()
  7361. {
  7362. try
  7363. {
  7364. let l = [];
  7365. for (let element of MapboxPlayer.getStyle().layers)
  7366. {
  7367. l.push(element.id);
  7368. }
  7369. if (l.includes('sky'))
  7370. {
  7371. styleMapboxAll("All", true);
  7372. }
  7373. else
  7374. {
  7375. setTimeout(waitSky, 250);
  7376. }
  7377. }
  7378. catch(error)
  7379. {
  7380. console.log(error)
  7381. setTimeout(waitSky, 250);
  7382. }
  7383. }
  7384. waitSky();
  7385. //
  7386. // Satellite mode should still work even with no panorama - EC.
  7387. //
  7388.  
  7389. setTimeout(()=>{
  7390. if (document.querySelector('.baidu_guess_map')){
  7391. // Remove duplicate or old guess map and button.
  7392. let baiduGuessMap = document.querySelector('.baidu_guess_map');
  7393. baiduGuessMap._remove();
  7394. }
  7395.  
  7396. let failedToLoadRoundMsg = checkFailedToLoadRoundMsg();
  7397. if (failedToLoadRoundMsg){
  7398. // The streetview was created but for some reason it's blank.
  7399. // Manually set a random position to start the webgl procesfor some reason it's blanks.
  7400. const fenway = { lat: 42.345573, lng: -71.098326 };
  7401.  
  7402. GooglePlayer.setPosition(fenway) ;
  7403.  
  7404. failedToLoadRoundMsg.style.display = 'none';
  7405. setTimeout(() => {
  7406. // Wait a while incase geoguessr map guess button appears late.
  7407. makeGuessMapHack({
  7408. guessBtnText: "Satellite Guess Button",
  7409. mapContainer: document.querySelector('sat-map'),
  7410. locationUrl: '',
  7411. });
  7412. }, 2000);
  7413. }
  7414. }, 500);
  7415. }
  7416. else if (nextPlayer === "Mapy")
  7417. {
  7418. if (global_BDID)
  7419. {
  7420. SMap.Pano.get(parseInt(global_BDID)).then(function(place) {
  7421. // console.log(place)
  7422. MapyPlayer.show(place);
  7423. }, function() {
  7424. alert("Panorama se nepodařilo zobrazit !");
  7425. });
  7426. }
  7427. else
  7428. {
  7429. let mpcz = SMap.Coords.fromWGS84(global_lng, global_lat);
  7430. // zobrazime panorama dle ID
  7431. SMap.Pano.getBest(mpcz, 200).then(function(place) {
  7432. MapyPlayer.show(place);
  7433. }, function() {
  7434. alert("Panorama se nepodařilo zobrazit !");
  7435. });
  7436. }
  7437. }
  7438. if (nextPlayer === "Google" && fire1)
  7439. {
  7440. window.dispatchEvent(new Event('resize'));
  7441. if (rtded)
  7442. {
  7443. document.getElementById("Clear").click();
  7444. }
  7445. fire1 = false;
  7446. }
  7447.  
  7448. if (cond)
  7449. {
  7450. switchCovergeButton.lat = global_lat;
  7451. switchCovergeButton.lng = global_lng;
  7452. RestrictBoundsBtn.lat = global_lat;
  7453. RestrictBoundsBtn.lng = global_lng;
  7454. }
  7455.  
  7456. }
  7457.  
  7458. function checkFailedToLoadRoundMsg(){
  7459. let loadingSpinner = document.body.querySelector(`[class*="fullscreen-spinner"]`);
  7460. let panoMsg = document.body.querySelector(`[class*="game_panoramaMessage"]`);
  7461. return loadingSpinner || panoMsg;
  7462. }
  7463.  
  7464. /**
  7465. * Handle undo using the location history of the current round
  7466. */
  7467.  
  7468. function goToUndoMove(data) {
  7469. /* console.log(global_lat);
  7470. console.log(global_lng); */
  7471. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  7472. let teleportMenu = document.getElementById("Teleport Button");
  7473. let switchCovergeButton = document.getElementById("switch");
  7474. let options = {};
  7475. let prevStep = null;
  7476. if (locHistory.length === 1) {
  7477. prevStep = locHistory[0];
  7478. }
  7479. else {
  7480. prevStep = locHistory.pop();
  7481. }
  7482. // console.log(prevStep);
  7483. // console.log(locHistory)
  7484. if (nextPlayer === "Yandex") {
  7485. defaultPanoIdChange = false;
  7486. YandexPlayer.moveTo([prevStep[0], prevStep[1]], options);
  7487. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  7488. YandexPlayer.setSpan([10, 67]);
  7489. switchCovergeButton.lat = prevStep[0];
  7490. switchCovergeButton.lng = prevStep[1];
  7491. }
  7492. else if (nextPlayer === "Kakao") {
  7493. let btn = document.querySelector("button[data-qa='undo-move']");
  7494. btn.disabled = false;
  7495. btn.classList.remove('styles_disabled__2YdHD');
  7496. defaultPanoIdChange = false;
  7497. let position = new kakao.maps.LatLng(prevStep[0], prevStep[1]);
  7498. KakaoPlayer.setPanoId(prevStep[2], position);
  7499. switchCovergeButton.lat = prevStep[0];
  7500. switchCovergeButton.lng = prevStep[1];
  7501. switchCovergeButton.useGoogle = false;
  7502. teleportMenu.google = false;
  7503. // console.log("Undo 1 step");
  7504. // console.log(locHistory);
  7505. }
  7506. else if (nextPlayer === "Mapillary" ) {
  7507. // console.log(prevStep[1]);
  7508.  
  7509. MapillaryPlayer.moveTo(prevStep[2]).then(
  7510. image => {
  7511. //console.log(image);
  7512. switchCovergeButton.lat = prevStep[1];
  7513. switchCovergeButton.lng = prevStep[0];
  7514. },
  7515. error => { console.log(error); });
  7516. }
  7517. else if (nextPlayer === "Bing Streetside") {
  7518. defaultPanoIdChange = false;
  7519. // console.log(locHistory);
  7520. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(prevStep[0], prevStep[1]),});
  7521. switchCovergeButton.lat = prevStep[0];
  7522. switchCovergeButton.lng = prevStep[1];
  7523. switchCovergeButton.heading = prevStep[2];
  7524. }
  7525. else if (nextPlayer === "Mapy") {
  7526. defaultPanoIdChange = false;
  7527. let mapyCords = SMap.Coords.fromWGS84(prevStep[1], prevStep[0]);
  7528. SMap.Pano.getBest(mapyCords, 200).then(function(place) {
  7529. MapyPlayer.show(place,{
  7530. yaw: DegreesToRadians(prevStep[2]),
  7531. });
  7532. }, function() {
  7533. alert("Panorama se nepodařilo zobrazit !");
  7534. });
  7535. // console.log(locHistory);
  7536. switchCovergeButton.lat = prevStep[0];
  7537. switchCovergeButton.lng = prevStep[1];
  7538. switchCovergeButton.heading = prevStep[2];
  7539. }
  7540.  
  7541. }
  7542.  
  7543. function handleTeleport()
  7544. {
  7545. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  7546. let teleportMenu = document.getElementById("Teleport Button");
  7547. let switchCovergeButton = document.getElementById("switch");
  7548. if (teleportMenu)
  7549. {
  7550. function tpt(direction)
  7551. {
  7552. if (!teleportMenu.google)
  7553. {
  7554. // console.log("non-Google Teleport");
  7555. function forwardReverse(heading)
  7556. {
  7557. if (direction)
  7558. {
  7559. return heading;
  7560. }
  7561. else
  7562. {
  7563. return (heading + 180) % 360;
  7564. }
  7565. }
  7566.  
  7567. let prevStep = null;
  7568. if (locHistory.length === 1) {
  7569. prevStep = locHistory[0];
  7570. }
  7571. else {
  7572. prevStep = locHistory[locHistory.length - 1];
  7573. }
  7574. // console.log(locHistory);
  7575.  
  7576. let options = {};
  7577. let place, position, pID;
  7578. if (nextPlayer === "Yandex") {
  7579.  
  7580. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  7581. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  7582. YandexPlayer.moveTo([place.lat, place.lng], options);
  7583. YandexPlayer.setSpan([10, 67]);
  7584. switchCovergeButton.lat = place.lat;
  7585. switchCovergeButton.lng = place.lng;
  7586. }
  7587. else if (nextPlayer === "Kakao") {
  7588. var roadviewClient = new kakao.maps.RoadviewClient();
  7589. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[3])), teleportMenu.distance * 0.001);
  7590. position = new kakao.maps.LatLng(place.lat, place.lng);
  7591. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  7592. KakaoPlayer.setPanoId(panoId, position);
  7593. });
  7594. switchCovergeButton.lat = place.lat;
  7595. switchCovergeButton.lng = place.lng;
  7596. }
  7597. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  7598. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  7599. handleMapillary(place, {meters: 500, limit: 500});
  7600. switchCovergeButton.lat = place.lat;
  7601. switchCovergeButton.lng = place.lng;
  7602. // locHistory.push([place.lat, place.lng, prevStep[2], prevStep[3]]);
  7603. }
  7604. else if (nextPlayer === "Bing Streetside") {
  7605. // console.log("teleport")
  7606. // console.log(prevStep);
  7607. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  7608. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(place.lat, place.lng), 1, 1);
  7609. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  7610. function onSuccess(panoramaInfo) {
  7611. // console.log("Coverage")
  7612. // console.log([panoramaInfo.la, panoramaInfo.lo])
  7613. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  7614. });
  7615. }
  7616. function onMissingCoverage() {
  7617. console.log("No Coverage")
  7618. }
  7619. }
  7620. else if (nextPlayer === "Mapy") {
  7621. place = FindPointAtDistanceFrom(MapyPlayer.getPlace()._data.mark.lat, MapyPlayer.getPlace()._data.mark.lon, MapyPlayer.getCamera().yaw, teleportMenu.distance * 0.001);
  7622. let mapyCords = SMap.Coords.fromWGS84(place.lng, place.lat);
  7623. SMap.Pano.getBest(mapyCords, 200).then(function(placeN) {
  7624. MapyPlayer.show(placeN,{
  7625. yaw: MapyPlayer.getCamera().yaw,
  7626. });
  7627. }, function() {
  7628. alert("Panorama se nepodařilo zobrazit !");
  7629. });
  7630. }
  7631.  
  7632. if (teleportMenu.distance > 150)
  7633. {
  7634. teleportMenu.distance = 100;
  7635. teleportMenu.innerHTML = "Teleport: " + teleportMain.distance + " m";
  7636. }
  7637. }
  7638. }
  7639. document.getElementById("Teleport Forward").addEventListener("click", () => {
  7640. tpt(true);
  7641.  
  7642. });
  7643. document.getElementById("Teleport Reverse").addEventListener("click", () => {
  7644. tpt(false);
  7645.  
  7646. });
  7647. }
  7648. }
  7649.  
  7650. function SyncListener()
  7651. {
  7652. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  7653. let switchCovergeButton = document.getElementById("switch");
  7654. switchCovergeButton.addEventListener("click", () => {
  7655. if (switchCovergeButton.useGoogle == false) {
  7656. // switchCovergeButton.useGoogle = true;
  7657. console.log(nextPlayer)
  7658. if (nextPlayer === "Yandex") {
  7659. let options = {};
  7660. YandexPlayer.moveTo([switchCovergeButton.lat, switchCovergeButton.lng], options);
  7661. YandexPlayer.setDirection([switchCovergeButton.heading, 0]);
  7662.  
  7663. // nextPlayer = "Yandex";
  7664. }
  7665. else if (nextPlayer === "Kakao") {
  7666. let roadviewClient = new kakao.maps.RoadviewClient();
  7667. // console.log(switchCovergeButton.lat);
  7668. let position = new kakao.maps.LatLng(switchCovergeButton.lat, switchCovergeButton.lng);
  7669. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  7670. KakaoPlayer.setPanoId(panoId, position);
  7671. });
  7672. KakaoPlayer.setViewpoint({
  7673. pan: switchCovergeButton.heading,
  7674. tilt: 0,
  7675. zoom: -3
  7676. });
  7677. // nextPlayer = "Kakao";
  7678. }
  7679. else if (nextPlayer === "Mapy") {
  7680. let mapyCords = SMap.Coords.fromWGS84(switchCovergeButton.lng, switchCovergeButton.lat);
  7681. SMap.Pano.getBest(mapyCords, 200).then(function(place) {
  7682. MapyPlayer.show(place,{
  7683. yaw: DegreesToRadians(switchCovergeButton.heading),
  7684. });
  7685. }, function() {
  7686. alert("Panorama se nepodařilo zobrazit !");
  7687. });
  7688. }
  7689. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  7690. // nextPlayer = "Kakao";
  7691. handleMapillary({lat: switchCovergeButton.lat, lng: switchCovergeButton.lng}, {meters: 100, limit: 100});
  7692. }
  7693. else if (nextPlayer === "Bing Streetside") {
  7694. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(switchCovergeButton.lat, switchCovergeButton.lng), 0.01, 0.01);
  7695. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  7696. function onSuccess(panoramaInfo) {
  7697. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  7698. heading: switchCovergeButton.heading
  7699. });
  7700. }
  7701. function onMissingCoverage() {
  7702. console.log("No Coverage")
  7703. }
  7704. }
  7705. }
  7706. });
  7707.  
  7708. }
  7709.  
  7710. /**
  7711. * Gets the seed data for the current game
  7712. *
  7713. * @returns Promise with seed data as object
  7714. */
  7715. function getSeed() {
  7716.  
  7717. console.log("get seed");
  7718. // myHighlight("Get Seed");
  7719. return new Promise((resolve, reject) => {
  7720. let token = getToken();
  7721. let URL;
  7722. let cred = ""
  7723.  
  7724. const PATHNAME = getPathName();
  7725. if (PATHNAME.startsWith("/game/")) {
  7726. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  7727. }
  7728. else if (PATHNAME.startsWith("/results/")) {
  7729. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  7730. }
  7731. else if (PATHNAME.startsWith("/challenge/")) {
  7732. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  7733. }
  7734. else if (PATHNAME.startsWith("/battle-royale/")) {
  7735. URL = `https://game-server.geoguessr.com/api/battle-royale/${token}`;
  7736. }
  7737. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  7738. URL = `https://game-server.geoguessr.com/api/duels/${token}`;
  7739. }
  7740. else if (PATHNAME.startsWith("/bullseye/")) {
  7741. URL = `https://game-server.geoguessr.com/api/bullseye/${token}`;
  7742. }
  7743. else if (PATHNAME.startsWith("/live-challenge/")) {
  7744. URL = `https://game-server.geoguessr.com/api/live-challenge/${token}`;
  7745. }
  7746.  
  7747. if (getSeed.prevReqURL === URL && Date.now() - getSeed.prevReqDate < 1000){
  7748. // Added by EC.
  7749. return resolve(getSeed.prevReq);
  7750. }
  7751.  
  7752. if (isBattleRoyale) {
  7753. fetch(URL, {
  7754. // Include credentials to GET from the endpoint
  7755. credentials: 'include'
  7756. })
  7757. .then((response) => response.json())
  7758. .then((data) => {
  7759. getSeed.prevReqURL = URL
  7760. getSeed.prevReq = data;
  7761. getSeed.prevReqDate = Date.now();
  7762. resolve(data);
  7763. })
  7764. .catch((error) => {
  7765. reject(error);
  7766. });
  7767. }
  7768. else {
  7769. fetch(URL)
  7770. .then((response) => response.json())
  7771. .then((data) => {
  7772. getSeed.prevReqURL = URL
  7773. getSeed.prevReq = data;
  7774. getSeed.prevReqDate = Date.now();
  7775.  
  7776. resolve(data);
  7777. })
  7778. .catch((error) => {
  7779. reject(error);
  7780. });
  7781. }
  7782. });
  7783. }
  7784. getSeed.prevReq = null;
  7785. getSeed.prevReqDate = null;
  7786.  
  7787. /**
  7788. * Gets the token from the current URL
  7789. *
  7790. * @returns token
  7791. */
  7792. function getToken() {
  7793.  
  7794. const PATHNAME = getPathName();
  7795. if (PATHNAME.startsWith("/game/")) {
  7796. return PATHNAME.replace("/game/", "");
  7797. }
  7798. else if (PATHNAME.startsWith("/results/")) {
  7799. return PATHNAME.replace("/results/", "");
  7800. }
  7801. else if (PATHNAME.startsWith("/challenge/")) {
  7802. return PATHNAME.replace("/challenge/", "");
  7803. }
  7804. else if (PATHNAME.startsWith("/battle-royale/")) {
  7805. return PATHNAME.replace("/battle-royale/", "");
  7806. }
  7807. else if (PATHNAME.startsWith("/duels/")) {
  7808. return PATHNAME.replace("/duels/", "");
  7809. }
  7810. else if (PATHNAME.startsWith("/team-duels/")) {
  7811. return PATHNAME.replace("/team-duels/", "");
  7812. }
  7813. else if (PATHNAME.startsWith("/bullseye/")) {
  7814. return PATHNAME.replace("/bullseye/", "");
  7815. }
  7816. else if (PATHNAME.startsWith("/live-challenge/")) {
  7817. return PATHNAME.replace("/live-challenge/", "");
  7818. }
  7819. }
  7820.  
  7821. /**
  7822. * Gets the round number from the ongoing game from the page itself
  7823. *
  7824. * @returns Round number
  7825. */
  7826. function getRoundFromPage() {
  7827. const roundData = document.querySelector("div[data-qa='round-number']");
  7828. if (roundData) {
  7829. let roundElement = roundData.querySelector("div:last-child");
  7830. if (roundElement) {
  7831. let round = parseInt(roundElement.innerText.charAt(0));
  7832. if (!isNaN(round) && round >= 1 && round <= 5) {
  7833. return round;
  7834. }
  7835. }
  7836. }
  7837. else {
  7838. return ROUND;
  7839. }
  7840. }
  7841.  
  7842.  
  7843. /**
  7844. * Injects Yandex Script
  7845. */
  7846. function injectYandexScript() {
  7847.  
  7848. return new Promise((resolve, reject) => {
  7849. if (!YANDEX_INJECTED) {
  7850. if (YANDEX_API_KEY === "") {
  7851. console.log("No Yandex Key")
  7852. reject();
  7853. }
  7854. else {
  7855. if (!partialCreateYandex)
  7856. {
  7857. let spacey = document.getElementById('SpOver Button');
  7858. let _spacey = spacey.innerHTML;
  7859.  
  7860. const SCRIPT = document.createElement("script");
  7861. SCRIPT.type = "text/javascript";
  7862.  
  7863. SCRIPT.async = true;
  7864. SCRIPT.src = `https://api-maps.yandex.ru/2.1/?lang=en_US&apikey=${YANDEX_API_KEY}`;
  7865. document.body.appendChild(SCRIPT);
  7866. SCRIPT.onload = () => {
  7867. let timer = setTimeout(function(){
  7868. spacey.style.visibility = 'visible';
  7869. spacey.innerHTML = "Initializing Yandex, This Could Take Awhile!";
  7870. }, 2000);
  7871. console.log(ymaps);
  7872. ymaps.ready(() => {
  7873. spacey.innerHTML = _spacey;
  7874. spacey.style.visibility = 'hidden';
  7875. clearTimeout(timer);
  7876. YANDEX_INJECTED = true;
  7877. myHighlight("Yandex API Loaded");
  7878. resolve();
  7879. });
  7880. }
  7881. }
  7882. else
  7883. {
  7884. YANDEX_INJECTED = true;
  7885. resolve();
  7886. }
  7887. }
  7888. }
  7889. else {
  7890. resolve();
  7891. }
  7892. });
  7893. }
  7894.  
  7895. /**
  7896. * Injects Yandex Player and calls handleReturnToStart
  7897. */
  7898. function injectYandexPlayer() {
  7899. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  7900. let switchCovergeButton = document.getElementById("switch");
  7901.  
  7902. let lng = 33.722662 ;//41.321861;
  7903. let lat = 44.402915; //69.212920;
  7904.  
  7905. let options = {
  7906. "direction": [0, 16],
  7907. "span": [10, 67],
  7908. "controls": ["zoomControl"],
  7909. //"scrollZoomBehavior": scrollZoom,
  7910. };
  7911.  
  7912. ymaps.panorama.createPlayer("player", [lat, lng], options)
  7913. .done((player) => {
  7914. let __ymaps = document.querySelector('ymaps');
  7915. __ymaps.style.display = "none";
  7916.  
  7917. // Remove markers and arrows then check for forbidmoving.
  7918. player.getPanorama().__proto__.getMarkers = function(){}
  7919.  
  7920. let trys = 0;
  7921. let t = setInterval(function(){
  7922. if (trys++ < 20 && !global_data?.token) return;
  7923. let _ymaps = document.querySelector('ymaps');
  7924.  
  7925. clearInterval(t);
  7926.  
  7927. if (_ymaps && global_data?.forbidZooming && global_data?.forbidMoving && global_data?.forbidRotating){
  7928. // NMPZ
  7929. _ymaps.style.pointerEvents = 'none';
  7930. return;
  7931. }
  7932.  
  7933. if (global_data?.forbidMoving){
  7934. // Don't do anything because the arrows are alread removed.
  7935. return;
  7936. }
  7937.  
  7938. // Remove pesky markers
  7939. player.getPanorama().__proto__.getMarkers = function(){ return []; }
  7940. }, 100);
  7941.  
  7942. YandexPlayer = player;
  7943. YandexPlayer.events.add("directionchange", (e) => {
  7944. updateCompass();
  7945. let pov = YandexPlayer.getDirection();
  7946. if (locHistory.length > 0 && nextPlayer == "Yandex") {
  7947. switchCovergeButton.heading = pov[0];
  7948. locHistory[locHistory.length - 1][2] = pov[0];
  7949. locHistory[locHistory.length - 1][3] = pov[1];
  7950. }
  7951. });
  7952.  
  7953. YandexPlayer.events.add("panoramachange", (e) => {
  7954. if (defaultPanoIdChange) {
  7955. let num = YandexPlayer.getPanorama().getPosition();
  7956. let pov = YandexPlayer.getDirection();
  7957. // console.log(num);
  7958. // console.log(pov);
  7959. if (nextPlayer == "Yandex")
  7960. {
  7961. locHistory.push([num[0], num[1], pov[0], pov[1]]);
  7962. switchCovergeButton.lat = num[0];
  7963. switchCovergeButton.lng = num[1];
  7964. }
  7965. let btn = document.querySelector("button[data-qa='undo-move']");
  7966. if (locHistory.length > 1) {
  7967. btn.disabled = false;
  7968. btn.classList.remove('styles_disabled__2YdHD');
  7969. }
  7970. // console.log(locHistory);
  7971. }
  7972. defaultPanoIdChange = true;
  7973.  
  7974. });
  7975.  
  7976. YandexPlayer.events.add("error", (e) => {
  7977. console.error("Yandex error:", e);
  7978. });
  7979. console.log("Yandex Player injected");
  7980. });
  7981.  
  7982. }
  7983.  
  7984.  
  7985. /**
  7986. * Injects Baidu script
  7987. */
  7988.  
  7989. function reportWindowSize() {
  7990. // console.log("report window size");
  7991. let iframeC = document.getElementById("i_container");
  7992. if (iframeC)
  7993. {
  7994. if (nextPlayer == "Baidu")
  7995. {
  7996. iframeC.style.top = '-60px';
  7997. iframeC.style.height = (window.innerHeight + 200) + 'px';
  7998. // TODO
  7999. iframeC.style.right = '-55px';
  8000. iframeC.style.width = (window.innerWidth + 55) + 'px';
  8001. }
  8002. else if (nextPlayer == "Youtube")
  8003. {
  8004. iframeC.style.top = '-250px';
  8005. iframeC.style.bottom = '250px';
  8006. iframeC.style.height = (window.innerHeight + 500) + 'px';
  8007. iframeC.style.right = '0px';
  8008. iframeC.style.width = window.innerWidth + 'px';
  8009. }
  8010. else if (nextPlayer == "Image" || nextPlayer === "Minecraft")
  8011. {
  8012. iframeC.style.top = '0px';
  8013. iframeC.style.height = (window.innerHeight) + 'px';
  8014. iframeC.style.right = '0px';
  8015. iframeC.style.width = (window.innerWidth) + 'px';
  8016. }
  8017. else if (nextPlayer === "Wikipedia")
  8018. {
  8019. iframeC.style.top = '0px';
  8020. iframeC.style.height = (window.innerHeight) + 'px';
  8021. iframeC.style.right = '-325px';
  8022. iframeC.style.width = (window.innerWidth + 325) + 'px';
  8023. }
  8024. else if (nextPlayer === "Carte")
  8025. {
  8026. // console.log([window.innerHeight, window.innerWidth])
  8027. iframeC.style.bottom = '190px';
  8028. if ((1.14 * window.innerHeight) >= window.innerWidth)
  8029. {
  8030. iframeC.style.top = '-100px';
  8031. iframeC.style.height = (window.innerHeight + 290) + 'px';
  8032. }
  8033. else
  8034. {
  8035. iframeC.style.top = '-60px';
  8036. iframeC.style.height = (window.innerHeight + 250) + 'px';
  8037. }
  8038. iframeC.style.left = '-20px';
  8039. iframeC.style.right = '20px';
  8040. iframeC.style.width = (window.innerWidth + 40) + 'px';
  8041. iframeC.style.visibility = "";
  8042. iframeC.src = carteCity;
  8043. }
  8044.  
  8045.  
  8046. }
  8047. }
  8048.  
  8049. window.onresize = reportWindowSize;
  8050.  
  8051.  
  8052.  
  8053. function injectContainer() {
  8054. myHighlight("iframe container loaded")
  8055. const iframe = document.createElement('iframe');
  8056. iframe.frameBorder = 0;
  8057. iframe.style.position = "absolute";
  8058. iframe.style.zIndex = "2";
  8059. iframe.id = "i_container";
  8060.  
  8061. if (isBattleRoyale) {
  8062. if (isDuel)
  8063. {
  8064. iframe.className = "inactive";
  8065. }
  8066. else if (isBullseye)
  8067. {
  8068. iframe.className = "game-panorama_panorama__ncMwh";
  8069. }
  8070. else if (isLiveChallenge)
  8071. {
  8072. iframe.className = "game-panorama_panorama__IuPsO";
  8073. }
  8074. else
  8075. {
  8076. iframe.className = "br-game-layout__panorama";
  8077. }
  8078. }
  8079. else {
  8080. iframe.className = "game-layout__panorama";
  8081. }
  8082. var div = document.getElementById("player");
  8083. if (div)
  8084. {
  8085. div.style.overflow = "hidden";
  8086. if (isBullseye || isLiveChallenge)
  8087. {
  8088. div.prepend(iframe);
  8089. }
  8090. else
  8091. {
  8092. div.appendChild(iframe);
  8093. }
  8094. }
  8095.  
  8096. }
  8097.  
  8098. /**
  8099. * Injects Kakao script
  8100. */
  8101.  
  8102. function injectKakaoScript() {
  8103. return new Promise((resolve, reject) => {
  8104. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  8105. let switchCovergeButton = document.getElementById("switch");
  8106. if (!KAKAO_INJECTED) {
  8107. if (KAKAO_API_KEY === "") {
  8108. console.log("No Kakao Key")
  8109. }
  8110. else {
  8111.  
  8112. let canvas = document.createElement("kmap");
  8113. if (isBattleRoyale) {
  8114. if (isDuel)
  8115. {
  8116. canvas.innerHTML = `
  8117. <div id="roadview" class="inactive" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  8118. `;
  8119. }
  8120. else if (isBullseye)
  8121. {
  8122. canvas.innerHTML = `
  8123. <div id="roadview" class="game-panorama_panorama__ncMwh" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  8124. `;
  8125. }
  8126. else if (isLiveChallenge)
  8127. {
  8128. canvas.innerHTML = `
  8129. <div id="roadview" class="game-panorama_panorama__IuPsO" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  8130. `;
  8131. }
  8132. else
  8133. {
  8134. canvas.innerHTML = `
  8135. <div id="roadview" class="br-game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  8136. `;
  8137. }
  8138. }
  8139. else {
  8140. canvas.innerHTML = `
  8141. <div id="roadview" class="game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  8142. `;
  8143. }
  8144.  
  8145.  
  8146. var div = document.getElementById("player");
  8147. if (isBullseye || isLiveChallenge)
  8148. {
  8149. div.prepend(canvas);
  8150. }
  8151. else
  8152. {
  8153. div.appendChild(canvas);
  8154. }
  8155.  
  8156. let SCRIPT;
  8157. if (!partialCreateKakao)
  8158. {
  8159. SCRIPT = document.createElement("script");
  8160. SCRIPT.async = true;
  8161. // SCRIPT.type = "text/javascript";
  8162. SCRIPT.src = `//dapi.kakao.com/v2/maps/sdk.js?appkey=${KAKAO_API_KEY}&autoload=false`;
  8163. document.body.appendChild(SCRIPT);
  8164. }
  8165.  
  8166. function drawmapKakao()
  8167. {
  8168. kakao.maps.load(function () {
  8169. var position = new kakao.maps.LatLng(33.450701, 126.560667);
  8170. let roadviewContainer = document.getElementById('roadview');
  8171. KakaoPlayer = new kakao.maps.Roadview(roadviewContainer);
  8172. var panoId = 1023434522;
  8173. KakaoPlayer.setPanoId(panoId, position);
  8174. KAKAO_INJECTED = true;
  8175. // Remove the compass from Kakao
  8176. kakao.maps.event.addListener(KakaoPlayer, 'init', () => {
  8177. const compassContainer = roadviewContainer.querySelector('div[id*="_box_util_"]');
  8178. if (compassContainer) compassContainer.style.display = 'none';
  8179. });
  8180. kakao.maps.event.addListener(KakaoPlayer, 'panoid_changed', function() {
  8181. if (defaultPanoIdChange && KakaoPlayer) {
  8182. let latlng = KakaoPlayer.getPosition();
  8183. let lat = latlng.getLat();
  8184. let lng = latlng.getLng();
  8185. let pID = KakaoPlayer.getViewpointWithPanoId();
  8186. if (nextPlayer == "Kakao" && lat != 33.45047613915499)
  8187. {
  8188. // console.log("push");
  8189. locHistory.push([lat, lng, pID.panoId, pID.pan]);
  8190. switchCovergeButton.lat = lat;
  8191. switchCovergeButton.lng = lng;
  8192. switchCovergeButton.heading = pID.pan;
  8193. }
  8194. let btn = document.querySelector("button[data-qa='undo-move']");
  8195. if (locHistory.length > 1 && (btn != null)) {
  8196. btn.disabled = false;
  8197. btn.classList.remove('styles_disabled__2YdHD');
  8198. }
  8199. // console.log(locHistory);
  8200. }
  8201. defaultPanoIdChange = true;
  8202. });
  8203. kakao.maps.event.addListener(KakaoPlayer, 'viewpoint_changed', function() {
  8204. // console.log("pov_listener attached");
  8205. let pID = KakaoPlayer.getViewpointWithPanoId();
  8206. if (locHistory.length > 0 && nextPlayer == "Kakao") {
  8207. switchCovergeButton.heading = pID.pan;
  8208. locHistory[locHistory.length - 1][3] = pID.pan;
  8209. }
  8210. if (GooglePlayer) {
  8211. const { heading, pitch } = GooglePlayer.getPov()
  8212. if ((!almostEqual(pID.pan, heading) || !almostEqual(pID.tilt, pitch)) && nextPlayer == "Kakao") {
  8213. // Updating the google street view POV will update the compass
  8214. GooglePlayer.setPov({ heading: pID.pan, pitch: pID.tilt })
  8215. }
  8216. }
  8217. // console.log(locHistory);
  8218. })
  8219. });
  8220. }
  8221.  
  8222. if (partialCreateKakao)
  8223. {
  8224. drawmapKakao();
  8225. }
  8226. else
  8227. {
  8228. SCRIPT.onload = () => {
  8229. drawmapKakao();
  8230. myHighlight("Kakao API Loaded");
  8231. resolve();
  8232. };
  8233. }
  8234.  
  8235. }
  8236. }
  8237. else {
  8238. resolve();
  8239. }
  8240. });
  8241. }
  8242.  
  8243. function getTMSTilePath(tile) {
  8244. var yN = Math.pow(2, tile.zoom) - tile.y - 1;
  8245. // console.log([tile.zoom,tile.x,yN]);
  8246. if (planetType == "Moon")
  8247. {
  8248. // document.getElementById("Moon (Labels)").click();
  8249. return "https://s3.amazonaws.com/opmbuilder/301_moon/tiles/w/hillshaded-albedo/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  8250. }
  8251. else if (planetType == "Mars")
  8252. {
  8253. // document.getElementById("Mars (Labels)").click();
  8254. return "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  8255. }
  8256. else
  8257. {
  8258. return handleSpURL(document.getElementById(planetType).url, tile.x, tile.y, tile.zoom);
  8259. }
  8260. // else if (planetType == "GTAV")
  8261. // {
  8262. // return "https://tiles.mapgenie.io/games/gta5/los-santos/satellite/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  8263. // // https://tiles.mapgenie.io/games/gta5/los-santos/road/4/2/5.png
  8264. // }
  8265. // else if (planetType == "GTASA")
  8266. // {
  8267. // return "https://tiles.mapgenie.io/games/grand-theft-auto-san-andreas/san-andreas/satellite-v1/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  8268. // // "https://tiles.mapgenie.io/games/grand-theft-auto-san-andreas/san-andreas/atlas-v1/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  8269. // }
  8270. }
  8271.  
  8272. function injectMSPlayer() {
  8273. return new Promise((resolve, reject) => {
  8274. if (!MS_INJECTED) {
  8275. if (MS_API_KEY === "") {
  8276. let canvas = document.getElementById("player");
  8277. console.log("No MS Key")
  8278. }
  8279. else {
  8280.  
  8281. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  8282. let switchCovergeButton = document.getElementById("switch");
  8283. let SCRIPT;
  8284. if (!partialCreateMS)
  8285. {
  8286. SCRIPT = document.createElement("script");
  8287. SCRIPT.type = "text/javascript";
  8288. SCRIPT.async = true;
  8289. SCRIPT.src = `https://www.bing.com/api/maps/mapcontrol?key=${MS_API_KEY}`;
  8290. document.body.appendChild(SCRIPT);
  8291. }
  8292. let canvas = document.createElement("msmap");
  8293. if (isBattleRoyale) {
  8294. if (isDuel)
  8295. {
  8296. canvas.innerHTML = `<div id="ms-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  8297. }
  8298. else if (isBullseye)
  8299. {
  8300. 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>`;
  8301. }
  8302. else if (isLiveChallenge)
  8303. {
  8304. 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>`;
  8305. }
  8306. else
  8307. {
  8308. 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>`;
  8309. }
  8310. }
  8311. else {
  8312. canvas.innerHTML = `<div id="ms-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  8313. }
  8314.  
  8315. var div = document.getElementById("player");
  8316. if (isBullseye || isLiveChallenge)
  8317. {
  8318. div.prepend(canvas);
  8319. }
  8320. else
  8321. {
  8322. div.appendChild(canvas);
  8323. }
  8324. function drawmapMS()
  8325. {
  8326. try
  8327. {
  8328. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  8329. MS_INJECTED = true;
  8330. // MSStreetPlayer.setOptions({
  8331. // minZoom: 13
  8332. // });
  8333. Microsoft.Maps.Events.addHandler(MSStreetPlayer, 'viewchangeend', function () { updateView(MSStreetPlayer); });
  8334. function updateView(map) {
  8335. let ctrm = map.getCenter();
  8336. if (nextPlayer == "Bing Streetside" && (switchCovergeButton.lat !== ctrm.latitude && switchCovergeButton.lng !== ctrm.longitude))
  8337. {
  8338. let heading2 = bearing(switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude)
  8339. // console.log("moved");
  8340. // console.log([switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude])
  8341. // console.log(heading2);
  8342. locHistory.push([ctrm.latitude, ctrm.longitude, heading2]);
  8343. switchCovergeButton.lat = ctrm.latitude;
  8344. switchCovergeButton.lng = ctrm.longitude;
  8345. switchCovergeButton.heading = heading2;
  8346. let btn = document.querySelector("button[data-qa='undo-move']");
  8347. if (locHistory.length > 1 && (btn != null)) {
  8348. btn.disabled = false;
  8349. btn.classList.remove('styles_disabled__2YdHD');
  8350. }
  8351. }
  8352. }
  8353. }
  8354. catch(error)
  8355. {
  8356. console.log(error);
  8357. alert("Bing Maps API Loading Failed, please refresh");
  8358. // setTimeout(drawmapMS(), 1000);
  8359. }
  8360.  
  8361. }
  8362.  
  8363. if (partialCreateMS)
  8364. {
  8365. // drawmapMS();
  8366. if (isBullseye)
  8367. {
  8368. setTimeout(drawmapMS(), 1000);
  8369. }
  8370. else
  8371. {
  8372. drawmapMS();
  8373. }
  8374. resolve();
  8375. }
  8376. else
  8377. {
  8378. SCRIPT.addEventListener('load', () => {
  8379. myHighlight("Bing Maps API loaded");
  8380. let timeout = 0;
  8381. let interval = setInterval(() => {
  8382. // console.log(timeout);
  8383. if (timeout >= 40) {
  8384. reject();
  8385. clearInterval(interval);
  8386. }
  8387. if (document.getElementById('ms-player') !== null && Microsoft.Maps.Map !== typeof undefined) {
  8388. drawmapMS();
  8389. resolve();
  8390. clearInterval(interval);
  8391. }
  8392. timeout += 1;
  8393. }, 1000);
  8394. })
  8395. }
  8396. }
  8397. }
  8398. else {
  8399. resolve();
  8400. }
  8401. });
  8402. }
  8403.  
  8404.  
  8405.  
  8406. function injectMapillaryPlayer() {
  8407. return new Promise((resolve, reject) => {
  8408. if (!MAPILLARY_INJECTED) {
  8409. if (MAPILLARY_API_KEY === "") {
  8410. let canvas = document.getElementById("player");
  8411. console.log("No Mapillary Key")
  8412. }
  8413. else {
  8414. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  8415. let switchCovergeButton = document.getElementById("switch");
  8416. let SCRIPT;
  8417. if (!partialCreateMapillary)
  8418. {
  8419. SCRIPT = document.createElement("script");
  8420. SCRIPT.type = "text/javascript";
  8421. SCRIPT.async = true;
  8422. SCRIPT.src = `https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.js`;
  8423. document.body.appendChild(SCRIPT);
  8424. document.querySelector('head').innerHTML += '<link href="https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.css" rel="stylesheet"/>';
  8425. }
  8426. let canvas = document.createElement("mmap");
  8427. if (isBattleRoyale) {
  8428. if (isDuel)
  8429. {
  8430.  
  8431. canvas.innerHTML = `<div id="mapillary-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  8432. }
  8433. else if (isBullseye)
  8434. {
  8435. 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>`;
  8436. }
  8437. else if (isLiveChallenge)
  8438. {
  8439. 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>`;
  8440. }
  8441. else
  8442. {
  8443. 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>`;
  8444. }
  8445. }
  8446. else {
  8447. canvas.innerHTML = `<div id="mapillary-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  8448. }
  8449.  
  8450. var div = document.getElementById("player");
  8451. if (isBullseye || isLiveChallenge)
  8452. {
  8453. div.prepend(canvas);
  8454. // setTimeout(drawmapMS(), 1000);
  8455. }
  8456. else
  8457. {
  8458. div.appendChild(canvas);
  8459. }
  8460.  
  8461. function drawMapML()
  8462. {
  8463. var {Viewer} = mapillary;
  8464.  
  8465. MapillaryPlayer = new Viewer({
  8466. accessToken: MAPILLARY_API_KEY,
  8467. container: 'mapillary-player', // the ID of our container defined in the HTML body
  8468. });
  8469.  
  8470. MapillaryPlayer.on('image', async (event) => {
  8471. // cnt = cnt + 1;
  8472. // console.log(cnt);
  8473. let image = event.image;
  8474. let pos = image.originalLngLat;
  8475. let cond = true;
  8476. for (const element of locHistory) {
  8477. if (element[2] == image.id)
  8478. {
  8479. cond = false;
  8480. }
  8481. }
  8482. if (cond)
  8483. {
  8484. switchCovergeButton.lat = pos.lat;
  8485. switchCovergeButton.lng = pos.lng;
  8486. switchCovergeButton.heading = image.compassAngle;
  8487. // console.log(pos);
  8488. locHistory.push([pos.lat, pos.lng, image.id, image.compassAngle]);
  8489. }
  8490. let btn = document.querySelector("button[data-qa='undo-move']");
  8491. if (btn !== null && locHistory.length > 1)
  8492. {
  8493. btn.disabled = false;
  8494. btn.classList.remove('styles_disabled__2YdHD');
  8495. }
  8496. });
  8497.  
  8498. MAPILLARY_INJECTED = true;
  8499. }
  8500. if (partialCreateMapillary)
  8501. {
  8502. drawMapML();
  8503. }
  8504. else
  8505. {
  8506.  
  8507. SCRIPT.addEventListener('load', () => {
  8508. myHighlight("Mapillary API Loaded");
  8509. // resolve(BMap);
  8510. drawMapML();
  8511. resolve();
  8512. })
  8513. }
  8514. }
  8515. }
  8516. else {
  8517. resolve();
  8518. }
  8519. });
  8520. }
  8521.  
  8522. function changeInnerHTML(canvas1, init)
  8523. {
  8524. canvas1.style.display = "";
  8525. var div = document.getElementById("player");
  8526. if (isBullseye || isLiveChallenge)
  8527. {
  8528. div.prepend(canvas1);
  8529. }
  8530. else
  8531. {
  8532. div.appendChild(canvas1);
  8533. }
  8534.  
  8535. let canvas;
  8536. if (init)
  8537. {
  8538. canvas = document.createElement("div");
  8539. canvas.id = "mapbox-player";
  8540. canvas.style.cssText = `overflow: visible; zIndex: 1; position: 'absolute'; top: 0; left: 0; width: 100%; height: 100%;`;
  8541. setTimeout(()=> {
  8542. canvas.style.overFlow = 'visible';
  8543. // canvas.style.width = '100%';
  8544. // canvas.style.height = '100%';
  8545. }
  8546. , 1000);
  8547. canvas1.appendChild(canvas);
  8548. }
  8549. else
  8550. {
  8551. 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");
  8552. }
  8553. canvas = document.getElementById("mapbox-player");
  8554. if (isBattleRoyale) {
  8555. if (isDuel)
  8556. {
  8557. canvas.classList.add("inactive");
  8558. }
  8559. else if (isBullseye)
  8560. {
  8561. canvas.classList.add("game-panorama_panorama__ncMwh");
  8562. }
  8563. else if (isLiveChallenge)
  8564. {
  8565. canvas.classList.add("game-panorama_panorama__IuPsO");
  8566. }
  8567. else
  8568. {
  8569. canvas.classList.add("br-game-layout__panorama");
  8570. }
  8571. }
  8572. else {
  8573. canvas.classList.add("game-layout__panorama");
  8574. }
  8575. if (rainLayer)
  8576. {
  8577. MapboxPlayer.resize();
  8578. }
  8579. // console.log(canvas);
  8580.  
  8581. }
  8582.  
  8583. function updateSunPosition(sunPos) {
  8584. MapboxPlayer.setPaintProperty('sky', 'sky-atmosphere-sun', sunPos);
  8585. }
  8586.  
  8587. function getSunPosition(date) {
  8588. const center = MapboxPlayer.getCenter();
  8589. const sunPos = SunCalc.getPosition(
  8590. date || Date.now(),
  8591. center.lat,
  8592. center.lng
  8593. );
  8594. const sunAzimuth = 180 + (sunPos.azimuth * 180) / Math.PI;
  8595. const sunAltitude = 90 - (sunPos.altitude * 180) / Math.PI;
  8596. return [sunAzimuth, sunAltitude];
  8597. }
  8598.  
  8599. // function handleRainLayer()
  8600. // {
  8601. // if (typeof RainLayer !== typeof undefined)
  8602. // {
  8603.  
  8604. // MapboxPlayer.addLayer(rainLayer);
  8605.  
  8606. // console.log("Rain Layer loaded");
  8607. // }
  8608. // else
  8609. // {
  8610. // setTimeout(handleRainLayer, 1000);
  8611. // }
  8612. // }
  8613.  
  8614. function skyLayer(reset, time, style)
  8615. {
  8616. try
  8617. {
  8618. if (reset.includes("reset"))
  8619. {
  8620. if (time == "")
  8621. {
  8622. time = [360, 30];
  8623. }
  8624. MapboxPlayer.addLayer({
  8625. 'id': 'sky',
  8626. 'type': 'sky',
  8627. 'paint': {
  8628. 'sky-opacity': [
  8629. 'interpolate',
  8630. ['linear'],
  8631. ['zoom'],
  8632. 0,
  8633. 0,
  8634. 5,
  8635. 0.3,
  8636. 8,
  8637. 1
  8638. ],
  8639. // set up the sky layer for atmospheric scattering
  8640. 'sky-type': 'atmosphere',
  8641. // explicitly set the position of the sun rather than allowing the sun to be attached to the main light source
  8642. 'sky-atmosphere-sun': time,
  8643. // set the intensity of the sun as a light source (0-100 with higher values corresponding to brighter skies)
  8644. 'sky-atmosphere-sun-intensity': 5
  8645. }
  8646. });
  8647.  
  8648. // handleRainLayer();
  8649.  
  8650.  
  8651. // Reset Fog
  8652. }
  8653. let percentage;
  8654. // console.log(time);
  8655.  
  8656. if (time[1] <= 75)
  8657. {
  8658. percentage = 0;
  8659. }
  8660. else if (time[1] > 75 && time[1] <= 90)
  8661. {
  8662. percentage = (90 - time[1]) / 20;
  8663. }
  8664. else
  8665. {
  8666. percentage = 1;
  8667. }
  8668.  
  8669. // console.log(MapboxPlayer.getStyle());
  8670.  
  8671. if (style)
  8672. {
  8673. MapboxPlayer.setPaintProperty(
  8674. 'heatmap',
  8675. 'heatmap-opacity',
  8676. percentage * 0.35
  8677. );
  8678. MapboxPlayer.setPaintProperty(
  8679. 'satellite',
  8680. 'raster-brightness-max',
  8681. 0.25 + (1 - percentage) * 0.75
  8682. );
  8683. MapboxPlayer.setPaintProperty(
  8684. 'road-simple',
  8685. 'line-opacity',
  8686. percentage * 0.25
  8687. );
  8688. MapboxPlayer.setPaintProperty(
  8689. 'bridge-case-simple',
  8690. 'line-opacity',
  8691. percentage * 0.25
  8692. );
  8693. MapboxPlayer.setPaintProperty(
  8694. 'bridge-simple',
  8695. 'line-opacity',
  8696. percentage * 0.25
  8697. );
  8698. }
  8699. let fogVal = 100 - percentage * 100;
  8700. // console.log(`rgba(${parseInt(fogVal)}, ${parseInt(fogVal)}, ${parseInt(fogVal)}, 1.0)`)
  8701. let val = [0, 5, 0.1];
  8702. if (ms_radius < 10000)
  8703. {
  8704. val[1] = ms_radius / 10000 * 4 + 1;
  8705. }
  8706. MapboxPlayer.setFog({ 'color': `hsl(0, 0, ${fogVal}%)` , 'range': [val[0], val[1]],'horizon-blend': val[2]});
  8707. // console.log(MapboxPlayer.getStyle());
  8708. }
  8709. catch (error) {
  8710. console.error(error);
  8711. // expected output: ReferenceError: nonExistentFunction is not defined
  8712. // Note - error messages will vary depending on browser
  8713. }
  8714. }
  8715.  
  8716.  
  8717. // function fetchTime(lat, lng)
  8718. // {
  8719. // return new Promise((resolve, reject) => {
  8720. // fetch(`https://api.timezonedb.com/v2.1/get-time-zone?key=D95ISGQ041BQ&format=json&by=position&lat=${lat}&lng=${lng}`)
  8721. // .then((response) => {resolve(response.json())})
  8722. // .catch((error) => {console.log(error);});
  8723. // });
  8724. // }
  8725. // fetchTime(global_lat, global_lng).then((data) => {
  8726.  
  8727. function styleMapboxAll(changeAttr, attrVal)
  8728. {
  8729. let satelliteStyleBtn = document.getElementById("Satellite Type Button");
  8730. const sunPositions = SunCalc.getTimes(
  8731. Date.now(),
  8732. global_lat,
  8733. global_lng
  8734. );
  8735.  
  8736. if (changeAttr === "Dimension" || changeAttr === "All" )
  8737. {
  8738. if (changeAttr === "All")
  8739. {
  8740. attrVal = Dimension;
  8741. }
  8742. // console.log(["arrval", attrVal]);
  8743.  
  8744. let tempRadius;
  8745. if (attrVal)
  8746. {
  8747. // 3D mode = 1/2 radius + pitch.
  8748. // From Unity Script documentation: https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit#heading=h.wce3rggpxz7i
  8749. // "*In 3D, radius is reduced by 50% but maximum viewing area with pitch is ~110%."
  8750. tempRadius = ms_radius * 0.5;
  8751. }
  8752. else
  8753. {
  8754. // 2D mode = full radius.
  8755. tempRadius = ms_radius;
  8756. }
  8757.  
  8758. let loc_centre = {lat: global_lat, lng: global_lng};
  8759. let latlngBounds = getBBox2(loc_centre, tempRadius);
  8760. // console.log([latlngBounds[0], latlngBounds[1]], [latlngBounds[2], latlngBounds[3]])
  8761. let mpBounds = [
  8762. [latlngBounds[1], latlngBounds[2]], // Southwest coordinates
  8763. [latlngBounds[3], latlngBounds[0]] // Northeast coordinates
  8764. ];
  8765.  
  8766. MapboxPlayer.setMaxBounds(mpBounds);
  8767.  
  8768. MapboxPlayer.once("moveend", (x) => {
  8769. setTimeout(()=>{
  8770. // Wait for the map to load a bit and then reset the map.
  8771.  
  8772. MapboxMarker.setLngLat([global_lng, global_lat])
  8773. .addTo(MapboxPlayer);
  8774.  
  8775. MapboxPlayer.easeTo({
  8776. bearing: 0,
  8777. pitch: 0,
  8778. zoom: 0,
  8779. duration: 1,
  8780. });
  8781. }, 1);
  8782. });
  8783.  
  8784. setTimeout(()=>{
  8785. // Added by EC waiting a bit seems to make the the animation
  8786. // more reliable. Sometimes it won't set the center properly.
  8787. MapboxPlayer.setCenter([global_lng, global_lat]);
  8788. }, 1);
  8789.  
  8790. if (attrVal)
  8791. {
  8792. MapboxPlayer.dragRotate.enable();
  8793. MapboxPlayer.touchZoomRotate.enableRotation();
  8794. }
  8795. else
  8796. {
  8797. MapboxPlayer.setPitch(0);
  8798. MapboxPlayer.dragRotate.disable();
  8799. MapboxPlayer.touchZoomRotate.disableRotation();
  8800. }
  8801. }
  8802. if (changeAttr === "SunPos")
  8803. {
  8804. // if (changeAttr === "All")
  8805. // {
  8806. // attrVal = satelliteStyleBtn.currentTime;
  8807. // }
  8808. let sunPos = getSunPosition(sunPositions[attrVal]);
  8809. updateSunPosition(sunPos);
  8810. skyLayer("", sunPos, mapSty);
  8811. }
  8812. if (changeAttr === "mapSty")
  8813. {
  8814. if (attrVal)
  8815. {
  8816. MapboxPlayer.setStyle("mapbox://styles/jupaoqq/cl0xjs63k003a15ml3essawbk");
  8817. }
  8818. else
  8819. {
  8820. MapboxPlayer.setStyle("mapbox://styles/jupaoqq/cl0ro0tm0001l14nyi17a91rs");
  8821. }
  8822.  
  8823. // MapboxPlayer.addLayer(rainLayer);
  8824. setTimeout(() => {
  8825. skyLayer("reset", getSunPosition(sunPositions[satelliteStyleBtn.currentTime]), mapSty);
  8826. if (!MapboxPlayer.getSource('mapbox-dem')) {
  8827. MapboxPlayer.addSource('mapbox-dem', {
  8828. 'type': 'raster-dem',
  8829. 'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',
  8830. 'tileSize': 512,
  8831. 'maxzoom': 14
  8832. });
  8833. // add the DEM source as a terrain layer with exaggerated height
  8834. MapboxPlayer.setTerrain({ 'source': 'mapbox-dem', 'exaggeration': 1.5 });
  8835. }
  8836. MapboxPlayer.addLayer(rainLayer);
  8837. }, 1000);
  8838. }
  8839. if (changeAttr === "Building" || changeAttr === "All")
  8840. {
  8841. if (changeAttr === "All")
  8842. {
  8843. attrVal = Building;
  8844. console.log("building")
  8845. }
  8846. if (attrVal)
  8847. {
  8848. MapboxPlayer.setPaintProperty(
  8849. 'building-extrusion',
  8850. 'fill-extrusion-opacity',
  8851. 0.8
  8852. );
  8853. }
  8854. else
  8855. {
  8856. MapboxPlayer.setPaintProperty(
  8857. 'building-extrusion',
  8858. 'fill-extrusion-opacity',
  8859. 0
  8860. );
  8861. }
  8862.  
  8863. }
  8864. if (changeAttr === "Weather" || changeAttr === "All")
  8865. {
  8866. if (changeAttr === "All")
  8867. {
  8868. attrVal = Weather;
  8869. }
  8870. if (attrVal)
  8871. {
  8872. rainLayer.setMeshOpacity(0.1);
  8873. rainLayer.setRainColor("rgba(204, 204, 255, 1)");
  8874. }
  8875. else
  8876. {
  8877. rainLayer.setMeshOpacity(0);
  8878. rainLayer.setRainColor("rgba(204, 204, 255, 0)");
  8879. }
  8880. }
  8881. }
  8882.  
  8883. function injectMapboxPlayer() {
  8884. return new Promise((resolve, reject) => {
  8885. if (!MAPBOX_INJECTED) {
  8886. if (MAPBOX_API_KEY === "") {
  8887. let canvas = document.getElementById("player");
  8888. console.log("No Mapbox Key")
  8889. }
  8890. else {
  8891. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  8892. let switchCovergeButton = document.getElementById("switch");
  8893.  
  8894. let canvas = document.createElement("sat-map");
  8895. canvas.id = "sat_map";
  8896. canvas.style.cssText = `z-index: 1; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%;`;
  8897. canvas.classList.add("sat_map");
  8898. changeInnerHTML(canvas, true);
  8899.  
  8900.  
  8901. // mapbox://styles/jupaoqq/cl0rnlwp9001914mz2vpinynt
  8902. // mapbox://styles/jupaoqq/cl0ro0tm0001l14nyi17a91rs
  8903.  
  8904. let SCRIPT;
  8905. if (!partialCreateMapbox)
  8906. {
  8907. const SCRIPT2 = document.createElement("script");
  8908. SCRIPT2.type = "text/javascript";
  8909. SCRIPT2.async = true;
  8910. SCRIPT2.src = `https://cdnjs.cloudflare.com/ajax/libs/suncalc/1.8.0/suncalc.min.js`;
  8911. document.body.appendChild(SCRIPT2);
  8912.  
  8913. SCRIPT = document.createElement("script");
  8914. SCRIPT.type = "text/javascript";
  8915. SCRIPT.async = true;
  8916. //SCRIPT.src = `https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.js`;
  8917. SCRIPT.src = `https://api.mapbox.com/mapbox-gl-js/v3.2.0/mapbox-gl.js`;
  8918. document.body.appendChild(SCRIPT);
  8919. //document.querySelector('head').innerHTML += '<link href="https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.css" rel="stylesheet"/>';
  8920. document.querySelector('head').innerHTML += '<link href="https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.css" rel="stylesheet"/>';
  8921. handleSatColor(true, true);
  8922. SCRIPT.addEventListener('load', () => {
  8923. const SCRIPT3 = document.createElement("script");
  8924. SCRIPT3.type = "text/javascript";
  8925. SCRIPT3.async = true;
  8926. SCRIPT3.src = `https://cdn.jsdelivr.net/npm/mapbox-gl-rain-layer@latest/dist/mapbox-gl-rain-layer.min.js`;
  8927. document.body.appendChild(SCRIPT3);
  8928. SCRIPT3.addEventListener('load', () => {
  8929. myHighlight("Mapbox API and Rainlayer Loaded");
  8930. // resolve(BMap);
  8931. mapboxgl.accessToken = MAPBOX_API_KEY;
  8932.  
  8933. // jsfiddle for flickering panning issue with map: https://jsfiddle.net/api/post/library/pure/
  8934.  
  8935. MapboxPlayer = new mapboxgl.Map({
  8936. container: 'mapbox-player', // container ID
  8937. // Using this style appears to cause flickering when used with the mapbox-dem source below.
  8938. style: 'mapbox://styles/jupaoqq/cl0xjs63k003a15ml3essawbk', // style URL
  8939. center: [0, 0], // starting position [lng, lat]
  8940. zoom: 13, // starting zoom
  8941. pitch: 0,
  8942. //bearing: 200
  8943. bearing: 0
  8944. });
  8945.  
  8946. console.log("New Mapbox API Call");
  8947.  
  8948. MapboxMarker = new mapboxgl.Marker()
  8949. // .setLngLat([0, 0])
  8950. // .addTo(MapboxPlayer);
  8951. MapboxPlayer.addControl(new mapboxgl.NavigationControl(), 'top-left');
  8952. MapboxPlayer.addControl(new mapboxgl.ScaleControl({}));
  8953. MapboxPlayer.on('load', () => {
  8954. MapboxPlayer.addSource('mapbox-dem', {
  8955. 'type': 'raster-dem',
  8956. 'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',
  8957. 'tileSize': 512,
  8958. 'maxzoom': 14
  8959. });
  8960.  
  8961. // add the DEM source as a terrain layer with exaggerated height
  8962. MapboxPlayer.setTerrain({ 'source': 'mapbox-dem', 'exaggeration': 1.5 });
  8963.  
  8964. rainLayer = new RainLayer({
  8965. id: 'rain',
  8966. source: 'rainviewer',
  8967. scale: 'noaa'
  8968. });
  8969. //MapboxPlayer.addLayer(rainLayer); // Players don't seem to like rain.
  8970.  
  8971. // TODO
  8972. // MapboxPlayer.setFog({'range': [-1, 1.5], 'color': `rgba(255, 255, 255, 1.0)`,'horizon-blend': 0.1});
  8973. //styleMapboxAll("All", true);
  8974.  
  8975. skyLayer("reset", "", true);
  8976.  
  8977. });
  8978.  
  8979. });
  8980. });
  8981.  
  8982. MAPBOX_INJECTED = true;
  8983. resolve();
  8984.  
  8985. }
  8986. else
  8987. {
  8988. resolve();
  8989. }
  8990. }
  8991. }
  8992. else {
  8993. resolve();
  8994. }
  8995. });
  8996. }
  8997.  
  8998.  
  8999.  
  9000. function handleMapillary(latlng, options)
  9001. {
  9002. console.log("handleMapillary")
  9003. return;// Added by EC
  9004. handleMapillaryHelper(latlng, options).then((data) => {
  9005. //console.log(data.data)
  9006. let idToSet = 0;
  9007. let curDist = 100000000;
  9008. for (const element of data.data) {
  9009. // console.log(element)
  9010. if (element.hasOwnProperty("computed_geometry"))
  9011. {
  9012. try {
  9013. let rCord = element.computed_geometry["coordinates"];
  9014. let dist = distance(latlng.lat,latlng.lng,rCord[1],rCord[0])
  9015. if (dist < curDist)
  9016. {
  9017. idToSet = element.id;
  9018. curDist = dist
  9019. }
  9020. } catch (e) {
  9021. console.log("Error")
  9022. }
  9023. }
  9024. }
  9025. if (idToSet !== 0)
  9026. {
  9027. MapillaryPlayer.moveTo(idToSet).then(
  9028. image => { //console.log(image);
  9029. },
  9030. error => { console.log(error); });
  9031. }}).catch((error) => {
  9032. console.log(error);
  9033. });
  9034. }
  9035.  
  9036. function handleMapillaryHelper(latlng, options)
  9037. {
  9038. return new Promise((resolve, reject) => {
  9039. // console.log("1")
  9040. let bbox = getBBox(latlng, options.meters);
  9041. 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)
  9042. // console.log(URL)
  9043. fetch(URL)
  9044. .then((response) => {resolve(response.json())})
  9045. .catch((error) => {console.log(error);});
  9046. });
  9047. }
  9048.  
  9049. function injectMapyPlayer() {
  9050. return new Promise((resolve, reject) => {
  9051. if (!MAPY_INJECTED) {
  9052. if (MAPY_API_KEY === "") {
  9053. let canvas = document.getElementById("player");
  9054. MAPY_INJECTED = true;
  9055. console.log("No Mapy Key")
  9056. }
  9057. else {
  9058.  
  9059. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  9060. let switchCovergeButton = document.getElementById("switch");
  9061. let SCRIPT;
  9062. if (!partialCreateMapy)
  9063. {
  9064. SCRIPT = document.createElement("script");
  9065. SCRIPT.type = "text/javascript";
  9066. SCRIPT.async = true;
  9067. SCRIPT.src = `https://api.mapy.cz/loader.js`;
  9068. document.body.appendChild(SCRIPT);
  9069. }
  9070. let canvas = document.createElement("czmap");
  9071. if (isBattleRoyale) {
  9072. if (isDuel)
  9073. {
  9074.  
  9075. canvas.innerHTML = `<div id="mapy-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  9076. }
  9077. else if (isBullseye)
  9078. {
  9079. 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>`;
  9080. }
  9081. else if (isLiveChallenge)
  9082. {
  9083. 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>`;
  9084. }
  9085. else
  9086. {
  9087. 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>`;
  9088. }
  9089. }
  9090. else {
  9091. canvas.innerHTML = `<div id="mapy-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  9092. }
  9093.  
  9094. var div = document.getElementById("player");
  9095. if (isBullseye || isLiveChallenge)
  9096. {
  9097. div.prepend(canvas);
  9098. // setTimeout(drawmapMS(), 1000);
  9099. }
  9100. else
  9101. {
  9102. div.appendChild(canvas);
  9103. }
  9104.  
  9105. var mapyPanoChange = function (signal) {
  9106. if (defaultPanoIdChange) {
  9107. let mapyLat = MapyPlayer.getPlace()._data.mark.lat;
  9108. let mapyLng = MapyPlayer.getPlace()._data.mark.lon;
  9109. let mapyHeading = toDegrees(MapyPlayer.getCamera().yaw);
  9110. switchCovergeButton.lat = mapyLat;
  9111. switchCovergeButton.lng = mapyLng;
  9112. switchCovergeButton.heading = mapyHeading;
  9113.  
  9114. if (locHistory.length > 0)
  9115. {
  9116. let toPush = true;
  9117. for (let locHy of locHistory)
  9118. {
  9119. if (mapyLat === locHy[0] && mapyLng === locHy[1])
  9120. {
  9121. toPush = false;
  9122. }
  9123. }
  9124. if (toPush)
  9125. {
  9126. locHistory.push([mapyLat, mapyLng, mapyHeading]);
  9127. }
  9128. }
  9129. else
  9130. {
  9131. locHistory.push([mapyLat, mapyLng, mapyHeading]);
  9132. }
  9133. let btn = document.querySelector("button[data-qa='undo-move']");
  9134. if (locHistory.length > 1 && btn) {
  9135. btn.disabled = false;
  9136. btn.classList.remove('styles_disabled__2YdHD');
  9137. }
  9138. }
  9139. else
  9140. {
  9141. defaultPanoIdChange = true;
  9142. }
  9143. }
  9144.  
  9145. function crMap()
  9146. {
  9147. MapyPlayer = new SMap.Pano.Scene(document.getElementById("mapy-player"));
  9148. var signals = MapyPlayer.getSignals();
  9149. signals.addListener(window, "pano-change", mapyPanoChange);
  9150. }
  9151. if (partialCreateMapy)
  9152. {
  9153. crMap();
  9154. MAPY_INJECTED = true;
  9155. }
  9156. else
  9157. {
  9158. SCRIPT.addEventListener('load', () => {
  9159. myHighlight("Mapy API Loaded");
  9160. MAPY_INJECTED = true;
  9161. Loader.async = true;
  9162. Loader.load(null, {pano: true}, crMap);
  9163. resolve();
  9164. })
  9165. }
  9166. }
  9167. }
  9168. else {
  9169. resolve();
  9170. }
  9171. });
  9172. }
  9173.  
  9174.  
  9175. /**
  9176. * Minimap presets
  9177. */
  9178.  
  9179.  
  9180.  
  9181. let water_name_only, country_name_only,no_label_or_terrain,no_label,blank,thick_border,Indonesia,dark,default_preset,presetMinimap,GEOJSON_INVISIBLE,presetOverlay,spaceMinimap,spaceMinimap2,spaceMinimap3,spaceList,neon;
  9182.  
  9183. (function makeMiniMapPresets(){
  9184. //setTimeout(function makeMiniMapPresets(){
  9185. // Made by EC
  9186. // Trying to make this script load faster, by delaying unnecessary stuff.
  9187.  
  9188. water_name_only =
  9189. [
  9190. {
  9191. "elementType": "geometry",
  9192. "stylers": [
  9193. {
  9194. "visibility": "off"
  9195. }
  9196. ]
  9197. },
  9198. {
  9199. "featureType": "administrative",
  9200. "stylers": [
  9201. {
  9202. "visibility": "off"
  9203. }
  9204. ]
  9205. },
  9206. {
  9207. "featureType": "landscape",
  9208. "stylers": [
  9209. {
  9210. "visibility": "off"
  9211. }
  9212. ]
  9213. },
  9214. {
  9215. "featureType": "poi",
  9216. "stylers": [
  9217. {
  9218. "visibility": "off"
  9219. }
  9220. ]
  9221. },
  9222. {
  9223. "featureType": "road",
  9224. "stylers": [
  9225. {
  9226. "visibility": "off"
  9227. }
  9228. ]
  9229. },
  9230. {
  9231. "featureType": "transit",
  9232. "stylers": [
  9233. {
  9234. "visibility": "off"
  9235. }
  9236. ]
  9237. }
  9238. ]
  9239.  
  9240. country_name_only =
  9241. [
  9242. {
  9243. "elementType": "geometry",
  9244. "stylers": [
  9245. {
  9246. "visibility": "off"
  9247. }
  9248. ]
  9249. },
  9250. {
  9251. "featureType": "administrative",
  9252. "stylers": [
  9253. {
  9254. "visibility": "off"
  9255. }
  9256. ]
  9257. },
  9258. {
  9259. "featureType": "administrative.country",
  9260. "elementType": "labels",
  9261. "stylers": [
  9262. {
  9263. "visibility": "on"
  9264. }
  9265. ]
  9266. },
  9267. {
  9268. "featureType": "landscape",
  9269. "stylers": [
  9270. {
  9271. "visibility": "off"
  9272. }
  9273. ]
  9274. },
  9275. {
  9276. "featureType": "poi",
  9277. "stylers": [
  9278. {
  9279. "visibility": "off"
  9280. }
  9281. ]
  9282. },
  9283. {
  9284. "featureType": "road",
  9285. "stylers": [
  9286. {
  9287. "visibility": "off"
  9288. }
  9289. ]
  9290. },
  9291. {
  9292. "featureType": "transit",
  9293. "stylers": [
  9294. {
  9295. "visibility": "off"
  9296. }
  9297. ]
  9298. },
  9299. {
  9300. "featureType": "water",
  9301. "stylers": [
  9302. {
  9303. "visibility": "off"
  9304. }
  9305. ]
  9306. }
  9307. ]
  9308.  
  9309. no_label_or_terrain =
  9310. [
  9311. {
  9312. "elementType": "geometry",
  9313. "stylers": [
  9314. {
  9315. "visibility": "off"
  9316. }
  9317. ]
  9318. },
  9319. {
  9320. "featureType": "administrative",
  9321. "stylers": [
  9322. {
  9323. "visibility": "off"
  9324. }
  9325. ]
  9326. },
  9327. {
  9328. "featureType": "landscape",
  9329. "stylers": [
  9330. {
  9331. "visibility": "off"
  9332. }
  9333. ]
  9334. },
  9335. {
  9336. "featureType": "poi",
  9337. "stylers": [
  9338. {
  9339. "visibility": "off"
  9340. }
  9341. ]
  9342. },
  9343. {
  9344. "featureType": "road",
  9345. "stylers": [
  9346. {
  9347. "visibility": "off"
  9348. }
  9349. ]
  9350. },
  9351. {
  9352. "featureType": "transit",
  9353. "stylers": [
  9354. {
  9355. "visibility": "off"
  9356. }
  9357. ]
  9358. },
  9359. {
  9360. "featureType": "water",
  9361. "stylers": [
  9362. {
  9363. "visibility": "on"
  9364. }
  9365. ]
  9366. },
  9367. {
  9368. "featureType": "water",
  9369. "elementType": "labels",
  9370. "stylers": [
  9371. {
  9372. "visibility": "off"
  9373. }
  9374. ]
  9375. }
  9376. ]
  9377.  
  9378. no_label =
  9379. [
  9380. {
  9381. "elementType": "labels",
  9382. "stylers": [
  9383. {
  9384. "visibility": "off"
  9385. }
  9386. ]
  9387. },
  9388. {
  9389. "featureType": "administrative",
  9390. "stylers": [
  9391. {
  9392. "visibility": "off"
  9393. }
  9394. ]
  9395. }
  9396. ]
  9397.  
  9398. blank =
  9399.  
  9400. [
  9401. {
  9402. "stylers": [
  9403. {
  9404. "visibility": "off"
  9405. }
  9406. ]
  9407. }
  9408. ]
  9409.  
  9410. thick_border =
  9411.  
  9412. [
  9413. {
  9414. "featureType": "administrative.country",
  9415. "elementType": "geometry.stroke",
  9416. "stylers": [
  9417. {
  9418. "weight": 1.5
  9419. }
  9420. ]
  9421. },
  9422. {
  9423. "featureType": "administrative.province",
  9424. "elementType": "geometry.stroke",
  9425. "stylers": [
  9426. {
  9427. "weight": 3.5
  9428. }
  9429. ]
  9430. }
  9431. ]
  9432.  
  9433. Indonesia =
  9434. [
  9435. {
  9436. "featureType": "administrative",
  9437. "stylers": [
  9438. {
  9439. "visibility": "off"
  9440. }
  9441. ]
  9442. },
  9443. {
  9444. "featureType": "landscape",
  9445. "elementType": "labels",
  9446. "stylers": [
  9447. {
  9448. "visibility": "off"
  9449. }
  9450. ]
  9451. },
  9452. {
  9453. "featureType": "poi.park",
  9454. "elementType": "labels",
  9455. "stylers": [
  9456. {
  9457. "visibility": "off"
  9458. }
  9459. ]
  9460. },
  9461. {
  9462. "featureType": "road",
  9463. "elementType": "labels",
  9464. "stylers": [
  9465. {
  9466. "visibility": "off"
  9467. }
  9468. ]
  9469. },
  9470. {
  9471. "featureType": "transit",
  9472. "elementType": "labels",
  9473. "stylers": [
  9474. {
  9475. "visibility": "off"
  9476. }
  9477. ]
  9478. },
  9479. {
  9480. "featureType": "water",
  9481. "elementType": "labels",
  9482. "stylers": [
  9483. {
  9484. "visibility": "off"
  9485. }
  9486. ]
  9487. }
  9488. ];
  9489.  
  9490. dark = [
  9491. {
  9492. "elementType": "geometry",
  9493. "stylers": [
  9494. {
  9495. "color": "#212121"
  9496. }
  9497. ]
  9498. },
  9499. {
  9500. "elementType": "labels.icon",
  9501. "stylers": [
  9502. {
  9503. "visibility": "off"
  9504. }
  9505. ]
  9506. },
  9507. {
  9508. "elementType": "labels.text.fill",
  9509. "stylers": [
  9510. {
  9511. "color": "#757575"
  9512. }
  9513. ]
  9514. },
  9515. {
  9516. "elementType": "labels.text.stroke",
  9517. "stylers": [
  9518. {
  9519. "color": "#212121"
  9520. }
  9521. ]
  9522. },
  9523. {
  9524. "featureType": "administrative",
  9525. "elementType": "geometry",
  9526. "stylers": [
  9527. {
  9528. "color": "#757575"
  9529. }
  9530. ]
  9531. },
  9532. {
  9533. "featureType": "administrative.country",
  9534. "elementType": "labels.text.fill",
  9535. "stylers": [
  9536. {
  9537. "color": "#9e9e9e"
  9538. }
  9539. ]
  9540. },
  9541. {
  9542. "featureType": "administrative.land_parcel",
  9543. "stylers": [
  9544. {
  9545. "visibility": "off"
  9546. }
  9547. ]
  9548. },
  9549. {
  9550. "featureType": "administrative.locality",
  9551. "elementType": "labels.text.fill",
  9552. "stylers": [
  9553. {
  9554. "color": "#bdbdbd"
  9555. }
  9556. ]
  9557. },
  9558. {
  9559. "featureType": "poi",
  9560. "elementType": "labels.text.fill",
  9561. "stylers": [
  9562. {
  9563. "color": "#757575"
  9564. }
  9565. ]
  9566. },
  9567. {
  9568. "featureType": "poi.park",
  9569. "elementType": "geometry",
  9570. "stylers": [
  9571. {
  9572. "color": "#181818"
  9573. }
  9574. ]
  9575. },
  9576. {
  9577. "featureType": "poi.park",
  9578. "elementType": "labels.text.fill",
  9579. "stylers": [
  9580. {
  9581. "color": "#616161"
  9582. }
  9583. ]
  9584. },
  9585. {
  9586. "featureType": "poi.park",
  9587. "elementType": "labels.text.stroke",
  9588. "stylers": [
  9589. {
  9590. "color": "#1b1b1b"
  9591. }
  9592. ]
  9593. },
  9594. {
  9595. "featureType": "road",
  9596. "elementType": "geometry.fill",
  9597. "stylers": [
  9598. {
  9599. "color": "#2c2c2c"
  9600. }
  9601. ]
  9602. },
  9603. {
  9604. "featureType": "road",
  9605. "elementType": "labels.text.fill",
  9606. "stylers": [
  9607. {
  9608. "color": "#8a8a8a"
  9609. }
  9610. ]
  9611. },
  9612. {
  9613. "featureType": "road.arterial",
  9614. "elementType": "geometry",
  9615. "stylers": [
  9616. {
  9617. "color": "#373737"
  9618. }
  9619. ]
  9620. },
  9621. {
  9622. "featureType": "road.highway",
  9623. "elementType": "geometry",
  9624. "stylers": [
  9625. {
  9626. "color": "#3c3c3c"
  9627. }
  9628. ]
  9629. },
  9630. {
  9631. "featureType": "road.highway.controlled_access",
  9632. "elementType": "geometry",
  9633. "stylers": [
  9634. {
  9635. "color": "#4e4e4e"
  9636. }
  9637. ]
  9638. },
  9639. {
  9640. "featureType": "road.local",
  9641. "elementType": "labels.text.fill",
  9642. "stylers": [
  9643. {
  9644. "color": "#616161"
  9645. }
  9646. ]
  9647. },
  9648. {
  9649. "featureType": "transit",
  9650. "elementType": "labels.text.fill",
  9651. "stylers": [
  9652. {
  9653. "color": "#757575"
  9654. }
  9655. ]
  9656. },
  9657. {
  9658. "featureType": "water",
  9659. "elementType": "geometry",
  9660. "stylers": [
  9661. {
  9662. "color": "#000000"
  9663. }
  9664. ]
  9665. },
  9666. {
  9667. "featureType": "water",
  9668. "elementType": "labels.text.fill",
  9669. "stylers": [
  9670. {
  9671. "color": "#3d3d3d"
  9672. }
  9673. ]
  9674. }
  9675. ];
  9676.  
  9677. neon = [
  9678. {
  9679. "stylers": [
  9680. {
  9681. "saturation": 100
  9682. },
  9683. {
  9684. "gamma": 0.6
  9685. }
  9686. ]
  9687. }
  9688. ];
  9689.  
  9690. default_preset = []
  9691.  
  9692. presetMinimap = [[default_preset, "Default"],
  9693. [blank, "Blank"],
  9694. [water_name_only, "Oceanman"],
  9695. [country_name_only, "Impossible"],
  9696. [no_label_or_terrain, "Streaks"],
  9697. [no_label, "Easy 5K"],
  9698. [Indonesia, "POI only"],
  9699. [dark, "Dark Mode"],
  9700. [thick_border, "Borders"],
  9701. [default_preset, "Satellite"],
  9702. [default_preset, "Terrain"],
  9703. [default_preset, "Hybrid"],
  9704. [custom, "Custom"],
  9705. [neon, "Neon"],
  9706. [default_preset, "Country Streak"],
  9707. [default_preset, "RMC"]]
  9708.  
  9709. GEOJSON_INVISIBLE =
  9710. {
  9711. strokeOpacity: 0,
  9712. fillOpacity: 0,
  9713. clickable: false,
  9714. }
  9715.  
  9716. presetOverlay = [["Clear",""],
  9717. ["Coverage",""],
  9718. ["Official",""],
  9719. ["OSM",""],
  9720. ["City Lights",""],
  9721. ["Watercolor",""],
  9722. ["Toner",""],
  9723. ["Fire",""],
  9724. ["Longitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/lonl.json"],
  9725. ["Latitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/latl.json"],
  9726. ["US County","https://raw.githubusercontent.com/CodeForCary/CountyDataUSA5m/master/cb_2017_us_county_5m.json"],
  9727. ["France","https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements.geojson"],
  9728. ["Time Zone", "https://raw.githubusercontent.com/treyerl/timezones/master/timezones_wVVG8.geojson"],
  9729. ["UK Parliament", "https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/electoral/gb/wpc.json"],
  9730. ["Custom", YOUR_URL]]
  9731.  
  9732. spaceMinimap = [["Earth",""],
  9733. ["Moon", "https://s3.amazonaws.com/opmbuilder/301_moon/tiles/w/hillshaded-albedo/"],
  9734. ["Moon (Labels)", "https://cartocdn-gusc.global.ssl.fastly.net/opmbuilder/api/v1/map/named/opm-moon-basemap-v0-1/all/"],
  9735. ["Mars", "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/"],
  9736. ["Mars (Labels)", "https://cartocdn-gusc.global.ssl.fastly.net/opmbuilder/api/v1/map/named/opm-mars-basemap-v0-2/all/"],
  9737. ["Mars-Viking", "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/viking_mdim21_global/"],
  9738. ]
  9739.  
  9740. spaceMinimap2 = [["Mercury", "mercury/mercury_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=MESSENGER_May2013"],
  9741. ["Venus", "venus/venus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=MAGELLAN_color"],
  9742. ["Phobos", "mars/phobos_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=VIKING"],
  9743. ["Deimos", "mars/deimos_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=VIKING"],
  9744. ["Ceres", "asteroid_belt/ceres_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Ceres_FC_global"],
  9745. ["Vesta", "asteroid_belt/vesta_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Dawn_HAMO_global"],
  9746. ["Jupiter", "jupiter/jupiter_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  9747. ["Callisto", "jupiter/callisto_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=GALILEO_VOYAGER"],
  9748. ["Europa", "jupiter/europa_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=GALILEO_VOYAGER"],
  9749. ["Ganymede", "jupiter/ganymede_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=GALILEO_VOYAGER"],
  9750. ["Io", "jupiter/io_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=SSI_VGR_color"]
  9751. ]
  9752.  
  9753. spaceMinimap3 = [["Saturn", "saturn/saturn_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  9754. ["Dione", "saturn/dione_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_VOYAGER"],
  9755. ["Enceladus", "saturn/enceladus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  9756. ["Iapetus", "saturn/iapetus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_VOYAGER"],
  9757. ["Mimas", "saturn/mimas_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_MIMAS_MOSAIC"],
  9758. ["Rhea", "saturn/rhea_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_VOYAGER"],
  9759. ["Tethys", "saturn/tethys_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  9760. ["Titan", "saturn/titan_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  9761. ["Uranus", "uranus/uranus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=JHT_VOYAGER_HST"],
  9762. ["Neptune", "neptune/neptune_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=JHT_VOYAGER"],
  9763. ["Pluto", "pluto/pluto_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=NEWHORIZONS_PLUTO_MOSAIC"],
  9764. ]
  9765.  
  9766. spaceList = ["Moon", "Mars", "Mercury", "Venus", "Phobos", "Deimos", "Ceres", "Vesta", "Jupiter", "Callisto", "Europa", "Ganymede", "Io",
  9767. "Saturn", "Dione", "Enceladus", "Iapetus", "Mimas", "Rhea", "Tethys", "Titan", "Uranus", "Neptune", "Pluto", "Solar System"];
  9768. })();
  9769.  
  9770. function handleSpURL(url, x1, y1, z1)
  9771. {
  9772. function tile2long(x,z) {
  9773. return (x/Math.pow(2,z)*360-180);
  9774. }
  9775. function tile2lat(y,z) {
  9776. var n=Math.PI-2*Math.PI*y/Math.pow(2,z);
  9777. return (180/Math.PI*Math.atan(0.5*(Math.exp(n)-Math.exp(-n))));
  9778. }
  9779.  
  9780. let NWlon = tile2long(x1,z1)
  9781. let NWlat = tile2lat(y1,z1)
  9782. let SElon = tile2long(x1 + 1,z1)
  9783. let SElat = tile2lat(y1 + 1,z1)
  9784. 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}`;
  9785. }
  9786.  
  9787. // return `https://tiles.mapgenie.io/games/gta5/los-santos/satellite/${z}/${x}/${y}.png`
  9788. // return `https://mapsv0.bdimg.com/tile/?udt=20200825&qt=tile&styles=pl&x=${x}&y=${y}&z=${z+2}`
  9789.  
  9790. let langDict = {
  9791. "sn": ["fr"],
  9792. "za": ["af"],
  9793. "mg": ["mg", "fr"],
  9794. "tn": ["ar"],
  9795. "bd": ["bn"],
  9796. "kh": ["km"],
  9797. "in": ["hi"],
  9798. "cn": ["zh"],
  9799. "hk": ["zh"],
  9800. "id": ["id"],
  9801. "ir": ["fa"],
  9802. "il": ["he"],
  9803. "jp": ["ja"],
  9804. "jo": ["ar"],
  9805. "ky": ["ru", "ky"],
  9806. "la": ["lo"],
  9807. "my": ["ms"],
  9808. "mn": ["mn"],
  9809. "np": ["ne"],
  9810. "ru": ["ru"],
  9811. "sg": ["zh"],
  9812. "kr": ["ko"],
  9813. "lk": ["ta"],
  9814. "tw": ["zh"],
  9815. "th": ["th"],
  9816. "ae": ["ar"],
  9817. "vn": ["vi"],
  9818. "al": ["sq"],
  9819. "ad": ["es", "fr"],
  9820. "at": ["de"],
  9821. "be": ["nl", "fr"],
  9822. "bg": ["bg"],
  9823. "hr": ["hr"],
  9824. "cy": ["el"],
  9825. "cz": ["cs"],
  9826. "dk": ["da"],
  9827. "ee": ["et"],
  9828. "fo": ["fo"],
  9829. "fi": ["fi"],
  9830. "fr": ["fr"],
  9831. "de": ["de"],
  9832. "gr": ["el"],
  9833. "hu": ["hu"],
  9834. "is": ["is"],
  9835. "ie": ["ga"],
  9836. "it": ["it"],
  9837. "lv": ["lv"],
  9838. "lt": ["lt"],
  9839. "lu": ["lb", "fr", "de"],
  9840. "mc": ["fr"],
  9841. "nl": ["nl"],
  9842. "mk": ["mk"],
  9843. "no": ["no"],
  9844. "pl": ["pl"],
  9845. "pt": ["pt"],
  9846. "ro": ["ro"],
  9847. "sm": ["it"],
  9848. "rs": ["sr"],
  9849. "sk": ["sk"],
  9850. "si": ["sl"],
  9851. "es": ["es"],
  9852. "se": ["sv"],
  9853. "ch": ["de", "fr"],
  9854. "tr": ["tr"],
  9855. "ua": ["uk"],
  9856. "cw": ["nl"],
  9857. "do": ["es"],
  9858. "gt": ["es"],
  9859. "mx": ["es"],
  9860. "pr": ["es"],
  9861. "ar": ["es"],
  9862. "bo": ["es"],
  9863. "br": ["pt"],
  9864. "cl": ["es"],
  9865. "ec": ["es"],
  9866. "pe": ["es"],
  9867. "uy": ["es"]
  9868. };
  9869.  
  9870. // ch, lu, be, ad
  9871.  
  9872. let carteDict = {
  9873. "AG": "agadir",
  9874. "AS": "asilah",
  9875. "CA": "casablanca",
  9876. "ER": "errachidia",
  9877. "ES": "essaouira",
  9878. "FE": "fes",
  9879. "IR": "ifrane",
  9880. "MA": "marrakech",
  9881. "ME": "meknes",
  9882. "RA": "rabat",
  9883. };
  9884.  
  9885. let satType = [["Weather", "Weather: On", "Weather: Off"],
  9886. ["Building", "Building: On", "Building: Off"],
  9887. ["Dimension", "3D", "2D"],
  9888. ["mapSty", "Satellite", "Road"]];
  9889.  
  9890. let satStyle = [["solarNoon","Noon"],
  9891. ["sunriseEnd","Sunrise"],
  9892. ["goldenHourEnd","Morning"],
  9893. ["goldenHour","Evening"],
  9894. ["sunsetStart","Sunset"],
  9895. ["nadir","Midnight"],
  9896. ["getlocal","Local Time"],
  9897. ];
  9898.  
  9899.  
  9900.  
  9901. let HUD_ZINDEX_UPDATER = setInterval(()=>{
  9902. // Added by EC
  9903. let huds = document.querySelectorAll(`div[class*="Hud"i]`);
  9904.  
  9905. huds.forEach((hudEl)=>{
  9906. if (hudEl._zindexSet) return;
  9907. hudEl.style.zIndex = '2';
  9908. hudEl._zindexSet = true;
  9909. })
  9910.  
  9911. }, 2000);
  9912.  
  9913.  
  9914. setInterval(function () {
  9915. const guessmap = document.querySelector("div[data-qa='guess-map']");
  9916. //const canvas = document.querySelector("#satMapContainer");
  9917. const canvass = document.querySelectorAll("canvas");
  9918.  
  9919. if (guessmap && !guessmap.__n) {
  9920. // Sometimes the guess map doesn't open back up.
  9921.  
  9922. guessmap.addEventListener("mouseover", function (e) {
  9923. if (!guessmap.activeClass) {
  9924. setTimeout(()=>{
  9925. guessmap.activeClass = Array.from(guessmap.classList).reduce( (x, a) => x + (/active/i.test(a) ? a : ""), "",);
  9926. }, 100);
  9927. return;
  9928. }
  9929. guessmap.classList.add(guessmap.activeClass);
  9930. });
  9931. guessmap.__n = true;
  9932. }
  9933.  
  9934. canvass.forEach(canvas =>{
  9935. if (canvas && canvas.__n) return;
  9936.  
  9937. canvas.addEventListener("mousedown", function () {
  9938. const guessmap = document.querySelector("div[data-qa='guess-map']");
  9939. if (!guessmap) return;
  9940. if (!guessmap.activeClass) {
  9941. guessmap.activeClass = Array.from(guessmap.classList).reduce( (x, a) => x + (/active/i.test(a) ? a : ""), "",);
  9942. }
  9943. guessmap.classList.remove(guessmap.activeClass);
  9944. });
  9945.  
  9946. canvas.__n = true;
  9947. });
  9948. }, 2000);
  9949.  
  9950. function makeGuessMapHack(options){
  9951. const guessButton = document.querySelector('[data-qa="perform-guess"]');
  9952. if (guessButton){
  9953. console.log(guessButton);
  9954.  
  9955. // Geoguessr guess map is loaded.
  9956. return;
  9957. }
  9958.  
  9959. if (document.querySelector('.baidu_guess_map')){
  9960. // Remove duplicate or old guess map and button.
  9961. // Timing out is one issue that could cause duplicate guess map and button.
  9962. let baiduGuessMap = document.querySelector('.baidu_guess_map');
  9963. baiduGuessMap._remove();
  9964. }
  9965.  
  9966. const geoGuessContainer = document.querySelector(`[class*="game_guessMap"]`);
  9967. geoGuessContainer.style.flexDirection = "column";
  9968.  
  9969. let closeMiniMapTimer = null;
  9970.  
  9971. options.mapContainer.addEventListener("mouseover", () =>{
  9972. clearTimeout(closeMiniMapTimer);
  9973. closeMiniMapTimer = setTimeout(function(){
  9974. mapContainer.classList.remove(`baidu_guess_map_active`)
  9975. }, 500);
  9976. });
  9977.  
  9978. const mapContainer = document.createElement("div");
  9979. mapContainer.classList.add("baidu_guess_map");
  9980. mapContainer._remove = ()=>{
  9981. let baiduGuessMap = document.querySelector('.baidu_guess_map');
  9982. baiduGuessMap.parentElement.removeChild(baiduGuessMap);
  9983.  
  9984. let baiduGuessButton = document.querySelector('.baidu_guess_button');
  9985. if (baiduGuessButton){
  9986. baiduGuessButton.parentElement.removeChild(baiduGuessButton);
  9987. }
  9988. };
  9989. mapContainer.addEventListener("mouseover", () =>{
  9990. clearTimeout(closeMiniMapTimer);
  9991. mapContainer.classList.add(`baidu_guess_map_active`)
  9992. });
  9993. mapContainer.geoguessrGuessButtonWatcher = setInterval(()=>{
  9994. // Remove mapContainer if geoguessr guess button appears out of the blue.
  9995. const guessButton = document.querySelector('[data-qa="perform-guess"]');
  9996. if (!guessButton) return;
  9997. clearInterval(mapContainer.geoguessrGuessButtonWatcher);
  9998. mapContainer._remove();
  9999. }, 2000);
  10000.  
  10001. geoGuessContainer.appendChild(mapContainer);
  10002.  
  10003. let map = new google.maps.Map(mapContainer, {
  10004. center: { lat: 0, lng: 0 },
  10005. zoom: 5,
  10006. disableDefaultUI: true,
  10007. clickableIcons: false,
  10008. draggableCursor: "crosshair",
  10009. });
  10010.  
  10011. const bounds = new google.maps.LatLngBounds();
  10012. bounds.extend(global_bounds.min);
  10013. bounds.extend(global_bounds.max);
  10014.  
  10015. map.fitBounds(bounds)
  10016. setTimeout(()=> (map.getZoom() === 0) && map.setZoom(1), 100);
  10017.  
  10018. let marker = new google.maps.Marker({
  10019. map,
  10020. // label:{
  10021. // text: "5",
  10022. // color: "#ffffff",
  10023. // fontSize: "20px",
  10024. // fontWeight: "bold"
  10025. // }
  10026. });
  10027.  
  10028. let latLng = null;
  10029.  
  10030. const clickHandler = map.addListener("click", playClick);
  10031.  
  10032. function playClick(evt) {
  10033. console.log(evt);
  10034. latLng = evt.latLng.toJSON();
  10035. guessBtn.disabled = false;
  10036. guessBtn.classList.add('baidu_guess_button_enabled');
  10037. marker.setPosition(evt.latLng);
  10038. };
  10039.  
  10040. const guessBtnContainer = document.createElement("div");
  10041. const guessBtn = document.createElement("button");
  10042. guessBtn.classList.add('baidu_guess_button');
  10043. guessBtn.innerHTML = options.guessBtnText; //"Baidu Guess Button";
  10044. guessBtn.style.cssText =
  10045. "background: #368ce7; border-radius: 0px 0px 10px 10px; width: 100%; padding: 1em; cursor: pointer; font-family: var(--default-font); transistion: 100ms ease;";
  10046. guessBtn.disabled = true;
  10047. guessBtn.addEventListener("click", (evt) => {
  10048. if (guessBtn._doReload){
  10049. location.reload();
  10050. return;
  10051. }
  10052. const mapId = location.href.replace(/.*\/(.*)/, "$1");
  10053.  
  10054. fetch(`https://www.geoguessr.com/api/v3/games/${global_data.token}`, {
  10055. headers: {
  10056. accept: "*/*",
  10057. "accept-language": "en-US,en;q=0.9",
  10058. "cache-control": "no-cache",
  10059. "content-type": "application/json",
  10060. pragma: "no-cache",
  10061. "sec-ch-ua":
  10062. '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
  10063. "sec-ch-ua-mobile": "?0",
  10064. "sec-ch-ua-platform": '"Linux"',
  10065. "sec-fetch-dest": "empty",
  10066. "sec-fetch-mode": "cors",
  10067. "sec-fetch-site": "same-origin",
  10068. "x-client": "web",
  10069. },
  10070. referrer: location.href, // "https://www.geoguessr.com/game/rks2XFcZOIQlZQg9",
  10071. referrerPolicy: "strict-origin-when-cross-origin",
  10072. body: `{"token":"${mapId}","lat\":${latLng.lat},"lng\":${latLng.lng},"timedOut":false, "skipRound": false}`,
  10073. method: "POST",
  10074. mode: "cors",
  10075. credentials: "include",
  10076. }).then(res => {
  10077. return res.json();
  10078. }).then(jSon => {
  10079. console.log("jSon", jSon);
  10080.  
  10081. const len = jSon.round;
  10082. const PATHNAME = getPathName();
  10083. if (PATHNAME.startsWith("/challenge/") || len === 5){
  10084. location.reload();
  10085. return;
  10086. }
  10087.  
  10088. const locationMarker = new google.maps.Marker({
  10089. map,
  10090. position: {lat: global_lat, lng: global_lng},
  10091. icon: options.markerIcon || 'http://maps.gstatic.com/mapfiles/ms2/micons/flag.png'
  10092. });
  10093.  
  10094. locationMarker.addListener('click', (e)=>{
  10095.  
  10096. window.open(options.locationUrl, '_blank');
  10097. }) ;
  10098.  
  10099. if (!options.markerIcon){
  10100. let markerShadow = new google.maps.Marker({
  10101. clickable: false,
  10102. position: {lat: global_lat, lng: global_lng},
  10103. map: map,
  10104. icon:{
  10105. url: 'http://maps.google.com/mapfiles/ms/micons/flag.shadow.png',
  10106. //The size image file.
  10107. // size: new google.maps.Size(225, 120),
  10108. //The point on the image to measure the anchor from. 0, 0 is the top left.
  10109. // origin: new google.maps.Point(150, 0),
  10110. //The x y coordinates of the anchor point on the marker. e.g. If your map marker was a drawing pin then the anchor would be the tip of the pin.
  10111. anchor: new google.maps.Point(15, 32)
  10112. },
  10113. zIndex: (Math.round(global_lat*-100000)<<5)-1
  10114. });
  10115. }
  10116.  
  10117. mapContainer.classList.remove("baidu_guess_map_active");
  10118. mapContainer.classList.add("baidu_guess_map_between_rounds");
  10119.  
  10120. const interpolated = google.maps.geometry.spherical.interpolate({lat: global_lat, lng: global_lng}, marker.position, 0.5);
  10121.  
  10122. const dist = jSon.player.guesses[len-1].distance.meters;
  10123.  
  10124. const contentString = `
  10125. <div id="content_string" style="color: rgb(40, 40, 40); font-size: 1.3rem; font-family: var(--default-font); font-style:italic; padding: 1rem;">
  10126. <div>
  10127. <span style="font-size:1.1rem;">Points:</span> <span style="font-weight: 700">${jSon.player.guesses[len-1].roundScoreInPoints.toLocaleString()}</span>
  10128. </div>
  10129. <div>
  10130. <span style="font-size:1.1rem;">Distance:</span> <span style="font-weight: 700">${(+dist.amount).toLocaleString()} <span style="font-weight: 100; font-size: 1.1rem;">${dist.unit}</span></span>
  10131. </div>
  10132. </div>`;
  10133.  
  10134. const infowindow = new google.maps.InfoWindow({
  10135. content: contentString,
  10136. ariaLabel: "Uluru",
  10137. map: map,
  10138. position: interpolated,
  10139. });
  10140.  
  10141. setTimeout(()=>{
  10142. // Hack to hide scroll bars by painting them white.
  10143. // It's a wierd bug that doens't happen to everyone.
  10144. let el = document.getElementById('content_string');
  10145. el.parentElement.parentElement.style.scrollbarColor = "white white";
  10146. }, 100);
  10147.  
  10148. const line= new google.maps.Polyline({
  10149. path: [{lat: global_lat, lng: global_lng}, marker.position],
  10150. geodesic: true,
  10151. strokeColor: '#FF0000',
  10152. strokeOpacity: 1.0,
  10153. strokeWeight: 2,
  10154. //geodesic: false, // If true infowindow won't be in middle of line.
  10155. });
  10156.  
  10157. line.setMap(map);
  10158.  
  10159. const bounds = new google.maps.LatLngBounds();
  10160. bounds.extend({lat: global_lat, lng: global_lng});
  10161. bounds.extend( marker.position);
  10162.  
  10163. google.maps.event.addListenerOnce(map, 'idle', function() {
  10164. map.fitBounds(bounds, 100)
  10165. });
  10166.  
  10167. guessBtn.innerHTML = "Click to reload page for next round!";
  10168. guessBtn._doReload = true;
  10169.  
  10170. localStorage['unity_immediate_load'] = true;
  10171.  
  10172. google.maps.event.removeListener(clickHandler);
  10173.  
  10174. });
  10175. });
  10176.  
  10177. guessBtnContainer.appendChild(guessBtn);
  10178.  
  10179. geoGuessContainer.appendChild(guessBtnContainer);
  10180.  
  10181. document.head.insertAdjacentHTML(
  10182. "beforeend",
  10183. `<style>
  10184. .baidu_guess_map {
  10185. --active-height: 4vh;
  10186. --active-width: 4vw;
  10187. width: max(15vw, var(--active-width));
  10188. height: max(20vh, var(--active-height));
  10189. border-radius: 10px 10px 0px 0px;
  10190. position: relative;
  10191. overflow: hidden;
  10192. transition: 0.08s all ease;
  10193. }
  10194.  
  10195. .baidu_guess_map_active {
  10196. --active-height: 75vh !important;
  10197. --active-width: 60vw !important;
  10198. }
  10199.  
  10200. .baidu_guess_map_between_rounds {
  10201. --parent-right-offset: 2rem;
  10202. --active-height: 100vh !important;
  10203. --active-width: calc(100vw - var(--parent-right-offset) * 2) !important;
  10204. }
  10205.  
  10206. .baidu_guess_button_enabled:hover {
  10207. color: white;
  10208. scale: 1.0 1.1;
  10209. background-color: #1666ba !important;
  10210. }
  10211. .baidu_guess_button_enabled:active {
  10212. scale: 1.0 1.0;
  10213. }
  10214.  
  10215. .baidu_guess_button_clicked {
  10216. scale: 1.0 0.99 !important;
  10217. }
  10218.  
  10219. div[class*="game_panoramaMessage"] { visibility: hidden; z-index: 1; }
  10220.  
  10221. div[class*="game_panoramaMessage"]::after {
  10222. content: "UAC - You are awsome and you know it!";
  10223. color: white;
  10224. visibility: visible;
  10225. position: absolute;
  10226. width: 100%;
  10227. text-align: center;
  10228. translate: 0px 50vh;
  10229. }
  10230. </style>`);
  10231.  
  10232. setTimeout(function(){
  10233. let clockTimerEl = document.querySelector('[class*="clock-timer"]');
  10234. if (clockTimerEl){
  10235. clockTimerEl.parentElement.style.zIndex = '3';
  10236. }
  10237. }, 2000);
  10238. return
  10239. }
  10240.  
  10241.  
  10242.  
  10243. // ==UserScript==
  10244. // @name GeoNoCar test
  10245. // @description Redacts the car from geoguessr. Shift-K to toggle compass.
  10246. // @namespace GeoNoCar
  10247. // @version 0.1.9
  10248. // @author drparse
  10249. // @match https://www.geoguessr.com/*
  10250. // @grant unsafeWindow
  10251. // @run-at document-start
  10252. // @updateURL https://openuserjs.org/meta/drparse/GeoNoCar.meta.js
  10253. // @copyright 2020, drparse
  10254. // @license GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
  10255. // @noframes
  10256. // ==/UserScript==
  10257.  
  10258. let globalGL = null;
  10259. (function() {
  10260. 'use strict';
  10261.  
  10262. function injected() {
  10263.  
  10264. const OPTIONS = {
  10265. colorR: 0.5,
  10266. colorG: 0.5,
  10267. colorB: 0.5,
  10268. };
  10269.  
  10270. // If the script breaks, search devtools for "BINTULU" and replace these lines with the new one
  10271. const vertexOld = "const float f=3.1415926;varying vec3 a;uniform vec4 b;attribute vec3 c;attribute vec2 d;uniform mat4 e;void main(){vec4 g=vec4(c,1);gl_Position=e*g;a=vec3(d.xy*b.xy+b.zw,1);a*=length(c);}";
  10272. const fragOld = "precision highp float;const float h=3.1415926;varying vec3 a;uniform vec4 b;uniform float f;uniform sampler2D g;void main(){vec4 i=vec4(texture2DProj(g,a).rgb,f);gl_FragColor=i;}";
  10273.  
  10274. const vertexNew = `
  10275. const float f=3.1415926;
  10276. varying vec3 a;
  10277. varying vec3 potato;
  10278. uniform vec4 b;
  10279. attribute vec3 c;
  10280. attribute vec2 d;
  10281. uniform mat4 e;
  10282. void main(){
  10283. vec4 g=vec4(c,1);
  10284. gl_Position=e*g;
  10285. a = vec3(d.xy * b.xy + b.zw,1);
  10286. a *= length(c);
  10287.  
  10288. potato = vec3(d.xy, 1.0) * length(c);
  10289. }`;
  10290. const fragNew = `precision highp float;
  10291. const float h=3.1415926;
  10292. varying vec3 a;
  10293. varying vec3 potato;
  10294. uniform vec4 b;
  10295. uniform float f;
  10296. uniform sampler2D g;
  10297.  
  10298. uniform float theArray1[4];
  10299. uniform float theArray2[4];
  10300.  
  10301.  
  10302. uniform float isNoob;
  10303. uniform float theArray[8];
  10304. uniform float transition;
  10305.  
  10306. uniform sampler2D sampler2d_logoImg;
  10307. uniform float u_showCustomPano;
  10308.  
  10309. void main(){
  10310.  
  10311. vec2 aD = potato.xy / a.z;
  10312. float thetaD = aD.y;
  10313.  
  10314. float thresholdD1 = 0.6;
  10315. float thresholdD2 = 0.7;
  10316.  
  10317. float x = aD.x;
  10318. float y = abs(4.0*x - 2.0);
  10319. float phiD = smoothstep(0.0, 1.0, y > 1.0 ? 2.0 - y : y);
  10320.  
  10321. float x1 = theArray[0];
  10322. float y1 = theArray[1];
  10323. float x2 = theArray[2];
  10324. float y2 = theArray[3];
  10325.  
  10326. vec4 gold = vec4(1.0,0.8431,0.0,1.0);
  10327. vec4 blue = vec4(0.0,0.3412,0.7176,1.0);
  10328.  
  10329. float r = smoothstep(-1.0, 1.0, transition);
  10330. vec4 theColor = mix(gold, blue, r);
  10331.  
  10332. if (x2 > x1){
  10333. if (aD.x > x1 && aD.y > y1 && aD.x < x2 && aD.y < y2){
  10334. if (isNoob == 1.0){
  10335. float lineWidth = 0.0025;
  10336. if ((aD.x < x1 + lineWidth)
  10337. || (aD.y < y1 + lineWidth)
  10338. || (aD.x > x2 - lineWidth)
  10339. || (aD.y > y2 - lineWidth)){
  10340.  
  10341. gl_FragColor = theColor;
  10342. //gl_FragColor = vec4(0.0,0.3412,0.7176,1.0);
  10343. return;
  10344. }
  10345. } else {
  10346. gl_FragColor = vec4(0.0,0.3412,0.7176,1.0);
  10347. return;
  10348. }
  10349. }
  10350. } else {
  10351. // x1 is greater than x2.
  10352. if ((aD.y > y1 && aD.y < y2) && (aD.x > x1 || aD.x < x2)){
  10353. if (isNoob == 1.0){
  10354. float lineWidth = 0.0025;
  10355. if (((aD.x < x1+lineWidth) && (aD.x > x1))
  10356. || (aD.x < x2 && aD.x > x2-lineWidth)
  10357. || (x2 == 0.0 && aD.x > 1.0-lineWidth)
  10358. || (aD.y < y1 + lineWidth)
  10359. || (aD.y > y2 - lineWidth)
  10360. ){
  10361. gl_FragColor = theColor; //vec4(0.0,0.3412,0.7176,1.0);
  10362. return;
  10363. }
  10364. } else {
  10365. gl_FragColor = vec4(0.0,0.3412,0.7176,1.0);
  10366. return;
  10367. }
  10368. }
  10369. }
  10370.  
  10371. x1 = theArray[4];
  10372. y1 = theArray[5];
  10373. x2 = theArray[6];
  10374. y2 = theArray[7];
  10375.  
  10376. if (x2 > x1){
  10377. if (aD.x > x1 && aD.y > y1 && aD.x < x2 && aD.y < y2){
  10378. if (isNoob == 1.0){
  10379. float lineWidth = 0.0025;
  10380. if ((aD.x < x1 + lineWidth)
  10381. || (aD.y < y1 + lineWidth)
  10382. || (aD.x > x2 - lineWidth)
  10383. || (aD.y > y2 - lineWidth)){
  10384. gl_FragColor = theColor; //mix(gold, blue, r);
  10385. //gl_FragColor = vec4(1.0,0.8431,0.0,1.0);
  10386. return;
  10387. }
  10388. } else {
  10389. gl_FragColor = vec4(1.0,0.8431,0.0,1.0);
  10390. return;
  10391. }
  10392. }
  10393. } else {
  10394. // x1 is greater than x2.
  10395. if ((aD.y > y1 && aD.y < y2) && (aD.x > x1 || aD.x < x2)){
  10396. if (isNoob == 1.0){
  10397. float lineWidth = 0.0025;
  10398. if (((aD.x < x1+lineWidth) && (aD.x > x1))
  10399. || (aD.x < x2 && aD.x > x2-lineWidth)
  10400. || (x2 == 0.0 && aD.x > 1.0-lineWidth)
  10401. || (aD.y < y1 + lineWidth)
  10402. || (aD.y > y2 - lineWidth)
  10403. ){
  10404. gl_FragColor = theColor; //vec4(1.0,0.8431,0.0,1.0);
  10405. return;
  10406. }
  10407. } else {
  10408. gl_FragColor = vec4(1.0,0.8431,0.0,1.0);
  10409. return;
  10410. }
  10411. }
  10412. }
  10413.  
  10414. //vec4 i = vec4(
  10415. // thetaD > mix(thresholdD1, thresholdD2, phiD)
  10416. // ? vec3(float(${OPTIONS.colorR}), float(${OPTIONS.colorG}), float(${OPTIONS.colorB})) // texture2DProj(g,a).rgb * 0.25
  10417. // : texture2DProj(g,a).rgb
  10418. //,f);
  10419. //gl_FragColor=i;
  10420. vec4 t = texture2DProj(g,a).rgba;
  10421.  
  10422. if (u_showCustomPano == 1.0){
  10423. if ((aD.y > 0.99 && aD.y < 1.0) && (aD.x > 0.99 || aD.x < 1.0)){
  10424. // Draw circle at bottom to let player know script worked.
  10425. gl_FragColor = vec4(1.0,0.8431,0.0,1.0);
  10426. return;
  10427. }
  10428. vec4 logo = texture2DProj(sampler2d_logoImg, potato).rgba;
  10429. //t = mix(t, logo, 1.0);
  10430. t = logo; // mix(t, logo, 1.0);
  10431. }
  10432.  
  10433. //gl_FragColor=vec4(t.rgb,f);
  10434.  
  10435. gl_FragColor=vec4(t.rgb,f);
  10436.  
  10437. }`;
  10438.  
  10439. function installShaderSource(ctx) {
  10440. const g = ctx.shaderSource;
  10441. function shaderSource() {
  10442. if (typeof arguments[1] === 'string') {
  10443. let glsl = arguments[1];
  10444. // console.log('BINTULU shader', glsl);
  10445. if (glsl === vertexOld){
  10446. glsl = vertexNew;
  10447. globalGL = ctx;
  10448.  
  10449. console.log("ctx assigned to globalGL");
  10450.  
  10451. let oldCtx = ctx.linkProgram;
  10452. ctx.linkProgram = function(...args){
  10453. let p = oldCtx.call(this, args[0]);
  10454.  
  10455. initWebGl(args[0]);
  10456.  
  10457. return p;
  10458. }
  10459. }
  10460. else if (glsl === fragOld) glsl = fragNew;
  10461. return g.call(this, arguments[0], glsl);
  10462. }
  10463. return g.apply(this, arguments);
  10464. }
  10465. shaderSource.bestcity = 'bintulu';
  10466. ctx.shaderSource = shaderSource;
  10467. }
  10468.  
  10469. function installGetContext(el) {
  10470. const g = el.getContext;
  10471. el.getContext = function() {
  10472. if (arguments[0] === 'webgl' || arguments[0] === 'webgl2') {
  10473. const ctx = g.apply(this, arguments);
  10474. if (ctx && ctx.shaderSource && ctx.shaderSource.bestcity !== 'bintulu') {
  10475. installShaderSource(ctx);
  10476. }
  10477. return ctx;
  10478. }
  10479. return g.apply(this, arguments);
  10480. };
  10481. }
  10482.  
  10483. const f = document.createElement;
  10484.  
  10485. document.createElement = function() {
  10486. if (arguments[0] === 'canvas' || arguments[0] === 'CANVAS') {
  10487. const el = f.apply(this, arguments);
  10488. installGetContext(el);
  10489. return el;
  10490. }
  10491. return f.apply(this, arguments);
  10492. };
  10493.  
  10494. window.theArray = [];
  10495. window.unityNerdTimer = null;
  10496. window.ignoreUnityNerd = true;
  10497. window.ignoreUnityNoob = true;
  10498. window.isOkToShowCustomPano = false;
  10499.  
  10500. async function initWebGl(program){
  10501. let ell = document.querySelector('[aria-label="Street View"]');
  10502. let eventt;
  10503.  
  10504. triggerEvent(ell, "mouseup", eventt);
  10505.  
  10506. let _trans = 0;
  10507. window.unityNerdTimer = setInterval(function(){
  10508. // webgl main loop
  10509. if (window.ignoreUnityNerd && window.ignoreUnityNoob){
  10510. let uu_showCustomPano = globalGL.getUniformLocation(program, 'u_showCustomPano');
  10511. globalGL.uniform1f(uu_showCustomPano, window.isOkToShowCustomPano ? 1.0 : 0.0);
  10512. return;
  10513. }
  10514.  
  10515. let _theArray = globalGL.getUniformLocation(program, 'theArray');
  10516.  
  10517. if (!_theArray) {
  10518. clearInterval(window.unityNerdTimer)
  10519. return;
  10520. }
  10521.  
  10522. let location = globalGL.getUniformLocation(program, "sampler2d_logoImg");
  10523. globalGL.uniform1i(location, 1);
  10524.  
  10525. let isNoob = globalGL.getUniformLocation(program, 'isNoob');
  10526. let transition = globalGL.getUniformLocation(program, 'transition');
  10527. let uu_showCustomPano = globalGL.getUniformLocation(program, 'u_showCustomPano');
  10528. globalGL.uniform1fv(_theArray, new Float32Array(window.theArray.slice(0,8)));//[/*Nw*//*x*/0.40,/*y*/0.30, /*Se*//*x*/0.50, /*y*/0.40]));
  10529. globalGL.uniform1f(isNoob, window.ignoreUnityNoob ? 0.0 : 1.0);
  10530. globalGL.uniform1f(uu_showCustomPano, window.isOkToShowCustomPano ? 1.0 : 0.0);
  10531.  
  10532. _trans += 0.1;
  10533.  
  10534. globalGL.uniform1f(transition, Math.sin(_trans));
  10535.  
  10536. triggerEvent(ell, "mouseout", eventt);
  10537.  
  10538. globalGL.flush();
  10539. }, 100);
  10540.  
  10541. return;
  10542.  
  10543. }
  10544.  
  10545. function triggerRefresh(){
  10546. let el = document.querySelector('[aria-label="Street View"]');
  10547. let event;
  10548. triggerEvent(el, "mouseout", event);
  10549. }
  10550.  
  10551. function triggerEvent( elem, type, event ) {
  10552. // From stack overflow can't remember where.
  10553. event = document.createEvent("MouseEvents");
  10554. event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
  10555. 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  10556. elem.dispatchEvent( event );
  10557. }
  10558.  
  10559. function loadImg(_src, maskBool, callback){
  10560. // https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL
  10561. const gl = globalGL;
  10562.  
  10563. if (!gl){
  10564. setTimeout(function(){
  10565. loadImg(_src, maskBool, callback);
  10566. }, 500);
  10567. return;
  10568. }
  10569.  
  10570. const level = 0;
  10571. const internalFormat = gl.RGBA;
  10572. const width = 1;
  10573. const height = 1;
  10574. const border = 0;
  10575. const srcFormat = gl.RGBA;
  10576. const srcType = gl.UNSIGNED_BYTE;
  10577. const pixel = new Uint8Array([0, 0, 255, 255]); // opaque blue
  10578.  
  10579. const image = new Image();
  10580.  
  10581. image.onload = () => {
  10582. const texture = gl.createTexture();
  10583.  
  10584. gl.bindTexture(gl.TEXTURE_2D, texture);
  10585. gl.texImage2D(
  10586. gl.TEXTURE_2D,
  10587. level,
  10588. internalFormat,
  10589. srcFormat,
  10590. srcType,
  10591. image
  10592. );
  10593.  
  10594. // WebGL1 has different requirements for power of 2 images
  10595. // vs. non power of 2 images so check if the image is a
  10596. // power of 2 in both dimensions.
  10597. if (isPowerOf2(image.width) && isPowerOf2(image.height)) {
  10598. // Yes, it's a power of 2. Generate mips.
  10599. gl.generateMipmap(gl.TEXTURE_2D);
  10600. } else {
  10601. // No, it's not a power of 2. Turn off mips and set
  10602. // wrapping to clamp to edge
  10603. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  10604. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  10605. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  10606. }
  10607. // Tell WebGL we want to affect texture unit 1
  10608. //gl.activeTexture(gl.TEXTURE1);
  10609. gl.activeTexture(maskBool? gl.TEXTURE2: gl.TEXTURE1);
  10610.  
  10611. // gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
  10612.  
  10613. // Bind the texture to texture unit 1
  10614. gl.bindTexture(gl.TEXTURE_2D, texture);
  10615.  
  10616. gl.activeTexture(gl.TEXTURE0);
  10617. console.log('loadImg onload');
  10618. callback();
  10619. };
  10620. image.onerror = function(e){
  10621. console.log(e);
  10622. alert("UAC panorama didn't load, try again later? Maybe refreshing the page will fix it?");
  10623. }
  10624.  
  10625. image.src = _src;
  10626. // image.src = "https://c7.alamy.com/360/WKMJE4/full-seamless-spherical-panorama-360-degrees-angle-view-on-bank-of-wide-river-in-front-of-bridge-in-city-center-360-panorama-in-equirectangular-proje-WKMJE4.jpg";
  10627. // image.src = "https://i.imgur.com/ZONu5JU.jpeg";
  10628. //image.src = "https://streetviewpixels-pa.googleapis.com/v1/tile?cb_client=apiv3&panoid=NK_fhzsEFds-fZW3pyKjzg&output=tile&x=2&y=1&zoom=3&nbt=1&fover=2";
  10629.  
  10630. function isPowerOf2(value) {
  10631. // Might not be necessary
  10632. return (value & (value - 1)) === 0;
  10633. }
  10634. }
  10635. window.loadImg = loadImg;
  10636. }
  10637.  
  10638. eval(`(${injected.toString()})()`);
  10639.  
  10640. })();
  10641.  
  10642. function unityNerdFn(data){
  10643.  
  10644. // Reset theArray to hide rectangles.
  10645. window.theArray = [0.1, 0.4, 0.3, 0.2, 0.5, 0.8, 0.7, 0.6];
  10646. window.isOkToShowCustomPano = false;
  10647.  
  10648. const isNerd = (/\[unity nerd/i.test(data.mapName));
  10649. const isNoob = (/\[unity noob/i.test(data.mapName));
  10650. const isTimed = (/\[.*timed/i.test(data.mapName));
  10651. const isUnhackable = (/\[.*UAC/i.test(data.mapName));
  10652.  
  10653. console.log("isunhackable", isUnhackable);
  10654.  
  10655. if (isUnhackable){
  10656. let _url = hex2a(global_panoID);
  10657.  
  10658. if (/http/i.test(_url) === false) {
  10659. console.log("Didn't find url for unhackable.");
  10660. window.isOkToShowCustomPano = false;
  10661. // deactivateUnityNerd();
  10662. return;
  10663. }
  10664.  
  10665. if (unityNerdFn.UAC_URLS[_url]){
  10666. alert('Was there an error? Is this a repeat? Maybe refreshing the page will fix it?');
  10667. }
  10668.  
  10669. unityNerdFn.UAC_URLS[_url] = true;
  10670.  
  10671. // Setting this to true hides the default street view panorama.
  10672. window.isOkToShowCustomPano = true;
  10673.  
  10674. fetch(_url)
  10675. .then((r) => {
  10676. return r.blob();
  10677. })
  10678. .then(async (blob) => {
  10679. let srcUrl = "";
  10680.  
  10681. if (/\.enc$/.test(_url)){
  10682. srcUrl = await blob.text().then(text => {
  10683. return new Promise((res, rej)=>{
  10684. let script = document.createElement('script');
  10685. script.src = "https://echandler.github.io/test-geo-noob-script/misc/CryptoJS_AES.js";
  10686. script.addEventListener('load', async function(){
  10687. console.log('CryptoJS_AES.js loaded');
  10688.  
  10689. if (!unityNerdFn.UAC_PassPhrase){
  10690. //unityNerdFn.UAC_PassPhrase = prompt("Enter UAC passphrase here:");
  10691. unityNerdFn.UAC_PassPhrase = await new Promise((res, rej) =>{
  10692. let unityAlert = document.querySelector('.unity_alert');
  10693. let _unityAlert = unityAlert.innerHTML;
  10694. unityAlert.innerHTML = "";
  10695. let container = document.createElement('div');
  10696. let textBox = document.createElement('input');
  10697. textBox.placeholder = "Type AES passphrase here!";
  10698. textBox.addEventListener('keydown', (e)=>{
  10699. // Prevent space bar from deleting unity buttons.
  10700. e.stopImmediatePropagation();
  10701. e.stopPropagation();
  10702. });
  10703. textBox.addEventListener('keyup', (e)=>{
  10704. // Prevent f from making full screen.
  10705. e.stopImmediatePropagation();
  10706. e.stopPropagation();
  10707. });
  10708. let btn = document.createElement('button');
  10709. btn.style.cssText = `padding: 5px; background: white; margin-left: 1em; border-radius: 5px; cursor: pointer;`;
  10710. btn.innerText = "Update";
  10711. btn.addEventListener('click', function(e){
  10712. //unityNerdFn.UAC_PassPhrase = textBox.value;
  10713. unityAlert.style.visibility = 'hidden';
  10714. unityAlert.innerHTML = _unityAlert;
  10715. res(textBox.value);
  10716. });
  10717. container.appendChild(textBox);
  10718. container.appendChild(btn);
  10719. unityAlert.appendChild(container);
  10720.  
  10721. unityAlert.style.visibility = 'visible';
  10722. })
  10723.  
  10724. if (!unityNerdFn.UAC_PassPhrase) {
  10725. alert("Passphrase is blank, refresh screen and try again.");
  10726. }
  10727. }
  10728.  
  10729. let decrypted = null;
  10730.  
  10731. try {
  10732. decrypted = CryptoJS.AES.decrypt(text, unityNerdFn.UAC_PassPhrase).toString(CryptoJS.enc.Utf8);
  10733. } catch(error){
  10734. alert("There was a problem decrypting the image. Refresh page and try again.\r\n If the problem continues, inform the person that created the challenge.");
  10735. console.error(error);
  10736. return;
  10737. }
  10738.  
  10739. res(decrypted);
  10740. });
  10741. document.body.appendChild(script) ;
  10742. });
  10743. }).then((text)=> text);
  10744. } else {
  10745. srcUrl = URL.createObjectURL(blob);
  10746. }
  10747. let failedToLoadRoundMsg = checkFailedToLoadRoundMsg();
  10748. if (failedToLoadRoundMsg){
  10749. // The streetview was created but for some reason it's blank.
  10750. // Manually set a random position to start the webgl procesfor some reason it's blanks.
  10751. const fenway = { lat: 42.345573, lng: -71.098326 };
  10752.  
  10753. GooglePlayer.setPosition(fenway) ;
  10754.  
  10755. failedToLoadRoundMsg.style.display = 'none';
  10756. makeGuessMapHack({
  10757. guessBtnText:"UAC Guess Button",
  10758. mapContainer: document.querySelector('canvas'),
  10759. locationUrl: '',
  10760. });
  10761. }
  10762. const noGlReloadTimer = setTimeout(()=>{
  10763. if (globalGL) return;
  10764. location.reload();
  10765. }, 2000);
  10766.  
  10767. window.loadImg(srcUrl, false, () => {
  10768. setTimeout(()=>{
  10769. clearTimeout(noGlReloadTimer);
  10770.  
  10771. GoogleMapsObj.setCenter({lat:0,lng:0})
  10772. GoogleMapsObj.setZoom(2)
  10773.  
  10774. console.log("Resized map in loadImg callback.")
  10775. }, 1000);
  10776. });
  10777. });
  10778.  
  10779. activateUnityNerd();
  10780. }
  10781.  
  10782. if (!isNerd && !isNoob) return;
  10783.  
  10784. if (isTimed){
  10785. let p = setInterval(function () {
  10786. const el = document.elementFromPoint(2, 2);
  10787. const ariaLabel = el.parentElement.getAttribute("aria-label");
  10788.  
  10789. if (!ariaLabel || ariaLabel !== "Street View") {
  10790. return;
  10791. }
  10792.  
  10793. clearInterval(p);
  10794.  
  10795. const timedWait = +data.mapName.replace(/.*\[.*timed.*?(\d+.?\d*)s.*/i, "$1");
  10796.  
  10797. if (!timedWait){
  10798. doUnityNerd(data, 0);
  10799. } else {
  10800. console.log('timed wait', timedWait);
  10801. doUnityNerd(data, timedWait);
  10802. }
  10803.  
  10804. }, 10);
  10805. return;
  10806. }
  10807.  
  10808. doUnityNerd(data, 0);
  10809. }
  10810. unityNerdFn.UAC_URLS = [];
  10811. unityNerdFn.UAC_PassPhrase = null;
  10812.  
  10813. let unityNerdTimer = null;
  10814.  
  10815. function doUnityNerd(data, waitTimeSeconds){
  10816.  
  10817. let curRound = data.rounds[data.rounds.length -1];
  10818.  
  10819. console.log('timed wait', waitTimeSeconds);
  10820. console.time('timer');
  10821.  
  10822. clearTimeout(unityNerdTimer);
  10823.  
  10824. unityNerdTimer = setTimeout(() => {
  10825. //console.log.bind(console, "1 second"), 1000);
  10826. let t = [];
  10827. let lat = curRound.lat.toFixed(14);
  10828. let lng = curRound.lng.toFixed(14);
  10829.  
  10830. t[3] = +(lat[lat.length - 1 - 1] + lat[lat.length - 1 - 0]) / 100;
  10831. t[2] = +(lat[lat.length - 1 - 3] + lat[lat.length - 1 - 2]) / 100;
  10832. t[1] = +(lat[lat.length - 1 - 5] + lat[lat.length - 1 - 4]) / 100;
  10833. t[0] = +(lat[lat.length - 1 - 7] + lat[lat.length - 1 - 6]) / 100;
  10834.  
  10835. t[7] = +(lng[lng.length - 1 - 1] + lng[lng.length - 1 - 0]) / 100;
  10836. t[6] = +(lng[lng.length - 1 - 3] + lng[lng.length - 1 - 2]) / 100;
  10837. t[5] = +(lng[lng.length - 1 - 5] + lng[lng.length - 1 - 4]) / 100;
  10838. t[4] = +(lng[lng.length - 1 - 7] + lng[lng.length - 1 - 6]) / 100;
  10839.  
  10840.  
  10841. window.theArray = t.map(el => el === 0? 1.0: el);
  10842.  
  10843. console.log(t, window.theArray);
  10844. console.timeEnd('timer');
  10845. }, waitTimeSeconds * 1000);
  10846. }
  10847.  
  10848. function activateUnityNerd(){
  10849. window.ignoreUnityNerd = false;
  10850. }
  10851.  
  10852. function deactivateUnityNerd(){
  10853. window.theArray = [];
  10854. // setTimeout(()=>{
  10855. window.ignoreUnityNerd = true;
  10856. // }, 500);
  10857. }
  10858.  
  10859. function activateUnityNoob(){
  10860. window.ignoreUnityNoob = false;
  10861. }
  10862.  
  10863. function deactivateUnityNoob(){
  10864. window.theArray = [];
  10865. setTimeout(()=>{
  10866. window.ignoreUnityNoob = true;
  10867. }, 500);
  10868. }
  10869.  
  10870. function download(filename, text) {
  10871. // https://stackoverflow.com/questions/3665115/how-to-create-a-file-in-memory-for-user-to-download-but-not-through-server
  10872. var element = document.createElement('a');
  10873. element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  10874. element.setAttribute('download', filename);
  10875. element.style.display = 'none';
  10876. document.body.appendChild(element);
  10877. element.click();
  10878. document.body.removeChild(element);
  10879. }
  10880.  
  10881. function getOverlayView(map){
  10882. var ov = new google.maps.OverlayView();
  10883. ov.onAdd = function(){};
  10884. ov.draw = function(){};
  10885. ov.onRemove = function(){};
  10886. ov.setMap(map);
  10887. return ov;
  10888. }
  10889.  
  10890. function showUACAnswerBtn(json = null){
  10891. let unity_alert = document.querySelector('.unity_alert');
  10892. let msg = document.createElement('div');
  10893. msg.style.cssText = `color: white;`;
  10894. msg.innerText = "Click here for UAC answers.";
  10895. msg.onclick = function(e){
  10896. if (!json) {
  10897. unhackableAnsswersShowPrompt();
  10898. } else {
  10899. unhackableAnswers(json);
  10900. }
  10901. unity_alert.innerHTML = "";
  10902. unity_alert.style.visibility = "hidden";
  10903. };
  10904.  
  10905. unity_alert.innerHTML = "";
  10906. unity_alert.appendChild(msg);
  10907. unity_alert.style.visibility = 'visible'
  10908. setTimeout(()=>{
  10909. unity_alert.style.visibility = 'hidden';
  10910. unity_alert.innerHTML = "";
  10911. }, 5000);
  10912. }
  10913.  
  10914. function unhackableAnsswersShowPrompt() {
  10915.  
  10916. let _prompt = prompt("Paste UAC answer info. here:")
  10917.  
  10918. if (!_prompt) return;
  10919.  
  10920. unhackableAnswers(_prompt);
  10921. }
  10922. async function unhackableAnswers(json = null){
  10923. let data = null;
  10924.  
  10925. const PATHNAME = window.location.pathname;
  10926. const token = getToken();
  10927. const bounds = new google.maps.LatLngBounds();
  10928.  
  10929. if (!global_data?.rounds || global_data.token !== token){
  10930. let URL = null;
  10931.  
  10932. if (PATHNAME.startsWith("/game/")) {
  10933. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  10934. }
  10935. else if (PATHNAME.startsWith("/results/" )) {
  10936. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  10937. // URL = `https://www.geoguessr.com/api/v3/results/highscores/${token}"`;
  10938. // URL = `https://www.geoguessr.com/api/v3/results/highscores/${token}?friends=false&limit=26&minRounds=5`;
  10939. }
  10940.  
  10941. global_data = await fetch(URL).then((response) => response.json());
  10942.  
  10943. if (!global_data){
  10944. alert('An unkown error happened.');
  10945. return;
  10946. }
  10947. }
  10948.  
  10949. try {
  10950. data = JSON.parse(json);
  10951. } catch (e){
  10952. alert(e.message);
  10953. console.log("From prompt", e.message);
  10954. return
  10955. }
  10956.  
  10957. // Lower opacity for correct location overlays for effect.
  10958. document.querySelectorAll("[data-qa=\"correct-location-marker\"]").forEach(el=> el.style.opacity = 0.2);
  10959.  
  10960. let thisRoundData = {};
  10961.  
  10962. for (let n = 0; n < global_data.rounds.length; n++){
  10963. let panoId = global_data.rounds[n].panoId;
  10964.  
  10965. if (!panoId) continue;
  10966.  
  10967. let url = hex2a(panoId);
  10968.  
  10969. if (!data[url]) continue;
  10970.  
  10971. let latLng = data[url].latLng.split(',');
  10972. latLng = {lat: +latLng[0], lng: +latLng[1]};
  10973.  
  10974. thisRoundData[url] = data[url];
  10975.  
  10976. global_data.rounds[n]._unhackable_answer = latLng;
  10977.  
  10978. bounds.extend(latLng);
  10979.  
  10980. const svgMarker = {
  10981. // Path is just a filler for a 0 opacity marker.
  10982. path: "M18.8-31.8c.3-3.4 1.3-6.6 3.2-9.5l-7-6.7c-2.2 1.8-4.8 2.8-7.6 3-2.6.2-5.1-.2-7.5-1.4-2.4 1.1-4.9 1.6-7.5 1.4-2.7-.2-5.1-1.1-7.3-2.7l-7.1 6.7c1.7 2.9 2.7 6 2.9 9.2.1 1.5-.3 3.5-1.3 6.1-.5 1.5-.9 2.7-1.2 3.8-.2 1-.4 1.9-.5 2.5 0 2.8.8 5.3 2.5 7.5 1.3 1.6 3.5 3.4 6.5 5.4 3.3 1.6 5.8 2.6 7.6 3.1.5.2 1 .4 1.5.7l1.5.6c1.2.7 2 1.4 2.4 2.1.5-.8 1.3-1.5 2.4-2.1.7-.3 1.3-.5 1.9-.8.5-.2.9-.4 1.1-.5.4-.1.9-.3 1.5-.6.6-.2 1.3-.5 2.2-.8 1.7-.6 3-1.1 3.8-1.6 2.9-2 5.1-3.8 6.4-5.3 1.7-2.2 2.6-4.8 2.5-7.6-.1-1.3-.7-3.3-1.7-6.1-.9-2.8-1.3-4.9-1.2-6.4z",
  10983. fillColor: "rgb(0, 102, 204)",
  10984. scale: 0.75,
  10985. fillOpacity: 1,
  10986. strokeColor: "rgb(0, 102, 204)",
  10987. strokeOpacity: 1,
  10988. anchor: new google.maps.Point(0, -20),
  10989. labelOrigin: new google.maps.Point(0, -25)
  10990. };
  10991.  
  10992. let marker = new google.maps.Marker({
  10993. position: latLng,
  10994. map: GoogleMapsObj,
  10995. icon: svgMarker,
  10996. label:{
  10997. text: `${n+1}`,
  10998. color: "#ffffff",
  10999. fontSize: "20px",
  11000. fontWeight: "bold"
  11001. }
  11002. });
  11003.  
  11004. marker.addListener('click', function(){
  11005. //window.open(`http://maps.google.com/maps?q=&layer=c&cbll=${latLng.lat},${latLng.lng}`, "_blank")
  11006. window.open(data[url].locationUrl, "_blank")
  11007. });
  11008.  
  11009. unhackableAnswers.markers.push(marker);
  11010. }
  11011.  
  11012. if (Object.keys(thisRoundData).length === 0){
  11013. alert("No answers found for this game.");
  11014. return;
  11015. }
  11016. let resultRows = document.querySelectorAll('div[class*="results_row"]');
  11017. resultRows.forEach(row =>{
  11018. if (/selected/i.test(row.getAttribute('class'))){
  11019. row.click();
  11020. }
  11021. })
  11022.  
  11023. GoogleMapsObj.fitBounds(bounds)
  11024.  
  11025. hideDottedConnectingLinesOnMap();
  11026.  
  11027. if (!google.maps.OverlayView.prototype._setMap){
  11028. // Listen for new overlays being made and use the latlng coordinates from them to
  11029. // draw the connecting polylines.
  11030. google.maps.OverlayView.prototype._setMap = google.maps.OverlayView.prototype.setMap;
  11031. google.maps.OverlayView.prototype.setMap = function(...args){
  11032. setTimeout(()=>{
  11033. if (this.to && this.from) {
  11034. queOverlaysForUnhackable(this);
  11035. return;
  11036. }
  11037. if (!this.position) return;
  11038.  
  11039. this.div.firstElementChild.addEventListener('mouseover', (e)=>{
  11040. const dMarker = newDistanceMarker(this);
  11041. setTimeout(()=> {
  11042. dMarker.setMap(null);
  11043. dMarker._msgDiv.remove();
  11044. }, 2500);
  11045. })
  11046. }, 100);
  11047.  
  11048. google.maps.OverlayView.prototype._setMap.apply(this, args);
  11049. };
  11050. }
  11051.  
  11052. if (Object.keys(data).length <= 5) return;
  11053.  
  11054. let _confirm = confirm("Do you want to download the answers for this game only, filtering out all other answers?");
  11055.  
  11056. if (!_confirm) return;
  11057.  
  11058. try {
  11059. thisRoundData = JSON.stringify(thisRoundData);
  11060. } catch(e){
  11061. alert("Couldn't convert this game's answers for some reason.");
  11062. console.log(e.message);
  11063. }
  11064.  
  11065. download("answers.json", thisRoundData);
  11066. }
  11067. unhackableAnswers.markers = [];
  11068.  
  11069. function queOverlaysForUnhackable(overlay, dataIsReady){
  11070. if (dataIsReady){
  11071. queOverlaysForUnhackable._overlaysWaiting.forEach((overlay) =>{
  11072. makePolylinesForUnhackable(overlay);
  11073. });
  11074. queOverlaysForUnhackable._overlaysWaiting = [];
  11075. return;
  11076. }
  11077.  
  11078. let hasAnswers = global_data?.rounds?.some((round) => round?._unhackable_answer);
  11079. if (!hasAnswers){
  11080. queOverlaysForUnhackable._overlaysWaiting.push(overlay);
  11081. return;
  11082. }
  11083. makePolylinesForUnhackable(overlay);
  11084. }
  11085.  
  11086. queOverlaysForUnhackable._overlaysWaiting = [];
  11087.  
  11088. function makePolylinesForUnhackable(toFromOverlay){
  11089. const _rounds = global_data.rounds;
  11090. const div = toFromOverlay.div;
  11091. const jsonFrom = toFromOverlay.from.toJSON();
  11092. const jsonTo = toFromOverlay.to.toJSON(); // Guess location.
  11093.  
  11094. let round = _rounds.filter( round =>{
  11095. if (jsonFrom.lat === round.lat && jsonFrom.lng === round.lng){
  11096. return true;
  11097. }
  11098. });
  11099. round = round.length > 0? round[0] : null;
  11100. if (round === null) return;
  11101.  
  11102. if (!round._unhackable_answer) return;
  11103. round._uacGuesses = round._uacGuesses? round._uacGuesses: [];
  11104. round._uacGuesses.push(jsonTo);
  11105.  
  11106. const answer = round._unhackable_answer;
  11107. const pos = jsonTo;
  11108.  
  11109. const line = new google.maps.Polyline({
  11110. path: [pos, answer],
  11111. geodesic: true,
  11112. strokeColor: "rgb(0, 102, 204)",
  11113. //strokeColor: '#FF0000',
  11114. strokeOpacity: 1.0,
  11115. strokeWeight: 2,
  11116. //geodesic: false, // If true infowindow won't be in middle of line.
  11117. });
  11118. line.setMap(GoogleMapsObj);
  11119.  
  11120. toFromOverlay.__to = toFromOverlay.to;
  11121.  
  11122. Object.defineProperty(toFromOverlay, "to", {
  11123. // Geoguessr re-uses old overlays instead of making a whole new overlay in some situations.
  11124. set : function (value) {
  11125. // Listen for changes to the "to" property and remove line if set with new value.
  11126. toFromOverlay.__to = value;
  11127. line.setMap(null);
  11128. if (toFromOverlay.div.children.length > 0){
  11129. makePolylinesForUnhackable(toFromOverlay);
  11130. }
  11131. },
  11132. get : function () { return toFromOverlay.__to }
  11133. });
  11134.  
  11135. const observer = new MutationObserver(
  11136. function (){
  11137. // Remove polyline if div is gutted.
  11138. if (toFromOverlay.div.children.length > 0) return;
  11139.  
  11140. line.setMap(null);
  11141. setTimeout(function(){
  11142. if (!location.pathname.startsWith("/results/")){
  11143. // Remove markers if not on results page.
  11144. observer.disconnect();
  11145. unhackableAnswers.markers.forEach((marker) => marker.setMap(null));
  11146. unhackableAnswers.markers = [];
  11147. }
  11148. }, 5000);
  11149. }
  11150. );
  11151. observer.observe(toFromOverlay.div, {childList: true, subtree: true });
  11152. }
  11153.  
  11154. function makeStreetViewCanvasHidden(){
  11155. document.head.insertAdjacentHTML("beforeend", `<style>${GENERAL_CANVAS} {visibility: hidden;}</style>`)
  11156. }
  11157. function hideDottedConnectingLinesOnMap(){
  11158. document.head.insertAdjacentHTML("beforeend", `<style> div[class*="map_line"] {visibility: hidden;}</style>`)
  11159. }
  11160.  
  11161. function newDistanceMarker(overlay){
  11162. const svgMarker = {
  11163. // Path is just a filler for a 0 opacity marker.
  11164. path: "M-1.547 12l6.563-6.609-1.406-1.406-5.156 5.203-2.063-2.109-1.406 1.406z",
  11165. fillOpacity: 0,
  11166. };
  11167.  
  11168. const pos = overlay.position.toJSON();
  11169. const _rounds = global_data.rounds;
  11170. let answer = _rounds.filter((round)=>{
  11171. if (!round._uacGuesses) return false;
  11172. return round._uacGuesses.some((guess) => guess.lat == pos.lat && guess.lng == pos.lng);
  11173. });
  11174. answer = answer[0]._unhackable_answer;
  11175.  
  11176. const interpolated = google.maps.geometry.spherical.interpolate(answer, pos, 0.5);
  11177. let distanceBetween = google.maps.geometry.spherical.computeDistanceBetween(pos, answer);
  11178.  
  11179. const units = distanceBetween > 1000 ? "km" : "m";
  11180.  
  11181. distanceBetween = distanceBetween >= 1000
  11182. ? (distanceBetween / 1000).toFixed(2)
  11183. : distanceBetween >= 100
  11184. ? distanceBetween.toFixed(2)
  11185. : distanceBetween.toFixed(3);
  11186.  
  11187.  
  11188. distanceBetween = (+distanceBetween).toLocaleString();// Add commas for large numbers.
  11189.  
  11190. document.head.insertAdjacentHTML("beforeend", `<style>.unhackableLabel {background: rgb(0, 102, 204); padding: 10px; border-radius: 5px;}</style>`)
  11191.  
  11192. const distanceMarker = new google.maps.Marker({
  11193. position: interpolated,
  11194. icon: svgMarker,
  11195. map: GoogleMapsObj,
  11196. label: {
  11197. text: `${distanceBetween} ${units}`,
  11198. color: "#ffffff",
  11199. fontSize: "15px",
  11200. fontWeight: "bold",
  11201. className: "unhackableLabel",
  11202. },
  11203. clickable: true,
  11204. });
  11205.  
  11206. distanceMarker._msgDiv = document.createElement('div');
  11207. distanceMarker._msgDiv.innerHTML = `${distanceBetween} ${units}`;
  11208. distanceMarker._msgDiv.style.cssText = "position: absolute; bottom: 5px; left: 5px; color: rgba(100,100,100,0.1); font-size: 13px;";
  11209. document.body.appendChild(distanceMarker._msgDiv);
  11210.  
  11211. return distanceMarker;
  11212. };
  11213. UnityInitiate.callbacks.push(function(){
  11214. if (sessionStorage['unity_streak']){
  11215. initCountryStreakCounter();
  11216. }
  11217. });
  11218.  
  11219.  
  11220. async function initCountryStreakCounter(){
  11221. // TODO EC: Refactor this to a Object or class, this is just a test to see if it works.
  11222.  
  11223. let PATHNAME = getPathName();
  11224. if (PATHNAME.startsWith(`/play-along/`)){
  11225. // Only map is showing in play-along mode.
  11226. // Get reference to websocket for sending messages.
  11227. window._unity_fetch_ = (function () {
  11228. let _fetch = window._unity_fetch_;
  11229. return async function (...args) {
  11230. if (!PATHNAME.startsWith(`/play-along/`)) {
  11231. return _fetch.apply(window, args);
  11232. }
  11233.  
  11234. if (/geoguessr.com.api.v4.*result/i.test(args[0])) {
  11235.  
  11236. let v3APIRes = await _fetch.apply(window, args);
  11237.  
  11238. let resJSON = await v3APIRes.clone().json();
  11239.  
  11240. const round = resJSON?.rounds? resJSON.rounds[resJSON.rounds.length-1]: resJSON?.round;
  11241.  
  11242. if (round) {
  11243. global_lat = round.location.lat;
  11244. global_lng = round.location.lng;
  11245. }
  11246.  
  11247. versionEl.guessBtnClickListener();
  11248.  
  11249. return new Promise((res) => {
  11250. res(v3APIRes);
  11251. });
  11252. } else if (/geoguessr.com.api.v4/i.test(args[0]) && args[1]?.method === "POST") {
  11253. let json = JSON.parse(args[1].body);
  11254.  
  11255. if (json?.lat && json?.lng) {
  11256. setScoreBoardLastLagLng(json);
  11257. }
  11258. }
  11259.  
  11260. return _fetch.apply(window, args);
  11261. };
  11262. })();
  11263. // for (let element of document.getElementsByClassName("preset-minimap")){
  11264. // element.addEventListener('click', function(e){
  11265. // sendWSMsg({presetId: element.id});
  11266. // });
  11267. // }
  11268. }
  11269.  
  11270. const versionEl = document.getElementById("unity_version");
  11271. if (versionEl._outerHTML){
  11272. versionEl.outerHTML = versionEl._outerHTML;
  11273. versionEl._outerHTML = null;
  11274. delete sessionStorage['unity_streak'];
  11275. google.maps.event.removeListener(versionEl.mapsClickListener);
  11276. guessButtonCallback.removeCallback(versionEl.guessBtnClickListener);
  11277. clearInterval( versionEl._interval );
  11278. clearInterval( versionEl.noClickOnMapInterval );
  11279. return;
  11280. }
  11281.  
  11282. const scoreBoard = document.createElement('font');
  11283. scoreBoard.title = "Use mouse wheel to change score!";
  11284.  
  11285. versionEl._outerHTML = versionEl.outerHTML;
  11286. versionEl.innerHTML = '';
  11287. versionEl.appendChild(scoreBoard);
  11288.  
  11289. scoreBoard.style.color = "rgb(0, 102, 204)";
  11290. scoreBoard.style.fontWeight = "bold";
  11291. scoreBoard.setAttribute('size', '2');
  11292.  
  11293. if (!scoreBoard.score){
  11294. scoreBoard.score = 0;
  11295. }
  11296.  
  11297. if (sessionStorage['unity_streak']){
  11298. scoreBoard.score = +sessionStorage['unity_streak'];
  11299. } else {
  11300. sessionStorage['unity_streak'] = scoreBoard.score;
  11301. }
  11302.  
  11303. scoreBoard.innerHTML = scoreBoard.score;
  11304.  
  11305. // Create simple reverse geocoding object.
  11306. eval(await fetch('https://echandler.github.io/Simple-Reverse-Geocoding-Script/reverseGeocodingScript.user.js').then(x => x.text()).catch(x => console.log(x)));
  11307. scoreBoard.lastLatLng = null;
  11308. let mapsObj = null;
  11309. versionEl._interval = setInterval(()=>{
  11310. // Let this run until counter is turned off by player.
  11311. if (!GoogleMapsObj || mapsObj === GoogleMapsObj) return;
  11312. mapsObj = GoogleMapsObj;
  11313. google.maps.event.removeListener(versionEl.mapsClickListener);
  11314. versionEl.mapsClickListener = GoogleMapsObj.addListener("click", mapsClicker);
  11315. }, 1000);
  11316. async function mapsClicker(e) {
  11317. if (versionEl._outerHTML == null) return;
  11318.  
  11319. const latLng = e.latLng.toJSON();
  11320.  
  11321. let PATHNAME = getPathName();
  11322. if (!PATHNAME.startsWith(`/play-along/`)){
  11323. setScoreBoardLastLagLng(latLng);
  11324. debugger;
  11325. tempLastLatLng = latLng;// delete soon used to test 5k country streak scores
  11326. }
  11327.  
  11328. const l = await sgs.reverse(latLng).then(e => e);
  11329. console.log(l.country);
  11330. showFlag(l.country.country_code);
  11331. };
  11332. async function setScoreBoardLastLagLng(latLng){
  11333. const l = await sgs.reverse(latLng).then(e => e);
  11334.  
  11335. scoreBoard.lastLatLng = l;
  11336. console.log(l.country);
  11337. showFlag(l.country.country_code);
  11338.  
  11339. }
  11340. versionEl.guessBtnClickListener = async function(){
  11341. const curRoundLatLng = {lat: global_lat, lng: global_lng};
  11342. const cur = await sgs.reverse(curRoundLatLng).then(e => e);
  11343. let unityAlert = document.querySelector('.unity_alert');
  11344. let _unityAlert = unityAlert.innerHTML;
  11345. let svgFlag = sgs.countryFlags[cur.country.admin_country_code.toUpperCase()];
  11346. svgFlag = svgFlag.replace("<svg", `<svg style="position: relative; top: 1px; border-radius: 3px;"`);
  11347.  
  11348. if (scoreBoard.lastLatLng && (cur.country.admin_country_code == scoreBoard.lastLatLng.country.admin_country_code)){
  11349. unityAlert.innerHTML = `Yay! It was <span style="font-weight:bold">${cur.country.country_name}</span> ${svgFlag} ! Score is now <span style="font-weight:bold">${scoreBoard.score} + 1</span>!`;
  11350. scoreBoard.score += 1;
  11351. tempChangeScore = true;
  11352. } else {
  11353. unityAlert.innerHTML = `<span>Nooooooo! It was <span style="font-weight:bold">${cur.country.country_name}</span> ${svgFlag} ! Final score was <span style="font-weight:bold">${scoreBoard.score}</span>!</span>`;
  11354. scoreBoard.score = 0;
  11355. }
  11356.  
  11357. scoreBoard.innerHTML = scoreBoard.score;
  11358.  
  11359. sessionStorage['unity_streak'] = scoreBoard.score;
  11360.  
  11361. unityAlert.style.minWidth = '22.75em';
  11362. unityAlert.style.width = 'fit-content';
  11363. unityAlert.style.padding = '0px 10px';
  11364. unityAlert.style.visibility = 'visible';
  11365. unityAlert._streakShowing = true;
  11366.  
  11367. let guessBtn = document.querySelector("[data-qa='perform-guess']");
  11368. if (!scoreBoard.waitIntervals){
  11369. scoreBoard.waitIntervals = [];
  11370. }
  11371.  
  11372. scoreBoard.waitIntervals.push(setInterval(() => {
  11373. const resultLayout = document.querySelector('div[class*="result-layout"]');
  11374. if (document.body.contains(guessBtn) || resultLayout) return;
  11375. guessBtn = null;// Now waiting for resultLayout to be removed.
  11376. scoreBoard.waitIntervals.forEach( x => clearInterval(x));
  11377. setTimeout(()=>{
  11378. unityAlert.style.visibility = 'hidden';
  11379. unityAlert._streakShowing = false;
  11380. tempLastLatLng = null;// delete soon used to test 5k country streak scores
  11381. }, 2000);
  11382. tempChangeScore = false;
  11383. }, 500));
  11384. scoreBoard.lastLatLng = null;
  11385.  
  11386. } // End guessbuttonListener.
  11387. guessButtonCallback.callbacks.push(versionEl.guessBtnClickListener);
  11388.  
  11389. let showFlagTimer = null;
  11390. function showFlag(code){
  11391. clearTimeout(showFlagTimer);
  11392. const svgFlag = sgs.countryFlags[code.toUpperCase()];
  11393.  
  11394. scoreBoard.innerHTML = svgFlag.replace("<svg", `<svg style="position: relative; top: 2px; height: 1em; overflow: visible; border-radius: 3px;"`);
  11395. showFlagTimer = setTimeout(()=>{
  11396. scoreBoard.innerHTML = scoreBoard.score;
  11397. scoreBoard._flagInnerHTML = null;
  11398. }, 900);
  11399. }
  11400. let d = Date.now();
  11401. scoreBoard.addEventListener('wheel', (e)=>{
  11402. if (Date.now() - d < 50) return;
  11403. d = Date.now();
  11404.  
  11405. e.preventDefault();
  11406. e.stopPropagation();
  11407. e.stopImmediatePropagation();
  11408.  
  11409. if (e.wheelDelta > 0){
  11410. scoreBoard.score += 1;
  11411. } else {
  11412. scoreBoard.score -= 1;
  11413. }
  11414. sessionStorage['unity_streak'] = scoreBoard.score;
  11415. scoreBoard.innerHTML = scoreBoard.score;
  11416. console.log(e.wheelDelta, e.deltaY);
  11417. });
  11418.  
  11419. versionEl.noClickOnMapInterval = setInterval(() => {
  11420. // Incase Player doesn't click on map.
  11421. const resultLayout = document.querySelector('div[class*="result-layout"]');
  11422. if (!resultLayout) return;
  11423. const unityAlert = document.querySelector('.unity_alert');
  11424. //if (unityAlert.style.visibility !== 'hidden') return;
  11425. if (unityAlert._streakShowing) return;
  11426. // Alert should have been shown by now, if not then player didn't click on guess button.
  11427. versionEl.guessBtnClickListener();
  11428. }, 1000);
  11429. }
  11430.  
  11431.  
  11432.  
  11433. /// -------------------------------------- RANDOM MAP CHALLENGE ---------------------------------------------------------------------
  11434.  
  11435. async function randomMapChallenge_map_init(mapInfo){
  11436. let info = await fetch(`https://www.geoguessr.com/api/maps/${mapInfo.map}`).then(res => res.json());
  11437. let gameJSONUrl = info.description.match(/{\[(.*)]}/);
  11438.  
  11439. if (!gameJSONUrl.length != 2 && gameJSONUrl[1][0] != "h") {
  11440. alert("Can't find Random Map Challenge Information is description.");
  11441. return;
  11442. }
  11443. let _json = await fetch(gameJSONUrl[1]).then(res=> res.json());
  11444.  
  11445. loadRandomMapChallenge(()=>{
  11446. window.playFinishedGame(_json);
  11447. });
  11448. }
  11449. function checkForRanomMapChallenge(){
  11450. if (localStorage["RandomMapChallenge"]){
  11451. loadRandomMapChallenge(()=>{
  11452. setTimeout(()=>{
  11453. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11454. if (!rmcMenuBtn) return;
  11455. rmcMenuBtn.doShow = true;
  11456. }, 500);
  11457. });
  11458. }
  11459. if (localStorage["RandomMapChallenge_onHomePage"]){
  11460. setTimeout(()=>{
  11461. showRandomMapChallengeBtnOnHomePage(true);
  11462. }, 1000);
  11463. }
  11464. }
  11465. let showRandomMapChallengeBtnOnHomePageTimer = null;
  11466. function showRandomMapChallengeBtnOnHomePage(trueFalse){
  11467. if (trueFalse === false){
  11468. clearInterval(showRandomMapChallengeBtnOnHomePageTimer);
  11469. return;
  11470. }
  11471. showRandomMapChallengeBtnOnHomePageTimer = setInterval(()=>{
  11472. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11473. if (!/^\/\w?\w?$/.test(getPathName())) {
  11474. if (rmcMenuBtn?.doShow) return;
  11475.  
  11476. if (rmcMenuBtn){
  11477. rmcMenuBtn.style.display = "none";
  11478. }
  11479. return;
  11480. }
  11481.  
  11482. if (rmcMenuBtn){
  11483. rmcMenuBtn.style.display = "";
  11484. return;
  11485. }
  11486. loadRandomMapChallenge(()=>{
  11487. setTimeout(()=>{
  11488. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11489. if (!rmcMenuBtn) return;
  11490. rmcMenuBtn.style.display = "";
  11491. }, 1000);
  11492. });
  11493. }, 1000);
  11494. }
  11495.  
  11496. function initRandomMapChallenge(){
  11497. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11498. if (rmcMenuBtn?.style?.display === "none"){
  11499. rmcMenuBtn.style.display = '';
  11500. rmcMenuBtn.doShow = true;
  11501. rmcMenuBtn.click();
  11502. return;
  11503. }
  11504.  
  11505. if (rmcMenuBtn){
  11506. if (localStorage["RandomMapChallenge"] && !confirm("This will end your Random Map Challenge?")){
  11507. return;
  11508. }
  11509. delete localStorage["RandomMapChallenge"];
  11510. location.reload();
  11511. return;
  11512. }
  11513. loadRandomMapChallenge(()=>{
  11514. setTimeout(()=>{
  11515. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11516. if (!rmcMenuBtn) return;
  11517. rmcMenuBtn.style.display = '';
  11518. rmcMenuBtn.doShow = true;
  11519. rmcMenuBtn.click();
  11520. }, 500);
  11521. });
  11522. }
  11523. function loadRandomMapChallenge(fn){
  11524. const s = document.createElement( 'script' );
  11525. s.addEventListener('load', fn);
  11526. s.setAttribute( 'src', `https://echandler.github.io/test-geo-noob-script/misc/test1.js` );
  11527. document.body.appendChild( s );
  11528. checkForRMCButtonOnWrongPage();
  11529. }
  11530.  
  11531. function checkForRMCButtonOnWrongPage(){
  11532. if (checkForRMCButtonOnWrongPage.isChecking) return;
  11533.  
  11534. checkForRMCButtonOnWrongPage.isChecking = true;
  11535. setInterval(()=>{
  11536. const pathname = getPathName();
  11537. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11538. const onHomePage = /^\/\w?\w?$/.test(pathname);
  11539. const onGameMapsPage = /game\/|maps\//.test(pathname);
  11540.  
  11541. if (rmcMenuBtn && !onHomePage && !onGameMapsPage) {
  11542. rmcMenuBtn.style.display = 'none';
  11543. } else if (rmcMenuBtn?.doShow){
  11544. rmcMenuBtn.style.display = '';
  11545. }
  11546. }, 1000)
  11547. }
  11548. checkForRMCButtonOnWrongPage.isChecking = null;
  11549.  
  11550. /// -------------------------------------- PLAY ALONG WEBSOCKET STUFF ---------------------------------------------------------------------
  11551.  
  11552. const mapStylesCodes = {
  11553. "oool": { id: 'Default', fn : function(id){ document.getElementById(this.id)?.click(); } },
  11554. "oolo": { id: 'Oceanman', fn : function(id){ document.getElementById(this.id)?.click(); } },
  11555. "ooll": { id: 'Satellite', fn : function(id){ document.getElementById(this.id)?.click(); } },
  11556. "oloo": { id: "Easy 5K", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11557. "olol": { id: "Neon", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11558. "ollo": { id: "Impossible", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11559. "olll": { id: "Choekaas.no",
  11560. fn : function(id){
  11561. const coverageLayer = new google.maps.ImageMapType({
  11562. getTileUrl({ x, y }, z) {
  11563. return `https://echandler.github.io/test-geo-noob-script/misc/geoguessr%20artwork%20map%20tiles/${z}/${x}/${y}.png`;
  11564. },
  11565. maxZoom: 20,
  11566. tileSize: new google.maps.Size(256, 256),
  11567. });
  11568.  
  11569. GoogleMapsObj.overlayMapTypes.push(coverageLayer);
  11570. }
  11571. },
  11572. "looo": { id: "Fire", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11573. "lool": { id: "City Lights", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11574. "lolo": { id: "show menu",
  11575. fn : function(id){
  11576. const PATHNAME = getPathName();
  11577. //if (code === "lolo" && !PATHNAME.startsWith("/play-along/")/*is player not streamer*/){
  11578. if (PATHNAME.startsWith("/play-along/") /*player has play-along in url*/) return;
  11579. unity.play_along.showOptions;
  11580. }
  11581. },
  11582. "loll": { id: "Hybrid", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11583. "llll": { id: "CG's 📸travel-pics-game",
  11584. fn : function(id){
  11585. const coverageLayer = new google.maps.ImageMapType({
  11586. getTileUrl({ x, y }, z) {
  11587. return `https://echandler.github.io/a/misc/tiles/${z}/${x}/${y}.webp`
  11588. },
  11589. maxZoom: 20,
  11590. tileSize: new google.maps.Size(256, 256),
  11591. })
  11592.  
  11593. GoogleMapsObj.overlayMapTypes.push(coverageLayer);
  11594. }
  11595. },
  11596. };
  11597.  
  11598. function playAlongWebSocketInit(){
  11599. console.log("Play along websoket listener initiated")
  11600. let old_WS_Send = window.WebSocket.prototype.send;
  11601. let msgCode = [];
  11602. let msgCodeTimer = null;
  11603.  
  11604. window.WebSocket.prototype.send = async function (...args) {
  11605. if (this._unity_message_listener_added === undefined) {
  11606. this.addEventListener('message', function (e) {
  11607. if (!e.data) return;
  11608. onMsg(JSON.parse(e.data));
  11609. });
  11610. sendWSMsg._this = this;
  11611. this._unity_message_listener_added = true;
  11612. }
  11613. return old_WS_Send.apply(this, args);
  11614. }
  11615.  
  11616. function onMsg(json) {
  11617. if (json?.code !== "PlayAlongGameUpdated") return;
  11618.  
  11619. if (msgCodeTimer === null) {
  11620. msgCodeTimer = setTimeout(() => {
  11621. if (msgCode.length === 4) {
  11622. _delay = null;
  11623.  
  11624. const code = msgCode.join("");
  11625. console.log("code", code);
  11626. // Clear the overlays before doing anything else.
  11627. document.getElementById('Clear').click();
  11628.  
  11629. mapStylesCodes[code].fn();
  11630. }
  11631.  
  11632. msgCodeTimer = null;
  11633. msgCode = [];
  11634. }, 2000);
  11635. }
  11636.  
  11637. let payload = JSON.parse(json.payload);
  11638.  
  11639. if (payload.status.toLowerCase() === 'lockedround') {
  11640. msgCode.push("l");
  11641. } else if (payload.status.toLowerCase() === 'ongoinground') {
  11642. msgCode.push("o");
  11643. }
  11644. }
  11645.  
  11646. function sendWSMsg(msg) {
  11647. if (sendWSMsg._this === null) return;
  11648. sendWSMsg._this.send(JSON.stringify(
  11649. {
  11650. "code": "ChatMessage",
  11651. "topic": "chat:Friend:TextMessages:5dc13f46e9473f1aa89d8f24",
  11652. "payload": "Ignore this also lol",
  11653. "client": "web"
  11654. }));
  11655. // sendWSMsg._this.send(JSON.stringify({
  11656. // unity:true,
  11657. // msg: msg,
  11658. // }));
  11659. };
  11660. sendWSMsg._this = null;
  11661. }
  11662. playAlongWebSocketInit();
  11663.  
  11664. let _delay = null;
  11665. function playAlongSendMsg(str){
  11666. if (_delay !== null) {
  11667. console.log("Need to wait!");
  11668. return;
  11669. }
  11670. const keyObj = {
  11671. 'l': "LockedRound",
  11672. 'o': "OngoingRound"
  11673. };
  11674.  
  11675. _delay = true;
  11676.  
  11677. setTimeout(()=> _delay = null, 2500 );
  11678.  
  11679. const nextData = JSON.parse(document.getElementById('__NEXT_DATA__').innerHTML);
  11680. const gameId = location.href.replace(/.*\/(.*)/, "$1");
  11681. const token = nextData?.query?.token || gameId || null;
  11682. //let userId = nextData?.props?.accountProps?.account?.user?.userId || null;
  11683.  
  11684. if (token === null) {
  11685. console.log("Next data query token not found");
  11686. return;
  11687. }
  11688.  
  11689. for(let n = 0, fetchDelay = 0; n < str.length + 1; n++){
  11690. let gameStatus = keyObj[str[n]];
  11691.  
  11692. if (n === str.length){
  11693. // Make sure game is in unlock state once code is sent.
  11694. fetchDelay += 2000;
  11695. gameStatus = keyObj["o"];
  11696. }
  11697.  
  11698. setTimeout(()=>{
  11699. fetch(`https://www.geoguessr.com/api/v4/play-along/streamer/${token}/3/update`, {
  11700. "headers": {
  11701. "accept": "*/*",
  11702. "accept-language": "en-US,en;q=0.9",
  11703. "cache-control": "no-cache",
  11704. "content-type": "application/json",
  11705. "pragma": "no-cache",
  11706. "x-client": "web"
  11707. },
  11708. "referrer": location.href,
  11709. "referrerPolicy": "strict-origin-when-cross-origin",
  11710. "body": `{\"status\":\"${gameStatus}\"}`,
  11711. "method": "POST",
  11712. "mode": "cors",
  11713. "credentials": "include"
  11714. });
  11715. }, fetchDelay);
  11716. fetchDelay += 250;
  11717. }
  11718. }
  11719.  
  11720. window.unity = {
  11721. play_along: {
  11722. get showOptions(){
  11723. const keys = Object.keys(mapStylesCodes);
  11724. let optionsTxt = "";
  11725.  
  11726. let idx = 1;
  11727. keys.forEach((k)=>{
  11728. let _id_ = mapStylesCodes[k].id;
  11729. if (_id_ == "show menu"){
  11730. idx += 1; // Lazy fix for menu item numbers being one off after this is skipped.
  11731. return;
  11732. }
  11733. optionsTxt += `\n ${idx++}. ${_id_}`;
  11734. });
  11735.  
  11736. const num = prompt(` Unity Script Play Along Options:${optionsTxt}`);
  11737.  
  11738. if (num === null) return;
  11739.  
  11740. const code = keys[parseInt(num)-1];
  11741.  
  11742. try {
  11743. playAlongSendMsg(code);
  11744. } catch (e) {
  11745. alert("Ooops, try again!")
  11746. }
  11747. }
  11748. }
  11749. };
  11750.  
  11751.  
  11752. },1)

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址