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

Fra 10.03.2025. Se den seneste versjonen.

  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. // @unwrap
  11. // @tag Unity Script
  12. // @tag games
  13. // @namespace https://greatest.deepsurf.us/users/838374
  14. // @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
  15. // ==/UserScript==
  16.  
  17. Object.freeze(window.console);
  18.  
  19. const globalScriptVersion = "7.4.2.4";
  20.  
  21. let tempChangeScore = false; // delete soon used to test 5k country streak scores
  22. let tempLastLatLng = null; // delete soon used to test 5k country streak scores
  23.  
  24. let global_lat = 0;
  25. let global_lng = 0;
  26.  
  27. if (!window._unity_fetch_){
  28. // Added by EC
  29. window._unity_fetch_ = window.fetch;
  30.  
  31. window.fetch = (function(){
  32. return async function (...args){
  33. // console.log(args)
  34. // if (/lat|lng/.test(args[1]?.body)){
  35.  
  36. // +++++++ country streak 5k for correct country and 0 points for wrong country test +++++++++++++
  37. // console.log("-------------------------------------------------------------------------------------")
  38. // let body = JSON.parse(args[1].body);
  39. // if (tempChangeScore){
  40. // body.lat = global_lat + 0.0001;
  41. // body.lng = global_lng;
  42. // } else {
  43.  
  44. // debugger;
  45. // //body.lat = -84000.399864;
  46. // body.lat = global_lat > 0? -90: 90;
  47. // body.lng = 0; global_lng > 0? -180: 180
  48. // }
  49. // args[1].body = JSON.stringify(body);
  50. // let res = await window._unity_fetch_.apply(window, args);
  51. // let cloned = res.clone();
  52. // let ppp = await cloned.json().then( x => x);
  53. // if (ppp?.player?.guesses){
  54. // ppp.player.guesses[ppp.player.guesses.length - 1].lat = tempLastLatLng.lat;
  55. // ppp.player.guesses[ppp.player.guesses.length - 1].lng = tempLastLatLng.lng;
  56. // }
  57. // // console.log(ppp);
  58. // debugger;
  59. // res.json = function() {
  60. // return ppp;
  61. // return new Promise((res, rej)=>{
  62. // debugger;
  63. // return {
  64. // hi: "hi"
  65. // }
  66. // });
  67. // };
  68. // // return {
  69. // // text: function(){
  70. // // return new Promise((res, rej)=>{
  71. // // return JSON.stringify(ppp) ;
  72. // // } )
  73. // // }
  74. // // };
  75.  
  76. // return res;
  77. // +++++++ country streak 5k for correct country and 0 points for wrong country test +++++++++++++
  78. // }
  79. return window._unity_fetch_.apply(window, args);
  80. };
  81. })();
  82. }
  83.  
  84. setTimeout(()=>{
  85.  
  86. // Added by EC
  87. checkForRanomMapChallenge();
  88.  
  89. /**
  90. * Custom your YouTube Search here!
  91. * Replace " Tour Visit" with any keyword,
  92. * e.g. "Drone", to customize YouTube mode
  93. * search results.
  94. */
  95.  
  96. let customWord = " Tour Visit";
  97.  
  98. /**
  99. * Custom your minimap here!
  100. */
  101.  
  102. /**
  103. * 1: replace "roadmap" in the customMode field with any of the options below:
  104. * "roadmap" displays the default road map view. This is the default map type.
  105. * "satellite" displays Google Earth satellite images.
  106. * "hybrid" displays a mixture of normal and satellite views.
  107. * "terrain" displays a physical map based on terrain information.
  108. */
  109.  
  110. let customMode = "roadmap";
  111.  
  112. /**
  113. * 2: Go to https://mapstyle.withgoogle.com/ first click "No thanks, take me to the old style wizard"
  114. * then click "MORE OPTIONS" to hide or reveal certain features.
  115. * When you are done, click "FINISH", then "COPY JSON", and replace my settings in custom with your settings below.
  116. */
  117.  
  118. let custom =
  119.  
  120. [
  121. {
  122. "featureType": "administrative",
  123. "stylers": [
  124. {
  125. "visibility": "off"
  126. }
  127. ]
  128. },
  129. {
  130. "featureType": "landscape",
  131. "stylers": [
  132. {
  133. "visibility": "off"
  134. }
  135. ]
  136. },
  137. {
  138. "featureType": "poi.park",
  139. "stylers": [
  140. {
  141. "visibility": "off"
  142. }
  143. ]
  144. },
  145. {
  146. "featureType": "road",
  147. "elementType": "labels",
  148. "stylers": [
  149. {
  150. "visibility": "off"
  151. }
  152. ]
  153. },
  154. {
  155. "featureType": "transit",
  156. "stylers": [
  157. {
  158. "visibility": "off"
  159. }
  160. ]
  161. }
  162. ]
  163.  
  164. /**
  165. * End of Minimap customization instruction section
  166. */
  167.  
  168. /**
  169. * Overlay anything on the minimap here!
  170. * 1. overlay an GeoJSON object
  171. * 2. overlay a custom image
  172. */
  173.  
  174. /**
  175. * Overlay an GeoJSON object:
  176. */
  177.  
  178. // change the GeoJson display style.
  179. // strokeOpacity, strokeWeight, fillOpacity takes a value between 0 and 1.
  180. // strokeColor and fillColor supports Hexadecimal color (#00FF00 is green)
  181. // If clickable is set to true, you would not be able to make a guess within the shape
  182.  
  183. let GEOJSON_STYLE =
  184. {
  185. strokeColor: "black",
  186. strokeOpacity: 1,
  187. strokeWeight: 0.2,
  188. fillColor: "#00FF00",
  189. fillOpacity: 0,
  190. clickable: false,
  191. }
  192.  
  193. // replace the URL with your desired link
  194. // For example, search "Germany GeoJson" on Github, find this link (https://github.com/isellsoap/deutschlandGeoJSON/blob/main/4_kreise/4_niedrig.geo.json)
  195. // Then click "Download" to get the raw.githubusercontent.com link (https://raw.githubusercontent.com/isellsoap/deutschlandGeoJSON/main/4_kreise/4_niedrig.geo.json)
  196. // and replace the URL below with that URL.
  197. // State zipcode: see this site https://github.com/OpenDataDE/State-zip-code-GeoJSON
  198.  
  199. let YOUR_URL = "https://raw.githubusercontent.com/severinlandolt/map-switzerland/main/02%20GeoJSON/CH_Kantonsgrenzen_100_geo.json"
  200.  
  201. // set it to true to add your custom GeoJSON by copy it to the code below (this is for
  202.  
  203. let GeoJsonCustomUser = true; //false
  204.  
  205. // replace with your custom GeoJson, go to https://geojson.io/ to customize it then copy the Json to here
  206.  
  207. let CUSTOM_GEOJSON = null;
  208.  
  209. CUSTOM_GEOJSON =
  210.  
  211. {
  212. "type": "FeatureCollection",
  213. "features": [
  214. {
  215. "type": "Feature",
  216. "properties": {},
  217. "geometry": {
  218. "type": "LineString",
  219. "coordinates": [
  220. [
  221. 2.493896484375,
  222. 52.7163309360463
  223. ],
  224. [
  225. 2.4609375,
  226. 53.15994678846807
  227. ],
  228. [
  229. 3.2025146484375,
  230. 53.179703893605385
  231. ],
  232. [
  233. 3.2080078125,
  234. 52.96518371955126
  235. ],
  236. [
  237. 2.48291015625,
  238. 52.948637884883205
  239. ]
  240. ]
  241. }
  242. },
  243. {
  244. "type": "Feature",
  245. "properties": {},
  246. "geometry": {
  247. "type": "LineString",
  248. "coordinates": [
  249. [
  250. 3.218994140625,
  251. 52.05586831074774
  252. ],
  253. [
  254. 3.218994140625,
  255. 52.13685974852633
  256. ],
  257. [
  258. 2.515869140625,
  259. 52.1267438596429
  260. ],
  261. [
  262. 2.515869140625,
  263. 51.77803705914517
  264. ],
  265. [
  266. 3.2354736328125,
  267. 51.78993084774129
  268. ],
  269. [
  270. 3.228607177734375,
  271. 51.96119237712624
  272. ],
  273. [
  274. 2.8571319580078125,
  275. 51.95230623740452
  276. ]
  277. ]
  278. }
  279. },
  280. {
  281. "type": "Feature",
  282. "properties": {
  283. "stroke": "#555555",
  284. "stroke-width": 2,
  285. "stroke-opacity": 1
  286. },
  287. "geometry": {
  288. "type": "LineString",
  289. "coordinates": [
  290. [
  291. 2.5048828125,
  292. 52.619725272670266
  293. ],
  294. [
  295. 2.5103759765625,
  296. 52.274880130680536
  297. ],
  298. [
  299. 2.867431640625,
  300. 52.284962354465726
  301. ],
  302. [
  303. 3.2299804687499996,
  304. 52.29504228453735
  305. ],
  306. [
  307. 3.2135009765625,
  308. 52.63973017532399
  309. ],
  310. [
  311. 2.5096893310546875,
  312. 52.621392697207625
  313. ]
  314. ]
  315. }
  316. }
  317. ]
  318. }
  319. /**
  320. * Overlay a custom image:
  321. */
  322.  
  323. // set it to true to add your image overlay
  324.  
  325. let OverlayCustom = false;
  326.  
  327. // replace the URL with your desired link
  328.  
  329. let OVERLAY_URL = "https://www.battleface.com/blog/wp-content/uploads/2020/10/patreon-profile-tom-geowizard.jpg"
  330.  
  331. // set the bounds for the image - latitude (North and South), longitude (North and South)
  332.  
  333. let OVERLAY_BOUNDS =
  334. {
  335. north: 53,
  336. west: -3,
  337. south: 51,
  338. east: 1,
  339. };
  340.  
  341. // change the image overlay display style.
  342.  
  343. let OVERLAY_STYLE =
  344. {
  345. fillOpacity: 0.2,
  346. clickable: false,
  347. }
  348.  
  349. /**
  350. * End of Minimap Overlay instruction section
  351. */
  352.  
  353. // API Keys
  354.  
  355. var MS_API_KEY = "Ap2DwDDitzY7jJuYeIJF6YyfqDkYt-QxIBjeQ6SDEJelSfb6ghAVb-V4I-G3om-s";
  356. var YANDEX_API_KEY = "b704b5a9-3d67-4d19-b702-ec7807cecfc6";
  357. var KAKAO_API_KEY = "cbacbe41e3a223d794f321de4f3e247b";
  358. var MAPBOX_API_KEY = "pk.eyJ1IjoianVwYW9xcSIsImEiOiJjbDB2dTBnbngweWIzM2NtdWR5NXZ1dncyIn0.bJixk3kN5Mmedw_C3vQmmw";
  359. const MAPS_API_URL = "https://maps.googleapis.com/maps/api/js"; // removed "?" from the link
  360. var MAPILLARY_API_KEY_LIST =
  361. ["MLY|6723031704435203|5afd537469b114cf814881137ad74b7c",
  362. "MLY|6691659414239148|b45e7e82cde126044cbc2cf5d4a7c9b1",
  363. "MLY|5074369465929308|f7ad2802cbaf26c63f88046a292df68b",
  364. "MLY|7451643761528219|6477f2db0e3928b51e45ec9311983936",
  365. "MLY|4855256237866198|6d0464771831c8a4bf2be095e1e1aabc",
  366. "MLY|4772941976102161|8458d4f08d2e1970cdfe0a4e242c04ff",
  367. "MLY|4492067214235489|94c44703942362ad6f6b70b5d32c3a45",
  368. "MLY|4618251611628426|0cef71d6ec8b997a5ec06ecdeabf11ec",
  369. "MLY|4096846270415982|fa2ce29641503e6ef665f17459633570",
  370. "MLY|4231415756962414|fe353880fd246e8a4a6ae32152f7dbb0",]
  371.  
  372. var MAPILLARY_API_KEY = MAPILLARY_API_KEY_LIST[Math.floor(Math.random() * MAPILLARY_API_KEY_LIST.length)];
  373. var MAPY_API_KEY = "placeholder";
  374.  
  375. console.log(`Geoguessr Unity Script v${globalScriptVersion} by Jupaoqq`);
  376.  
  377.  
  378. // Store each player instance
  379.  
  380. let YandexPlayer, KakaoPlayer, GooglePlayer, MapillaryPlayer, MSStreetPlayer, MapboxPlayer, MapboxMarker, MapyPlayer;
  381. let YANDEX_INJECTED = false;
  382. let BAIDU_INJECTED = false;
  383. let KAKAO_INJECTED = false;
  384. let MAPILLARY_INJECTED = false;
  385. let MS_INJECTED = false;
  386. let MAPBOX_INJECTED = false;
  387. let MAPY_INJECTED = false;
  388. let rainLayer;
  389.  
  390. let GoogleMapsObj = null;
  391.  
  392. // Game mode detection
  393.  
  394. let isBattleRoyale = false;
  395. let isDuel = false;
  396. let isBullseye = false;
  397. let isLiveChallenge = false;
  398. let isPlayAlong = false;
  399.  
  400. // Player detection and coordinate conversion
  401.  
  402. let nextPlayer = "Google";
  403. let nextPlayer_save = "Google";
  404. let global_data = {};
  405. let global_bounds = {max : {lat: 50.387397, lng: 57.412767}, min : {lat: 50.181227, lng: 57.077273}};
  406. let global_cc = null;
  407. let global_panoID = null;
  408. let global_BDID, global_BDAh, global_BDBh;
  409. let yId, yTime, yEnd, iId;
  410. let global_heading = null;
  411. let global_pitch = null;
  412.  
  413. let krCoordinates = [38.75292321084364, 124.2804539232574, 33.18509676203202, 129.597381999198]
  414. let global_radi = 100
  415.  
  416. // Callback variables
  417.  
  418. let eventListenerAttached = false;
  419. let povListenerAttached = false;
  420. let playerLoaded = false;
  421. let teleportLoaded = false;
  422. let syncLoaded = false;
  423.  
  424. // Minimize Yandex API use
  425.  
  426. let yandex_map = false;
  427. let Kakao_map = false;
  428. let Wikipedia_map = false;
  429. let WikiXplore_map = false; // Added by EC.
  430. let randomMapChallenge_map = false;// Added by EC.
  431. let Minecraft_map = false;
  432. let Youtube_map = false;
  433. let bing_map = false;
  434. let Mapy_map = false;
  435.  
  436. // Mapillary Image Key
  437.  
  438. let mmKey = 0;
  439.  
  440. // Handle Yandex compass
  441.  
  442. let COMPASS = null;
  443.  
  444. // Handle undo
  445.  
  446. let locHistory = [];
  447. let defaultPanoIdChange = true;
  448.  
  449. // Round check
  450.  
  451. let ROUND = 0;
  452. let CURRENT_ROUND_DATA = null;
  453.  
  454. let switch_call = true;
  455. let one_reset = false;
  456. // let cnt = 0;
  457.  
  458. var isFirefox = typeof InstallTrigger !== 'undefined';
  459.  
  460. let linksList = []
  461. let fire1 = true;
  462. let allowDetect = false;
  463. let planetType = "None";
  464.  
  465. // Satellite Map Radius (in Meters)
  466. let ms_radius = 15000;
  467. //let sat_choice = false;
  468. const ls_sat_choice = localStorage['unity_sat_choice']; // Added by EC
  469. let sat_choice = !(ls_sat_choice === undefined || ls_sat_choice === "false"); // Added by EC
  470.  
  471. // Create the Maps, but not reload API
  472. let partialCreateYandex = false;
  473. let partialCreateKakao = false;
  474. let partialCreateMapillary = false;
  475. let partialCreateMS = false;
  476. let partialCreateMapbox = false;
  477. let partialCreateMapy = false;
  478.  
  479. // let NEW_ROUND_LOADED = false;
  480.  
  481. // Geoguessr Canvas String Names
  482.  
  483. let GENERAL_LAYOUT = `[class*="game_canvas"]`;//`[aria-label="Street View"] > canvas`;//".game-layout__canvas";
  484. let GENERAL_CANVAS = `[data-qa*="panorama-canvas"]`; //".game-layout__panorama-canvas";
  485. let BR_CANVAS = ".br-game-layout__panorama-canvas";
  486. let BR_WRAPPER = ".br-game-layout__panorama-wrapper";
  487. let BR_LAYOUT = ".br-game-layout";
  488. let FAIL_TO_LOAD_CANVAS = ".game-layout__panorama-message";
  489. let DUEL_LAYOUT = ".game_layout__TO_jf";
  490. let DUELS_CANVAS = ".game-panorama_panorama__rdhFg";
  491. let DUELS_CANVAS2 = ".game-panorama_panoramaCanvas__PNKve";
  492. let BULLSEYE_CANVAS = ".game-panorama_panorama__ncMwh";
  493. let BULLSEYE_CANVAS2 = ".game-panorama_panoramaCanvas__r_5ea";
  494. let LIVE_CANVAS = ".game-panorama_panorama__IuPsO";
  495. let LIVE_CANVAS2 = ".game-panorama_panoramaCanvas__HbDig";
  496. let DUELS_POPUP = ".overlay_overlay__AR02x";
  497. let BR_POPUP = ".popup__content";
  498.  
  499. let BR_LOAD_KAKAO = false;
  500. let BR_LOAD_YANDEX = false;
  501. let BR_LOAD_MS = false;
  502. let BR_LOAD_MP = false;
  503. let BR_LOAD_MAPILLARY = false;
  504. let BR_LOAD_MAPY = false;
  505.  
  506. let ms_sat_map = false;
  507. let rtded = false;
  508. let NM = false;
  509. let NP = false;
  510. let NZ = false;
  511.  
  512. let initBing = false;
  513.  
  514. let menuLocCounter = 0;
  515. let wikiUrl = "";
  516. let bullseyeMapillary = false;
  517. let randomPlanets = false;
  518.  
  519. let corsString = "https://nameless-bastion-28139.herokuapp.com/"
  520. // Additional: https://cors.eu.org/
  521. let carteCity = ""
  522.  
  523. let youtubeIndex = -1;
  524. let youtubeList = [];
  525.  
  526. let GAME_CANVAS = "";
  527. let DUEL_CANVAS = "";
  528.  
  529. let skySpecial = false;
  530. let soilSpecial = false;
  531. let skewedSpecial = false;
  532. let zoomSpecial = false;
  533. let randomSpecial = false;
  534. let nmpzSpecial = false;
  535.  
  536. let mosaicPre = false;
  537. let restrictMovement = false;
  538.  
  539. var Weather = false;
  540.  
  541. const ls_Dimension_choice = localStorage['Satallite_2D_3D_setting']; // Added by EC
  542. let Dimension = ls_Dimension_choice == undefined ? true /* Default = true 3D*/: (ls_Dimension_choice == "3D"? true/*3D*/: false /*2D*/); // Added by EC
  543.  
  544. var mapSty = true;
  545. var Building = false;
  546.  
  547. setTimeout(function createWindowFunctions(){
  548. // Made by EC
  549. // Trying to make this script load faster, by delaying unnecessary stuff.
  550.  
  551. window.toggleSatellite = (e) => {
  552. if (e.checked) {
  553. sat_choice = true;
  554. document.getElementById('tgs').style.display = "";
  555. }
  556. else {
  557. sat_choice = false;
  558. document.getElementById('tgs').style.display = "none";
  559. }
  560. localStorage['unity_sat_choice'] = sat_choice;
  561. }
  562.  
  563. window.toggleWeather = (e) => {
  564. Weather = e.checked ? true : false;
  565. }
  566.  
  567. window.toggleBuildings = (e) => {
  568. Building = e.checked ? true : false;
  569. }
  570.  
  571. window.toggle3D = (e) => {
  572. Dimension = e.checked ? true : false;
  573. }
  574.  
  575. window.toggleSky = (e) => {
  576. skySpecial = e.checked ? true : false;
  577. }
  578.  
  579. window.toggleSoil = (e) => {
  580. soilSpecial = e.checked ? true : false;
  581. }
  582.  
  583. window.toggleSkewed = (e) => {
  584. skewedSpecial = e.checked ? true : false;
  585. }
  586.  
  587. window.toggleMaxZoom = (e) => {
  588. zoomSpecial = e.checked ? true : false;
  589. }
  590.  
  591. window.toggleRdn = (e) => {
  592. randomSpecial = e.checked ? true : false;
  593. }
  594.  
  595. window.toggleNMPZSpecial = (e) => {
  596. nmpzSpecial = e.checked ? true : false;
  597. }
  598.  
  599. window.toggleMosaic = (e) => {
  600. mosaicPre = e.checked ? true : false;
  601. }
  602.  
  603. window.toggleRestrictMovement = (e) => {
  604. restrictMovement = e.checked ? true : false;
  605. }
  606.  
  607. window.toggleRandomMapChallenge = (_this) => {
  608. if (_this.id === 'toggleRandomMapChallenge') {
  609. initRandomMapChallenge();
  610. return;
  611. }
  612. if (_this.id === 'toggleRandomMapChallengeOnHomePage') {
  613. if (_this.checked) {
  614. localStorage["RandomMapChallenge_onHomePage"] = true;
  615. showRandomMapChallengeBtnOnHomePage(true);
  616. } else {
  617. delete localStorage["RandomMapChallenge_onHomePage"];
  618. showRandomMapChallengeBtnOnHomePage(false);
  619. }
  620. }
  621. }
  622. }, 100);
  623.  
  624. function getPathName(){
  625. // Hopefully this fixes most issues with localization.
  626. // Thanks to Destroy666x for bringing this to our attention.
  627. // https://github.com/echandler/Geoguessr-Unity-Script-Fork/issues/1
  628. return location.pathname.replace(/^\/[a-z]{2}\//i, "/");
  629. }
  630.  
  631. function getLocalizationFromPathName(){
  632. const pathname = location.pathname;
  633. const local = /^\/[a-z]{2}\//.test(pathname)? pathname[1] + pathname[2] : "en";
  634.  
  635. return local;
  636. }
  637.  
  638. let guiEnabled = true;
  639.  
  640. function guiHTML(){
  641. const sectionHeader = document.querySelector('div[class*="section_sectionHeader"]');
  642. //const standardGameModeSettings = document.querySelector('div[class*="start-standard-game_settings"]');
  643. const standardGameModeSettings = document.querySelector('div[class*="-game_settings_"]');
  644. const barsRoot = document.querySelector('div[class*="bars_root"]');
  645. const barsBefore = document.querySelector('div[class*="bars_before"]');
  646. const barsContent = document.querySelector('[class*="bars_content"]');
  647. const barsAfter = document.querySelector('div[class*="bars_after"]');
  648. 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"]');//
  649. const bodyText = {};//document.querySelector('div[class*="body-text_bodyText"]');
  650. const toggle = {className: "toggle"};//document.querySelector('input[class*="toggle_toggle"]');
  651.  
  652. document.head.insertAdjacentHTML(
  653. // EC: Styles for toggle copied from the streaks page before it was changed to new style.
  654. "beforeend",
  655. `<style id='unity_guiHTML_styles'>
  656. .toggle:checked {
  657. background: var(--ds-color-purple-50);
  658. }
  659. .toggle {
  660. -webkit-appearance: none;
  661. -moz-appearance: none;
  662. appearance: none;
  663. background: var(--ds-color-white-10);
  664. border: 0;
  665. border-radius: 2rem;
  666. cursor: pointer;
  667. display: inline-block;
  668. height: 1.25rem;
  669. position: relative;
  670. transition: background-color .2s ease;
  671. width: 2.5rem;
  672. }
  673. input {
  674. border: .0625rem solid #ddd;
  675. box-sizing: border-box;
  676. outline: none;
  677. padding: .625rem
  678. }
  679. .toggle:before {
  680. background: var(--ds-color-purple-50);
  681. content: "";
  682. height: 100%;
  683. left: 0;
  684. opacity: 0;
  685. position: absolute;
  686. top: 0;
  687. transition: opacity .3s ease;
  688. width: 100%;
  689. }
  690. .toggle:after {
  691. background: var(--ds-color-white);
  692. border-radius: 100%;
  693. content: "";
  694. height: 1rem;
  695. left: 0;
  696. margin: 0.125rem;
  697. opacity: .1;
  698. position: absolute;
  699. top: 0;
  700. transition: transform .1s ease, opacity .1s ease;
  701. width: 1rem;
  702. }
  703. .toggle:checked:after {
  704. opacity: 1;
  705. transform: translateX(125%);
  706. }
  707. </style>`);
  708.  
  709. return `
  710. <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);">
  711. <div class="${sectionHeader?.className}">
  712. <div class="${barsRoot?.className}" style="display:flex; align-items: center; margin-bottom: 1rem;">
  713. <div class="${barsBefore?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  714. <span class="${barsContent?.className}" style="font-style: italic; padding: 0px 1rem; color: var(--hlTextColor);"> <h3>Satellite Mode (Unity Script)</h3> </span>
  715. <div class="${barsAfter?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  716. </div>
  717. </div>
  718. <div class="${standardGameModeSettings?.className}">
  719. <div style="display: flex; justify-content: space-around;">
  720. <div style="display: flex; align-items: center;">
  721.  
  722. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  723. <span class="${optionsLabel?.className}" style="${optionsLabel}">Enabled</span>
  724. <input type="checkbox" id="toggleSatellite" onclick="toggleSatellite(this)" class="${toggle?.className}">
  725. </label>
  726.  
  727. </div>
  728. </div>
  729. <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>
  730. </div>
  731. <div class="${standardGameModeSettings?.className}" id="tgs" style="display:none">
  732. <div style="display: flex; justify-content: space-around;">
  733. <div style="display: flex; align-items: center;">
  734.  
  735. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  736. <span class="${optionsLabel?.className}" style="${optionsLabel}">Live Weather</span>
  737. <input type="checkbox" id="toggleWeather" onclick="toggleWeather(this)" class="${toggle?.className}">
  738. </label>
  739.  
  740. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  741. <span class="${optionsLabel?.className}" style="${optionsLabel}">Buildings</span>
  742. <input type="checkbox" id="toggleBuildings" onclick="toggleBuildings(this)" class="${toggle?.className}">
  743. </label>
  744.  
  745. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  746. <span class="${optionsLabel?.className}" style="${optionsLabel}">3D</span>
  747. <input type="checkbox" id="toggle3D" onclick="toggle3D(this)" class="${toggle?.className}">
  748. </label>
  749. </div>
  750. </div>
  751. <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>
  752. </div>
  753.  
  754. <!-- Section -->
  755.  
  756. <!-- Random Map Challenge by Alok -->
  757.  
  758. <div class="${sectionHeader?.className}">
  759. <div class="${barsRoot?.className}"style="display:flex; align-items: center; margin-bottom: 1rem;">
  760. <div class="${barsBefore?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  761. <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>
  762. <div class="${barsAfter?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);" ></div>
  763. </div>
  764. </div>
  765. <div class="${standardGameModeSettings?.className}">
  766. <div style="display: flex; justify-content: space-around;">
  767. <div style="display: flex; align-items: center;">
  768.  
  769. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  770. <span class="${optionsLabel?.className}" style="${optionsLabel}">Enabled</span>
  771. <input type="checkbox" id="toggleRandomMapChallenge" onclick="toggleRandomMapChallenge(this)" class="${toggle?.className}">
  772. </label>
  773.  
  774. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  775. <span class="${optionsLabel?.className}" style="${optionsLabel}">Show on homepage?</span>
  776. <input type="checkbox" id="toggleRandomMapChallengeOnHomePage" onclick="toggleRandomMapChallenge(this)" class="${toggle?.className}">
  777. </label>
  778. </div>
  779. </div>
  780. <!--
  781. <div style="display: flex; justify-content: space-around;">
  782. <div style="display: flex; align-items: center;">
  783. <span class="${optionsLabel?.className}" style="${optionsLabel}">Show on homepage?</span>
  784. <input type="checkbox" id="toggleRandomMapChallengeOnHomePage" onclick="toggleRandomMapChallenge(this)" class="${toggle?.className}">
  785. </div>
  786. </div>
  787. -->
  788. <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>
  789. </div>
  790.  
  791. <!-- Section -->
  792.  
  793. <div class="${sectionHeader?.className}">
  794. <div class="${barsRoot?.className}" style="display:flex; align-items: center; margin-bottom: 1rem;">
  795. <div class="${barsBefore?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  796. <span class="${barsContent?.className}" style="font-style: italic; padding: 0px 1rem; color: var(--hlTextColor);"><h3>Mosaic & Peek Mode (Unity Script)</h3></span>
  797. <div class="${barsAfter?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  798. </div>
  799. </div>
  800. <div class="${standardGameModeSettings?.className}">
  801. <div style="display: flex; justify-content: space-around;">
  802. <div style="display: flex; align-items: center;">
  803. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  804. <span class="${optionsLabel?.className}" style="${optionsLabel}">Enabled</span>
  805. <input type="checkbox" id="toggleMosaic" onclick="toggleMosaic(this)" class="${toggle?.className}">
  806. </label>
  807. </div>
  808. </div>
  809. <p class="${bodyText?.className}" style="margin-top: 1rem;margin-bottom: 1rem;">Default mosaic grid: 5x5.</p>
  810. </div>
  811.  
  812. <!-- Section -->
  813.  
  814. <div class="${sectionHeader?.className}">
  815. <div class="${barsRoot?.className}" style="display:flex; align-items: center; margin-bottom: 1rem;">
  816. <div class="${barsBefore?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  817. <span class="${barsContent?.className}" style="font-style: italic; padding: 0px 1rem; color: var(--hlTextColor);"><h3>No Escape Mode (Unity Script)</h3></span>
  818. <div class="${barsAfter?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  819. </div>
  820. </div>
  821. <div class="${standardGameModeSettings?.className}">
  822. <div style="display: flex; justify-content: space-around;">
  823. <div style="display: flex; align-items: center;">
  824. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  825. <span class="${optionsLabel?.className}" style="${optionsLabel}">Enabled</span>
  826. <input type="checkbox" id="toggleRestrictMovement" onclick="toggleRestrictMovement(this)" class="${toggle?.className}">
  827. </labe>
  828. </div>
  829. </div>
  830. <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>
  831. </div>
  832.  
  833. <!-- Section -->
  834.  
  835. <div class="${sectionHeader?.className}">
  836. <div class="${barsRoot?.className}" style="display:flex; align-items: center; margin-bottom: 1rem;">
  837. <div class="${barsBefore?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  838. <span class="${barsContent?.className}" style="font-style: italic; padding: 0px 1rem; color: var(--hlTextColor);"><h3>Circus Mode (Unity Script)</h3></span>
  839. <div class="${barsAfter?.className}" style="flex:1; height: 3px; background-color: var(--hlColor);"></div>
  840. </div>
  841. </div>
  842. <div class="${standardGameModeSettings?.className}">
  843. <div style="display: flex; justify-content: space-around;">
  844. <div style="display: flex; align-items: center;">
  845. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  846. <span class="${optionsLabel?.className}" style="${optionsLabel}">Sky</span>
  847. <input type="checkbox" id="toggleSky" onclick="toggleSky(this)" class="${toggle?.className}">
  848. </label>
  849. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  850. <span class="${optionsLabel?.className}" style="${optionsLabel}">Soiled</span>
  851. <input type="checkbox" id="toggleSoil" onclick="toggleSoil(this)" class="${toggle?.className}">
  852. </label>
  853. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  854. <span class="${optionsLabel?.className}" style="${optionsLabel}">Skewed</span>
  855. <input type="checkbox" id="toggleSkewed" onclick="toggleSkewed(this)" class="${toggle?.className}">
  856. </label>
  857. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  858. <span class="${optionsLabel?.className}" style="${optionsLabel}">Max Zoom</span>
  859. <input type="checkbox" id="toggleMaxZoom" onclick="toggleMaxZoom(this)" class="${toggle?.className}">
  860. </label>
  861. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  862. <span class="${optionsLabel?.className}" style="${optionsLabel}">Random</span>
  863. <input type="checkbox" id="toggleRdn" onclick="toggleRdn(this)" class="${toggle?.className}">
  864. </label>
  865. <label style="display:flex; align-items: center; cursor: pointer; margin-right: 10px;">
  866. <span class="${optionsLabel?.className}" style="${optionsLabel}">NMPZ</span>
  867. <input type="checkbox" id="toggleNMPZSpecial" onclick="toggleNMPZSpecial(this)" class="${toggle?.className}">
  868. </label>
  869. </div>
  870. </div>
  871. <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>
  872. </div>
  873. </div>
  874. `;
  875. }
  876.  
  877.  
  878. const checkInsertGui = () => {
  879. if (document.querySelector(`div[class*="map-block_root"]`) && document.getElementById('toggleSky') === null){
  880.  
  881. document.querySelector(`div[class*="map-block_root"]`).lastChild.remove();
  882. document.querySelector(`div[class*="map-block_root"]`).insertAdjacentHTML('beforeend', guiHTML());
  883.  
  884. if (sat_choice) {
  885. document.getElementById('toggleSatellite').checked = true;
  886. document.getElementById('tgs').style.display = "";
  887. }
  888. if (Weather)
  889. {
  890. document.getElementById('toggleWeather').checked = true;
  891. }
  892. if (Building)
  893. {
  894. document.getElementById('toggleBuildings').checked = true;
  895. }
  896. if (Dimension)
  897. {
  898. document.getElementById('toggle3D').checked = true;
  899. }
  900. if (skySpecial) {
  901. document.getElementById('toggleSky').checked = true;
  902. }
  903. if (soilSpecial) {
  904. document.getElementById('toggleSoil').checked = true;
  905. }
  906. if (skewedSpecial) {
  907. document.getElementById('toggleSkewed').checked = true;
  908. }
  909. if (zoomSpecial) {
  910. document.getElementById('toggleMaxZoom').checked = true;
  911. }
  912. if (randomSpecial) {
  913. document.getElementById('toggleRdn').checked = true;
  914. }
  915. if (nmpzSpecial)
  916. {
  917. document.getElementById('toggleNMPZSpecial').checked = true;
  918. }
  919. if (mosaicPre)
  920. {
  921. document.getElementById('toggleMosaic').checked = true;
  922. }
  923. if (restrictMovement)
  924. {
  925. document.getElementById('toggleRestrictMovement').checked = true;
  926. }
  927. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  928. if ((rmcMenuBtn && rmcMenuBtn.style.display !== "none") || localStorage["RandomMapChallenge"])
  929. {
  930. // Added by EC
  931. document.getElementById('toggleRandomMapChallenge').checked = true;
  932. }
  933. if (localStorage["RandomMapChallenge_onHomePage"]){
  934. // Added by EC
  935. document.getElementById('toggleRandomMapChallengeOnHomePage').checked = true;
  936. }
  937. }
  938. }
  939.  
  940. let observerNew = new MutationObserver((mutations) => {
  941. // Inserts Menu on map options screen.
  942. if (guiEnabled) {
  943. checkInsertGui();
  944. }
  945. if (document.getElementById('Unity Start Menu'))
  946. {
  947. if (document.querySelector('div[class*="map-selector_root"]'))
  948. {
  949. document.getElementById('Unity Start Menu').style.display = "";
  950. }
  951. else
  952. {
  953. document.getElementById('Unity Start Menu').style.display = "none";
  954. }
  955. }
  956. });
  957.  
  958. observerNew.observe(document.body, {
  959. characterDataOldValue: false,
  960. subtree: true,
  961. childList: true,
  962. characterData: false
  963. });
  964.  
  965. function sleep(milliseconds) {
  966. var start = new Date().getTime();
  967. for (var i = 0; i < 1e7; i++) {
  968. if ((new Date().getTime() - start) > milliseconds){
  969. break;
  970. }
  971. }
  972. }
  973.  
  974. // window.addEventListener('popstate', function(event) {
  975. // var photo = document.getElementById("sat_map");
  976. // console.log(photo);
  977. // document.body.appendChild(photo);
  978. // }, false);
  979.  
  980.  
  981.  
  982. /**
  983. * Helper Functions
  984. */
  985.  
  986. // Highlight API Load Message
  987.  
  988. function myHighlight(...args) {
  989. console.log(`%c${[...args]}`, "color: dodgerblue; font-size: 24px;");
  990. }
  991.  
  992. // Hex to number conversion for Baidu coordinate conversion
  993.  
  994. function hex2a(hexx) {
  995. var hex = hexx.toString();
  996. var str = '';
  997. for (var i = 0; i < hex.length; i += 2)
  998. {
  999. str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
  1000. }
  1001. return str;
  1002. }
  1003. window._hex2a = hex2a;
  1004.  
  1005. // Coordinate computation given heading, distance and current coordinates for teleport
  1006.  
  1007. function FindPointAtDistanceFrom(lat, lng, initialBearingRadians, distanceKilometres) {
  1008. const radiusEarthKilometres = 6371.01;
  1009. var distRatio = distanceKilometres / radiusEarthKilometres;
  1010. var distRatioSine = Math.sin(distRatio);
  1011. var distRatioCosine = Math.cos(distRatio);
  1012.  
  1013. var startLatRad = DegreesToRadians(lat);
  1014. var startLonRad = DegreesToRadians(lng);
  1015.  
  1016. var startLatCos = Math.cos(startLatRad);
  1017. var startLatSin = Math.sin(startLatRad);
  1018.  
  1019. var endLatRads = Math.asin((startLatSin * distRatioCosine) + (startLatCos * distRatioSine * Math.cos(initialBearingRadians)));
  1020.  
  1021. var endLonRads = startLonRad
  1022. + Math.atan2(
  1023. Math.sin(initialBearingRadians) * distRatioSine * startLatCos,
  1024. distRatioCosine - startLatSin * Math.sin(endLatRads));
  1025.  
  1026. return { lat: RadiansToDegrees(endLatRads), lng: RadiansToDegrees(endLonRads) };
  1027. }
  1028.  
  1029. function DegreesToRadians(degrees) {
  1030. const degToRadFactor = Math.PI / 180;
  1031. return degrees * degToRadFactor;
  1032. }
  1033.  
  1034. function RadiansToDegrees(radians) {
  1035. const radToDegFactor = 180 / Math.PI;
  1036. return radians * radToDegFactor;
  1037. }
  1038.  
  1039. function toRadians(degrees) {
  1040. return degrees * Math.PI / 180;
  1041. };
  1042.  
  1043. // Converts from radians to degrees.
  1044. function toDegrees(radians) {
  1045. return radians * 180 / Math.PI;
  1046. }
  1047.  
  1048. function bearing(start_latitude, start_longitude, stop_latitude, stop_longitude){
  1049. let y = Math.sin(stop_longitude-start_longitude) * Math.cos(stop_latitude);
  1050. let x = Math.cos(start_latitude)*Math.sin(stop_latitude) -
  1051. Math.sin(start_latitude)*Math.cos(stop_latitude)*Math.cos(stop_longitude-start_longitude);
  1052. let brng = Math.atan2(y, x) * 180 / Math.PI;
  1053. return brng
  1054. }
  1055.  
  1056. // Check if two floating point numbers are really really really really close to each other (to 10 decimal points)
  1057. function almostEqual (a, b) {
  1058. return a.toFixed(10) === b.toFixed(10)
  1059. }
  1060.  
  1061. function almostEqual2 (a, b) {
  1062. return a.toFixed(3) === b.toFixed(3)
  1063. }
  1064.  
  1065. function moveFrom(coords, angle, distance){
  1066. const R_EARTH = 6378.137;
  1067. const M = (1 / ((2 * Math.PI / 360) * R_EARTH)) / 1000;
  1068. let radianAngle = -angle * Math.PI / 180;
  1069. let x = 0 + (distance * Math.cos(radianAngle));
  1070. let y = 0 + (distance * Math.sin(radianAngle));
  1071.  
  1072. let newLat = coords.lat + (y * M);
  1073. let newLng = coords.lng + (x * M) / Math.cos(coords.lat * (Math.PI / 180));
  1074. return { lat: newLat, lng: newLng };
  1075. }
  1076.  
  1077. function getBBox(coordinates, meters){
  1078. let SW = moveFrom(coordinates, 135, meters);
  1079. let NE = moveFrom(coordinates, 315, meters);
  1080. return `${SW.lng},${SW.lat},${NE.lng},${NE.lat}`;
  1081. }
  1082.  
  1083. // function getBBox2(coordinates, meters){
  1084. // let SW = moveFrom(coordinates, 135, meters * 1.44);
  1085. // let NE = moveFrom(coordinates, 315, meters * 1.44);
  1086. // return [NE.lat,SW.lng,SW.lat,NE.lng];
  1087. // }
  1088.  
  1089. function getBBox2(coordinates, meters){
  1090. let SW = moveFrom(coordinates, 135, meters * 1.44);
  1091. let NE = moveFrom(coordinates, 315, meters * 1.44);
  1092. if (NE.lat > 90)
  1093. {
  1094. SW.lat -= (NE.lat - 90);
  1095. NE.lat = 90;
  1096. }
  1097. if (SW.lat < -90)
  1098. {
  1099. NE.lat += (-90 - SW.lat);
  1100. SW.lat = -90;
  1101. }
  1102. if (SW.lng < -180)
  1103. {
  1104. NE.lng += (-180 - SW.lng);
  1105. SW.lng = -180;
  1106. }
  1107. if (NE.lng > 180)
  1108. {
  1109. SW.lng -= (NE.lng - 180);
  1110. NE.lng = 180;
  1111. }
  1112. return [NE.lat,SW.lng,SW.lat,NE.lng];
  1113. }
  1114.  
  1115. function distance(lat1, lon1, lat2, lon2) {
  1116. var p = 0.017453292519943295; // Math.PI / 180
  1117. var c = Math.cos;
  1118. var a = 0.5 - c((lat2 - lat1) * p)/2 +
  1119. c(lat1 * p) * c(lat2 * p) *
  1120. (1 - c((lon2 - lon1) * p))/2;
  1121.  
  1122. return 1000 * 12742 * Math.asin(Math.sqrt(a)); // 2 * R; R = 6371 km
  1123. }
  1124.  
  1125. function convertMMSS(input) {
  1126. var parts = input.split(':'),
  1127. minutes = +parts[0],
  1128. seconds = +parts[1];
  1129. return (minutes * 60 + seconds).toFixed(3);
  1130. }
  1131.  
  1132. function handleBtwRoundsClear()
  1133. {
  1134. youtubeIndex = -1;
  1135. youtubeList = [];
  1136. locHistory = [];
  1137. wikiUrl = "";
  1138. one_reset = false;
  1139. // let iframe = document.getElementById("i_container");
  1140. // if (iframe && nextPlayer !== "Image")
  1141. // {
  1142. // iframe.src = "";
  1143. // }
  1144. }
  1145.  
  1146. // Script injection, extracted from extenssr:
  1147. // https://gitlab.com/nonreviad/extenssr/-/blob/main/src/injected_scripts/maps_api_injecter.ts
  1148.  
  1149. function overrideOnLoad(googleScript, observer, overrider) {
  1150. const oldOnload = googleScript.onload
  1151. if (window.google){
  1152. // Delete this before uploading.
  1153. // alert('window google')
  1154. }
  1155. googleScript.onload = (event) => {
  1156. const google = window.google
  1157. if (google) {
  1158. observer.disconnect()
  1159. overrider(google)
  1160. }
  1161. if (oldOnload) {
  1162. oldOnload.call(googleScript, event)
  1163. }
  1164. }
  1165. }
  1166.  
  1167. function grabGoogleScript(mutations) {
  1168. for (const mutation of mutations) {
  1169. for (const newNode of mutation.addedNodes) {
  1170. const asScript = newNode
  1171. if (asScript && asScript.src && asScript.src.startsWith('https://maps.googleapis.com/')) {
  1172. //asScript.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyDqRTXlnHXELLKn7645Q1L_5oc4CswKZK4&v=3&libraries=places,drawing&language=ja&region=JP"
  1173. return asScript
  1174. }
  1175. }
  1176. }
  1177. return null
  1178. }
  1179.  
  1180. function injecter(overrider) {
  1181. if (document.documentElement)
  1182. {
  1183. injecterCallback(overrider);
  1184. }
  1185. else
  1186. {
  1187. alert("Script didn't load, refresh to try loading the script");
  1188. }
  1189. }
  1190.  
  1191.  
  1192. function injecterCallback(overrider)
  1193. {
  1194. new MutationObserver((mutations, observer) => {
  1195. const googleScript = grabGoogleScript(mutations)
  1196. if (googleScript) {
  1197. overrideOnLoad(googleScript, observer, overrider)
  1198. }
  1199. }).observe(document.documentElement, { childList: true, subtree: true })
  1200. }
  1201.  
  1202. function magic_formula(boundary)
  1203. {
  1204. let area = Math.abs((boundary[0] - boundary[2]) * (boundary[1] - boundary[3]))
  1205. // console.log(boundary);
  1206. // console.log(area);
  1207. let dist = Math.pow((area / 50000), 0.25) * 20000
  1208. if (dist < 250) dist = 250
  1209. return dist
  1210. }
  1211.  
  1212. function formatDist()
  1213. {
  1214. if (ms_radius > 999)
  1215. {
  1216. let d = ms_radius / 1000.0;
  1217. return parseFloat(d.toPrecision(2)).toString() + "km";
  1218. }
  1219. else
  1220. {
  1221. let d = ms_radius;
  1222. return parseFloat(d.toPrecision(3)).toString() + "m";
  1223. }
  1224. }
  1225.  
  1226. // Getter function for the button elements
  1227.  
  1228. function setButtons()
  1229. {
  1230. return [document.getElementById("Teleport Forward"), document.getElementById("Teleport Reverse"), document.getElementById("Teleport Button"), document.getElementById("plus"), document.getElementById("minus"),
  1231. document.getElementById("reset"), document.getElementById("switch"), document.getElementById("Show Buttons"),
  1232. document.getElementById("Date Button"), document.getElementById("minus year"), document.getElementById("plus year"),
  1233. document.getElementById("Teleport Options Button"), document.getElementById("Satellite Switch"),
  1234. document.getElementById("Restrict Bounds Main"),
  1235. document.getElementById("Restrict Distance"), document.getElementById("Increase Restrict Distance"),
  1236. document.getElementById("Decrease Restrict Distance"), document.getElementById("Restrict Bounds Enable"),
  1237. document.getElementById("Restrict Distance Reset")];
  1238. }
  1239.  
  1240. function setButtons2()
  1241. {
  1242. return [document.getElementById("Show Buttons"),
  1243. document.getElementById("Youtube Button"),
  1244. document.getElementById("Info Menu"),
  1245. document.getElementById("Teleport Menu"),
  1246. document.getElementById("Satellite Menu"),
  1247. document.getElementById("Mosaic Menu"),
  1248. document.getElementById("Minimap Menu Button"),
  1249. document.getElementById("Space Menu Button"),
  1250. document.getElementById("Time Machine Button"),
  1251. document.getElementById("Circus Menu"),
  1252. ];
  1253. }
  1254.  
  1255. function setButtons3()
  1256. {
  1257. // Added by EC - same as setButtons2 but with out youtube button.
  1258. return [document.getElementById("Show Buttons"),
  1259. document.getElementById("Info Menu"),
  1260. document.getElementById("Teleport Menu"),
  1261. document.getElementById("Satellite Menu"),
  1262. document.getElementById("Mosaic Menu"),
  1263. document.getElementById("Minimap Menu Button"),
  1264. document.getElementById("Space Menu Button"),
  1265. document.getElementById("Time Machine Button"),
  1266. document.getElementById("Circus Menu"),
  1267. ];
  1268. }
  1269.  
  1270. // Store default position for the button elements
  1271.  
  1272. function btnPosFinal(element)
  1273. {
  1274. if (element.id !== "Show Buttons")
  1275. {
  1276. if (element.classList.contains("menu-btn"))
  1277. {
  1278. element.style.right = "0.5em";
  1279. }
  1280.  
  1281. if (element.classList.contains("full") || element.classList.contains("extra-full"))
  1282. {
  1283. element.style.right = "4em";
  1284. }
  1285. else if (element.classList.contains("half"))
  1286. {
  1287. if (element.classList.contains("horizontal-1"))
  1288. {
  1289. element.style.right = "4em";
  1290. }
  1291. else if (element.classList.contains("horizontal-2"))
  1292. {
  1293. element.style.right = "11.75em";
  1294. }
  1295. else if (element.classList.contains("horizontal-3"))
  1296. {
  1297. element.style.right = "19.5em";
  1298. }
  1299. }
  1300. else if (element.classList.contains("small"))
  1301. {
  1302. if (element.classList.contains("horizontal-1"))
  1303. {
  1304. element.style.right = "17em";
  1305. }
  1306. else if (element.classList.contains("horizontal-3"))
  1307. {
  1308. element.style.right = "4em";
  1309. }
  1310. else if (element.classList.contains("horizontal-sp"))
  1311. {
  1312. element.style.right = "14.5em";
  1313. }
  1314. }
  1315. else if (element.classList.contains("large"))
  1316. {
  1317. element.style.right = "6.5em";
  1318. }
  1319. else if (element.classList.contains("lgMinus"))
  1320. {
  1321. element.style.right = "6.5em";
  1322. }
  1323.  
  1324. if (element.classList.contains("vertical-0"))
  1325. {
  1326. element.style.top = "6em";
  1327. }
  1328. else if (element.classList.contains("vertical-1"))
  1329. {
  1330. element.style.top = "9.5em";
  1331. }
  1332. else if (element.classList.contains("vertical-2"))
  1333. {
  1334. element.style.top = "12em";
  1335. }
  1336. else if (element.classList.contains("vertical-3"))
  1337. {
  1338. element.style.top = "14.5em";
  1339. }
  1340. else if (element.classList.contains("vertical-4"))
  1341. {
  1342. element.style.top = "17em";
  1343. }
  1344. else if (element.classList.contains("vertical-5"))
  1345. {
  1346. element.style.top = "19.5em";
  1347. }
  1348. else if (element.classList.contains("vertical-6"))
  1349. {
  1350. element.style.top = "22em";
  1351. }
  1352. else if (element.classList.contains("vertical-7"))
  1353. {
  1354. element.style.top = "24.5em";
  1355. }
  1356. }
  1357. }
  1358.  
  1359. function handleDropdown()
  1360. {
  1361. function dropdownHelper1(nm, val)
  1362. {
  1363. let hC = 0
  1364. for (let mapDiv of document.getElementsByClassName(nm)){
  1365. mapDiv.style.top = (val + (hC * 1.65)).toString() + "em";
  1366. hC++;
  1367. }
  1368. }
  1369.  
  1370. // let classN = ["preset-minimap", "overlay-minimap", "space-mainmap", "space-minimap"]
  1371. let classN = ["preset-minimap", "overlay-minimap", "space-minimap", "space-2minimap", "space-3minimap"]
  1372. for (let x of classN)
  1373. {
  1374. dropdownHelper1(x, 11.85);
  1375. }
  1376. let classN2 = ["grid-size", "grid-opt", "satellite-style", "satellite-type"];
  1377. for (let x of classN2)
  1378. {
  1379. dropdownHelper1(x, 14.1);
  1380. }
  1381. allowDetect = true;
  1382. }
  1383.  
  1384. function resetBtnPos()
  1385. {
  1386. let [
  1387. mainMenuBtn,
  1388. YoutubeBtn,
  1389. infoMenu,
  1390. teleportMenu,
  1391. satelliteMenu,
  1392. mosaicMenu,
  1393. MinimapMenuBtn,
  1394. SpaceMenuBtn,
  1395. ClockMenuBtn,
  1396. SpecialMapMenuBtn
  1397. ] = setButtons2();
  1398.  
  1399. // Manu Buttons
  1400.  
  1401. mainMenuBtn.style.top = "6em";
  1402. YoutubeBtn.style.top = "6em";
  1403. infoMenu.style.top = "9.5em";
  1404. teleportMenu.style.top = "12.5em";
  1405. MinimapMenuBtn.style.top = "15.5em";
  1406. satelliteMenu.style.top = "18.5em";
  1407. SpaceMenuBtn.style.top = "21.5em";
  1408. mosaicMenu.style.top = "24.5em";
  1409. ClockMenuBtn.style.top = "27.5em";
  1410. SpecialMapMenuBtn.style.top = "30.5em";
  1411.  
  1412. mainMenuBtn.style.right = "0.5em";
  1413. mainMenuBtn.style.width = "3em";
  1414.  
  1415. for (let element of document.getElementsByClassName("unity-btn")){
  1416. btnPosFinal(element);
  1417. }
  1418. handleDropdown();
  1419.  
  1420. }
  1421.  
  1422. // Adjust Buttons for different game modes
  1423.  
  1424. function AdjustBtnPos(top, right, arg)
  1425. {
  1426. if (arg)
  1427. {
  1428. resetBtnPos();
  1429. }
  1430. for (let element of document.getElementsByClassName("unity-btn")){
  1431. let eTop = element.style.top;
  1432. let eRight = element.style.right;
  1433. element.style.top = "calc(" + top.toString() + " + " + eTop + ")";
  1434. element.style.right = "calc(" + right.toString() + " + " + eRight + ")";
  1435. // console.log(element.style.top)
  1436. }
  1437. }
  1438.  
  1439. function handleStyles()
  1440. {
  1441. let unityCSS =
  1442. `visibility:hidden;
  1443. border-radius: 25px;
  1444. height:2em;
  1445. position:fixed;
  1446. z-index:99990;
  1447. background-color: #ba55d3cc;
  1448. box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
  1449. border: none;
  1450. color: white;
  1451. padding: none;
  1452. text-align: center;
  1453. vertical-align: text-top;
  1454. text-decoration: none;
  1455. display: inline-block;
  1456. font-size: 16px;`;
  1457.  
  1458. for (let element of document.getElementsByClassName("unity-btn")){
  1459. if (element.id !== "Show Buttons")
  1460. {
  1461. element.style = unityCSS;
  1462. // const classNames = ["preset-minimap", "overlay-minimap", "satellite-style", "satellite-type", "space-mainmap", "space-minimap"]
  1463. const classNames = ["preset-minimap", "overlay-minimap", "satellite-style", "satellite-type", "space-minimap","space-2minimap","space-3minimap", "grid-size", "grid-opt"]
  1464. if (classNames.some(className => element.classList.contains(className)))
  1465. {
  1466. element.style.height = "1.5em";
  1467. element.style.background = "#ff69b4cc";
  1468. if (["Clear", "Default", "Earth", "Grid 0"].includes(element.id))
  1469. {
  1470. if (element.id == "Clear")
  1471. {
  1472. element.loaded = true;
  1473. }
  1474. element.style.background = "#ff1493cc";
  1475. }
  1476. }
  1477.  
  1478. if (element.classList.contains("menu-btn"))
  1479. {
  1480. element.style.width = "3em";
  1481. element.style.height = "2.5em";
  1482. // element.style.borderStyle = "solid";
  1483. // element.style.borderWidth = "0.1px"
  1484. // element.style.borderColor = "black";
  1485.  
  1486. }
  1487.  
  1488. if (element.classList.contains("special-map-btn") && !element.classList.contains("full"))
  1489. {
  1490. element.style.background = "#ff69b4cc";
  1491. }
  1492.  
  1493. if (element.classList.contains("extra-height"))
  1494. {
  1495. element.style.height = "4.5em";
  1496. }
  1497.  
  1498. if (element.classList.contains("extra-full"))
  1499. {
  1500. element.style.width = "22.75em";
  1501. }
  1502. else if (element.classList.contains("full"))
  1503. {
  1504. element.style.width = "15em";
  1505. }
  1506. else if (element.classList.contains("half"))
  1507. {
  1508. element.style.width = "7.25em";
  1509. }
  1510. else if (element.classList.contains("small"))
  1511. {
  1512. element.style.width = "2em";
  1513. }
  1514. else if (element.classList.contains("large"))
  1515. {
  1516. element.style.width = "10em";
  1517. }
  1518. else if (element.classList.contains("lgMinus"))
  1519. {
  1520. element.style.width = "7.5em";
  1521. }
  1522. btnPosFinal(element);
  1523. }
  1524. }
  1525.  
  1526. let dict = {
  1527. 'Info Menu': ["url(https://www.svgrepo.com/show/299161/big-data.svg)", "#ff9999"],
  1528. 'Teleport Menu': ["url(https://www.svgrepo.com/show/12767/car.svg)", "#ffcba4"],
  1529. "Time Machine Button": ["url(https://www.svgrepo.com/show/38630/clock.svg)", "#D8BFD8"],
  1530. 'Minimap Menu Button': ["url(https://www.svgrepo.com/show/116365/map.svg)", "#faf0be"],
  1531. 'Mosaic Menu': ["url(https://www.svgrepo.com/show/77240/map.svg)", "#E6E6FA"],
  1532. 'Satellite Menu': ["url(https://www.svgrepo.com/show/29288/satellite.svg)", "#e8f48c"],
  1533. 'Space Menu Button': ["url(https://www.svgrepo.com/show/120980/saturn.svg)", "#e0ffff"],
  1534. 'Circus Menu': ["url(https://www.svgrepo.com/show/296852/circus.svg)", "#ff99c2"],
  1535. };
  1536.  
  1537. for (let element of document.getElementsByClassName("menu-btn"))
  1538. {
  1539. element.style.backgroundImage = dict[element.id][0];
  1540. element.style.backgroundColor = dict[element.id][1];
  1541. element.style.backgroundRepeat = "no-repeat";
  1542. element.style.backgroundOrigin = "content-box";
  1543. element.style.backgroundSize = "50%";
  1544. element.style.backgroundPositionX = "50%";
  1545. element.style.backgroundPositionY = "50%";
  1546. element.style.visibility = "";
  1547. }
  1548.  
  1549. handleDropdown();
  1550. }
  1551.  
  1552. /**
  1553. * Creates Unity buttons
  1554. *
  1555. * @returns Promise
  1556. */
  1557.  
  1558. function hideOtherBtn()
  1559. {
  1560. for (let element of document.getElementsByClassName("unity-btn")){
  1561. if (element.id !== "Show Buttons")
  1562. {
  1563. if (!element.styleTop){
  1564. element.styleTop = element.style.top;
  1565. }
  1566. clearTimeout(element._timer);
  1567.  
  1568. element.style.transition = "0.2s top ease";
  1569. element.style.top = "calc(6em)";
  1570. element._timer = setTimeout(()=>{
  1571. element.style.visibility = "hidden";
  1572. element.style.transition = "";
  1573. }, 950)
  1574.  
  1575. if (!element.classList.contains("menu-btn")) { element.style.visibility = "hidden"; }
  1576. }
  1577. if (nextPlayer == "Youtube" && element.classList.contains("youtube-btn"))
  1578. {
  1579. element.style.visibility = "";
  1580. }
  1581. if (nextPlayer == "Wikipedia" && (element.id == "local language" || element.id == "wikiXplore_btn"))
  1582. {
  1583. element.style.visibility = "";
  1584. }
  1585. }
  1586. }
  1587.  
  1588. function switchBtn(arg)
  1589. {
  1590. for (let element of document.getElementsByClassName("unity-btn")){
  1591. if (element.id !== "Show Buttons" && !element.classList.contains("menu-btn") && !element.classList.contains(arg))
  1592. {
  1593. element.style.visibility = "hidden";
  1594. }
  1595. if (nextPlayer == "Youtube" && element.classList.contains("youtube-btn"))
  1596. {
  1597. element.style.visibility = "";
  1598. }
  1599. if (nextPlayer == "Wikipedia" && (element.id == "local language" || element.id == "wikiXplore_btn"))
  1600. {
  1601. element.style.visibility = "";
  1602. }
  1603. }
  1604. }
  1605.  
  1606. function getVar(argm)
  1607. {
  1608. if (argm == "Weather")
  1609. {
  1610. return Weather;
  1611. }
  1612. else if (argm == "Building")
  1613. {
  1614. return Building;
  1615. }
  1616. else if (argm == "Dimension")
  1617. {
  1618. return Dimension;
  1619. }
  1620. else if (argm == "mapSty")
  1621. {
  1622. return mapSty;
  1623. }
  1624. else
  1625. {
  1626. return false;
  1627. }
  1628. }
  1629.  
  1630. function setVar(argm)
  1631. {
  1632. if (argm == "Weather")
  1633. {
  1634. Weather = !Weather;
  1635. }
  1636. else if (argm == "Building")
  1637. {
  1638. Building = !Building;
  1639. }
  1640. else if (argm == "Dimension")
  1641. {
  1642. Dimension = !Dimension;
  1643.  
  1644. // Added by EC
  1645. localStorage["Satallite_2D_3D_setting"] = Dimension === true? "3D" : "2D";
  1646. }
  1647. else if (argm == "mapSty")
  1648. {
  1649. mapSty = !mapSty;
  1650. }
  1651. }
  1652.  
  1653. function handleSatColor(cond1, cond2)
  1654. {
  1655. // Added by EC: Button innerHTML and background color is added in this function.
  1656.  
  1657. let sC = document.getElementById("Satellite Type Button");
  1658. if (cond1)
  1659. {
  1660. for (let element of satType)
  1661. {
  1662. let ele0 = document.getElementById(element[0]);
  1663. let strNmHere;
  1664. if (ele0.id !== "SunPos")
  1665. {
  1666. strNmHere = getVar(ele0.id);
  1667. }
  1668. else
  1669. {
  1670. strNmHere = ele0.id;
  1671. }
  1672. if (strNmHere)
  1673. {
  1674. ele0.innerHTML = element[1];
  1675. ele0.style.background = "#ff1493cc";
  1676. }
  1677. else
  1678. {
  1679. ele0.innerHTML = element[2];
  1680. ele0.style.background = "#ff69b4cc";
  1681. }
  1682. }
  1683. }
  1684. if (cond2)
  1685. {
  1686. for (let element of document.getElementsByClassName("satellite-style")){
  1687. if (element.id == sC.currentTime)
  1688. {
  1689. element.style.background = "#ff1493cc";
  1690. }
  1691. else
  1692. {
  1693. element.style.background = "#ff69b4cc";
  1694. }
  1695. }
  1696. }
  1697. }
  1698.  
  1699. function enterChaosMode(heading)
  1700. {
  1701. if (heading === -999)
  1702. {
  1703. try
  1704. {
  1705. heading = GooglePlayer.getPhotographerPov().heading;
  1706. }
  1707. catch (e) {
  1708. heading = 0;
  1709. }
  1710. }
  1711. setTimeout(
  1712. function()
  1713. {
  1714. let hdn = heading;
  1715. let pch = GooglePlayer.getPhotographerPov().pitch;
  1716. if (randomSpecial)
  1717. {
  1718. hdn = Math.random() * 360;
  1719. }
  1720. else if (skewedSpecial)
  1721. {
  1722.  
  1723. hdn = (GooglePlayer.getPhotographerPov().heading + 90) % 360;
  1724. }
  1725.  
  1726. if (randomSpecial)
  1727. {
  1728. pch = Math.random() * 180 - 90;
  1729. }
  1730. else if (soilSpecial)
  1731. {
  1732. pch = -60;
  1733. }
  1734. else if (skySpecial)
  1735. {
  1736. pch = 90;
  1737. }
  1738. GooglePlayer.setPov({ heading: hdn, pitch: pch});
  1739. }
  1740. , 300);
  1741. setTimeout(function() {
  1742. let zmn = 0;
  1743. if (randomSpecial)
  1744. {
  1745. zmn = Math.random() * 3;
  1746. }
  1747. else if (zoomSpecial)
  1748. {
  1749. zmn = 4;
  1750. }
  1751. GooglePlayer.setZoom(zmn);
  1752. }, 300);
  1753. }
  1754.  
  1755. function UnityInitiate() {
  1756. const google = window.google;
  1757. let curPosition;
  1758. let kakao_enabled = true;
  1759.  
  1760. ZoomControls();
  1761.  
  1762. function svCheck(data, status) {
  1763. if (status === 'OK') {
  1764. // console.log("STATUS OK");
  1765. let l = data.location.latLng.toString().split(',');
  1766. let lat = l[0].replaceAll('(', '');
  1767. let lng = l[1].replaceAll(')', '');
  1768. if (lat == curPosition.lat && lng == curPosition.lng && !switch_call)
  1769. {
  1770. console.log("Trying more distance");
  1771. teleportMain.distance += 100;
  1772. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1773. }
  1774. else
  1775. {
  1776. // console.log("Teleport Success");
  1777. let hd = 0;
  1778. if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Bing Streetside" || nextPlayer === "Mapy")
  1779. {
  1780. hd = switchCovergeButton.heading;
  1781. }
  1782. GooglePlayer.setPosition(data.location.latLng);
  1783. if (hd !== 0)
  1784. {
  1785. GooglePlayer.setPov({
  1786. heading: hd,
  1787. pitch: 0,
  1788. })
  1789. }
  1790. else
  1791. {
  1792. GooglePlayer.setPov({
  1793. heading: switchCovergeButton.heading,
  1794. pitch: 0,
  1795. })
  1796. }
  1797. if (teleportMain.distance > 150)
  1798. {
  1799. teleportMain.distance = 100;
  1800. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1801. }
  1802. }
  1803. switch_call = false;
  1804. }
  1805. else {
  1806. console.log("STATUS NOT OK");
  1807. teleportMain.distance += 100;
  1808. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  1809. }
  1810. }
  1811.  
  1812. google.maps.Map = class extends google.maps.Map {
  1813. constructor(...args) {
  1814. super(...args);
  1815.  
  1816. GoogleMapsObj = this;
  1817.  
  1818. if (GeoJsonCustomUser)
  1819. {
  1820. if (GeoJsonCustomUser)
  1821. {
  1822. this.data.addGeoJson(CUSTOM_GEOJSON);
  1823. }
  1824. this.data.setStyle(function(feature) {
  1825. return GEOJSON_STYLE
  1826. });
  1827. }
  1828. if (OverlayCustom)
  1829. {
  1830. let customOverlay = new google.maps.GroundOverlay(OVERLAY_URL, OVERLAY_BOUNDS, OVERLAY_STYLE);
  1831. customOverlay.setMap(this);
  1832. }
  1833.  
  1834. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  1835. google.maps.event.addDomListener(mapDiv, "click", () => {
  1836. // Create click handler for mini-map buttons.
  1837. this.unity_is_blocking_style_changes = false;
  1838. MinimapBtn.current = mapDiv.id;
  1839. if (mapDiv.id == "Hybrid")
  1840. {
  1841. this.setMapTypeId('hybrid');
  1842. }
  1843. else if (mapDiv.id == "Terrain")
  1844. {
  1845. this.setMapTypeId('terrain');
  1846. }
  1847. else if (mapDiv.id == "Satellite")
  1848. {
  1849. this.setMapTypeId('satellite');
  1850. }
  1851. else if (mapDiv.id == "Custom")
  1852. {
  1853. this.setMapTypeId(customMode);
  1854. }
  1855. else if (mapDiv.id == "Country Streak")
  1856. {
  1857. // Created by EC.
  1858. initCountryStreakCounter();
  1859. }
  1860. else if (mapDiv.id == "RMC")
  1861. {
  1862. // Created by EC.
  1863. initRandomMapChallenge();
  1864. }
  1865. else
  1866. {
  1867. this.setMapTypeId('roadmap');
  1868. }
  1869.  
  1870. // this.setTilt(45);
  1871. for (let ar of presetMinimap)
  1872. {
  1873. if (ar[1] == mapDiv.id)
  1874. {
  1875.  
  1876. if (!this.set.alreadySet){
  1877.  
  1878. this.set.alreadySet = true;
  1879. let p = this.set;
  1880. this.set = function(...args){
  1881. // Total hack by EC, because I can't be bothered with this
  1882. // unpaid "job".
  1883. // Prevents map style from changing once set by this script.
  1884. // So if map style is set to "Easy 5k", it won't change.
  1885. if ((args[0] === 'styles' || args[0] === "mapTypeId")){
  1886. if (args[2] !== "unity" && this.unity_is_blocking_style_changes){
  1887. return;
  1888. }
  1889. }
  1890. p.apply(this, args);
  1891. }
  1892. }
  1893.  
  1894. this.unity_is_blocking_style_changes = ar[1] === 'Default'? false: true;
  1895.  
  1896. this.set('styles', ar[0], "unity");
  1897. }
  1898. }
  1899. for (let element of document.getElementsByClassName("preset-minimap")){
  1900. if (element.id == MinimapBtn.current)
  1901. {
  1902. element.style.background = "#ff1493cc";
  1903. }
  1904. else
  1905. {
  1906. element.style.background = "#ff69b4cc";
  1907. }
  1908. if (rtded || nextPlayer == "Planets") {
  1909. if (["Borders", "Satellite", "Terrain", "Hybrid", "Custom"].includes(element.id))
  1910. {
  1911. element.style.backgroundColor = "red";
  1912. element.disabled = true;
  1913. }
  1914. }
  1915. }
  1916. });
  1917. }
  1918.  
  1919. for (let mapDiv of document.getElementsByClassName("overlay-minimap")){
  1920. google.maps.event.addDomListener(mapDiv, "click", () => {
  1921. OverlayBtn.current = mapDiv.id;
  1922. // console.log(mapDiv.url)
  1923. // console.log(mapDiv.id)
  1924. // console.log(mapDiv.loaded)
  1925. if (!mapDiv.loaded)
  1926. {
  1927. this.data.loadGeoJson(mapDiv.url, {
  1928. id: mapDiv.id
  1929. });
  1930. mapDiv.loaded = true;
  1931. }
  1932. if (mapDiv.id == "Clear")
  1933. {
  1934. this.overlayMapTypes.clear();
  1935. this.data.setStyle(function(feature) {
  1936. return GEOJSON_INVISIBLE
  1937. });
  1938. for (let element of document.getElementsByClassName("overlay-minimap")){
  1939. if (element.id === "Clear")
  1940. {
  1941. element.style.background = "#ff1493cc";
  1942. }
  1943. else
  1944. {
  1945. element.style.background = "#ff69b4cc";
  1946. if (["Coverage", "Official", "OSM"].includes(element.id))
  1947. {
  1948. if (rtded || nextPlayer == "Planets")
  1949. {
  1950. element.style.background = "red";
  1951. }
  1952. }
  1953. if (["Coverage", "Official", "City Lights", "OSM", "Watercolor", "Toner", "Fire", "Choekaas.no"].includes(element.id))
  1954. {
  1955. element.loaded = false;
  1956. }
  1957. }
  1958. }
  1959. }
  1960. else
  1961. {
  1962. if (["Coverage", "Official", "City Lights", "OSM", "Watercolor", "Toner", "Fire", "Choekaas.no"].includes(mapDiv.id))
  1963. {
  1964. this.overlayMapTypes.clear();
  1965. const coverageLayer = new google.maps.ImageMapType({
  1966. getTileUrl ({ x, y }, z) {
  1967.  
  1968. // Omits photospheres
  1969. // return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:apiv3&style=5,8&x=${x}&y=${y}&z=${z}`
  1970.  
  1971. // Omits unofficial and trekker, but also half of mongolia
  1972.  
  1973. if (mapDiv.id == "Official") {
  1974. return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:app&style=5,8&x=${x}&y=${y}&z=${z}`
  1975. } else if (mapDiv.id == "OSM") {
  1976. return `https://tile.openstreetmap.org/${z}/${x}/${y}.png`
  1977. } else if (mapDiv.id == "City Lights") {
  1978. return `https://map1.vis.earthdata.nasa.gov/wmts-webmerc/VIIRS_CityLights_2012/default/{time}/GoogleMapsCompatible_Level8/${z}/${y}/${x}.jpg`
  1979. } else if (mapDiv.id == "Watercolor") {
  1980. return `https://tiles.stadiamaps.com/tiles/stamen_watercolor/${z}/${x}/${y}.jpg`
  1981. //return `https://stamen-tiles.a.ssl.fastly.net/watercolor/${z}/${x}/${y}.jpg`
  1982. } else if (mapDiv.id == "Toner") {
  1983. return `https://stamen-tiles.a.ssl.fastly.net/toner/${z}/${x}/${y}.png`
  1984. } else if (mapDiv.id == "Fire") {
  1985. return `https://tile.thunderforest.com/spinal-map/${z}/${x}/${y}.png?apikey=1360c6d2440c4202bf725238d1b9c761`
  1986. }
  1987. // 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`
  1988.  
  1989. // Includes everything
  1990. else if (mapDiv.id == "Coverage") {
  1991. 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`
  1992. }
  1993. },
  1994. maxZoom: 20,
  1995. tileSize: new google.maps.Size(256, 256),
  1996. })
  1997. this.overlayMapTypes.push(coverageLayer);
  1998.  
  1999. // let other = "Official";
  2000. // if (mapDiv.id == "Official")
  2001. // {
  2002. // other = "Coverage";
  2003. // }
  2004.  
  2005. for (let element of document.getElementsByClassName("overlay-minimap")){
  2006. if (["Clear", "City Lights", "Watercolor", "Toner", "Fire", "Choekaas.no"].includes(element.id))
  2007. {
  2008. element.style.background = "#ff69b4cc";
  2009. element.loaded = false;
  2010. }
  2011. if (["Coverage", "Official", "OSM"].includes(element.id))
  2012. {
  2013. if (!rtded && nextPlayer !== "Planets")
  2014. {
  2015. element.style.background = "#ff69b4cc";
  2016. element.loaded = false;
  2017. }
  2018. }
  2019. }
  2020. mapDiv.style.background = "#ff1493cc";
  2021. mapDiv.loaded = true;
  2022. }
  2023. else
  2024. {
  2025. this.data.setStyle(function(feature) {
  2026. return GEOJSON_STYLE
  2027. });
  2028. for (let element of document.getElementsByClassName("overlay-minimap")){
  2029. if (element.id !== "Clear" && element.loaded)
  2030. {
  2031. element.style.background = "#ff1493cc";
  2032. }
  2033. else
  2034. {
  2035. element.style.background = "#ff69b4cc";
  2036. }
  2037. if (["Coverage", "Official", "OSM"].includes(element.id))
  2038. {
  2039. if (rtded || nextPlayer == "Planets")
  2040. {
  2041. element.style.background = "red";
  2042. }
  2043. }
  2044.  
  2045. }
  2046. }
  2047. }
  2048. });
  2049. }
  2050.  
  2051. for (let spMini of document.getElementsByClassName("spaceMM")) {
  2052. google.maps.event.addDomListener(spMini, "click", () => {
  2053. OverlayBtn.current = spMini.id;
  2054. setMapstylePlanet(planetType);
  2055. if (spMini.id == "Earth") {
  2056. this.overlayMapTypes.clear();
  2057. this.setMapTypeId('roadmap');
  2058. this.set('styles', default_preset);
  2059. // for (let element of document.getElementsByClassName("space-minimap")) {
  2060. // if (element.id === spMini.id) {
  2061. // element.style.background = "#ff1493cc";
  2062. // }
  2063. // else {
  2064. // element.style.background = "#ff69b4cc";
  2065. // }
  2066. // }
  2067. }
  2068. else
  2069. {
  2070. this.set('styles', blank);
  2071. setTimeout(this.set('styles', blank), 1000)
  2072. this.overlayMapTypes.clear();
  2073. const coverageLayer = new google.maps.ImageMapType({
  2074. getTileUrl({ x, y }, z) {
  2075. if (spMini.id.includes("Moon") || spMini.id.includes("Mars"))
  2076. {
  2077. if (spMini.id.includes("Label")) {
  2078. return spMini.url + z + "/" + x + "/" + y + ".png";
  2079. }
  2080. else
  2081. {
  2082. y = Math.pow(2, z) - y - 1;
  2083. return spMini.url + z + "/" + x + "/" + y + ".png";;
  2084. }
  2085. }
  2086. else
  2087. {
  2088. return handleSpURL(spMini.url, x, y, z);;
  2089. }
  2090. },
  2091. maxZoom: 20,
  2092. tileSize: new google.maps.Size(256, 256),
  2093. })
  2094.  
  2095. this.overlayMapTypes.push(coverageLayer);
  2096.  
  2097. if (spMini.id == ("Mars (Labels)"))
  2098. {
  2099. const coverageLayer2 = new google.maps.ImageMapType({
  2100. getTileUrl({ x, y }, z) {
  2101. y = Math.pow(2, z) - y - 1;
  2102. return `http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/${z}/${x}/${y}.png`;
  2103. },
  2104. maxZoom: 20,
  2105. tileSize: new google.maps.Size(256, 256),
  2106. opacity: 0.5
  2107. })
  2108. this.overlayMapTypes.push(coverageLayer2);
  2109. }
  2110. }
  2111. for (let element of document.getElementsByClassName("spaceMM")) {
  2112. if (element.id === spMini.id) {
  2113. element.style.background = "#ff1493cc";
  2114. }
  2115. else if (element.id.includes(planetType)) {
  2116. element.style.background = "#ff69b4cc";
  2117. }
  2118. }
  2119. });
  2120. }
  2121.  
  2122.  
  2123. }
  2124.  
  2125. }
  2126.  
  2127. const svService = new google.maps.StreetViewService();
  2128. google.maps.StreetViewPanorama = class extends google.maps.StreetViewPanorama {
  2129. constructor(...args) {
  2130. super(...args);
  2131.  
  2132. GooglePlayer = this;
  2133.  
  2134. const path = getPathName();
  2135. const isGamePage = () => path.startsWith("/challenge/") || path.startsWith("/results/") ||
  2136. path.startsWith("/game/")|| path.startsWith("/battle-royale/") ||
  2137. path.startsWith("/duels/") || path.startsWith("/team-duels/") || path.startsWith("/bullseye/")
  2138. || path.startsWith("/live-challenge/");
  2139.  
  2140. // const isGamePage = () => location.pathname.startsWith("/challenge/") || location.pathname.startsWith("/results/") ||
  2141. // location.pathname.startsWith("/game/")|| location.pathname.startsWith("/battle-royale/") ||
  2142. // location.pathname.startsWith("/duels/") || location.pathname.startsWith("/team-duels/") || location.pathname.startsWith("/bullseye/")
  2143. // || location.pathname.startsWith("/live-challenge/");
  2144.  
  2145. this.addListener('position_changed', () => {
  2146. // Maybe this could be used to update the position in the other players
  2147. // so that they are always in sync
  2148.  
  2149. try {
  2150. if (!isGamePage()) return;
  2151. // timeMachineBtn.panoId = GooglePlayer.pano;
  2152. // timeMachineBtn.index = -1;
  2153. const lat = this.getPosition().lat();
  2154. const lng = this.getPosition().lng();
  2155. const { heading, pitch } = this.getPov();
  2156.  
  2157. if (skySpecial || soilSpecial || skewedSpecial || zoomSpecial || randomSpecial)
  2158. {
  2159. enterChaosMode(heading);
  2160. }
  2161.  
  2162. curPosition = { lat, lng, heading };
  2163.  
  2164. if (switchCovergeButton.useGoogle)
  2165. {
  2166. switchCovergeButton.lng = lng;
  2167. switchCovergeButton.lat = lat;
  2168. switchCovergeButton.heading = heading;
  2169. if (!timeMachineBtn.list.some(row => row.includes(GooglePlayer.pano)))
  2170. {
  2171. timeMachineBtn.innerHTML = "Time Machine";
  2172. timeMachineBtn.panoId = GooglePlayer.pano;
  2173. timeMachineBtn.index = -1;
  2174. timeMachineBtn.plusminusLock = true;
  2175. timeMachineNewerBtn.style.backgroundColor = "red";
  2176. timeMachineNewerBtn.disabled = true;
  2177. timeMachineOlderBtn.style.backgroundColor = "red";
  2178. timeMachineOlderBtn.disabled = true;
  2179. }
  2180. }
  2181. // switchCovergeButton.useGoogle = true;
  2182. teleportMain.google = true;
  2183.  
  2184.  
  2185. if (restrictMovement)
  2186. {
  2187. let dist = distance(lat, lng , global_lat, global_lng);
  2188. if (dist > RestrictBoundsBtn.maxDist)
  2189. {
  2190. let prevD = distance(RestrictBoundsBtn.lat, RestrictBoundsBtn.lng, global_lat, global_lng);
  2191. if (prevD > RestrictBoundsBtn.maxDist)
  2192. {
  2193. svService.getPanorama({ location: { lat: global_lat, lng: global_lng }, radius: 1000 }, svCheck);
  2194. RestrictBoundsBtn.lng = global_lng;
  2195. RestrictBoundsBtn.lat = global_lat;
  2196. }
  2197. else
  2198. {
  2199. svService.getPanorama({ location: { lat: RestrictBoundsBtn.lat, lng: RestrictBoundsBtn.lng }, radius: 1000 }, svCheck);
  2200. }
  2201. }
  2202. else
  2203. {
  2204. RestrictBoundsBtn.lng = lng;
  2205. RestrictBoundsBtn.lat = lat;
  2206. }
  2207. let d = Math.round(distance(RestrictBoundsBtn.lat, RestrictBoundsBtn.lng , global_lat, global_lng));
  2208. let pct = Math.round((d / RestrictBoundsBtn.maxDist*100));
  2209. RestrictBoundsBtn.innerHTML = "<font size=2>Straight Line Distance: " + d + "m (" + pct + "%)</font>";
  2210. }
  2211. }
  2212. catch (e) {
  2213. console.error("Error:", e);
  2214. }
  2215. });
  2216.  
  2217. this.addListener('pov_changed', () => {
  2218. const { heading, pitch } = this.getPov();
  2219. if (KakaoPlayer) {
  2220. if (typeof KakaoPlayer !== 'string' )
  2221. {
  2222. const vp = KakaoPlayer.getViewpoint();
  2223. // Prevent a recursive loop: only update kakao's viewpoint if it got out of sync with google's
  2224. if ((!almostEqual(vp.pan, heading) || !almostEqual(vp.tilt, pitch)) && nextPlayer == "Kakao") {
  2225. KakaoPlayer.setViewpoint({ pan: heading, tilt: pitch, zoom: vp.zoom });
  2226. }
  2227. }
  2228. }
  2229. });
  2230. }
  2231. };
  2232.  
  2233. document.head.insertAdjacentHTML(
  2234. // Added by EC. Can't do hover effects with out style sheet.
  2235. "beforeend",
  2236. `<style>
  2237. .unity-btn:not([class*="nonclickable"]):hover { scale: 0.95; } , "unity-btn-nonclickable"
  2238. </style>`);
  2239.  
  2240. var mainMenuBtn = document.createElement("Button");
  2241. mainMenuBtn.classList.add("unity-btn", "main-btn");
  2242. mainMenuBtn.id = "Show Buttons";
  2243. mainMenuBtn.hide = false;
  2244. mainMenuBtn.menuBtnCache = true;
  2245. mainMenuBtn.innerHTML = "<font size=2>Unity<br><font size=1 id='unity_version'>v7.4.2EC</font></font>";
  2246. mainMenuBtn.style =
  2247. "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;";
  2248. // document.querySelector(".game-layout__status").appendChild(mainMenuBtn)
  2249. document.body.appendChild(mainMenuBtn);
  2250. mainMenuBtn.addEventListener("click", () => {
  2251. if (mainMenuBtn.hide) {
  2252. for (let element of document.getElementsByClassName("unity-btn")){
  2253.  
  2254. if (!element.styleTop){
  2255. if (element.classList.contains("menu-btn")) { element.style.visibility = "";}
  2256. //element.styleTop = element.style.top;
  2257. continue;
  2258. }
  2259. clearTimeout(element._timer);
  2260.  
  2261. if (element.classList.contains("menu-btn")) { element.style.visibility = "";}
  2262.  
  2263. element.style.transition = "0.2s all ease";
  2264. element.style.top = element.styleTop;
  2265.  
  2266. element._timer = setTimeout(()=>{
  2267. element.style.transition = "";
  2268. }, 950)
  2269. }
  2270.  
  2271. mainMenuBtn.menuBtnCache = true;
  2272. mainMenuBtn.hide = false;
  2273. }
  2274. else {
  2275. hideOtherBtn();
  2276. mainMenuBtn.menuBtnCache = false;
  2277. mainMenuBtn.hide = true;
  2278. }
  2279. });
  2280.  
  2281. var infoBtn = document.createElement("Button");
  2282. infoBtn.classList.add("unity-btn", "info-btn", "full", "vertical-1", "extra-height", "unity-button-nonclickable");
  2283. infoBtn.id = "Info Button";
  2284. infoBtn.innerHTML = `Geoguessr Unity Script<font size=1><br>&#169; Jupaoqq | v${globalScriptVersion}</font>`;
  2285. document.body.appendChild(infoBtn);
  2286. // infoBtn.addEventListener("click", () => {
  2287. // window.open('https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing');
  2288. // });
  2289.  
  2290. var HelpBtn = document.createElement("Button");
  2291. HelpBtn.classList.add("unity-btn", "info-btn", "half", "horizontal-1", "vertical-3");
  2292. HelpBtn.id = "Help Button";
  2293. HelpBtn.innerHTML = "Help & Credits";
  2294. document.body.appendChild(HelpBtn);
  2295. HelpBtn.addEventListener("click", () => {
  2296. window.open('https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing');
  2297. });
  2298.  
  2299. var UpdateBtn = document.createElement("Button");
  2300. UpdateBtn.classList.add("unity-btn", "info-btn", "half", "horizontal-2", "vertical-3");
  2301. UpdateBtn.id = "Update Button";
  2302. UpdateBtn.innerHTML = "Check Update";
  2303.  
  2304. document.body.appendChild(UpdateBtn);
  2305. UpdateBtn.addEventListener("click", () => {
  2306. window.open('https://greatest.deepsurf.us/en/scripts/436813-geoguessr-unity-script');
  2307. });
  2308.  
  2309. var menuResetBtn = document.createElement("Button");
  2310. menuResetBtn.classList.add("unity-btn", "info-btn", "large", "vertical-4", "unity-btn-nonclickable");
  2311. menuResetBtn.id = "Menu Reset";
  2312. menuResetBtn.innerHTML = "Menu Position";
  2313. document.body.appendChild(menuResetBtn);
  2314. menuResetBtn.addEventListener("click", () => {
  2315. menuLocCounter = 0;
  2316. btnAll();
  2317. });
  2318.  
  2319. var menuUpBtn = document.createElement("Button");
  2320. menuUpBtn.classList.add("unity-btn", "info-btn", "small", "horizontal-1", "vertical-4");
  2321. menuUpBtn.id = "Menu Up";
  2322. menuUpBtn.innerHTML = "↑";
  2323. document.body.appendChild(menuUpBtn);
  2324. menuUpBtn.addEventListener("click", () => {
  2325. AdjustBtnPos("-2em", "0em", false);
  2326. menuLocCounter++;
  2327. });
  2328.  
  2329. var menuDownBtn = document.createElement("Button");
  2330. menuDownBtn.classList.add("unity-btn", "info-btn", "small", "horizontal-3", "vertical-4");
  2331. menuDownBtn.id = "Menu down";
  2332. menuDownBtn.innerHTML = "↓";
  2333. document.body.appendChild(menuDownBtn);
  2334. menuDownBtn.addEventListener("click", () => {
  2335. AdjustBtnPos("2em", "0em", false);
  2336. menuLocCounter--;
  2337. });
  2338.  
  2339. var unity_alert = document.createElement("Button");
  2340. unity_alert.classList.add("unity-btn", "unity_alert", "extra-full", "vertical-0");
  2341. unity_alert.id = "Unhackable Button";
  2342. unity_alert.innerHTML = `Unity Alert Message`;
  2343. document.body.appendChild(unity_alert);
  2344. unity_alert.addEventListener("click", unhackableAnsswersShowPrompt);
  2345.  
  2346. function unhackableAnsswersShowPrompt() {
  2347. // TODO EC
  2348. }
  2349.  
  2350. document.body.addEventListener('keydown', function(e){
  2351. if (e.altKey && e.key === 'u'){
  2352. unhackableAnsswersShowPrompt();
  2353. }
  2354. });
  2355.  
  2356. var infoMenu = document.createElement("Button");
  2357. infoMenu.classList.add("unity-btn", "menu-btn");
  2358. infoMenu.classList.add();
  2359. infoMenu.id = "Info Menu";
  2360. // infoMenu.innerHTML = "In";
  2361. document.body.appendChild(infoMenu);
  2362. infoMenu.addEventListener("click", () => {
  2363. switchBtn("info-btn");
  2364. if (menuDownBtn.style.visibility == "hidden")
  2365. {
  2366. for (let element of document.getElementsByClassName("info-btn"))
  2367. {
  2368. element.style.visibility = "";
  2369. }
  2370. }
  2371. else
  2372. {
  2373. for (let element of document.getElementsByClassName("info-btn"))
  2374. {
  2375. element.style.visibility = "hidden";
  2376. }
  2377. }
  2378. });
  2379.  
  2380. function handleCountries(locStr)
  2381. {
  2382. let locStr2 = "";
  2383.  
  2384. let hardCode = {"Finland": 3, "United Kingdom": 3, "France": 3, "Czech": 3, "Slovakia": 3};
  2385. if (["Finland", "United Kingdom", "France", "Czech", "Slovakia"].some(v => locStr.includes(v)))
  2386. {
  2387. let ll = locStr.split(",");
  2388. for (let [key, value] of Object.entries(hardCode)) {
  2389. if (locStr.includes(key))
  2390. {
  2391. for (let ct = 0; ct < value; ct++)
  2392. {
  2393. if (ct < ll.length)
  2394. {
  2395. locStr2 = locStr2 + ll[ct] + " ";
  2396. }
  2397. }
  2398. }
  2399. }
  2400. }
  2401. else if (["Poland", "Brazil", "Denmark"].some(v => locStr.includes(v)))
  2402. {
  2403. let ll = locStr.split(",");
  2404. // console.log(ll);
  2405. for (let ct = 0; ct < ll.length; ct++)
  2406. {
  2407. if (!["gmina", "Region"].some(v => ll[ct].includes(v)))
  2408. {
  2409. locStr2 = locStr2 + ll[ct] + " ";
  2410. }
  2411. }
  2412. }
  2413. else if (["Russia"].some(v => locStr.includes(v)))
  2414. {
  2415. let ll = locStr.split(",");
  2416. let index = 0;
  2417. for (let ct1 = ll.length - 1; ct1 >= 0; ct1--)
  2418. {
  2419. if (["District", "district", "Oblast", "Krai", "Municipality", "Urban Okrug"].some(v => ll[ct1].includes(v)) && !["Federal District"].some(v => ll[ct1].includes(v)))
  2420. {
  2421. index = ct1;
  2422. }
  2423. }
  2424. if (locStr.includes("Amur"))
  2425. {
  2426. index = 0;
  2427. }
  2428. for (let ct = index; ct < ll.length; ct++)
  2429. {
  2430. if (!["Federal District"].some(v => ll[ct].includes(v)))
  2431. {
  2432. locStr2 = locStr2 + ll[ct] + " ";
  2433. }
  2434. }
  2435. }
  2436. else
  2437. {
  2438. locStr2 = locStr;
  2439. }
  2440.  
  2441. const toStrip = ["Região Geográfica Intermediária de", "Região Geográfica Imediata de", "Região Imediata de", "Região Metropolitana de",
  2442. "Voivodeship", "okres", "kraj", "Oblast", "Krai", "Urban Okrug", "Hromada", "Urban Hromada", "Raion", "Settlement",
  2443. "Metropolitan Municipality", "Municipality", "Municipal", "Administrative", "District", "Subdistrict", "Province", "Regional", "Council", "Township", "Department", "Local",
  2444. "Département de", "Arrondissement de", "Communauté rurale de",
  2445. "Municipio de", "Municipio", "Departamento", "Provincia de", "Provincia", " of"];
  2446. toStrip.forEach(x => {
  2447. locStr2 = locStr2.replaceAll(x, '');
  2448. });
  2449.  
  2450. if (!locStr2.includes("United States"))
  2451. {
  2452. locStr2 = locStr2.replaceAll("County", '');
  2453. }
  2454.  
  2455. if (!locStr2.includes("Botswana"))
  2456. {
  2457. locStr2 = locStr2.replaceAll("Region", '');
  2458. }
  2459.  
  2460. if (playYoutubeBtn.travel)
  2461. {
  2462. console.log("travel video")
  2463. locStr2 += customWord;
  2464. }
  2465. else
  2466. {
  2467. console.log("Any video")
  2468. }
  2469.  
  2470. return locStr2;
  2471. }
  2472.  
  2473. function moduleHandleYoutube()
  2474. {
  2475. // console.log(youtubeList);
  2476. let iframe = document.getElementById("i_container");
  2477. if (youtubeIndex !== -1)
  2478. {
  2479. yId = youtubeList[youtubeIndex];
  2480. }
  2481.  
  2482. let srcString = "https://www.youtube.com/embed/" + yId + "?&playlist=" + yId + "&autoplay=1&modestbranding=1&controls=0";
  2483.  
  2484. if (yTime !== "0")
  2485. {
  2486. srcString += "&start=" + yTime;
  2487. }
  2488. if (yEnd)
  2489. {
  2490. if (yEnd !== "0")
  2491. {
  2492. srcString += "&end=" + yEnd;
  2493. }
  2494. }
  2495. iframe.src = srcString;
  2496. iframe.style.visibility = "";
  2497. playYoutubeBtn.innerHTML = `Check | [${youtubeIndex + 1}]`;
  2498. }
  2499.  
  2500. var youtubeResetBtn = document.createElement("Button");
  2501. youtubeResetBtn.classList.add("unity-btn", "youtube-btn", "small", "horizontal-1", "vertical-0");
  2502. youtubeResetBtn.id = "Youtube Reset";
  2503. youtubeResetBtn.innerHTML = "&#8635;";
  2504. document.body.appendChild(youtubeResetBtn);
  2505. youtubeResetBtn.addEventListener("click", () => {
  2506. if (youtubeIndex !== -1 && youtubeIndex < youtubeList.length - 1)
  2507. {
  2508. moduleHandleYoutube();
  2509. }
  2510. });
  2511.  
  2512. var youtubeRandomBtn = document.createElement("Button");
  2513. youtubeRandomBtn.classList.add("unity-btn", "youtube-btn", "small", "horizontal-sp", "vertical-0");
  2514. youtubeRandomBtn.id = "Youtube Random";
  2515. youtubeRandomBtn.innerHTML = "&#8677;";
  2516. document.body.appendChild(youtubeRandomBtn);
  2517. youtubeRandomBtn.addEventListener("click", () => {
  2518. if (youtubeIndex !== -1 && youtubeIndex < youtubeList.length - 1)
  2519. {
  2520. youtubeIndex++;
  2521. moduleHandleYoutube();
  2522. }
  2523. });
  2524.  
  2525. var youtubeTravelBtn = document.createElement("Button");
  2526. youtubeTravelBtn.classList.add("unity-btn", "youtube-btn", "small", "horizontal-3", "vertical-0");
  2527. youtubeTravelBtn.id = "Youtube Travel";
  2528. youtubeTravelBtn.innerHTML = "<font size=2>Trip</font>";
  2529. document.body.appendChild(youtubeTravelBtn);
  2530. youtubeTravelBtn.addEventListener("click", () => {
  2531. if (playYoutubeBtn.travel)
  2532. {
  2533. playYoutubeBtn.travel = false;
  2534. youtubeTravelBtn.innerHTML = "<font size=2>Any</font>";
  2535. }
  2536. else
  2537. {
  2538. playYoutubeBtn.travel = true;
  2539. youtubeTravelBtn.innerHTML = "<font size=2>Trip</font>";
  2540. }
  2541. playYoutubeBtn.innerHTML = "Check YouTube";
  2542.  
  2543. });
  2544.  
  2545. var playYoutubeBtn = document.createElement("Button");
  2546. playYoutubeBtn.classList.add("unity-btn", "lgMinus", "youtube-btn", "vertical-0");
  2547. playYoutubeBtn.id = "Youtube Button";
  2548. playYoutubeBtn.travel = true;
  2549. playYoutubeBtn.innerHTML = "Check YouTube";
  2550. document.body.appendChild(playYoutubeBtn);
  2551. playYoutubeBtn.addEventListener("click", () => {
  2552. let iframe = document.getElementById("i_container");
  2553. iframe.style.position = "absolute";
  2554. iframe.allow = "autoplay";
  2555.  
  2556. if (!yEnd)
  2557. {
  2558. let url = `https://nominatim.openstreetmap.org/reverse?format=jsonv2&zoom=10&lat=${global_lat}&lon=${global_lng}`
  2559. fetch(url).then(function(response) {
  2560. return response.json();
  2561. }).then(function(data) {
  2562. // console.log(data)
  2563. youtubeList = [];
  2564. youtubeIndex = -1;
  2565. let locStr = data.display_name.replaceAll(/[\u3400-\u9FBF]/g, "").replace(/[0-9]/g, '');;
  2566. // console.log(locStr);
  2567. let locStr2 = handleCountries(locStr)
  2568. // console.log(locStr2);
  2569. let url2 = corsString + `https://youtube-scrape.herokuapp.com/api/search?q=${locStr2}`
  2570. fetch(url2).then(function(response) {
  2571. return response.json();
  2572. }).then(function(data) {
  2573. // console.log(data.results);
  2574. for (let vid of data.results)
  2575. {
  2576. if (vid.hasOwnProperty("video"))
  2577. {
  2578. let vidLen = convertMMSS(vid.video.duration);
  2579. if (vidLen > 120)
  2580. {
  2581. // console.log(vid.video.title);
  2582. youtubeList.push(vid.video.id);
  2583. }
  2584. }
  2585. }
  2586. if (youtubeList.length > 0)
  2587. {
  2588. youtubeIndex = 0;
  2589. }
  2590. yTime = 20;
  2591. moduleHandleYoutube();
  2592. }).catch(function() {
  2593. console.log("youtube scrappe failure");
  2594. });
  2595. }).catch(function() {
  2596. console.log("nominatim failure");
  2597. });
  2598. }
  2599. else
  2600. {
  2601. moduleHandleYoutube();
  2602. }
  2603. });
  2604.  
  2605. // Teleport Module Buttons
  2606. // Class: teleport-btn
  2607. // Button: teleportMenu
  2608. // Buttons: teleportForward, teleportReverse, teleportMain, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, TeleportArisBtn
  2609.  
  2610. function teleportModule(dir)
  2611. {
  2612. // Added by EC - Victheturtle said that someone was using teleport in nm duels games.
  2613. const PATH = getPathName();
  2614. if (PATH.startsWith("/duels/")) return;
  2615.  
  2616. if (switchCovergeButton.init)
  2617. {
  2618. // console.log("run");
  2619. switchCovergeButton.init = false;
  2620. if (teleportMain.google)
  2621. {
  2622. switchCovergeButton.useGoogle = true;
  2623. teleportMain.google = true;
  2624. }
  2625. else
  2626. {
  2627. switchCovergeButton.useGoogle = false;
  2628. teleportMain.google = false;
  2629. }
  2630. }
  2631. else
  2632. {
  2633. // console.log(teleportMenu.google)
  2634. if (teleportMain.google && GooglePlayer != null)
  2635. {
  2636. let heading = GooglePlayer.getPov().heading;
  2637. if (!dir)
  2638. {
  2639. heading = (heading + 180) % 360;
  2640. }
  2641. let place = FindPointAtDistanceFrom(curPosition.lat, curPosition.lng , DegreesToRadians(heading), teleportMain.distance * 0.001)
  2642. svService.getPanorama({ location: place, radius: 1000, source: teleportMain.teleType}, svCheck);
  2643. }
  2644. }
  2645. }
  2646.  
  2647. var teleportForward = document.createElement("Button");
  2648. teleportForward.classList.add("unity-btn", "teleport-btn", "half", "horizontal-1", "vertical-1");
  2649. teleportForward.id = "Teleport Forward";
  2650. teleportForward.innerHTML = "↑ Forward";
  2651. document.body.appendChild(teleportForward);
  2652.  
  2653. teleportForward.addEventListener("click", () => {
  2654. teleportModule(true);
  2655. });
  2656.  
  2657. var teleportReverse = document.createElement("Button");
  2658. teleportReverse.classList.add("unity-btn", "teleport-btn", "half", "horizontal-2", "vertical-1");
  2659. teleportReverse.id = "Teleport Reverse";
  2660. teleportReverse.innerHTML = "↓ Reverse";
  2661. document.body.appendChild(teleportReverse);
  2662.  
  2663. teleportReverse.addEventListener("click", () => {
  2664. teleportModule(false);
  2665. });
  2666.  
  2667. var teleportMain = document.createElement("Button");
  2668. teleportMain.classList.add("unity-btn", "teleport-btn", "large", "vertical-2");
  2669. teleportMain.teleType = "default";
  2670. teleportMain.id = "Teleport Button";
  2671. teleportMain.distance = 100;
  2672. teleportMain.google = true;
  2673. teleportMain.innerHTML = "Teleport: 100m";
  2674. document.body.appendChild(teleportMain);
  2675.  
  2676. var teleportMoreBtn = document.createElement("Button");
  2677. teleportMoreBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-3", "vertical-2");
  2678. teleportMoreBtn.id = "plus"
  2679. teleportMoreBtn.innerHTML = "+";
  2680. document.body.appendChild(teleportMoreBtn);
  2681. teleportMoreBtn.addEventListener("click", () => {
  2682. if (teleportMain.distance > 21 && teleportMain.distance < 149) {
  2683. teleportMain.distance = teleportMain.distance + 25;
  2684. }
  2685. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  2686. });
  2687.  
  2688. var teleportLessBtn = document.createElement("Button");
  2689. teleportLessBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-1", "vertical-2");
  2690. teleportLessBtn.id = "minus"
  2691. teleportLessBtn.innerHTML = "-";
  2692. document.body.appendChild(teleportLessBtn);
  2693. teleportLessBtn.addEventListener("click", () => {
  2694. if (teleportMain.distance > 26) {
  2695. teleportMain.distance = teleportMain.distance - 25;
  2696. }
  2697. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  2698. });
  2699.  
  2700. var teleportDistResetBtn = document.createElement("Button");
  2701. teleportDistResetBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-1", "vertical-3");
  2702. teleportDistResetBtn.id = "reset"
  2703. teleportDistResetBtn.innerHTML = "Reset Teleport";
  2704. document.body.appendChild(teleportDistResetBtn);
  2705. teleportDistResetBtn.addEventListener("click", () => {
  2706. teleportMain.distance = 100;
  2707. teleportMain.innerHTML = "Teleport: " + teleportMain.distance + " m";
  2708. });
  2709.  
  2710. var TeleportArisBtn = document.createElement("Button");
  2711. TeleportArisBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-2", "vertical-3");
  2712. TeleportArisBtn.id = "Teleport Options Button";
  2713. TeleportArisBtn.innerHTML = "+ Unofficial";
  2714. document.body.appendChild(TeleportArisBtn);
  2715. TeleportArisBtn.addEventListener("click", () => {
  2716. if (teleportMain.teleType == "default")
  2717. {
  2718. teleportMain.teleType = "outdoor"
  2719. TeleportArisBtn.innerHTML = "No Unofficial";
  2720. }
  2721. else
  2722. {
  2723. teleportMain.teleType = "default"
  2724. TeleportArisBtn.innerHTML = "+ Unofficial";
  2725. }
  2726. });
  2727.  
  2728.  
  2729. var RestrictBoundsBtn = document.createElement("Button");
  2730. RestrictBoundsBtn.classList.add("unity-btn", "teleport-btn", "full", "horizontal-1", "vertical-4");
  2731. RestrictBoundsBtn.id = "Restrict Bounds Main";
  2732. RestrictBoundsBtn.innerHTML = "No Escape Mode Disabled";
  2733. RestrictBoundsBtn.lat = 0;
  2734. RestrictBoundsBtn.lng = 0;
  2735. RestrictBoundsBtn.maxDist = 250;
  2736. document.body.appendChild(RestrictBoundsBtn);
  2737.  
  2738.  
  2739. var RestrictBoundsDistBtn = document.createElement("Button");
  2740. RestrictBoundsDistBtn.classList.add("unity-btn", "teleport-btn", "large", "vertical-5");
  2741. RestrictBoundsDistBtn.id = "Restrict Distance";
  2742. RestrictBoundsDistBtn.innerHTML = "Limit: 250m";
  2743. document.body.appendChild(RestrictBoundsDistBtn);
  2744.  
  2745. var RestrictMoreBtn = document.createElement("Button");
  2746. RestrictMoreBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-3", "vertical-5");
  2747. RestrictMoreBtn.id = "Increase Restrict Distance";
  2748. RestrictMoreBtn.innerHTML = "+";
  2749. document.body.appendChild(RestrictMoreBtn);
  2750. RestrictMoreBtn.addEventListener("click", () => {
  2751. if (RestrictBoundsBtn.maxDist > 49 && RestrictBoundsBtn.maxDist < 249) {
  2752. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist + 50;
  2753. }
  2754. else if (RestrictBoundsBtn.maxDist > 249 && RestrictBoundsBtn.maxDist < 999) {
  2755. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist + 250;
  2756. }
  2757. else if (RestrictBoundsBtn.maxDist > 999 && RestrictBoundsBtn.maxDist < 9999) {
  2758. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist + 1000;
  2759. }
  2760. else if (RestrictBoundsBtn.maxDist > 9999) {
  2761. RestrictBoundsBtn.maxDist = 100000000;
  2762. }
  2763. if (RestrictBoundsBtn.maxDist < 10001)
  2764. {
  2765. RestrictBoundsDistBtn.innerHTML = "Limit: " + RestrictBoundsBtn.maxDist + "m";
  2766. }
  2767. else
  2768. {
  2769. RestrictBoundsDistBtn.innerHTML = "Limit: &#8734;";
  2770. }
  2771. });
  2772.  
  2773. var RestrictLessBtn = document.createElement("Button");
  2774. RestrictLessBtn.classList.add("unity-btn", "teleport-btn", "small", "horizontal-1", "vertical-5");
  2775. RestrictLessBtn.id = "Decrease Restrict Distance";
  2776. RestrictLessBtn.innerHTML = "-";
  2777. document.body.appendChild(RestrictLessBtn);
  2778. RestrictLessBtn.addEventListener("click", () => {
  2779. if (RestrictBoundsBtn.maxDist > 51 && RestrictBoundsBtn.maxDist < 251) {
  2780. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist - 50;
  2781. }
  2782. else if (RestrictBoundsBtn.maxDist > 251 && RestrictBoundsBtn.maxDist < 1001) {
  2783. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist - 250;
  2784. }
  2785. else if (RestrictBoundsBtn.maxDist > 1001 && RestrictBoundsBtn.maxDist < 10001) {
  2786. RestrictBoundsBtn.maxDist = RestrictBoundsBtn.maxDist - 1000;
  2787. }
  2788. else if (RestrictBoundsBtn.maxDist > 10001) {
  2789. RestrictBoundsBtn.maxDist = 10000;
  2790. }
  2791. if (RestrictBoundsBtn.maxDist < 10001)
  2792. {
  2793. RestrictBoundsDistBtn.innerHTML = "Limit: " + RestrictBoundsBtn.maxDist + "m";
  2794. }
  2795. else
  2796. {
  2797. RestrictBoundsDistBtn.innerHTML = "Limit: &#8734;";
  2798. }
  2799. });
  2800.  
  2801. var RestrictBoundsEnableBtn = document.createElement("Button");
  2802. RestrictBoundsEnableBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-2", "vertical-6");
  2803. RestrictBoundsEnableBtn.id = "Restrict Bounds Enable";
  2804. RestrictBoundsEnableBtn.innerHTML = "Enable Limit";
  2805. document.body.appendChild(RestrictBoundsEnableBtn);
  2806. RestrictBoundsEnableBtn.addEventListener("click", () => {
  2807. if (restrictMovement)
  2808. {
  2809. restrictMovement = false;
  2810. RestrictBoundsEnableBtn.innerHTML = "Enable Limit";
  2811. RestrictBoundsBtn.innerHTML = "No Escape Mode Disabled";
  2812. }
  2813. else
  2814. {
  2815. restrictMovement = true;
  2816. RestrictBoundsEnableBtn.innerHTML = "Disable Limit";
  2817. RestrictBoundsBtn.innerHTML = "No Escape Mode Enabled";
  2818. }
  2819. });
  2820.  
  2821. var RestrictResetBtn = document.createElement("Button");
  2822. RestrictResetBtn.classList.add("unity-btn", "teleport-btn", "half", "horizontal-1", "vertical-6");
  2823. RestrictResetBtn.id = "Restrict Distance Reset";
  2824. RestrictResetBtn.innerHTML = "Reset Limit";
  2825. document.body.appendChild(RestrictResetBtn);
  2826. RestrictResetBtn.addEventListener("click", () => {
  2827. RestrictBoundsBtn.maxDist = 250;
  2828. RestrictBoundsDistBtn.innerHTML = "Limit: " + RestrictBoundsBtn.maxDist + "m";
  2829. });
  2830.  
  2831.  
  2832.  
  2833. // Switch Coverage Module
  2834.  
  2835. var switchCovergeButton = document.createElement("Button");
  2836. switchCovergeButton.classList.add("unity-btn", "timemachine-btn", "full", "vertical-1");
  2837. switchCovergeButton.sat = false;
  2838. switchCovergeButton.id = "switch";
  2839. switchCovergeButton.init = false;
  2840. switchCovergeButton.useGoogle = false;
  2841. switchCovergeButton.lng = 0
  2842. switchCovergeButton.lat = 0
  2843. switchCovergeButton.heading = 0
  2844. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  2845. document.body.appendChild(switchCovergeButton);
  2846. switchCovergeButton.addEventListener("click", () => {
  2847. nextPlayer = nextPlayer_save;
  2848. let GOOGLE_MAPS_CANVAS1 = document.querySelector(GENERAL_CANVAS);
  2849. let GOOGLE_MAPS_CANVAS2 = document.querySelector(BR_CANVAS);
  2850. let GOOGLE_MAPS_CANVAS3 = document.querySelector(".inactive");
  2851. let GOOGLE_MAPS_CANVAS4 = document.querySelector(BULLSEYE_CANVAS2);
  2852. let GOOGLE_MAPS_CANVAS5 = document.querySelector(LIVE_CANVAS2);
  2853. let duel = false;
  2854.  
  2855. let GOOGLE_MAPS_CANVAS = null;
  2856. if (GOOGLE_MAPS_CANVAS1 !== null)
  2857. {
  2858. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS1;
  2859. }
  2860. else if (GOOGLE_MAPS_CANVAS2 !== null)
  2861. {
  2862. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS2;
  2863. }
  2864. else if (GOOGLE_MAPS_CANVAS4 !== null)
  2865. {
  2866. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS4;
  2867. }
  2868. else if (GOOGLE_MAPS_CANVAS5 !== null)
  2869. {
  2870. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS5;
  2871. }
  2872. if (GOOGLE_MAPS_CANVAS3 !== null)
  2873. {
  2874. duel = true;
  2875. }
  2876.  
  2877. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  2878. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  2879. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player")
  2880. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  2881. let MS_MAPS_CANVAS = document.getElementById("ms-player");
  2882. let MAPBOX_MAPS_CANVAS = document.getElementById("sat_map");
  2883. let MAPY_MAPS_CANVAS = document.getElementById("mapy-player");
  2884. // if (nextPlayer !== "Baidu") {
  2885. if (switchCovergeButton.useGoogle == false) {
  2886. if (duel)
  2887. {
  2888.  
  2889. if (nextPlayer == "Kakao")
  2890. {
  2891. KAKAO_MAPS_CANVAS.className = "inactive";
  2892. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  2893. }
  2894. else if (nextPlayer == "Bing Streetside")
  2895. {
  2896. MS_MAPS_CANVAS.className = "inactive";
  2897. MS_MAPS_CANVAS.style.visibility = "hidden";
  2898. }
  2899. else if (nextPlayer == "Mapbox Satellite")
  2900. {
  2901. MAPBOX_MAPS_CANVAS.className = "inactive";
  2902. MAPBOX_MAPS_CANVAS.style.visibility = "hidden";
  2903. }
  2904. else if (nextPlayer == "Yandex")
  2905. {
  2906. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  2907. YANDEX_MAPS_CANVAS.style.zIndex = "none";
  2908. }
  2909. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte")
  2910. {
  2911. BAIDU_MAPS_CANVAS.className = "inactive";
  2912. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  2913. }
  2914. else if (nextPlayer == "Mapy")
  2915. {
  2916. MAPY_MAPS_CANVAS.className = "inactive";
  2917. MAPY_MAPS_CANVAS.style.visibility = "hidden";
  2918. }
  2919. else
  2920. {
  2921. MAPILLARY_MAPS_CANVAS.className = "inactive";
  2922. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  2923. }
  2924. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  2925. document.getElementById("default_player").style.visibility = "";
  2926. window.dispatchEvent(new Event('resize'));
  2927. }
  2928. else
  2929. {
  2930. GOOGLE_MAPS_CANVAS.style.visibility = "";
  2931. if (nextPlayer == "Kakao")
  2932. {
  2933. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  2934. }
  2935. else if (nextPlayer == "Yandex")
  2936. {
  2937. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  2938. }
  2939. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte")
  2940. {
  2941. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  2942. }
  2943. else if (nextPlayer == "Mapillary" || nextPlayer == "Google")
  2944. {
  2945. //MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  2946. }
  2947. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  2948. {
  2949. MS_MAPS_CANVAS.style.visibility = "hidden";
  2950. }
  2951. else if (nextPlayer == "Mapbox Satellite")
  2952. {
  2953. MAPBOX_MAPS_CANVAS.style.visibility = "hidden";
  2954. }
  2955. else if (nextPlayer == "Mapy")
  2956. {
  2957. MAPY_MAPS_CANVAS.style.visibility = "hidden";
  2958. }
  2959. }
  2960. const lat = GooglePlayer.getPosition().lat();
  2961. const lng = GooglePlayer.getPosition().lng();
  2962. switch_call = true;
  2963. if ((!almostEqual2(lat, switchCovergeButton.lat) || !almostEqual2(lat, switchCovergeButton.lng)) && !(NM || NP || NZ)) {
  2964. svService.getPanorama({ location: { lat: switchCovergeButton.lat, lng: switchCovergeButton.lng }, radius: 1000 }, svCheck);
  2965. }
  2966. switchCovergeButton.useGoogle = true;
  2967. teleportMain.google = true;
  2968. switchCovergeButton.init = false;
  2969.  
  2970. console.log("use Google");
  2971. }
  2972. else {
  2973. // if (MS_MAPS_CANVAS)
  2974. // {
  2975. // MS_MAPS_CANVAS.style.visibility = "hidden";
  2976. // }
  2977.  
  2978. if (duel)
  2979. {
  2980. document.getElementById("default_player").className = "inactive";
  2981. document.getElementById("default_player").style.visibility = "hidden";
  2982. if (nextPlayer == "Kakao")
  2983. {
  2984. KAKAO_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  2985. KAKAO_MAPS_CANVAS.style.visibility = "";
  2986. }
  2987. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  2988. {
  2989. MS_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  2990. MS_MAPS_CANVAS.style.visibility = "";
  2991. }
  2992. else if (nextPlayer == "Mapbox Satellite")
  2993. {
  2994. MAPBOX_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  2995. MAPBOX_MAPS_CANVAS.style.visibility = "";
  2996. }
  2997. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte")
  2998. {
  2999. BAIDU_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  3000. BAIDU_MAPS_CANVAS.style.visibility = "";
  3001. }
  3002. else if (nextPlayer == "Yandex")
  3003. {
  3004. YANDEX_MAPS_CANVAS.style.visibility = "";
  3005. YANDEX_MAPS_CANVAS.style.zIndex = "1";
  3006. }
  3007. else if (nextPlayer == "Mapy")
  3008. {
  3009. MAPY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3010. MAPY_MAPS_CANVAS.style.visibility = "";
  3011. }
  3012. else
  3013. {
  3014. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3015. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  3016. MapillaryPlayer.resize();
  3017. //window.dispatchEvent(new Event('resize'));
  3018. // document.querySelector(".mapillary-canvas").style.;
  3019. // mapillary-canvas
  3020. }
  3021.  
  3022. }
  3023. else
  3024. {
  3025. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  3026. if (nextPlayer == "Kakao")
  3027. {
  3028. KAKAO_MAPS_CANVAS.style.visibility = "";
  3029. }
  3030. else if (nextPlayer == "Yandex")
  3031. {
  3032. YANDEX_MAPS_CANVAS.style.visibility = "";
  3033. }
  3034. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft"|| nextPlayer === "Carte")
  3035. {
  3036. BAIDU_MAPS_CANVAS.style.visibility = "";
  3037. }
  3038. else if (nextPlayer == "Mapillary" || nextPlayer == "Google" )
  3039. {
  3040. //MAPILLARY_MAPS_CANVAS.style.visibility = "";
  3041. }
  3042. else if (nextPlayer == "Bing Streetside" || nextPlayer == "Planets")
  3043. {
  3044. MS_MAPS_CANVAS.style.visibility = "";
  3045. }
  3046. else if (nextPlayer == "Mapbox Satellite")
  3047. {
  3048. MAPBOX_MAPS_CANVAS.style.visibility = "";
  3049. }
  3050. else if (nextPlayer == "Mapy")
  3051. {
  3052. MAPY_MAPS_CANVAS.style.visibility = "";
  3053. }
  3054. }
  3055. switchCovergeButton.useGoogle = false;
  3056. teleportMain.google = false;
  3057. switchCovergeButton.init = true;
  3058. console.log("use Others");
  3059. }
  3060. if (switchCovergeButton.useGoogle)
  3061. {
  3062. if (nextPlayer == "Google")
  3063. {
  3064. switchCovergeButton.innerHTML = "Switch to Mapillary";
  3065. satelliteSwitchButton.disabled = false;
  3066. satelliteSwitchButton.style.background = "#ba55d3cc";
  3067. }
  3068. else
  3069. {
  3070. switchCovergeButton.innerHTML = "Switch to " + nextPlayer;
  3071. satelliteSwitchButton.disabled = true;
  3072. satelliteSwitchButton.style.background = "red";
  3073. }
  3074. }
  3075. else
  3076. {
  3077. if (nextPlayer == "Google" || nextPlayer == "Baidu")
  3078. {
  3079. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  3080. satelliteSwitchButton.disabled = true;
  3081. satelliteSwitchButton.style.background = "red";
  3082. }
  3083. else
  3084. {
  3085. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  3086. satelliteSwitchButton.disabled = false;
  3087. satelliteSwitchButton.style.background = "#ba55d3cc";
  3088. }
  3089. }
  3090. });
  3091.  
  3092.  
  3093. var timeMachineNewerBtn = document.createElement("Button");
  3094. timeMachineNewerBtn.classList.add("unity-btn", "timemachine-btn", "small", "horizontal-3", "vertical-2");
  3095. timeMachineNewerBtn.id = "plus year"
  3096. timeMachineNewerBtn.innerHTML = "+";
  3097. document.body.appendChild(timeMachineNewerBtn);
  3098. timeMachineNewerBtn.addEventListener("click", () => {
  3099. if (timeMachineBtn.index < timeMachineBtn.list.length - 1 && !timeMachineBtn.plusminusLock) {
  3100. timeMachineBtn.index = timeMachineBtn.index + 1;
  3101. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  3102. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  3103. // console.log(timeMachineBtn.index)
  3104. }
  3105. GenBtnColor();
  3106.  
  3107. });
  3108.  
  3109. var timeMachineOlderBtn = document.createElement("Button");
  3110. timeMachineOlderBtn.classList.add("unity-btn", "timemachine-btn", "small", "horizontal-1", "vertical-2");
  3111. timeMachineOlderBtn.id = "minus year"
  3112. timeMachineOlderBtn.innerHTML = "-";
  3113. document.body.appendChild(timeMachineOlderBtn);
  3114. timeMachineOlderBtn.addEventListener("click", () => {
  3115. if (timeMachineBtn.index > 0 && !timeMachineBtn.plusminusLock) {
  3116. timeMachineBtn.index = timeMachineBtn.index - 1;
  3117. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  3118. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  3119. // console.log(timeMachineBtn.index)
  3120. }
  3121. GenBtnColor();
  3122. });
  3123.  
  3124. function svCheck2(data, status) {
  3125. let l = []
  3126. if (status === 'OK') {
  3127. // console.log("OK for " + data.location.latLng + " at ID " + data.location.pano);
  3128. // console.log(data.time)
  3129. for (const alt of data.time) {
  3130. let date = Object.values(alt).find((value) => value instanceof Date)
  3131.  
  3132. l.push([alt.pano, date.toDateString()]);
  3133. }
  3134. // console.log(l);
  3135. timeMachineBtn.list = l
  3136. timeMachineBtn.index = l.length - 1;
  3137. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  3138. GenBtnColor();
  3139. timeMachineBtn.plusminusLock = false;
  3140. // timeMachineOlderBtn.click()
  3141. // timeMachineBtn.innerHTML = "Default Date";
  3142. }
  3143. }
  3144.  
  3145. function waitPopulate()
  3146. {
  3147. // console.log(timeMachineBtn.list);
  3148. if (timeMachineBtn.list.length !== 0)
  3149. {
  3150. timeMachineBtn.index = timeMachineBtn.list.length - 1;
  3151. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  3152. }
  3153. else
  3154. {
  3155. setTimeout(waitPopulate, 250);
  3156. }
  3157. }
  3158.  
  3159. var timeMachineBtn = document.createElement("Button");
  3160. timeMachineBtn.classList.add("unity-btn", "timemachine-btn", "large", "vertical-2");
  3161. timeMachineBtn.id = "Date Button";
  3162. timeMachineBtn.plusminusLock = true;
  3163. timeMachineBtn.panoId = 0;
  3164. timeMachineBtn.index = -1;
  3165. timeMachineBtn.list = [];
  3166. timeMachineBtn.innerHTML = "Time Machine";
  3167. document.body.appendChild(timeMachineBtn);
  3168. timeMachineBtn.addEventListener("click", () => {
  3169. // console.log(timeMachineBtn.index)
  3170. if (timeMachineBtn.panoId != 0)
  3171. {
  3172. if(timeMachineBtn.index == -1)
  3173. {
  3174. timeMachineBtn.list = [];
  3175. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  3176. waitPopulate();
  3177. }
  3178. else
  3179. {
  3180. waitPopulate();
  3181. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  3182. GenBtnColor();
  3183. }
  3184. }
  3185. else
  3186. {
  3187. timeMachineBtn.panoId = GooglePlayer.pano;
  3188. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  3189. waitPopulate();
  3190. }
  3191. });
  3192.  
  3193.  
  3194. var timeMachineMenu = document.createElement("Button");
  3195. timeMachineMenu.classList.add("unity-btn", "menu-btn");
  3196. timeMachineMenu.id = "Time Machine Button";
  3197. document.body.appendChild(timeMachineMenu);
  3198. timeMachineMenu.addEventListener("click", () => {
  3199. switchBtn("timemachine-btn");
  3200. if (timeMachineBtn.style.visibility == "hidden")
  3201. {
  3202. for (let element of document.getElementsByClassName("timemachine-btn"))
  3203. {
  3204. element.style.visibility = "";
  3205. }
  3206. }
  3207. else
  3208. {
  3209. for (let element of document.getElementsByClassName("timemachine-btn"))
  3210. {
  3211. element.style.visibility = "hidden";
  3212. }
  3213. }
  3214. });
  3215.  
  3216.  
  3217. var teleportMenu = document.createElement("Button");
  3218. teleportMenu.classList.add("unity-btn", "menu-btn");
  3219. teleportMenu.id = "Teleport Menu";
  3220. document.body.appendChild(teleportMenu);
  3221. teleportMenu.addEventListener("click", () => {
  3222. switchBtn("teleport-btn");
  3223. if (teleportForward.style.visibility == "hidden")
  3224. {
  3225. for (let element of document.getElementsByClassName("teleport-btn"))
  3226. {
  3227. element.style.visibility = "";
  3228. }
  3229. }
  3230. else
  3231. {
  3232. for (let element of document.getElementsByClassName("teleport-btn"))
  3233. {
  3234. element.style.visibility = "hidden";
  3235. }
  3236. }
  3237. });
  3238.  
  3239. // Satellite Module Buttons
  3240. // Class: satelliteSwitchButton, satellite-menu
  3241. // subclass 1: satellite-btn-type
  3242. // subclass 2: satellite-btn-style
  3243. // Buttons: satelliteRadius, satelliteType, satelliteStyle
  3244. // satelliteDefault, satelliteNight, satelliteClassic, roadDefault, roadClassic
  3245. // skyDefault, skyCurrent, skyLocal
  3246.  
  3247. var satelliteTypeBtn = document.createElement("Button");
  3248. satelliteTypeBtn.classList.add("unity-btn", "satellite-btn", "half", "horizontal-1", "vertical-2", "unity-btn-nonclickable");
  3249. satelliteTypeBtn.id = "Satellite Type Button";
  3250. satelliteTypeBtn.innerHTML = "Map Style";
  3251. satelliteTypeBtn.currentTime = "solarNoon";
  3252. document.body.appendChild(satelliteTypeBtn);
  3253.  
  3254.  
  3255. var satelliteStyleBtn = document.createElement("Button");
  3256. satelliteStyleBtn.classList.add("unity-btn", "satellite-btn", "half", "horizontal-2", "vertical-2", "unity-btn-nonclickable");
  3257. satelliteStyleBtn.id = "Satellite Style Button";
  3258. satelliteStyleBtn.innerHTML = "Time";
  3259.  
  3260. document.body.appendChild(satelliteStyleBtn);
  3261.  
  3262.  
  3263. for (let satT of satType)
  3264. {
  3265. let satTButton = document.createElement("Button");
  3266. satTButton.id = satT[0];
  3267. satTButton.classList.add("unity-btn", "satellite-btn", "satellite-type", "half", "horizontal-1");
  3268. satTButton.addEventListener("click", () => {
  3269. // let sB = document.getElementById("Satellite Type Button");
  3270. let strNm = satTButton.id;
  3271. let val = getVar(strNm);
  3272. styleMapboxAll(strNm, !val);
  3273. setVar(strNm);
  3274. handleSatColor(true, false);
  3275. })
  3276. document.body.appendChild(satTButton);
  3277.  
  3278. if (satT[0] === "Dimension"){
  3279. satTButton.title = "In 3D mode, radius is 50%; tilt map to see full radius.";
  3280. }
  3281. }
  3282.  
  3283.  
  3284.  
  3285. for (let satS of satStyle)
  3286. {
  3287. let satSButton = document.createElement("Button");
  3288. satSButton.id = satS[0];
  3289. satSButton.classList.add("unity-btn", "satellite-btn", "satellite-style", "half", "horizontal-2");
  3290. satSButton.innerHTML = satS[1];
  3291. satSButton.addEventListener("click", () => {
  3292. styleMapboxAll("SunPos", satSButton.id);
  3293. satelliteTypeBtn.currentTime = satSButton.id;
  3294. handleSatColor(false, true);
  3295. })
  3296. document.body.appendChild(satSButton);
  3297. }
  3298.  
  3299.  
  3300.  
  3301. function handleSatMenu(cond)
  3302. {
  3303. let transition = true;
  3304. if (cond)
  3305. {
  3306. transition = (satelliteSwitchButton.innerHTML == "Streetview mode");
  3307. }
  3308. else
  3309. {
  3310. transition = (satelliteSwitchButton.innerHTML !== "Streetview mode");
  3311. }
  3312. if (transition)
  3313. {
  3314. for (let element of document.getElementsByClassName("satellite-btn"))
  3315. {
  3316. if (element.id !== "Satellite Switch")
  3317. {
  3318. element.style.visibility = "hidden";
  3319. }
  3320. }
  3321. }
  3322. else
  3323. {
  3324. for (let element of document.getElementsByClassName("satellite-btn"))
  3325. {
  3326. if (element.id !== "Satellite Switch")
  3327. {
  3328. element.style.visibility = "";
  3329. }
  3330. }
  3331. }
  3332. }
  3333.  
  3334. var satelliteSwitchButton = document.createElement("Button");
  3335. satelliteSwitchButton.classList.add("unity-btn", "satellite-btn", "full", "vertical-1");
  3336. satelliteSwitchButton.id = "Satellite Switch";
  3337. satelliteSwitchButton.state = false;
  3338. satelliteSwitchButton.innerHTML = "Streetview mode";
  3339. document.body.appendChild(satelliteSwitchButton);
  3340. satelliteSwitchButton.addEventListener("click", () => {
  3341. handleSatMenu(false);
  3342. if (!initBing)
  3343. {
  3344. let di = formatDist();
  3345. // satelliteRadius.innerHTML = `Satellite (${di})`;
  3346. satelliteSwitchButton.innerHTML = `Satellite (${di})`;
  3347.  
  3348. initBing = true;
  3349. MAPBOX_INJECTED = false;
  3350. BR_LOAD_MP = true;
  3351.  
  3352. let canvas = document.getElementById("sat_map");
  3353. if (!canvas)
  3354. {
  3355. injectMapboxPlayer();
  3356. }
  3357. else
  3358. {
  3359. changeInnerHTML(canvas, false);
  3360. MAPBOX_INJECTED = true;
  3361. }
  3362. nextPlayer = "Mapbox Satellite";
  3363. injectCanvas();
  3364. satCallback();
  3365.  
  3366. sat_choice = true;
  3367. console.log("Load Mapbox Satellite API")
  3368. //
  3369. }
  3370. else
  3371. {
  3372. if (!satelliteSwitchButton.innerHTML.includes("Satellite"))
  3373. {
  3374. // console.log("true!!")
  3375. let di2 = formatDist();
  3376. satelliteSwitchButton.innerHTML = `Satellite (${di2})`;
  3377.  
  3378. nextPlayer = "Mapbox Satellite";
  3379. injectCanvas();
  3380. satCallback();
  3381. nextPlayer = nextPlayer_save;
  3382.  
  3383. sat_choice = true;
  3384. // console.log("hello")
  3385. }
  3386. else
  3387. {
  3388. satelliteSwitchButton.innerHTML = "Streetview mode";
  3389. if (nextPlayer_save == "Mapbox Satellite")
  3390. {
  3391. nextPlayer = "Google";
  3392. }
  3393. else
  3394. {
  3395. nextPlayer = nextPlayer_save;
  3396. }
  3397.  
  3398. injectCanvas();
  3399. if (sat_choice)
  3400. {
  3401. if (nextPlayer !== "Google")
  3402. {
  3403. goToLocation(true);
  3404. }
  3405. handleButtons();
  3406. }
  3407. sat_choice = false;
  3408. }
  3409. if (satelliteSwitchButton.innerHTML !== "Streetview mode" || nextPlayer == "Baidu")
  3410. {
  3411. switchCovergeButton.disabled = true;
  3412. switchCovergeButton.style.background = "red";
  3413. }
  3414. else
  3415. {
  3416. switchCovergeButton.disabled = false;
  3417. switchCovergeButton.style.background = "#ba55d3cc";
  3418. }
  3419. }
  3420. localStorage['unity_sat_choice'] = sat_choice; // Added by EC
  3421. });
  3422.  
  3423. var satelliteMenu = document.createElement("Button");
  3424. satelliteMenu.classList.add("unity-btn", "menu-btn");
  3425. satelliteMenu.id = "Satellite Menu";
  3426. document.body.appendChild(satelliteMenu);
  3427. satelliteMenu.addEventListener("click", () => {
  3428. switchBtn("satellite-btn");
  3429. if (satelliteSwitchButton.style.visibility == "hidden")
  3430. {
  3431. satelliteSwitchButton.style.visibility = "";
  3432. handleSatMenu(true);
  3433. }
  3434. else
  3435. {
  3436. for (let element of document.getElementsByClassName("satellite-btn"))
  3437. {
  3438. element.style.visibility = "hidden";
  3439. }
  3440. }
  3441.  
  3442. });
  3443.  
  3444.  
  3445. // Mosaic Module Buttons
  3446.  
  3447. var mosaicMain = document.createElement("Button");
  3448. mosaicMain.classList.add("unity-btn", "mosaic-btn", "full", "vertical-1");
  3449. mosaicMain.id = "Mosaic Enable";
  3450. mosaicMain.grid = 0;
  3451. // mosaicMain.random = false;
  3452. mosaicMain.color = false;
  3453. mosaicMain.label = true;
  3454. // mosaicMain.blink = false;
  3455. mosaicMain.innerHTML = "Mosaic Mode";
  3456. document.body.appendChild(mosaicMain);
  3457.  
  3458. var mosaicGridSize = document.createElement("Button");
  3459. mosaicGridSize.classList.add("unity-btn", "mosaic-btn", "half", "horizontal-2", "vertical-2");
  3460. mosaicGridSize.id = "Mosaic Grid";
  3461. mosaicGridSize.innerHTML = "Grid Size";
  3462. document.body.appendChild(mosaicGridSize);
  3463.  
  3464. let gridWidth = [0, 3, 5, 7, 10, 20, 50, 100];
  3465. for (let i = 0; i < gridWidth.length; i++)
  3466. {
  3467. let gridButton = document.createElement("Button");
  3468. gridButton.id = `Grid ${gridWidth[i]}`;
  3469. gridButton.classList.add("unity-btn", "mosaic-btn", "grid-size", "half", "horizontal-2");
  3470. if (i !== 0)
  3471. {
  3472. gridButton.innerHTML = `${gridWidth[i]} x ${gridWidth[i]}`;
  3473. }
  3474. else
  3475. {
  3476. gridButton.innerHTML = `No Grid`;
  3477. }
  3478. document.body.appendChild(gridButton);
  3479. gridButton.addEventListener("click", () => {
  3480. mosaicMain.color = false;
  3481. mosaicMain.label = true;
  3482. loadGridBtn(gridWidth[i]);
  3483. });
  3484. }
  3485.  
  3486. var mosaicGridOpt = document.createElement("Button");
  3487. mosaicGridOpt.classList.add("unity-btn", "mosaic-btn", "half", "horizontal-1", "vertical-2");
  3488. mosaicGridOpt.id = "Mosaic Options";
  3489. mosaicGridOpt.innerHTML = "Options";
  3490. document.body.appendChild(mosaicGridOpt);
  3491.  
  3492. // ["Blink Mode"]
  3493. 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"];
  3494. for (let i = 0; i < gridOpt.length; i++)
  3495. {
  3496. let gridButton = document.createElement("Button");
  3497. gridButton.id = `Grid ${gridOpt[i]}`;
  3498. gridButton.classList.add("unity-btn", "mosaic-btn", "grid-opt", "half", "horizontal-1");
  3499. gridButton.innerHTML = `${gridOpt[i]}`;
  3500. document.body.appendChild(gridButton);
  3501. if (gridOpt[i] == "Reveal All")
  3502. {
  3503. gridButton.addEventListener("click", () => {
  3504. let gridCanvas = document.getElementById("grid");
  3505. if (gridCanvas)
  3506. {
  3507. gridCanvas.style.visibility = "hidden";
  3508. }
  3509. });
  3510. }
  3511. else if (gridOpt[i].includes("Peek"))
  3512. {
  3513. gridButton.addEventListener("click", () => {
  3514. let gridCanvas = document.getElementById("grid");
  3515. if (gridCanvas)
  3516. {
  3517. gridCanvas.style.visibility = "hidden";
  3518. let time = 500;
  3519. if (gridOpt[i].includes("0.01s"))
  3520. {
  3521. time = 10;
  3522. }
  3523. else if (gridOpt[i].includes("0.1s"))
  3524. {
  3525. time = 100;
  3526. }
  3527. else if (gridOpt[i].includes("0.25s"))
  3528. {
  3529. time = 250;
  3530. }
  3531. else if (gridOpt[i].includes("0.5s"))
  3532. {
  3533. time = 500;
  3534. }
  3535. else if (gridOpt[i].includes("1s"))
  3536. {
  3537. time = 1000;
  3538. }
  3539. else if (gridOpt[i].includes("3s"))
  3540. {
  3541. time = 3000;
  3542. }
  3543. setTimeout(function() {gridCanvas.style.visibility = "";}, time);
  3544. }
  3545. });
  3546. }
  3547. else if (gridOpt[i] == "Reveal 5%")
  3548. {
  3549. gridButton.addEventListener("click", () => {
  3550. for (let grid of document.getElementsByClassName("grid-btn"))
  3551. {
  3552. let num = Math.random();
  3553. if (num > 0.95)
  3554. {
  3555. grid.style.visibility = "hidden";
  3556. }
  3557. }
  3558. });
  3559. }
  3560. else if (gridOpt[i] == "Add Color")
  3561. {
  3562. gridButton.addEventListener("click", () => {
  3563. mosaicMain.color = true;
  3564. for (let grid of document.getElementsByClassName("grid-btn"))
  3565. {
  3566. grid.style.background = '#' + (Math.random() * 0xFFFFFF<<0).toString(16);
  3567. }
  3568. });
  3569. }
  3570. else if (gridOpt[i] == "Remove Label")
  3571. {
  3572. gridButton.addEventListener("click", () => {
  3573. mosaicMain.label = false;
  3574. for (let grid of document.getElementsByClassName("grid-btn"))
  3575. {
  3576. grid.innerHTML = "";
  3577. }
  3578. });
  3579. }
  3580. }
  3581.  
  3582. var mosaicMenu = document.createElement("Button");
  3583. mosaicMenu.classList.add("unity-btn", "menu-btn");
  3584. mosaicMenu.id = "Mosaic Menu";
  3585. document.body.appendChild(mosaicMenu);
  3586. mosaicMenu.addEventListener("click", () => {
  3587. switchBtn("mosaic-btn");
  3588. if (mosaicMain.style.visibility == "hidden")
  3589. {
  3590. for (let element of document.getElementsByClassName("mosaic-btn"))
  3591. {
  3592. element.style.visibility = "";
  3593. }
  3594. }
  3595. else
  3596. {
  3597. for (let element of document.getElementsByClassName("mosaic-btn"))
  3598. {
  3599. element.style.visibility = "hidden";
  3600. }
  3601. }
  3602. });
  3603.  
  3604.  
  3605.  
  3606. // Minimap Module
  3607.  
  3608. var MinimapBtn = document.createElement("Button");
  3609. MinimapBtn.classList.add("unity-btn", "minimap-btn", "half", "horizontal-2", "vertical-1");
  3610. MinimapBtn.id = "Minimap Button";
  3611. MinimapBtn.innerHTML = "Minimap Style";
  3612. MinimapBtn.current = "Default";
  3613. // MinimapBtn.childVisible = false;
  3614. document.body.appendChild(MinimapBtn);
  3615.  
  3616. for (let a of presetMinimap)
  3617. {
  3618. let aButton = document.createElement("Button");
  3619. aButton.id = a[1];
  3620. aButton.classList.add("unity-btn", "minimap-btn", "preset-minimap", "half", "horizontal-2");
  3621. aButton.innerHTML = a[1];
  3622. document.body.appendChild(aButton);
  3623. }
  3624.  
  3625. var OverlayBtn = document.createElement("Button");
  3626. OverlayBtn.classList.add("unity-btn", "minimap-btn", "half", "horizontal-1", "vertical-1");
  3627. OverlayBtn.id = "Overlay Button";
  3628. OverlayBtn.innerHTML = "Overlay";
  3629. OverlayBtn.current = "Clear";
  3630. // OverlayBtn.childVisible = false;
  3631. document.body.appendChild(OverlayBtn);
  3632.  
  3633. for (let b of presetOverlay)
  3634. {
  3635. let bButton = document.createElement("Button");
  3636. bButton.id = b[0];
  3637. bButton.url = b[1];
  3638. bButton.loaded = false;
  3639. bButton.classList.add("unity-btn", "minimap-btn", "overlay-minimap", "half", "horizontal-1");
  3640. bButton.innerHTML = b[0];
  3641. document.body.appendChild(bButton);
  3642. }
  3643.  
  3644. var MinimapMenuBtn = document.createElement("Button");
  3645. MinimapMenuBtn.classList.add("unity-btn", "menu-btn");
  3646. MinimapMenuBtn.id = "Minimap Menu Button";
  3647. document.body.appendChild(MinimapMenuBtn);
  3648. MinimapMenuBtn.addEventListener("click", () => {
  3649. switchBtn("minimap-btn");
  3650. if (OverlayBtn.style.visibility !== "hidden")
  3651. {
  3652. for (let element of document.getElementsByClassName("minimap-btn")){
  3653. element.style.visibility="hidden";
  3654. }
  3655. }
  3656. else
  3657. {
  3658. for (let element of document.getElementsByClassName("minimap-btn")){
  3659. element.style.visibility="";
  3660. }
  3661. }
  3662. });
  3663.  
  3664.  
  3665. // Space Buttons Module
  3666.  
  3667. // var SpaceMainmapBtn = document.createElement("Button");
  3668. // SpaceMainmapBtn.classList.add("unity-btn", "space-btn", "half", "horizontal-2", "vertical-1");
  3669. // SpaceMainmapBtn.id = "SpMini Button";
  3670. // SpaceMainmapBtn.innerHTML = "Minimap Style";
  3671. // SpaceMainmapBtn.current = "Default";
  3672. // // SpaceMainmapBtn.childVisible = false;
  3673. // document.body.appendChild(SpaceMainmapBtn);
  3674.  
  3675. // for (let a of spaceMainmap)
  3676. // {
  3677. // let saButton = document.createElement("Button");
  3678. // saButton.id = a[0];
  3679. // saButton.url = a[1];
  3680. // saButton.classList.add("unity-btn", "space-btn", "space-mainmap", "half", "horizontal-2");
  3681. // saButton.innerHTML = a[0];
  3682. // document.body.appendChild(saButton);
  3683. // }
  3684.  
  3685. var SpaceOverlayBtn = document.createElement("Button");
  3686. SpaceOverlayBtn.classList.add("unity-btn", "space-btn", "extra-full", "horizontal-1", "vertical-1");
  3687. SpaceOverlayBtn.id = "SpOver Button";
  3688. SpaceOverlayBtn.innerHTML = "Space";
  3689. SpaceOverlayBtn.current = "Clear";
  3690. // SpaceOverlayBtn.childVisible = false;
  3691. document.body.appendChild(SpaceOverlayBtn);
  3692.  
  3693. for (let b of spaceMinimap)
  3694. {
  3695. let sbButton = document.createElement("Button");
  3696. sbButton.id = b[0];
  3697. sbButton.url = b[1];
  3698. sbButton.classList.add("unity-btn", "space-btn", "spaceMM", "space-minimap", "half", "horizontal-1");
  3699. sbButton.innerHTML = b[0];
  3700. document.body.appendChild(sbButton);
  3701. }
  3702.  
  3703. for (let c of spaceMinimap2)
  3704. {
  3705. let scButton = document.createElement("Button");
  3706. scButton.id = c[0];
  3707. scButton.url = c[1];
  3708. scButton.classList.add("unity-btn", "space-btn", "spaceMM", "space-2minimap", "half", "horizontal-2");
  3709. scButton.innerHTML = c[0];
  3710. document.body.appendChild(scButton);
  3711. }
  3712.  
  3713. for (let d of spaceMinimap3)
  3714. {
  3715. let sdButton = document.createElement("Button");
  3716. sdButton.id = d[0];
  3717. sdButton.url = d[1];
  3718. sdButton.classList.add("unity-btn", "space-btn", "spaceMM", "space-3minimap", "half", "horizontal-3");
  3719. sdButton.innerHTML = d[0];
  3720. document.body.appendChild(sdButton);
  3721. }
  3722.  
  3723.  
  3724. var SpaceMenuBtn = document.createElement("Button");
  3725. SpaceMenuBtn.classList.add("unity-btn", "menu-btn");
  3726. SpaceMenuBtn.id = "Space Menu Button";
  3727. document.body.appendChild(SpaceMenuBtn);
  3728. SpaceMenuBtn.addEventListener("click", () => {
  3729. switchBtn("space-btn");
  3730. if (document.getElementById("Ceres").style.visibility !== "hidden")
  3731. {
  3732. for (let element of document.getElementsByClassName("space-btn")){
  3733. element.style.visibility = "hidden";
  3734. }
  3735. }
  3736. else
  3737. {
  3738. for (let element of document.getElementsByClassName("space-btn")){
  3739. element.style.visibility = "";
  3740. }
  3741. }
  3742. });
  3743.  
  3744. var wikiLocalLang = document.createElement("Button");
  3745. wikiLocalLang.classList.add("unity-btn", "full", "horizontal-1", "vertical-0");
  3746. wikiLocalLang.id = "local language";
  3747. wikiLocalLang.state = true;
  3748. wikiLocalLang.innerHTML = "Switch to Local Language";
  3749. document.body.appendChild(wikiLocalLang);
  3750. wikiLocalLang.addEventListener("click", () => {
  3751. if (wikiLocalLang.state && global_cc)
  3752. {
  3753. let cc = langDict[global_cc];
  3754. let fi = "en";
  3755. if (typeof cc !== typeof undefined)
  3756. {
  3757. fi = cc[Math.floor(Math.random() * cc.length)];
  3758. }
  3759. wiki(fi, document.getElementById("i_container"), teleportMenu);
  3760. wikiLocalLang.innerHTML = "Switch to English";
  3761. wikiLocalLang.state = false;
  3762. }
  3763. else if (wikiLocalLang.innerHTML == "Switch to English")
  3764. {
  3765. wiki("en", document.getElementById("i_container"), teleportMenu);
  3766. if (getLocalizationFromPathName() == "en"){
  3767. wikiLocalLang.innerHTML = "Switch to Local Language";
  3768. wikiLocalLang.state = true;
  3769. } else {
  3770. wikiLocalLang.innerHTML = "Switch to your language.";
  3771. }
  3772. } else {
  3773. wiki(getLocalizationFromPathName(), document.getElementById("i_container"), teleportMenu);
  3774. wikiLocalLang.innerHTML = "Switch to Local Language";
  3775. wikiLocalLang.state = true;
  3776. }
  3777. });
  3778.  
  3779. var specialMapMain = document.createElement("Button");
  3780. specialMapMain.classList.add("unity-btn", "special-map-btn", "full", "vertical-1");
  3781. specialMapMain.id = "Circus Main";
  3782. specialMapMain.innerHTML = "Circus Mode";
  3783. document.body.appendChild(specialMapMain);
  3784.  
  3785. var specialMapSky = document.createElement("Button");
  3786. specialMapSky.classList.add("unity-btn", "special-map-btn", "half", "horizontal-1", "vertical-2");
  3787. specialMapSky.id = "Circus Sky";
  3788. specialMapSky.innerHTML = "Sky";
  3789. document.body.appendChild(specialMapSky);
  3790. specialMapSky.addEventListener("click", () => {
  3791. skySpecial = !skySpecial;
  3792. if (skySpecial)
  3793. {
  3794. enterChaosMode(-999);
  3795. }
  3796. handleSpecialColor();
  3797. });
  3798.  
  3799. var specialMapSkewed = document.createElement("Button");
  3800. specialMapSkewed.classList.add("unity-btn", "special-map-btn", "half", "horizontal-2", "vertical-2");
  3801. specialMapSkewed.id = "Circus Skewed";
  3802. specialMapSkewed.innerHTML = "Skewed";
  3803. document.body.appendChild(specialMapSkewed);
  3804. specialMapSkewed.addEventListener("click", () => {
  3805. skewedSpecial = !skewedSpecial;
  3806. if (skewedSpecial)
  3807. {
  3808. enterChaosMode(-999);
  3809. }
  3810. handleSpecialColor();
  3811. });
  3812.  
  3813. var specialMapSoil = document.createElement("Button");
  3814. specialMapSoil.classList.add("unity-btn", "special-map-btn", "half", "horizontal-1", "vertical-3");
  3815. specialMapSoil.id = "Circus Soil";
  3816. specialMapSoil.innerHTML = "Soiled";
  3817. document.body.appendChild(specialMapSoil);
  3818. specialMapSoil.addEventListener("click", () => {
  3819. soilSpecial = !soilSpecial;
  3820. if (soilSpecial)
  3821. {
  3822. enterChaosMode(-999);
  3823. }
  3824. handleSpecialColor();
  3825. });
  3826.  
  3827. var specialMapZoom = document.createElement("Button");
  3828. specialMapZoom.classList.add("unity-btn", "special-map-btn", "half", "horizontal-2", "vertical-3");
  3829. specialMapZoom.id = "Circus Zoom";
  3830. specialMapZoom.innerHTML = "Max Zoom";
  3831. document.body.appendChild(specialMapZoom);
  3832. specialMapZoom.addEventListener("click", () => {
  3833. zoomSpecial = !zoomSpecial;
  3834. if (zoomSpecial)
  3835. {
  3836. enterChaosMode(-999);
  3837. }
  3838. handleSpecialColor();
  3839. });
  3840.  
  3841. var specialMapRandom = document.createElement("Button");
  3842. specialMapRandom.classList.add("unity-btn", "special-map-btn", "half", "horizontal-2", "vertical-4");
  3843. specialMapRandom.id = "Circus Random";
  3844. specialMapRandom.innerHTML = "Random";
  3845. document.body.appendChild(specialMapRandom);
  3846. specialMapRandom.addEventListener("click", () => {
  3847. randomSpecial = !randomSpecial;
  3848. if (randomSpecial)
  3849. {
  3850. enterChaosMode(-999);
  3851. }
  3852. handleSpecialColor();
  3853. });
  3854.  
  3855. var specialMapNMPZ = document.createElement("Button");
  3856. specialMapNMPZ.classList.add("unity-btn", "special-map-btn", "half", "horizontal-1", "vertical-4");
  3857. specialMapNMPZ.id = "Circus NMPZ";
  3858. specialMapNMPZ.innerHTML = "Force NMPZ";
  3859. document.body.appendChild(specialMapNMPZ);
  3860. specialMapNMPZ.addEventListener("click", () => {
  3861. if (!document.getElementById("specialNMPZ"))
  3862. {
  3863. loadNMPZ();
  3864. }
  3865. else
  3866. {
  3867. if (nmpzSpecial)
  3868. {
  3869. document.getElementById("specialNMPZ").style.visibility = "hidden";
  3870. }
  3871. else
  3872. {
  3873. document.getElementById("specialNMPZ").style.visibility = "";
  3874. }
  3875. nmpzSpecial = !nmpzSpecial;
  3876. }
  3877. handleSpecialColor();
  3878. });
  3879.  
  3880.  
  3881.  
  3882. var specialMapClear = document.createElement("Button");
  3883. specialMapClear.classList.add("unity-btn", "special-map-btn", "half", "horizontal-2", "vertical-5");
  3884. specialMapClear.id = "Circus Clear";
  3885. specialMapClear.innerHTML = "Clear All";
  3886. document.body.appendChild(specialMapClear);
  3887. specialMapClear.addEventListener("click", () => {
  3888. skySpecial = false;
  3889. skewedSpecial = false;
  3890. soilSpecial = false;
  3891. zoomSpecial = false;
  3892. randomSpecial = false;
  3893. enterChaosMode(-999);
  3894. handleSpecialColor();
  3895. });
  3896.  
  3897.  
  3898. var specialMapMenu = document.createElement("Button");
  3899. specialMapMenu.classList.add("unity-btn", "menu-btn");
  3900. specialMapMenu.id = "Circus Menu";
  3901. document.body.appendChild(specialMapMenu);
  3902. specialMapMenu.addEventListener("click", () => {
  3903. switchBtn("special-map-btn");
  3904. if (specialMapMain.style.visibility == "hidden")
  3905. {
  3906. for (let element of document.getElementsByClassName("special-map-btn"))
  3907. {
  3908. element.style.visibility = "";
  3909. }
  3910. }
  3911. else
  3912. {
  3913. for (let element of document.getElementsByClassName("special-map-btn"))
  3914. {
  3915. element.style.visibility = "hidden";
  3916. }
  3917. }
  3918. });
  3919.  
  3920. handleStyles();
  3921.  
  3922. if (sat_choice){
  3923. // Added by EC
  3924. const svCanvas = document.body.querySelector(GENERAL_CANVAS);
  3925. if (svCanvas) svCanvas.style.visibility = "hidden";
  3926. }
  3927.  
  3928. console.log("Script buttons Loaded");
  3929. UnityInitiate.callbacks.forEach( cb => cb() );
  3930. }// End UntityInitiate();
  3931.  
  3932. UnityInitiate.callbacks = [];
  3933. UnityInitiate.removeCallback = function(cb){
  3934. for (let n = 0; n < UnityInitiate.callbacks.length;n++){
  3935. if (UnityInitiate.callbacks[n] == cb){
  3936. UnityInitiate.callbacks.splice(n, 1);
  3937. return;
  3938. }
  3939. }
  3940. }
  3941.  
  3942. function loadNMPZ()
  3943. {
  3944. let gridBtn = document.createElement("div");
  3945. gridBtn.id = "specialNMPZ";
  3946. // visibility: hidden;
  3947. gridBtn.style =
  3948. `
  3949. display: grid;
  3950. gap: 0px;
  3951. top: 0px;
  3952. left: 0px;
  3953. position: absolute;
  3954. width: 100%;
  3955. height: 100%;
  3956. z-index: 1;
  3957. `;
  3958. GAME_CANVAS.appendChild(gridBtn);
  3959. }
  3960.  
  3961. // Handle Grid Mode
  3962.  
  3963. function loadGridBtn(num)
  3964. {
  3965. let gridCanvas = document.getElementById("grid");
  3966. let reload = false;
  3967. if (!gridCanvas && num !== 0)
  3968. {
  3969. let gridBtn = document.createElement("div");
  3970. gridBtn.id = "grid";
  3971. // visibility: hidden;
  3972. gridBtn.style =
  3973. `
  3974. display: grid;
  3975. gap: 0px;
  3976. top: 0px;
  3977. left: 0px;
  3978. position: absolute;
  3979. width: 100%;
  3980. height: 100%;
  3981. z-index: 1;
  3982. `;
  3983. GAME_CANVAS.appendChild(gridBtn);
  3984. gridCanvas = gridBtn;
  3985. reload = true;
  3986. }
  3987.  
  3988. if (gridCanvas)
  3989. {
  3990. let mosaicMenu = document.getElementById("Mosaic Enable");
  3991. if (num !== mosaicMenu.grid || reload)
  3992. {
  3993. console.log("Generate Mosaic tiles");
  3994. gridCanvas.innerHTML = "";
  3995. mosaicMenu.grid = num;
  3996. // cond = true;
  3997. if (num !== 0)
  3998. {
  3999. gridCanvas.style.visibility = "";
  4000. for (let i = 1; i < num+1; i++)
  4001. {
  4002. for (let ii = 1; ii < num+1; ii++)
  4003. {
  4004. let btn1 = document.createElement("Button");
  4005. btn1.style =
  4006. `grid-column: ${ii};
  4007. grid-row: ${i};
  4008. `;
  4009. btn1.classList.add("grid-btn");
  4010. if (num < 21 && mosaicMenu.label)
  4011. {
  4012. btn1.innerHTML = `(${ii}, ${i})`;
  4013. }
  4014. btn1.addEventListener("click", () => {
  4015. btn1.style.visibility = "hidden";
  4016. });
  4017. if (mosaicMenu.color)
  4018. {
  4019. btn1.style.background = '#' + (Math.random() * 0xFFFFFF<<0).toString(16);
  4020. }
  4021. gridCanvas.appendChild(btn1);
  4022. }
  4023. }
  4024. mosaicMenu.grid = num;
  4025. }
  4026. else
  4027. {
  4028. gridCanvas.style.visibility = "hidden";
  4029.  
  4030. }
  4031.  
  4032. for (let grid2 of document.getElementsByClassName("grid-size"))
  4033. {
  4034. grid2.style.background = "#ff69b4cc";
  4035. if (parseInt(grid2.id.replace(/\D/g,'')) == mosaicMenu.grid)
  4036. {
  4037. grid2.style.background = "#ff1493cc";
  4038. }
  4039. }
  4040. }
  4041.  
  4042. if (num !== 0)
  4043. {
  4044. gridCanvas.style.visibility = "";
  4045. for (let grid1 of document.getElementsByClassName("grid-btn"))
  4046. {
  4047. grid1.style.visibility = "";
  4048. }
  4049. mosaicPre = true;
  4050. }
  4051. else
  4052. {
  4053. mosaicPre = false;
  4054. }
  4055. }
  4056. }
  4057.  
  4058.  
  4059. function GenBtnColor()
  4060. {
  4061. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4062. let timeMachineOlderBtn = document.getElementById("minus year");
  4063. let timeMachineNewerBtn = document.getElementById("plus year");
  4064. let timeMachineBtn = document.getElementById("Date Button");
  4065. if (timeMachineBtn.index == timeMachineBtn.list.length - 1)
  4066. {
  4067. timeMachineNewerBtn.style.backgroundColor = "red";
  4068. timeMachineNewerBtn.disabled = true;
  4069. }
  4070. else
  4071. {
  4072. timeMachineNewerBtn.style.backgroundColor = "#ba55d3cc";
  4073. timeMachineNewerBtn.disabled = false;
  4074. }
  4075. if (timeMachineBtn.index == 0)
  4076. {
  4077. timeMachineOlderBtn.style.backgroundColor = "red";
  4078. timeMachineOlderBtn.disabled = true;
  4079. }
  4080. else
  4081. {
  4082. timeMachineOlderBtn.style.backgroundColor = "#ba55d3cc";
  4083. timeMachineOlderBtn.disabled = false;
  4084. }
  4085. }
  4086.  
  4087. /**
  4088. * Handle Keyboard inputs
  4089. */
  4090.  
  4091. function kBoard()
  4092. {
  4093. document.addEventListener('keydown', logKey);
  4094. }
  4095.  
  4096. function logKey(e) {
  4097. // console.log(e.code);
  4098. let isGamePage2 = ["challenge", "results", "game", "battle-royale", "duels", "team-duels", "bullseye"].some(v => window.location.pathname.includes(v));
  4099. if (isGamePage2)
  4100. {
  4101. let mainMenuBtn = document.getElementById("Show Buttons");
  4102. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4103. if (e.code == "Space")
  4104. {
  4105. setHidden(true);
  4106. }
  4107. if (e.code == "Digit4")
  4108. {
  4109. // Got a DM from Mika and this appeared to be causeing people to jump forward in nm duels.
  4110. // I can't duplicate it on my computer, but I don't think this is a feature that will be missed.
  4111. }
  4112. if (e.code == "Digit3")
  4113. {
  4114. // Got a DM from Mika and this appeared to be causeing people to jump forward in nm duels.
  4115. // I can't duplicate it on my computer, but I don't think this is a feature that will be missed.
  4116. }
  4117. else if (e.code == "Digit5")
  4118. {
  4119. document.getElementById("minus year").click();
  4120. }
  4121. else if (e.code == "Digit6")
  4122. {
  4123. document.getElementById("Date Button").click();
  4124. }
  4125. else if (e.code == "Digit7")
  4126. {
  4127. document.getElementById("plus year").click();
  4128. }
  4129. else if (e.code == "Digit8")
  4130. {
  4131. if (mainMenuBtn.style.visibility == "hidden")
  4132. {
  4133. mainMenuBtn.style.visibility = "";
  4134. }
  4135. else
  4136. {
  4137. mainMenuBtn.style.visibility = "hidden";
  4138. }
  4139. }
  4140. else if (e.code == "Digit9")
  4141. {
  4142. document.getElementById("Restrict Bounds Main").maxDist = 100000000;
  4143. document.getElementById("Increase Restrict Distance").click();
  4144. if (!document.getElementById("Restrict Bounds Main").enabled)
  4145. {
  4146. document.getElementById("Restrict Bounds Enable").click();
  4147. }
  4148. }
  4149. }
  4150. }
  4151.  
  4152.  
  4153. /**
  4154. * Hide or reveal the buttons, and disable buttons if such feature is not available
  4155. */
  4156.  
  4157. function setHidden(cond)
  4158. {
  4159. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4160. let teleportBtn = document.getElementById("Teleport Forward");
  4161. let mainMenuBtn = document.getElementById("Show Buttons");
  4162. if (mainMenuBtn != null)
  4163. {
  4164. mainMenuBtn.style.visibility = "";
  4165. // mainMenuBtn.hide = cond;
  4166. // console.log(["cache", mainMenuBtn.menuBtnCache]);
  4167. if (cond)
  4168. {
  4169. if (teleportBtn != null)
  4170. {
  4171. for (let element of document.getElementsByClassName("unity-btn")){
  4172. element.style.visibility = "hidden";
  4173. }
  4174. }
  4175. let iframe = document.getElementById("i_container");
  4176. if (iframe != null)
  4177. {
  4178. if (!isBattleRoyale)
  4179. {
  4180. iframe.src = ""
  4181. }
  4182. }
  4183. }
  4184. else
  4185. {
  4186. for (let element of document.getElementsByClassName("unity-btn")){
  4187. if (element.id !== "Show Buttons" && !element.classList.contains("menu-btn"))
  4188. {
  4189. element.style.visibility = "hidden";
  4190. }
  4191. }
  4192. }
  4193. }
  4194. }
  4195.  
  4196. function setMenuBtnsUnhidden(){
  4197. // Added by EC
  4198. let mainMenuBtn = document.getElementById("Show Buttons");
  4199. let btns= setButtons3();
  4200. for (let element of btns){
  4201. if (element == mainMenuBtn){
  4202. element.style.visibility = "";
  4203. }
  4204. if (!mainMenuBtn.hide){
  4205. element.style.visibility = "";
  4206. }
  4207. }
  4208. }
  4209.  
  4210. function setDisable(cond) {
  4211. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4212. let btnList = [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ];
  4213.  
  4214. function setAll(cond1, cond2)
  4215. {
  4216. for (let btn of btnList)
  4217. {
  4218. btn.style.backgroundColor = cond1;
  4219. btn.disabled = cond2;
  4220. }
  4221. }
  4222.  
  4223. function setMapstyle(cond1, cond2)
  4224. {
  4225. for (let mapDiv of document.getElementsByClassName("preset-minimap"))
  4226. {
  4227. if (["Borders", "Satellite", "Terrain", "Hybrid", "Custom"].includes(mapDiv.id))
  4228. {
  4229. mapDiv.style.backgroundColor = cond1;
  4230. mapDiv.disabled = cond2;
  4231. }
  4232. }
  4233. for (let mapDiv2 of document.getElementsByClassName("overlay-minimap"))
  4234. {
  4235. if (["Coverage", "Official", "OSM"].includes(mapDiv2.id))
  4236. {
  4237. mapDiv2.style.backgroundColor = cond1;
  4238. mapDiv2.disabled = cond2;
  4239. }
  4240. }
  4241. }
  4242.  
  4243. if (teleportBtn != null) {
  4244. setMapstylePlanet("None");
  4245. if (rtded) {
  4246. setAll("red", true);
  4247. setMapstyle("red", true);
  4248. }
  4249. else
  4250. {
  4251. setMapstyle("#ff69b4cc", false)
  4252. if (cond === "NMPZ") {
  4253. setAll("red", true);
  4254. if (nextPlayer !== "Baidu")
  4255. {
  4256. satelliteSwitchButton.style.backgroundColor = "#ba55d3cc";
  4257. satelliteSwitchButton.disabled = false;
  4258. }
  4259. if (nextPlayer !== "Google")
  4260. {
  4261. switchCovergeButton.style.backgroundColor = "#ba55d3cc";
  4262. switchCovergeButton.disabled = false;
  4263. }
  4264. if (NZ)
  4265. {
  4266. if (ms_radius > 5000)
  4267. {
  4268. ms_radius = 5000;
  4269. }
  4270. }
  4271. if (NM)
  4272. {
  4273. if (ms_radius > 2000)
  4274. {
  4275. ms_radius = 2000;
  4276. }
  4277. }
  4278. if (NM && NP && NZ)
  4279. {
  4280. if (ms_radius > 1000)
  4281. {
  4282. ms_radius = 1000;
  4283. }
  4284. }
  4285. }
  4286. else if (nextPlayer == "Google" || nextPlayer === "Wikipedia" || nextPlayer === "Youtube") {
  4287. setAll("#ba55d3cc", false);
  4288. if (bullseyeMapillary && nextPlayer === "Google")
  4289. {
  4290. switchCovergeButton.style.backgroundColor = "red";
  4291. switchCovergeButton.disabled = true;
  4292. }
  4293. }
  4294. else if (nextPlayer === "Baidu" || nextPlayer === "Image" || nextPlayer === "Minecraft" || nextPlayer === "Carte") {
  4295. setAll("red", true);
  4296. switchCovergeButton.style.backgroundColor = "#ba55d3cc";
  4297. switchCovergeButton.disabled = false;
  4298. if (nextPlayer !== "Baidu")
  4299. {
  4300. satelliteSwitchButton.style.backgroundColor = "#ba55d3cc";
  4301. satelliteSwitchButton.disabled = false;
  4302. }
  4303. }
  4304. else if (nextPlayer == "Kakao" || nextPlayer == "Yandex" || nextPlayer == "Mapillary" || nextPlayer == "Bing Streetside" || nextPlayer == "Mapy") {
  4305. setAll("#ba55d3cc", false);
  4306. timeMachineBtn.style.backgroundColor = "red";
  4307. timeMachineBtn.disabled = true;
  4308. let li = [RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn]
  4309. for (let btns of li)
  4310. {
  4311. btns.style.backgroundColor = "red";
  4312. btns.disabled = true;
  4313. }
  4314.  
  4315. }
  4316. else if (nextPlayer == "Mapbox Satellite") {
  4317. setAll("#ba55d3cc", false);
  4318. timeMachineBtn.style.backgroundColor = "red";
  4319. timeMachineBtn.disabled = true;
  4320. for (let btns of document.getElementsByClassName("teleport-btn"))
  4321. {
  4322. btns.style.backgroundColor = "red";
  4323. btns.disabled = true;
  4324. }
  4325. }
  4326. else if (nextPlayer == "Planets") {
  4327. setAll("red", true);
  4328. console.log("setting map style");
  4329. setMapstyle("red", true);
  4330. setMapstylePlanet(planetType);
  4331. }
  4332. }
  4333. timeMachineNewerBtn.style.backgroundColor = "red";
  4334. timeMachineNewerBtn.disabled = true;
  4335. timeMachineOlderBtn.style.backgroundColor = "red";
  4336. timeMachineOlderBtn.disabled = true;
  4337.  
  4338. }
  4339. }
  4340.  
  4341. function setMapstylePlanet(cond)
  4342. {
  4343. for (let mapDiv of document.getElementsByClassName("spaceMM"))
  4344. {
  4345. if (cond == "None" && mapDiv.id.includes("Earth"))
  4346. {
  4347. mapDiv.style.backgroundColor = "#ff1493cc";
  4348. mapDiv.disabled = false;
  4349. }
  4350. else if (mapDiv.id.includes(cond) || mapDiv.id.includes("Earth"))
  4351. {
  4352. mapDiv.style.backgroundColor = "#ff69b4cc";
  4353. mapDiv.disabled = false;
  4354. }
  4355. else
  4356. {
  4357. mapDiv.style.backgroundColor = "red";
  4358. mapDiv.disabled = true;
  4359. }
  4360. }
  4361. }
  4362.  
  4363.  
  4364. /**
  4365. * This observer stays alive while the script is running
  4366. */
  4367.  
  4368. let alreadyLaunchedObserver = false;
  4369. function launchObserver() {
  4370. if (alreadyLaunchedObserver) return;
  4371. alreadyLaunchedObserver = true;
  4372.  
  4373. //let sat4 = document.body.querySelector(".fullscreen-spinner_square__mwMfl");
  4374. let sat4 = document.body.querySelector(`div[class*="spinner"]`);
  4375. if (sat4) {
  4376. // Added by EC.
  4377. const svCanvas = document.body.querySelector(GENERAL_CANVAS);
  4378. if (svCanvas) svCanvas.style.visibility = "hidden";
  4379. }
  4380.  
  4381. UnityInitiate();
  4382. handleTeleport();
  4383. SyncListener();
  4384. kBoard();
  4385.  
  4386. console.log("Unity Main Observer");
  4387. // const OBSERVER = new MutationObserver((mutations, observer) => {
  4388. // detectGamePage();
  4389. // });
  4390. // OBSERVER.observe(document.head, { attributes: true, childList: true, subtree: true });
  4391. let observer3 = new MutationObserver((mutations) => {
  4392. mutations.forEach((mutation) => {
  4393. if (oldHref != document.location.href && allowDetect) {
  4394. oldHref = document.location.href;
  4395. }
  4396. if (mutation.removedNodes)
  4397. {
  4398. for (let m of mutation.removedNodes) {
  4399. if (m.classList)
  4400. {
  4401. // Comment added by EC: Recycle old sat-map by catching it before it gets deleted, saving it, then re-appending it later.
  4402. // TODO EC: Is recycling the mini map necessary?
  4403.  
  4404. let sat = m.getElementsByTagName('sat-map');
  4405. let sat0 = null;
  4406. // let minimap = m.querySelector('.game_guessMap__MTlQ_');
  4407.  
  4408. if (sat.length !== 0)
  4409. {
  4410. console.log("Recycling the satellite map.");
  4411.  
  4412. sat0 = sat[0];
  4413.  
  4414. sat0.style.display = "none";
  4415. //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")
  4416. document.body.appendChild(sat0);
  4417. //document.body.appendChild(minimap);
  4418.  
  4419. let t = setInterval(()=>{
  4420.  
  4421. let GAME_CANVAS = document.querySelector(GENERAL_LAYOUT);
  4422. if (!GAME_CANVAS) return;
  4423.  
  4424. clearInterval(t);
  4425.  
  4426. GAME_CANVAS.id = "player";
  4427. GAME_CANVAS.appendChild(sat0)
  4428.  
  4429. // GAME_CANVAS.appendChild(minimap)
  4430.  
  4431. sat0.style.display = "";
  4432.  
  4433. detectGamePage();
  4434.  
  4435. }, 100);
  4436. }
  4437.  
  4438.  
  4439. }
  4440. }
  4441. }
  4442. if (mutation.addedNodes)
  4443. {
  4444. for (let m of mutation.addedNodes) {
  4445. // console.log(m);
  4446. if (m.classList)
  4447. {
  4448. // console.log(m)
  4449. // let sat3 = m.getElementsByClassName("tooltip_tooltip__CHe2s");
  4450. let PATHNAME = getPathName();
  4451. let spinner = document.querySelector('div[class*="spinner"]');//(m.getElementsByClassName('fullscreen-spinner_square__NGIgc'));
  4452. //let sat4 = m.getElementsByClassName('fullscreen-spinner_square__mwMfl');
  4453. // console.log(m.classList.contains('round-starting_wrapper__1G_FC'));
  4454.  
  4455. //if (m.classList.contains("game-layout__panorama-message"))
  4456. // if (document.body.querySelector(`[class*="game_panoramaMessage"]`))
  4457. if (checkFailedToLoadRoundMsg())
  4458. {
  4459. console.log("Fail to load canvas message - observer3")
  4460. if (allowDetect)
  4461. {
  4462. detectGamePage();
  4463. }
  4464. }
  4465. else if (m.getElementsByClassName("tooltip_tooltip__CHe2s").length !== 0)
  4466. {
  4467. // console.log("detect setting")
  4468. let mainMenuBtn = document.getElementById("Show Buttons");
  4469. if (mainMenuBtn != null)
  4470. {
  4471. // console.log("try to show show buttons")
  4472. mainMenuBtn.style.visibility = "";
  4473. if (mainMenuBtn.menuBtnCache)
  4474. {
  4475. for (let element of document.getElementsByClassName("menu-btn"))
  4476. {
  4477. element.style.visibility = "";
  4478. }
  4479. }
  4480. }
  4481. detectGamePage();
  4482. }
  4483. else if ((PATHNAME.startsWith("/challenge/") ||PATHNAME.startsWith("/results/") ||
  4484. PATHNAME.startsWith("/game/")|| PATHNAME.startsWith("/battle-royale/") ||
  4485. PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/") ||
  4486. PATHNAME.startsWith("/bullseye/")) && spinner)
  4487. {
  4488. // console.log("detect spinner")
  4489. if (allowDetect)
  4490. {
  4491. // obeserver detect
  4492. console.log('Main observer detect')
  4493. detectGamePage();
  4494. }
  4495. }
  4496. else if (!isPlayAlong && PATHNAME.startsWith("/play-along/")){
  4497. console.log("unity main observer detected play-along")
  4498.  
  4499. isPlayAlong = true;
  4500.  
  4501. if (allowDetect)
  4502. {
  4503. //detectGamePage();
  4504. setTimeout(()=>{
  4505. btnAll();
  4506. setMenuBtnsUnhidden();
  4507. }, 2000);
  4508. playAlongWebSocketInit();
  4509. }
  4510.  
  4511. }
  4512. else if ((PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/play-along/")) && (m.classList.contains('new-round_roundInfo__UlMCc')))
  4513. {
  4514. // console.log("detect duel")
  4515. if (allowDetect)
  4516. {
  4517. detectGamePage();
  4518. }
  4519. }
  4520. else if (PATHNAME.startsWith("/live-challenge/") && (m.classList.contains('round-starting_wrapper__1G_FC')))
  4521. {
  4522. // console.log("detect live challie")
  4523. if (allowDetect)
  4524. {
  4525. detectGamePage();
  4526. }
  4527. }
  4528.  
  4529. let sat = m.getElementsByClassName('result-layout_bottom__qLPd2');
  4530.  
  4531. // if (m.querySelectorAll('div[class*="result-layout_bottom"]').length !== 0)
  4532. // {
  4533. // // console.log("Round middle Callback");
  4534. // // EC : This puts links at the bottom of the next round button for say satellite mode or something.
  4535. // // I'm not sure if this is necessary.
  4536. // nextButtonCallback();
  4537. // }
  4538.  
  4539. let sat2 = m.getElementsByClassName('guess-map__canvas-container');
  4540. if (sat2.length !== 0)
  4541. {
  4542. // console.log("Minimap Callback");
  4543. handleMinimapCallback();
  4544. return;
  4545. }
  4546.  
  4547. if (PATHNAME.startsWith("/results/")){
  4548. // Made by EC for UAC
  4549. let mapsAnchor = document.querySelector('a[href^="/maps/"]');
  4550. if (mapsAnchor){
  4551. fetchOnce(`https://www.geoguessr.com/api/${mapsAnchor.href.replace(/.*(maps.*)/, "$1")}`, 5000)
  4552. .then((res) => res.json())
  4553. .then((json)=> {
  4554. // TODO EC: Do something here.
  4555. if (!/UAC/.test(json.name)){
  4556. return;
  4557. }
  4558.  
  4559. if (!json?.description){
  4560. showUACAnswerBtn(null);
  4561. return;
  4562. }
  4563.  
  4564. const answerHref = json.description?.replace(/\[\[(http.*?)\]\]/, "$1");
  4565. let t = fetch(answerHref)
  4566. .then((res) => res.json())
  4567. .then((json) => {
  4568. showUACAnswerBtn(JSON.stringify(json));
  4569. //unhackableAnswers(JSON.stringify(json));
  4570. }).catch(()=>{
  4571. showUACAnswerBtn(null);
  4572. });
  4573. })
  4574. .catch(function(e){ console.warn("FetchOnce called more than once.")});
  4575. }
  4576. }
  4577. }
  4578. }
  4579. }
  4580. })
  4581. })
  4582. observer3.observe(document.body, {childList: true, subtree: true, attributes: false, characterData: false})
  4583. }
  4584.  
  4585. let fetchOnce = function(){
  4586. // Made by EC
  4587. let obj = {};
  4588. return function(url, timeToWait){
  4589. if (obj[url]) return new Promise((res, rej) =>{ rej(); });
  4590. obj[url] = true;
  4591. return fetch(url);
  4592. }
  4593. }();
  4594.  
  4595. /**
  4596. * Once the Google Maps API was loaded we can do more stuff
  4597. */
  4598.  
  4599. var oldHref = document.location.href;
  4600.  
  4601. const immediateLoad = localStorage['unity_immediate_load']; // EC
  4602. const _pathName = getPathName();
  4603. if (_pathName.startsWith("/play-along/") || _pathName.startsWith("/challenge/") || _pathName.startsWith("/game/") || _pathName.startsWith("/results/") || immediateLoad === "true"){
  4604. // EC made this to fix not loading during game.
  4605. injecter(() => {
  4606. launchObserver();
  4607. })
  4608. localStorage['unity_immediate_load'] = false;
  4609. }
  4610.  
  4611. window.addEventListener('DOMContentLoaded', (event) => {
  4612. // Added by EC
  4613. doInitScript();
  4614. });
  4615.  
  4616. window.addEventListener('load', (event) => {
  4617. // Added by EC
  4618. doInitScript();
  4619. });
  4620.  
  4621. function doInitScript(){
  4622. // doInitScript added by EC.
  4623. if (sat_choice){
  4624. // Added by EC
  4625. const svCanvas = document.body.querySelector(GENERAL_CANVAS);
  4626. if (svCanvas) svCanvas.style.visibility = "hidden";
  4627. }
  4628. if (!document.getElementById("Show Buttons"))
  4629. {
  4630. console.log('dom content loaded')
  4631. injecter(() => {
  4632. launchObserver();
  4633. })
  4634. }
  4635.  
  4636. }
  4637.  
  4638. const base62 = {
  4639. charset: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  4640. .split(''),
  4641. encode: integer => {
  4642. if (integer === 0) {
  4643. return 0;
  4644. }
  4645. let s = [];
  4646. while (integer > 0) {
  4647. s = [base62.charset[integer % 62], ...s];
  4648. integer = Math.floor(integer / 62);
  4649. }
  4650. return s.join('');
  4651. },
  4652. decode: chars => chars.split('').reverse().reduce((prev, curr, i) =>
  4653. prev + (base62.charset.indexOf(curr) * (62 ** i)), 0)
  4654. };
  4655.  
  4656.  
  4657. /**
  4658. * Check whether the current page is a game, if so which game mode
  4659. */
  4660.  
  4661. function detectGamePage() {
  4662. // console.log("detect game change");
  4663. if (document.querySelector(FAIL_TO_LOAD_CANVAS) !== null && !one_reset)
  4664. {
  4665. one_reset = true;
  4666. console.log("Hide fail to load panorama canvas");
  4667. document.querySelector(FAIL_TO_LOAD_CANVAS).style.visibility = "hidden";
  4668. }
  4669. function loadModule()
  4670. {
  4671. // console.log("load module")
  4672. if (toLoad) {
  4673. // console.log("initializeCanvas")
  4674. initializeCanvas();
  4675. }
  4676. waitLoad();
  4677. }
  4678.  
  4679. let toLoad = !playerLoaded && !isPlayAlong && !YANDEX_INJECTED && !KAKAO_INJECTED && !MAPILLARY_INJECTED && !MS_INJECTED && !MAPBOX_INJECTED && !MAPY_INJECTED;
  4680. const PATHNAME = getPathName();
  4681. if (PATHNAME.startsWith("/game/") || PATHNAME.startsWith("/challenge/") || PATHNAME.startsWith("/play-along/")) {
  4682. // console.log("Game page");
  4683. isBattleRoyale = false;
  4684. isDuel = false;
  4685. loadModule();
  4686. }
  4687. else if (PATHNAME.startsWith("/battle-royale/")) {
  4688. if (document.querySelector(BR_LAYOUT) == null) {
  4689. // console.log("Battle Royale Lobby");
  4690. rstValues();
  4691. }
  4692. else {
  4693. // console.log("Battle Royale");
  4694. isBattleRoyale = true;
  4695. isDuel = false;
  4696. loadModule();
  4697. }
  4698. }
  4699. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  4700. if (document.querySelector(DUEL_LAYOUT) == null) {
  4701. // console.log("Battle Royale Lobby");
  4702. rstValues();
  4703. }
  4704. else {
  4705. // console.log("Duels");
  4706. isBattleRoyale = true;
  4707. isDuel = true;
  4708. loadModule();
  4709. }
  4710. }
  4711. else if (PATHNAME.startsWith("/bullseye/")) {
  4712. if (document.querySelector(".game_layout__0vAWj") == null) {
  4713. // console.log("Battle Royale Lobby");
  4714. rstValues();
  4715. }
  4716. else {
  4717. // console.log("bullseye");
  4718. isBattleRoyale = true;
  4719. isBullseye = true;
  4720. // console.log(document.getElementById("player"));
  4721. if (document.getElementById("player") == null)
  4722. {
  4723. loadModule();
  4724. }
  4725. }
  4726. }
  4727. else if (PATHNAME.startsWith("/live-challenge/")) {
  4728. if (document.querySelector(".panorama-question_layout__wSP7g") == null) {
  4729. // console.log("Battle Royale Lobby");
  4730. rstValues();
  4731. }
  4732. else {
  4733. // console.log("bullseye");
  4734. isLiveChallenge = true;
  4735. isBattleRoyale = true;
  4736. loadModule();
  4737. }
  4738. }
  4739. else {
  4740. rstValues();
  4741. // console.log("Not a Game page");
  4742. }
  4743. }
  4744.  
  4745. function rstValues()
  4746. {
  4747. ROUND = 0;
  4748. YandexPlayer = null;
  4749. KakaoPlayer = null;
  4750. MapillaryPlayer = null;
  4751. MSStreetPlayer = null;
  4752. MapyPlayer = null;
  4753.  
  4754. // MapboxPlayer = null;
  4755. // MapboxMarker = null;
  4756.  
  4757. BAIDU_INJECTED = false;
  4758. YANDEX_INJECTED = false;
  4759. KAKAO_INJECTED = false;
  4760. MAPILLARY_INJECTED = false;
  4761. MS_INJECTED = false;
  4762. MAPBOX_INJECTED = false;
  4763. MAPY_INJECTED = false;
  4764.  
  4765. nextPlayer = "Google";
  4766. nextPlayer_save = "Google";
  4767.  
  4768. global_data = {};
  4769. global_lat = 0;
  4770. global_lng = 0;
  4771. global_bounds = {max : {lat: 50.387397, lng: 57.412767}, min : {lat: 50.181227, lng: 57.077273}};
  4772. global_panoID = null;
  4773. global_cc = null;
  4774. global_BDAh = null;
  4775. global_BDBh = null;
  4776. global_BDID = null;
  4777. yId = null;
  4778. yTime = null;
  4779. yEnd = null;
  4780. iId = null;
  4781.  
  4782. COMPASS = null;
  4783. eventListenerAttached = false;
  4784. povListenerAttached = false;
  4785. playerLoaded = false;
  4786. handleBtwRoundsClear();
  4787. setHidden(true);
  4788. yandex_map = false;
  4789. Kakao_map = false;
  4790. Wikipedia_map = false;
  4791. Minecraft_map = false;
  4792. Youtube_map = false;
  4793. bing_map = false;
  4794. Mapy_map = false;
  4795. mmKey = 0;
  4796. CURRENT_ROUND_DATA = null;
  4797. ms_radius = 15000;
  4798.  
  4799. isDuel = false;
  4800. isBattleRoyale = false;
  4801. isBullseye = false;
  4802. isLiveChallenge = false;
  4803.  
  4804. BR_LOAD_KAKAO = false;
  4805. BR_LOAD_YANDEX = false;
  4806. BR_LOAD_MS = false;
  4807. BR_LOAD_MP = false;
  4808. BR_LOAD_MAPILLARY = false;
  4809. BR_LOAD_MAPY = false;
  4810.  
  4811. ms_sat_map = false;
  4812. rtded = false;
  4813.  
  4814. linksList = [];
  4815.  
  4816. NM = false;
  4817. NP = false;
  4818. NZ = false;
  4819. initBing = false;
  4820.  
  4821. planetType = "None";
  4822. bullseyeMapillary = false;
  4823.  
  4824. GAME_CANVAS = "";
  4825. DUEL_CANVAS = "";
  4826. randomPlanets = false;
  4827.  
  4828. // let RestrictBoundsBtn = document.getElementById("Restrict Bounds Main");
  4829. // let RestrictBoundsEnableBtn = document.getElementById("Restrict Bounds Enable");
  4830. // if (RestrictBoundsBtn && RestrictBoundsEnableBtn)
  4831. // {
  4832. // RestrictBoundsBtn.innerHTML = "No Escape Mode Disabled";
  4833. // RestrictBoundsBtn.enabled = false;
  4834. // RestrictBoundsEnableBtn.innerHTML = "Enable Limit";
  4835. // }
  4836. }
  4837.  
  4838. /**
  4839. * Wait for various players to load
  4840. */
  4841.  
  4842. function btnAll()
  4843. {
  4844. // console.log([document.querySelector(BULLSEYE_CANVAS), "???"])
  4845. if (document.querySelector(".ticket-bar_root__H8RcX") != null)
  4846. {
  4847. if (document.querySelector(BR_CANVAS) != null)
  4848. {
  4849. AdjustBtnPos("-2em + 2px", "300px", true);
  4850. }
  4851. else if (document.querySelector(DUELS_CANVAS) != null)
  4852. {
  4853. AdjustBtnPos("6em", "0em", true);
  4854. }
  4855. else if (document.querySelector(BULLSEYE_CANVAS) != null)
  4856. {
  4857. AdjustBtnPos("5em", "18.5em", true);
  4858. }
  4859. else if (document.querySelector(LIVE_CANVAS) != null)
  4860. {
  4861. AdjustBtnPos("4em", "0em", true);
  4862. }
  4863. else
  4864. {
  4865. AdjustBtnPos("4em", "0em", true);
  4866. }
  4867. }
  4868. else
  4869. {
  4870. if (document.querySelector(BR_CANVAS) != null)
  4871. {
  4872. AdjustBtnPos("-6em + 2px", "300px", true);
  4873. }
  4874. else if (document.querySelector(DUELS_CANVAS) != null)
  4875. {
  4876. AdjustBtnPos("2em", "0em", true);
  4877. }
  4878. else if (document.querySelector(BULLSEYE_CANVAS) != null)
  4879. {
  4880. AdjustBtnPos("1em", "18.5em", true);
  4881. }
  4882. else if (document.querySelector(LIVE_CANVAS) != null)
  4883. {
  4884. AdjustBtnPos("0em", "0em", true);
  4885. }
  4886. else
  4887. {
  4888. AdjustBtnPos("0em", "0em", true);
  4889. }
  4890. }
  4891. if (menuLocCounter > 0)
  4892. {
  4893. for (let i = 0; i < menuLocCounter; i++) {
  4894. AdjustBtnPos("-2em", "0em", false);
  4895. }
  4896. }
  4897. else if (menuLocCounter < 0)
  4898. {
  4899. for (let i = 0; i < -menuLocCounter; i++) {
  4900. AdjustBtnPos("2em", "0em", false);
  4901. }
  4902. }
  4903. }
  4904.  
  4905. function waitLoad() {
  4906. //if (!YandexPlayer || !KakaoPlayer || !MapillaryPlayer || !MSStreetPlayer || !MapboxPlayer || !MapyPlayer || !document.getElementById("i_container") || !YANDEX_INJECTED || !KAKAO_INJECTED || !MAPILLARY_INJECTED || !MS_INJECTED || !MAPBOX_INJECTED || !MAPY_INJECTED) {
  4907. if (isPlayAlong) return;
  4908. if (!YandexPlayer || !KakaoPlayer || !MapillaryPlayer || !MSStreetPlayer || !MapboxPlayer || !MapyPlayer /*|| !document.getElementById("i_container")*/ || !YANDEX_INJECTED || !KAKAO_INJECTED || !MAPILLARY_INJECTED || !MS_INJECTED || !MAPBOX_INJECTED || !MAPY_INJECTED) {
  4909. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4910.  
  4911. if ((isBullseye || isLiveChallenge) && (document.getElementById("player") == null))
  4912. {
  4913. BAIDU_INJECTED = false;
  4914. YANDEX_INJECTED = false;
  4915. KAKAO_INJECTED = false;
  4916. MAPILLARY_INJECTED = false;
  4917. MS_INJECTED = false;
  4918. MAPBOX_INJECTED = false;
  4919. MAPY_INJECTED = false;
  4920. initializeCanvas();
  4921. // document.querySelector(BULLSEYE_CANVAS).id = "player";
  4922. // injectContainer();
  4923. }
  4924. btnAll();
  4925. // console.log("wait");
  4926. // console.log([!YandexPlayer, !KakaoPlayer,!MapillaryPlayer,!MSStreetPlayer,!MapboxPlayer,!MapyPlayer,!document.getElementById("i_container"),!YANDEX_INJECTED,!KAKAO_INJECTED,!MAPILLARY_INJECTED,!MS_INJECTED,!MAPBOX_INJECTED,!MAPY_INJECTED])
  4927. setTimeout(waitLoad, 250);
  4928. } else {
  4929. checkRound();
  4930. }
  4931. }
  4932.  
  4933. /**
  4934. * Checks for round changes
  4935. */
  4936.  
  4937. function checkRound() {
  4938. // console.log("Check Round");
  4939. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  4940. let switchCovergeButton = document.getElementById("switch");
  4941. if (!isBattleRoyale) {
  4942. // console.log("Check Round");
  4943. let currentRound = getRoundFromPage();
  4944. if (ROUND != currentRound) {
  4945. // fire1 = true;
  4946. switchCovergeButton.init = true;
  4947. console.log("New round");
  4948. ROUND = currentRound;
  4949. // NEW_ROUND_LOADED = true;
  4950. COMPASS = null;
  4951. handleBtwRoundsClear();
  4952. getMapData();
  4953. // nextButtonCallback();
  4954. }
  4955. }
  4956. else {
  4957. getMapData();
  4958. }
  4959. }
  4960.  
  4961. /**
  4962. * Add listeners if buttons have been created
  4963. */
  4964.  
  4965. function finalDetail()
  4966. {
  4967. let target = document.querySelector("a[data-qa='play-same-map']");
  4968. if (target)
  4969. {
  4970. var div = document.createElement("div");
  4971. div.classList.add("buttons_buttons__0B3SB")
  4972. document.querySelector('.result-layout_content__jAHfP').appendChild(div);
  4973. for (var rd of linksList)
  4974. {
  4975. let str;
  4976. if (rd[1] == "Mapbox Satellite")
  4977. {
  4978. str = "Google Maps";
  4979. }
  4980. else
  4981. {
  4982. str = rd[1];
  4983. }
  4984. // console.log(rd)
  4985. let cl = target.cloneNode( true );
  4986. let tx = "View R" + rd[0] + " in " + str;
  4987. cl.querySelector('.button_label__kpJrA').innerHTML = tx;
  4988. cl.removeAttribute('data-qa');
  4989. cl.removeAttribute('href');
  4990. cl.urlStr = rd[2];
  4991. cl.addEventListener("click", (e) => {
  4992. window.open(cl.urlStr);
  4993. })
  4994. cl.style = "top:10px;right:-10px;";
  4995. div.appendChild(cl);
  4996. }
  4997. }
  4998. else
  4999. {
  5000. setTimeout(finalDetail, 500);
  5001. }
  5002. }
  5003.  
  5004. function nextButtonCallback()
  5005. {
  5006. let nextButton = document.querySelector("button[data-qa='close-round-result']");
  5007. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5008. // if (nextButton != null && fire1)
  5009. // {
  5010. // fire1 = false;
  5011. nextButton.addEventListener("click", (e) => {
  5012.  
  5013. if (ROUND == 5)
  5014. {
  5015. console.log("Game Finished")
  5016. if (linksList)
  5017. {
  5018. finalDetail();
  5019. }
  5020. }
  5021. })
  5022. let urlStr = ""
  5023.  
  5024. if (nextPlayer !== "Google" && nextPlayer !== "Planets")
  5025. {
  5026. // console.log("Clone buttons");
  5027.  
  5028. let clone = document.querySelector("button[data-qa='close-round-result']").cloneNode( true );
  5029. let tx;
  5030. if (nextPlayer == "Mapbox Satellite")
  5031. {
  5032. tx = "View Location in Google Maps";
  5033. }
  5034. else
  5035. {
  5036. tx = "View Location in " + nextPlayer;
  5037. }
  5038. clone.querySelector('[class*="button_label"]').innerHTML = tx;
  5039. clone.setAttribute('id', "LinkBtn");
  5040. clone.removeAttribute('data-qa');
  5041. if (nextPlayer == "Baidu")
  5042. {
  5043. urlStr = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  5044. }
  5045. else if (nextPlayer == "Youtube")
  5046. {
  5047. urlStr = "https://www.youtube.com/watch?v=" + yId;
  5048. }
  5049. else if (nextPlayer == "Image")
  5050. {
  5051. urlStr = iId;
  5052. }
  5053. else if (nextPlayer == "Kakao")
  5054. {
  5055. urlStr = "https://map.kakao.com/link/roadview/" + global_lat + "," + global_lng;
  5056. }
  5057. else if (nextPlayer == "Mapillary")
  5058. {
  5059. urlStr = "https://www.mapillary.com/app/?pKey=" + mmKey + "&focus=photo";
  5060. }
  5061. else if (nextPlayer == "Yandex")
  5062. {
  5063. urlStr = "https://yandex.com/maps/?&panorama%5Bdirection%5D=16%2C0&panorama%5Bpoint%5D=" + global_lng + "%2C" + global_lat;
  5064. }
  5065. else if (nextPlayer == "Bing Streetside")
  5066. {
  5067. urlStr = "https://bing.com/maps/default.aspx?cp=" + global_lat + "~" + global_lng + "&lvl=20&style=r";
  5068. }
  5069. else if (nextPlayer == "Mapbox Satellite")
  5070. {
  5071. urlStr = `http://www.google.com/maps/place/${global_lat},${global_lng}`;
  5072. }
  5073. else if (nextPlayer == "Wikipedia")
  5074. {
  5075. urlStr = wikiUrl;
  5076. }
  5077. else if (nextPlayer == "Carte")
  5078. {
  5079. urlStr = carteCity;
  5080. }
  5081. // IMPLEMENT WIKIPEDIA
  5082. clone.addEventListener("click", (e) => {
  5083. window.open(urlStr);
  5084. })
  5085. if (ROUND == 5)
  5086. {
  5087. clone.style = "top:10px;";
  5088. }
  5089. else
  5090. {
  5091. clone.style = "right:-10px;";
  5092. }
  5093. linksList.push([ROUND, nextPlayer, urlStr]);
  5094. document.querySelector('[class*="round-result_actions"]').appendChild(clone);
  5095. }
  5096. // }
  5097. // else
  5098. // {
  5099. // setTimeout(nextButtonCallback, 1000);
  5100. // }
  5101. }
  5102.  
  5103. function guessButtonCallback()
  5104. {
  5105. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5106. let guessButton = document.querySelector("button[data-qa='perform-guess']");
  5107. let mainMenuBtn = document.getElementById("Show Buttons");
  5108. if (guessButton != null)
  5109. {
  5110.  
  5111. guessButton.addEventListener("click", (e) => {
  5112. if (mainMenuBtn != null)
  5113. {
  5114. console.log("try to hide show buttons")
  5115. mainMenuBtn.style.visibility = "hidden";
  5116. setHidden(true);
  5117. guessButtonCallback.callbacks.forEach((cb) => cb());
  5118. }
  5119. })
  5120. }
  5121. else
  5122. {
  5123. setTimeout(guessButtonCallback, 1000);
  5124. }
  5125. }
  5126. guessButtonCallback.callbacks = [];
  5127. guessButtonCallback.removeCallback = function(cb){
  5128. for (let n = 0; n < guessButtonCallback.callbacks.length;n++){
  5129. if (guessButtonCallback.callbacks[n] == cb){
  5130. guessButtonCallback.callbacks.splice(n, 1);
  5131. return;
  5132. }
  5133. }
  5134. }
  5135.  
  5136. /**
  5137. * Load different streetview players
  5138. */
  5139.  
  5140. function loaderChecker(map_name, map_description)
  5141. {
  5142. console.log('load checker')
  5143. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5144. let substrings = ["Yangle", "Goodex", "Yandex", "Bing Streetside", "Kakao", "Mapbox", "Bing Satellite", "Planets"]
  5145. bullseyeMapillary = ((isBullseye || isLiveChallenge) && !["Mapillary", "A United World", "A Unity World", "Unity Test","Unity Special Edition"].some(v => map_name.includes(v)));
  5146. if (substrings.some(v => map_name.includes(v)) || rtded || bullseyeMapillary)
  5147. {
  5148. MapillaryPlayer = "MA";
  5149. MAPILLARY_INJECTED = true;
  5150.  
  5151. console.log("Not loading Mapillary");
  5152. }
  5153. else
  5154. {
  5155. BR_LOAD_MAPILLARY = true;
  5156. injectMapillaryPlayer();
  5157. }
  5158.  
  5159. const unityNerd = /unity nerd/i.test(map_name);
  5160. const unityNoob = /unity noob/i.test(map_name);
  5161.  
  5162. if (!unityNerd){
  5163. deactivateUnityNerd();
  5164. } else {
  5165. activateUnityNerd();
  5166. }
  5167.  
  5168. if (!unityNoob){
  5169. deactivateUnityNoob();
  5170. } else {
  5171. activateUnityNoob();
  5172. }
  5173.  
  5174. if (map_name.includes("A United World") || map_name.includes("A Unity World") || map_name.includes("Unity Test") || map_name.includes("Unity Special Edition"))
  5175. {
  5176. console.log("Complete Map");
  5177. map_name = "Yandex Bing Streetside Kakao Mapbox Mapy";
  5178. }
  5179.  
  5180. if (map_name.includes("Yandex") || map_name.includes('Goodex') || map_name.includes('Yangle'))
  5181. {
  5182. console.log("Yandex Map or Goodex Map or Yangle Map");
  5183. if (map_name == "Yandex Bing Streetside Kakao Mapbox Mapy")
  5184. {
  5185. yandex_map = false;
  5186. }
  5187. else
  5188. {
  5189. yandex_map = true;
  5190. }
  5191.  
  5192. injectYandexScript().then(() => {
  5193. console.log("Ready to inject Yandex player");
  5194. injectYandexPlayer();
  5195. }).catch((error) => {
  5196. console.log(error);
  5197. });
  5198. BR_LOAD_YANDEX = true;
  5199. }
  5200. else
  5201. {
  5202. // console.log("Not Yandex map");
  5203. YANDEX_INJECTED = true;
  5204. YandexPlayer = "YD";
  5205. }
  5206.  
  5207. if (map_name.includes("Bing Streetside") || map_name.includes("Planets"))
  5208. {
  5209. console.log("Bing Map");
  5210. if (map_name.includes("Planets"))
  5211. {
  5212. let tempRad2;
  5213. tempRad2 = map_name.split("Planets")[1];
  5214. if (/\d/.test(tempRad2))
  5215. {
  5216. ms_radius = parseInt(tempRad2.replace(/\D/g,'')) * 1000;
  5217. }
  5218. bing_map = true;
  5219.  
  5220. for (let pl of spaceList)
  5221. {
  5222. if (map_name.includes(pl))
  5223. {
  5224. planetType = pl;
  5225. }
  5226. }
  5227. if (planetType == "Solar System")
  5228. {
  5229. randomPlanets = true;
  5230. }
  5231. console.log(planetType)
  5232. // else if (map_name.includes("GTA V"))
  5233. // {
  5234. // planetType = "GTAV";
  5235. // }
  5236. // else if (map_name.includes("GTA San Andreas"))
  5237. // {
  5238. // planetType = "GTASA";
  5239. // }
  5240.  
  5241. }
  5242. if (map_name == "Yandex Bing Streetside Kakao Mapbox Mapy")
  5243. {
  5244. bing_map = false;
  5245. }
  5246. injectMSPlayer();
  5247. // initBing = true;
  5248. BR_LOAD_MS = true;
  5249. }
  5250. else
  5251. {
  5252. // console.log("Not Bing map");
  5253. MS_INJECTED = true;
  5254. MSStreetPlayer = "MS";
  5255. }
  5256.  
  5257.  
  5258. let canvas = document.getElementById("sat_map");
  5259. if (/🛰️|🛰/.test(map_name) || map_name.includes("Bing Satellite") || map_name.includes("Mapbox") || map_name.includes("Unity Satellite") || (sat_choice && !rtded))
  5260. {
  5261. if (map_name == "Yandex Bing Streetside Kakao Mapbox Mapy")
  5262. {
  5263. ms_sat_map = false;
  5264. }
  5265. else
  5266. {
  5267. ms_sat_map = true;
  5268. }
  5269. let tempRad;
  5270. if (map_name.includes("Bing Satellite"))
  5271. {
  5272. tempRad = map_name.split("Bing Satellite")[1];
  5273. }
  5274. else if (map_name.includes("Mapbox"))
  5275. {
  5276. tempRad = map_name.split("Mapbox")[1];
  5277. }
  5278. else if (map_name.includes("Unity Satellite"))
  5279. {
  5280. tempRad = map_name.split("Unity Satellite")[1];
  5281. }
  5282. else if (/🛰️|🛰/.test(map_name))
  5283. {
  5284. tempRad = map_name.replace(/(🛰️|🛰)(\d+)(🛰️|🛰)/, '$2');
  5285. }
  5286.  
  5287. if (/\d/.test(tempRad))
  5288. {
  5289. ms_radius = parseInt(tempRad.replace(/\D/g,'')) * 1000;
  5290. }
  5291. console.log("Mapbox Satellite Map");
  5292. // console.log(canvas)
  5293.  
  5294. if (!canvas)
  5295. {
  5296. injectMapboxPlayer();
  5297. }
  5298. else
  5299. {
  5300. changeInnerHTML(canvas, false);
  5301. MAPBOX_INJECTED = true;
  5302. }
  5303. initBing = true;
  5304. BR_LOAD_MP = true;
  5305. }
  5306. else
  5307. {
  5308. if (canvas == null)
  5309. {
  5310. MapboxPlayer = "MP";
  5311. }
  5312. MAPBOX_INJECTED = true;
  5313. // console.log("Not Mapbox Satellite map");
  5314.  
  5315. }
  5316.  
  5317. if (map_name.includes("Kakao"))
  5318. {
  5319. console.log("Kakao Map");
  5320. if (map_name == "Yandex Bing Streetside Kakao Mapbox Mapy")
  5321. {
  5322. Kakao_map = false;
  5323. }
  5324. else
  5325. {
  5326. Kakao_map = true;
  5327. }
  5328. injectKakaoScript().then(() => {
  5329. console.log("Ready to inject Kakao player");
  5330. }).catch((error) => {
  5331. console.log(error);
  5332. });
  5333. BR_LOAD_KAKAO = true;
  5334. }
  5335. else{
  5336. KAKAO_INJECTED = true;
  5337. KakaoPlayer = "KK";
  5338. // console.log("Not Kakao map");
  5339. }
  5340.  
  5341. if (map_name.includes("Mapy") || map_name.includes("mapy"))
  5342. {
  5343. console.log("Mapy Map");
  5344. if (map_name == "Yandex Bing Streetside Kakao Mapbox Mapy")
  5345. {
  5346. Mapy_map = false;
  5347. }
  5348. else
  5349. {
  5350. Mapy_map = true;
  5351. }
  5352. injectMapyPlayer();
  5353. BR_LOAD_MAPY = true;
  5354. }
  5355. else{
  5356. MAPY_INJECTED = true;
  5357. MapyPlayer = "MPP";
  5358. // console.log("Not Kakao map");
  5359. }
  5360.  
  5361. if (map_name.includes("Wikipedia"))
  5362. {
  5363. console.log("Wikipedia Map");
  5364. Wikipedia_map = true;
  5365.  
  5366. }
  5367. else{
  5368. // console.log("Not Wikipedia map");
  5369. }
  5370.  
  5371. if (map_name.includes("WikiXplore"))
  5372. {
  5373. console.log("Wikipedia Map");
  5374. Wikipedia_map = true;
  5375. WikiXplore_map = true;
  5376. }
  5377. else{
  5378. // console.log("Not Wikipedia map");
  5379. }
  5380.  
  5381. if (map_name.includes("[RMC]"))
  5382. {
  5383. console.log("is Random map challenge");
  5384. randomMapChallenge_map = true;
  5385. randomMapChallenge_map_init(map_description);
  5386. }
  5387. else{
  5388. // console.log("Not Wikipedia map");
  5389. }
  5390. if (map_name.includes("Minecraft"))
  5391. {
  5392. console.log("Minecraft Map");
  5393. Minecraft_map = true;
  5394.  
  5395. }
  5396. else{
  5397. // console.log("Not Minecraft map");
  5398. }
  5399.  
  5400. if (map_name.includes("Youtube") || map_name.includes("YouTube"))
  5401. {
  5402. console.log("Youtube Map");
  5403. Youtube_map = true;
  5404.  
  5405. }
  5406. else{
  5407. // console.log("Not Minecraft map");
  5408. }
  5409.  
  5410. setHidden(false);
  5411.  
  5412. if (map_name.includes("China Tips for each province"))
  5413. {
  5414. guaranteeUI();
  5415. AdjustBtnPos("0em", "22em", true);
  5416. console.log("AdjustBtnPos");
  5417. }
  5418. }
  5419.  
  5420. function loadPlayers() {
  5421. let mapBounds;
  5422.  
  5423. playerLoaded = true;
  5424. injectContainer();
  5425. getSeed().then((data) => {
  5426. console.log('get seed', data)
  5427. let map_name = "Default"
  5428.  
  5429. if (typeof data.isRated !== 'undefined')
  5430. {
  5431. rtded = data.isRated;
  5432. }
  5433.  
  5434. if (typeof data.options !== 'undefined')
  5435. {
  5436. if (typeof data.options.isRated !== 'undefined')
  5437. {
  5438. rtded = data.options.isRated;
  5439. }
  5440. }
  5441.  
  5442. if (rtded)
  5443. {
  5444. map_name = "Public Game";
  5445. }
  5446. else
  5447. {
  5448. if (!isBattleRoyale)
  5449. {
  5450. mapBounds = [data.bounds.max.lat, data.bounds.max.lng, data.bounds.min.lat, data.bounds.min.lng];
  5451. map_name = data.mapName;
  5452. }
  5453. else
  5454. {
  5455. if (isBullseye)
  5456. {
  5457. mapBounds = [data.boundingBox.max.lat, data.boundingBox.max.lng, data.boundingBox.min.lat, data.boundingBox.min.lng];
  5458. map_name = data.mapName;
  5459. }
  5460. else if (isDuel)
  5461. {
  5462. mapBounds = [data.mapBounds.max.lat, data.mapBounds.max.lng, data.mapBounds.min.lat, data.mapBounds.min.lng];
  5463. map_name = data.options.map.name;
  5464. }
  5465. else if (isLiveChallenge)
  5466. {
  5467. mapBounds = [data.rounds[0].question.panoramaQuestionPayload.mapBounds.max.lat, data.rounds[0].question.panoramaQuestionPayload.mapBounds.max.lng,
  5468. data.rounds[0].question.panoramaQuestionPayload.mapBounds.min.lat, data.rounds[0].question.panoramaQuestionPayload.mapBounds.min.lng];
  5469. map_name = data.rounds[0].question.panoramaQuestionPayload.mapName;
  5470. }
  5471. else
  5472. {
  5473. map_name = "Unity Test";
  5474. }
  5475. }
  5476. }
  5477.  
  5478. if (mapBounds)
  5479. {
  5480. ms_radius = magic_formula(mapBounds);
  5481. // console.log(ms_radius / 1000)
  5482. }
  5483.  
  5484. loaderChecker(map_name, data)
  5485.  
  5486. }).catch((error) => {
  5487. console.log(error);
  5488. });
  5489. }
  5490.  
  5491. function guaranteeUI()
  5492. {
  5493. // console.log("UI")
  5494. if (document.getElementById("GH-ui") !== null)
  5495. {
  5496. document.getElementById("GH-ui").style.display = "block";
  5497. }
  5498. else
  5499. {
  5500. setTimeout(guaranteeUI, 500);
  5501. }
  5502. }
  5503.  
  5504. /**
  5505. * Handles Return to start and undo
  5506. */
  5507.  
  5508. function handleReturnToStart() {
  5509. let rtsButton = document.querySelector("button[data-qa='return-to-start']");
  5510. // console.log("Handle Return to start");
  5511. rtsButton.addEventListener("click", (e) => {
  5512. if (nextPlayer !== "Baidu")
  5513. {
  5514. goToLocation(true);
  5515. }
  5516. else
  5517. {
  5518. document.getElementById("i_container").src = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  5519. }
  5520. const elementClicked = e.target;
  5521. elementClicked.setAttribute('listener', 'true');
  5522. console.log("Return to start");
  5523. });
  5524. guessButtonCallback();
  5525. // setTimeout(function () {goToLocation();}, 1000);
  5526. }
  5527.  
  5528. function handleUndo() {
  5529. let undoButton = document.querySelector("button[data-qa='undo-move']");
  5530. // console.log("Handle undo");
  5531. undoButton.addEventListener("click", (e) => {
  5532. if (locHistory.length > 0) {
  5533. goToUndoMove();
  5534. console.log("Undo Move");
  5535. }
  5536. })
  5537. }
  5538.  
  5539. /**
  5540. * Load game information
  5541. */
  5542.  
  5543. function satCallback()
  5544. {
  5545. if (typeof MapboxPlayer.flyTo !== typeof undefined)
  5546. {
  5547. goToLocation(false);
  5548. }
  5549. else
  5550. {
  5551. setTimeout(satCallback, 250);
  5552. }
  5553. }
  5554.  
  5555. function kakaoCallback()
  5556. {
  5557. console.log("Kakao callback")
  5558. if (typeof kakao.maps !== typeof undefined)
  5559. {
  5560. goToLocation(true);
  5561. setTimeout(function () {goToLocation(true);}, 3000);
  5562. }
  5563. else
  5564. {
  5565. setTimeout(kakaoCallback, 250);
  5566. }
  5567. }
  5568.  
  5569.  
  5570. function modularget(data)
  5571. {
  5572. if (data)
  5573. {
  5574. locationCheck(data);
  5575. if (nextPlayer == "Kakao")
  5576. {
  5577. kakaoCallback();
  5578. }
  5579. else
  5580. {
  5581. goToLocation(true);
  5582. }
  5583. // handleMinimapCallback();
  5584. handleButtons();
  5585. }
  5586. }
  5587.  
  5588. function getMapData() {
  5589. // myHighlight("Seed data");
  5590.  
  5591. getSeed().then((data) => {
  5592. let switchCovergeButton = document.getElementById("switch");
  5593. let mainMenuBtn = document.getElementById("Show Buttons")
  5594. if (isBattleRoyale) {
  5595. if (data.status == "Finished" || typeof data.gameId == typeof undefined) {
  5596. // console.log("Battle Royale Lobby");
  5597. }
  5598. else
  5599. {
  5600. let origin = false;
  5601. if (!CURRENT_ROUND_DATA) {
  5602. CURRENT_ROUND_DATA = data
  5603. origin = true;
  5604. }
  5605.  
  5606. if (origin || !(data.currentRoundNumber === CURRENT_ROUND_DATA.currentRoundNumber)) {
  5607. // myHighlight("Battle Royale New round");
  5608. switchCovergeButton.init = true;
  5609. // NEW_ROUND_LOADED = true;
  5610. COMPASS = null;
  5611. handleBtwRoundsClear();
  5612. setHidden(false);
  5613. if (!origin) {
  5614. CURRENT_ROUND_DATA = data;
  5615. }
  5616. modularget(data);
  5617. }
  5618. }
  5619. }
  5620. else {
  5621. modularget(data);
  5622. }
  5623.  
  5624. }).catch((error) => {
  5625. console.log(error);
  5626. });
  5627. }
  5628.  
  5629. function handleMinimapCallback()
  5630. {
  5631. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5632. let MinimapBtn = document.getElementById("Minimap Button");
  5633. if (MinimapBtn)
  5634. {
  5635. let cur = MinimapBtn.current;
  5636. // console.log(cur)
  5637. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  5638. if (cur == mapDiv.id)
  5639. {
  5640. setTimeout(function () {mapDiv.click();}, 500);
  5641. setTimeout(function () {mapDiv.click();}, 1000);
  5642. setTimeout(function () {mapDiv.click();}, 3000);
  5643. }
  5644. }
  5645. }
  5646. else
  5647. {
  5648. setTimeout(handleMinimapCallback, 1000);
  5649. }
  5650. }
  5651.  
  5652. /**
  5653. * Hide unnecessary buttons for non-Google coverages
  5654. */
  5655.  
  5656. function handleButtons() {
  5657. let CHECKPOINT = document.querySelector("button[data-qa='set-checkpoint']");
  5658. let ZOOM_IN = document.querySelector("button[data-qa='pano-zoom-in']");
  5659. let ZOOM_OUT = document.querySelector("button[data-qa='pano-zoom-out']");
  5660. let UNDO_MOVE = document.querySelector("button[data-qa='undo-move']");
  5661. //let DEFAULT_COMPASS = document.querySelector(".compass");
  5662. let DEFAULT_COMPASS = document.querySelector("[title*='Compass' i]");
  5663. let NEW_COMPASS = document.querySelector(".panorama-compass_compassContainer__MEnh0");
  5664. let RETURN_TO_START = document.querySelector("button[data-qa='return-to-start']");
  5665.  
  5666. let C1 = (CHECKPOINT !== null);
  5667. let C2 = (ZOOM_IN !== null);
  5668. let C3 = (ZOOM_OUT !== null);
  5669. let C4 = (UNDO_MOVE !== null);
  5670. let C5 = (DEFAULT_COMPASS !== null);
  5671. let C6 = (NEW_COMPASS !== null);
  5672. let C7 = (RETURN_TO_START !== null);
  5673.  
  5674. let waitCond = C5 || C6;
  5675. let cpCond = true;
  5676. let comCond = true;
  5677. if (!NM)
  5678. {
  5679. cpCond = C1 && C4 && C7;
  5680. }
  5681. if (!NZ)
  5682. {
  5683. comCond = C2 && C3;
  5684. }
  5685.  
  5686. function moduleButtons(cond)
  5687. {
  5688.  
  5689. if (!NM)
  5690. {
  5691. CHECKPOINT.style.visibility = cond;
  5692. UNDO_MOVE.style.visibility = cond;
  5693. }
  5694. if (!NZ)
  5695. {
  5696. ZOOM_IN.style.visibility = cond;
  5697. ZOOM_OUT.style.visibility = cond;
  5698. }
  5699. if (C5)
  5700. {
  5701. DEFAULT_COMPASS.style.visibility = cond;
  5702. }
  5703. if (C6)
  5704. {
  5705. NEW_COMPASS.style.visibility = cond;
  5706. }
  5707. }
  5708.  
  5709. if (waitCond && cpCond && comCond)
  5710. {
  5711. // console.log("Handle Buttons");
  5712. if (nextPlayer === "Google" || nextPlayer === "Wikipedia" || nextPlayer === "Youtube") {
  5713. moduleButtons("");
  5714. }
  5715. else if (nextPlayer === "Baidu" || nextPlayer === "Image" || nextPlayer === "Mapbox Satellite" || nextPlayer === "Minecraft" || nextPlayer === "Planets" || nextPlayer === "Carte")
  5716. {
  5717. moduleButtons("hidden");
  5718. }
  5719. else if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Mapillary" || nextPlayer === "Bing Streetside" || nextPlayer === "Mapy")
  5720. {
  5721. moduleButtons("hidden");
  5722. if (nextPlayer === "Yandex" || nextPlayer === "Kakao")
  5723. {
  5724. if (C5)
  5725. {
  5726. DEFAULT_COMPASS.style.visibility = "";
  5727. }
  5728. if (C6)
  5729. {
  5730. NEW_COMPASS.style.visibility = "";
  5731. }
  5732. }
  5733. if (!NM)
  5734. {
  5735. UNDO_MOVE.style.visibility = "";
  5736. handleUndo();
  5737. }
  5738. }
  5739. if (!NM)
  5740. {
  5741. handleReturnToStart();
  5742. }
  5743. }
  5744. else
  5745. {
  5746. setTimeout(handleButtons, 250);
  5747. }
  5748. }
  5749.  
  5750. /**
  5751. * Check which player to use for the next location
  5752. */
  5753.  
  5754. function locationCheck(data) {
  5755. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  5756. console.log(data)
  5757. let curRound = data.rounds[data.rounds.length -1];
  5758.  
  5759.  
  5760. let round;
  5761. let switchCovergeButton = document.getElementById("switch");
  5762. let satelliteSwitchButton = document.getElementById("Satellite Switch");
  5763. // console.log(data)
  5764.  
  5765. if (isBattleRoyale) {
  5766. if (isDuel || isBullseye)
  5767. {
  5768. round = data.rounds[data.currentRoundNumber - 1].panorama;
  5769. global_cc = round.countryCode;
  5770. }
  5771. else if (isLiveChallenge)
  5772. {
  5773. round = data.rounds[data.currentRoundNumber - 1].question.panoramaQuestionPayload.panorama;
  5774. global_cc = round.countryCode;
  5775. }
  5776. else
  5777. {
  5778. round = data.rounds[data.currentRoundNumber - 1];
  5779. global_cc = "us"; // No field available
  5780. }
  5781.  
  5782. }
  5783. else {
  5784. round = data.rounds[data.round - 1];
  5785. global_cc = round.streakLocationCode;
  5786. }
  5787.  
  5788. global_data = data;
  5789. global_lat = round.lat;
  5790. global_lng = round.lng;
  5791. global_panoID = round.panoId;
  5792. global_bounds = data.bounds;
  5793.  
  5794. global_heading = round.heading;
  5795. global_pitch = round.pitch;
  5796.  
  5797. nextPlayer = "Google";
  5798. //
  5799. // Start of Unity Nerd stuff
  5800. //
  5801. unityNerdFn(data);
  5802. //
  5803. // End of Unity Nerd stuff
  5804. //
  5805.  
  5806. function runCheck()
  5807. {
  5808. if (Kakao_map)
  5809. {
  5810. nextPlayer = "Kakao";
  5811. }
  5812. else if (yandex_map)
  5813. {
  5814. nextPlayer = "Yandex";
  5815. }
  5816. else if (Wikipedia_map)
  5817. {
  5818. nextPlayer = "Wikipedia";
  5819. }
  5820. else if (Minecraft_map)
  5821. {
  5822. nextPlayer = "Minecraft";
  5823. }
  5824. else if (Youtube_map)
  5825. {
  5826. nextPlayer = "Youtube";
  5827. }
  5828. else if (bing_map)
  5829. {
  5830. nextPlayer = "Planets";
  5831. }
  5832. else if (Mapy_map)
  5833. {
  5834. nextPlayer = "Mapy";
  5835. }
  5836. else
  5837. {
  5838. nextPlayer = "Google";
  5839. }
  5840. }
  5841.  
  5842. if (global_panoID) {
  5843. let locInfo;
  5844. if (isBullseye)
  5845. {
  5846. locInfo = global_panoID;
  5847. }
  5848. else
  5849. {
  5850. locInfo = hex2a(global_panoID);
  5851. }
  5852. // console.log(locInfo)
  5853. if (locInfo.substring(0, 3) == "YTB")
  5854. {
  5855. nextPlayer = "Youtube";
  5856. let lengths = [3, 11, 4, 4];
  5857. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  5858. let fullID = locInfo.substring(3).split('START');
  5859. yId = toPiece[1];
  5860. yTime = Number(toPiece[2]);
  5861. yEnd = Number(toPiece[3]);
  5862. }
  5863. else
  5864. {
  5865. let mapType = locInfo.substring(0, 5);
  5866.  
  5867. // panoId unchanged
  5868.  
  5869. if (mapType === "YDMAP" ) {
  5870. nextPlayer = "Yandex";
  5871. }
  5872. else if (mapType === "KKMAP" ) {
  5873. nextPlayer = "Kakao";
  5874. }
  5875.  
  5876. // New panoId formats
  5877.  
  5878. else if (mapType === "BAIDU" ) {
  5879. nextPlayer = "Baidu";
  5880. let lengths = [5, 7, 7, 3];
  5881. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  5882. let panoId1 = base62.decode(toPiece[1]).toString().substring(1);
  5883. let panoId2 = base62.decode(toPiece[2]).toString().substring(1);
  5884. global_BDID = panoId1 + panoId2 + toPiece[3]
  5885. }
  5886. else if (mapType === "MAPIL")
  5887. {
  5888. nextPlayer = "Mapillary";
  5889. mmKey = locInfo.substring(5).replace(/\D/g,'');
  5890. }
  5891. else if (mapType === "IMAGE")
  5892. {
  5893. nextPlayer = "Image";
  5894. let lengths = [5, 4, 4, 7, 2];
  5895. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  5896. iId = "https://i.ibb.co/" + toPiece[3] + "/" + toPiece[1] + "." + toPiece[2].replace(/[^0-9a-z]/gi, '')
  5897. }
  5898. else if (mapType.includes("BING")) {
  5899. if (mapType === "BINGM")
  5900. {
  5901. nextPlayer = "Bing Streetside";
  5902. }
  5903. else
  5904. {
  5905. nextPlayer = "Planets";
  5906. let num = mapType.slice(-1).charCodeAt(0) - 65;
  5907. planetType = spaceList[num];
  5908.  
  5909. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  5910. }
  5911. }
  5912. else if (mapType === "SATEL" ) {
  5913. nextPlayer = "Mapbox Satellite";
  5914. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  5915. }
  5916. else if (mapType === "MINEC" ) {
  5917. nextPlayer = "Minecraft";
  5918. }
  5919. else if (mapType === "WIKIP" ) {
  5920. nextPlayer = "Wikipedia";
  5921. }
  5922. else if (mapType === "CARTE")
  5923. {
  5924. nextPlayer = "Carte";
  5925. let cityCode = locInfo.substring(5, 7);
  5926. let panoNum = locInfo.substring(7).replace(/\D/g,'');
  5927. console.log(cityCode);
  5928. carteCity = "http://" + carteDict[cityCode] + ".carte.ma/view/" + carteDict[cityCode] + ".php?sv=" + panoNum;
  5929. }
  5930. else if (mapType === "YOUTU")
  5931. {
  5932. nextPlayer = "Youtube";
  5933. }
  5934. else if (mapType === "MAPYC")
  5935. {
  5936. nextPlayer = "Mapy";
  5937. global_BDID = "";
  5938. }
  5939. else if (mapType === "MAPCZ")
  5940. {
  5941. nextPlayer = "Mapy";
  5942. global_BDID = locInfo.substring(5, 13);
  5943. }
  5944. else
  5945. {
  5946. runCheck();
  5947. }
  5948. }
  5949. }
  5950. else
  5951. {
  5952. runCheck();
  5953. }
  5954.  
  5955. // Disable buttons if NM, NMPZ
  5956.  
  5957. if(!isBattleRoyale)
  5958. {
  5959. NM = data.forbidMoving;
  5960. NP = data.forbidRotating;
  5961. NZ = data.forbidZooming;
  5962. }
  5963. else
  5964. {
  5965. // console.log(data)
  5966. if (isBullseye || isLiveChallenge)
  5967. {
  5968. NM = data.options.movementOptions.forbidMoving;
  5969. NP = data.options.movementOptions.forbidRotating;
  5970. NZ = data.options.movementOptions.forbidZooming;
  5971. }
  5972. else
  5973. {
  5974. NM = data.movementOptions.forbidMoving;
  5975. NP = data.movementOptions.forbidRotating;
  5976. NZ = data.movementOptions.forbidZooming;
  5977. let canvas = document.getElementById("sat_map");
  5978. if (!canvas)
  5979. {
  5980. injectMapboxPlayer();
  5981. }
  5982. else
  5983. {
  5984. changeInnerHTML(canvas, false);
  5985. MAPBOX_INJECTED = true;
  5986. }
  5987. nextPlayer = "Mapbox Satellite";
  5988. }
  5989. }
  5990. if (NM || NP || NZ)
  5991. {
  5992. // EC: Why disable the time machine feature for nm or np or nz?
  5993. //setDisable("NMPZ");
  5994. }
  5995. else
  5996. {
  5997. setDisable(nextPlayer);
  5998. }
  5999.  
  6000. if (nextPlayer == "Google")
  6001. {
  6002. switchCovergeButton.innerHTML = "Switch to Mapillary";
  6003. }
  6004. else
  6005. {
  6006. switchCovergeButton.innerHTML = "Switch to Google Streetview";
  6007. }
  6008. nextPlayer_save = nextPlayer;
  6009.  
  6010.  
  6011. // console.log("??")
  6012. // console.log(sessionStorage.getItem('Satellite') == "T")
  6013. // console.log(ms_sat_map)
  6014. if (ms_sat_map || (sat_choice && nextPlayer !== "Baidu" && !rtded))
  6015. {
  6016. nextPlayer = "Mapbox Satellite";
  6017. }
  6018.  
  6019. if (nextPlayer == "Mapbox Satellite")
  6020. {
  6021. let di3 = formatDist();
  6022. satelliteSwitchButton.innerHTML = `Satellite (${di3})`;
  6023. }
  6024. else
  6025. {
  6026. satelliteSwitchButton.innerHTML = "Streetview mode";
  6027. }
  6028. console.log(nextPlayer_save + "," + nextPlayer);
  6029. if (!rtded)
  6030. {
  6031. injectCanvas();
  6032. }
  6033. else
  6034. {
  6035. console.log("rated game, no canvas injection");
  6036. }
  6037. }
  6038.  
  6039.  
  6040. /**
  6041. * setID for canvas
  6042. */
  6043.  
  6044. function initializeCanvas() {
  6045. GAME_CANVAS = "";
  6046. DUEL_CANVAS = "";
  6047. //console.log("Is duels");
  6048. //console.log(duels);
  6049.  
  6050. if (isBattleRoyale) {
  6051. if (isDuel) {
  6052. GAME_CANVAS = document.querySelector(DUELS_CANVAS);
  6053. DUEL_CANVAS = document.querySelector(DUELS_CANVAS2);
  6054. }
  6055. else if (isBullseye) {
  6056. GAME_CANVAS = document.querySelector(BULLSEYE_CANVAS);
  6057. DUEL_CANVAS = "dummy";
  6058. }
  6059. else if (isLiveChallenge)
  6060. {
  6061. GAME_CANVAS = document.querySelector(LIVE_CANVAS);
  6062. DUEL_CANVAS = "dummy";
  6063. }
  6064. else
  6065. {
  6066. GAME_CANVAS = document.querySelector(BR_WRAPPER);
  6067. DUEL_CANVAS = "dummy";
  6068. }
  6069. }
  6070. else {
  6071. GAME_CANVAS = document.querySelector(GENERAL_LAYOUT);
  6072. DUEL_CANVAS = "dummy";
  6073. }
  6074. if (GAME_CANVAS && DUEL_CANVAS)
  6075. {
  6076. console.log("Canvas injected");
  6077. GAME_CANVAS.id = "player";
  6078.  
  6079. if (isDuel) {
  6080. DUEL_CANVAS.id = "default_player";
  6081. }
  6082.  
  6083. let mosaicBtn = document.getElementById("Mosaic Enable");
  6084. if (mosaicPre)
  6085. {
  6086. loadGridBtn(mosaicBtn.grid);
  6087. }
  6088.  
  6089. partialCreateMapillary = (typeof mapillary !== typeof undefined)
  6090. partialCreateYandex = (typeof ymaps !== typeof undefined)
  6091. partialCreateKakao = (typeof kakao !== typeof undefined)
  6092. partialCreateMS = (typeof Microsoft !== typeof undefined);
  6093. partialCreateMapbox = (typeof mapboxgl !== typeof undefined);
  6094. partialCreateMapy = (typeof SMap !== typeof undefined);
  6095. loadPlayers();
  6096. }
  6097. else
  6098. {
  6099. setTimeout(initializeCanvas, 250);
  6100. }
  6101.  
  6102. }
  6103.  
  6104. /**
  6105. * Hide or show players based on where the next location is
  6106. */
  6107.  
  6108. function injectCanvas() {
  6109. if (isDuel)
  6110. {
  6111. if (!rtded)
  6112. {
  6113. canvasSwitch();
  6114. }
  6115. }
  6116. else
  6117. {
  6118. Google();
  6119. Baidu();
  6120. if (BR_LOAD_KAKAO)
  6121. {
  6122. Kakao();
  6123. }
  6124. if (BR_LOAD_YANDEX)
  6125. {
  6126. Yandex();
  6127. }
  6128. if (BR_LOAD_MS)
  6129. {
  6130. // console.log("Yes")
  6131. Bing();
  6132. }
  6133. if (BR_LOAD_MP)
  6134. {
  6135. // console.log("Yes")
  6136. Mapbox();
  6137. }
  6138. if (BR_LOAD_MAPILLARY)
  6139. {
  6140. Mapillary();
  6141. }
  6142. if (BR_LOAD_MAPY)
  6143. {
  6144. Mapy();
  6145. }
  6146. }
  6147.  
  6148. }
  6149.  
  6150. // for duels (class ID change)
  6151.  
  6152. function canvasSwitch()
  6153. {
  6154.  
  6155. // console.log("canvas switch")
  6156. // let cond = true;
  6157. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6158. let teleportMenu = document.getElementById("Teleport Button");
  6159. let switchCovergeButton = document.getElementById("switch");
  6160.  
  6161. let GOOGLE_MAPS_CANVAS = document.querySelector(DUELS_CANVAS);
  6162. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  6163. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  6164. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  6165. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  6166. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  6167. let MAPBOX_MAPS_CANVAS = document.getElementById("mapbox-player");
  6168. let MAPY_MAPS_CANVAS = document.getElementById("mapy-player");
  6169. // 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])
  6170.  
  6171. if (GOOGLE_MAPS_CANVAS && BAIDU_MAPS_CANVAS && (!BR_LOAD_MAPILLARY || MAPILLARY_MAPS_CANVAS) && (!BR_LOAD_KAKAO || KAKAO_MAPS_CANVAS) &&
  6172. (!BR_LOAD_MS || BING_MAPS_CANVAS) && (!BR_LOAD_YANDEX || YANDEX_MAPS_CANVAS) && (!BR_LOAD_MP || MAPBOX_MAPS_CANVAS) && (!BR_LOAD_MAPY || MAPY_MAPS_CANVAS))
  6173. {
  6174. document.getElementById("default_player").style.position = "absolute";
  6175. document.getElementById("default_player").className = "inactive";
  6176. BAIDU_MAPS_CANVAS.style.position = "absolute";
  6177. BAIDU_MAPS_CANVAS.className = "inactive";
  6178. BAIDU_MAPS_CANVAS.visibility = "hidden";
  6179.  
  6180. if (BR_LOAD_MAPILLARY)
  6181. {
  6182. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  6183. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  6184. MAPILLARY_MAPS_CANVAS.className = "inactive";
  6185. }
  6186.  
  6187. if (BR_LOAD_KAKAO)
  6188. {
  6189. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  6190. KAKAO_MAPS_CANVAS.style.position = "absolute";
  6191. KAKAO_MAPS_CANVAS.className = "inactive";
  6192. }
  6193. if (BR_LOAD_YANDEX)
  6194. {
  6195. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  6196. YANDEX_MAPS_CANVAS.style.position = "absolute";
  6197. }
  6198. if (BR_LOAD_MS)
  6199. {
  6200. BING_MAPS_CANVAS.style.visibility = "hidden";
  6201. BING_MAPS_CANVAS.style.position = "absolute";
  6202. BING_MAPS_CANVAS.className = "inactive";
  6203. }
  6204.  
  6205. if (BR_LOAD_MP)
  6206. {
  6207. MAPBOX_MAPS_CANVAS.style.visibility = "hidden";
  6208. MAPBOX_MAPS_CANVAS.style.position = "absolute";
  6209. MAPBOX_MAPS_CANVAS.classList.remove("game-panorama_panorama__rdhFg")
  6210. MAPBOX_MAPS_CANVAS.classList.add("inactive");
  6211. }
  6212.  
  6213. if (BR_LOAD_MAPY)
  6214. {
  6215. MAPY_MAPS_CANVAS.style.visibility = "hidden";
  6216. MAPY_MAPS_CANVAS.style.position = "absolute";
  6217. MAPY_MAPS_CANVAS.className = "inactive";
  6218. }
  6219.  
  6220. teleportMenu.google = false;
  6221. switchCovergeButton.useGoogle = false;
  6222.  
  6223. if (nextPlayer === "Google") {
  6224. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  6225. if (BR_LOAD_KAKAO)
  6226. {
  6227. //console.log("doing")
  6228. window.dispatchEvent(new Event('resize'));
  6229. }
  6230. document.getElementById("default_player").style.visibility = "";
  6231. teleportMenu.google = true;
  6232. switchCovergeButton.useGoogle = true;
  6233. console.log("Google Duel Canvas loaded");
  6234. }
  6235. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte")
  6236. {
  6237. BAIDU_MAPS_CANVAS.style.visibility = "";
  6238. BAIDU_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  6239. console.log("Container Duel Canvas loaded");
  6240. }
  6241. else if (nextPlayer === "Kakao")
  6242. {
  6243. if (BR_LOAD_KAKAO)
  6244. {
  6245. KAKAO_MAPS_CANVAS.style.visibility = "";
  6246. KAKAO_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  6247. }
  6248. console.log("Kakao Duel Canvas loaded");
  6249. }
  6250. else if (nextPlayer === "Yandex")
  6251. {
  6252. if (BR_LOAD_YANDEX)
  6253. {
  6254. YANDEX_MAPS_CANVAS.style.visibility = "";
  6255. }
  6256. console.log("Yandex Duel Canvas loaded");
  6257. }
  6258. else if (nextPlayer === "Mapillary")
  6259. {
  6260. if (BR_LOAD_MAPILLARY)
  6261. {
  6262. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  6263. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  6264. MapillaryPlayer.resize();
  6265. }
  6266. //
  6267. console.log("Mapillary Duel Canvas loaded");
  6268. }
  6269. else if (nextPlayer === "Bing Streetside" || nextPlayer === "Planets")
  6270. {
  6271. if (BR_LOAD_MS)
  6272. {
  6273. BING_MAPS_CANVAS.style.visibility = "";
  6274. BING_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  6275. }
  6276. console.log("MS Duel Canvas loaded");
  6277. }
  6278. else if (nextPlayer === "Mapbox Satellite")
  6279. {
  6280. if (BR_LOAD_MP)
  6281. {
  6282. MAPBOX_MAPS_CANVAS.style.visibility = "";
  6283. MAPBOX_MAPS_CANVAS.classList.remove("inactive");
  6284. MAPBOX_MAPS_CANVAS.classList.add("game-panorama_panorama__rdhFg");
  6285. try
  6286. {
  6287. MapboxPlayer.resize();
  6288. }
  6289. catch (e)
  6290. {
  6291. console.error("MapboxPlayer resize failed", e);
  6292. }
  6293. }
  6294. console.log("Mapbox Satellite Duel Canvas loaded");
  6295. }
  6296. else if (nextPlayer === "Mapy")
  6297. {
  6298. if (BR_LOAD_MAPY)
  6299. {
  6300. MAPY_MAPS_CANVAS.style.visibility = "";
  6301. MAPY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  6302. }
  6303. console.log("Mapy Duel Canvas loaded");
  6304. }
  6305. }
  6306. else
  6307. {
  6308. setTimeout(canvasSwitch(), 1000);
  6309. }
  6310. }
  6311.  
  6312. // for Battle Royale and classic (change visibility)
  6313.  
  6314. function gCanvas()
  6315. {
  6316. let GOOGLE_MAPS_CANVAS = ""
  6317. if (isBattleRoyale) {
  6318. if (isBullseye)
  6319. {
  6320. GOOGLE_MAPS_CANVAS = document.querySelector(BULLSEYE_CANVAS2);
  6321. }
  6322. else if (isLiveChallenge)
  6323. {
  6324. GOOGLE_MAPS_CANVAS = document.querySelector(LIVE_CANVAS2);
  6325. }
  6326. else if (isDuel)
  6327. {
  6328. GOOGLE_MAPS_CANVAS = document.getElementById("default_player");
  6329. }
  6330. else
  6331. {
  6332. GOOGLE_MAPS_CANVAS = document.querySelector(BR_CANVAS);
  6333. }
  6334. }
  6335. else {
  6336. GOOGLE_MAPS_CANVAS = document.querySelector(GENERAL_CANVAS);
  6337. }
  6338. return GOOGLE_MAPS_CANVAS;
  6339. }
  6340.  
  6341. function Google() {
  6342. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6343. let teleportMenu = document.getElementById("Teleport Button");
  6344. let switchCovergeButton = document.getElementById("switch");
  6345.  
  6346. let GOOGLE_MAPS_CANVAS = gCanvas();
  6347. if (GOOGLE_MAPS_CANVAS !== null)
  6348. {
  6349. if (nextPlayer === "Google") {
  6350. GOOGLE_MAPS_CANVAS.style.visibility = "";
  6351. teleportMenu.google = true;
  6352. switchCovergeButton.useGoogle = true;
  6353. }
  6354. else {
  6355. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  6356. teleportMenu.google = false;
  6357. }
  6358. }
  6359. else
  6360. {
  6361. setTimeout(Google, 250);
  6362. }
  6363. }
  6364.  
  6365. function Baidu() {
  6366. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  6367. let switchCovergeButton = document.getElementById("switch");
  6368. // console.log("Baidu canvas");
  6369. if (BAIDU_MAPS_CANVAS !== null)
  6370. {
  6371. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6372. BAIDU_MAPS_CANVAS.style.position = "absolute";
  6373. if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte") {
  6374. BAIDU_MAPS_CANVAS.style.visibility = "";
  6375. switchCovergeButton.useGoogle = false;
  6376. console.log("Container Canvas loaded");
  6377. }
  6378. else {
  6379. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  6380. // console.log("Container Canvas hidden");
  6381. }
  6382. }
  6383. else
  6384. {
  6385. setTimeout(Baidu, 250);
  6386. }
  6387.  
  6388. }
  6389.  
  6390. function Kakao() {
  6391. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  6392. let switchCovergeButton = document.getElementById("switch");
  6393. // console.log("Kakao canvas");
  6394. if (KAKAO_MAPS_CANVAS != null)
  6395. {
  6396. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6397. KAKAO_MAPS_CANVAS.style.position = "absolute";
  6398. if (nextPlayer === "Kakao") {
  6399. KAKAO_MAPS_CANVAS.style.visibility = "";
  6400. switchCovergeButton.useGoogle = false;
  6401. console.log("Kakao Canvas loaded");
  6402. }
  6403. else {
  6404. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  6405. // console.log("Kakao Canvas hidden");
  6406. }
  6407. }
  6408. else
  6409. {
  6410. setTimeout(Kakao, 250);
  6411. }
  6412.  
  6413. }
  6414.  
  6415. function Yandex() {
  6416. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  6417. let switchCovergeButton = document.getElementById("switch");
  6418. if (YANDEX_MAPS_CANVAS != null)
  6419. {
  6420. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6421. if (isBullseye)
  6422. {
  6423. let div = document.getElementById("player");
  6424. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__ncMwh");
  6425. div.prepend(YANDEX_MAPS_CANVAS);
  6426. }
  6427. if (isLiveChallenge)
  6428. {
  6429. let div = document.getElementById("player");
  6430. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__IuPsO");
  6431. div.prepend(YANDEX_MAPS_CANVAS);
  6432. }
  6433. // console.log("Yandex canvas");
  6434. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  6435. // console.log("Yandex canvas");
  6436. /* console.log(YANDEX_MAPS_CANVAS); */
  6437. if (nextPlayer === "Yandex") {
  6438. // Make google street view visible so it doesn't blink.
  6439. gCanvas().style.visibility = "";
  6440.  
  6441. YANDEX_MAPS_CANVAS.style.visibility = "";
  6442. switchCovergeButton.useGoogle = false;
  6443. console.log("Yandex Canvas loaded");
  6444. }
  6445. else {
  6446. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  6447. console.log("Yandex Canvas hidden");
  6448. }
  6449. }
  6450. else
  6451. {
  6452. setTimeout(Yandex, 250);
  6453. }
  6454.  
  6455. }
  6456.  
  6457. function Mapillary()
  6458. {
  6459. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  6460. let switchCovergeButton = document.getElementById("switch");
  6461. if (MAPILLARY_MAPS_CANVAS != null)
  6462. {
  6463. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6464. // console.log("Mapillary canvas");
  6465. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  6466. if (nextPlayer === "Mapillary") {
  6467. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  6468. switchCovergeButton.useGoogle = false;
  6469. console.log("Mapillary Canvas loaded");
  6470.  
  6471. }
  6472. else {
  6473. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  6474. // console.log("Mapillary Canvas hidden");
  6475. }
  6476. }
  6477. else
  6478. {
  6479. setTimeout(Mapillary, 250);
  6480. }
  6481.  
  6482. }
  6483.  
  6484. function Bing() {
  6485. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  6486. let switchCovergeButton = document.getElementById("switch");
  6487. // console.log("stuck")
  6488. if (BING_MAPS_CANVAS != null)
  6489. {
  6490. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6491. // console.log("Mapillary canvas");
  6492. BING_MAPS_CANVAS.style.position = "absolute";
  6493. if (nextPlayer === "Bing Streetside" || nextPlayer === "Planets") {
  6494. BING_MAPS_CANVAS.style.visibility = "";
  6495. switchCovergeButton.useGoogle = false;
  6496. console.log("Bing Canvas loaded");
  6497. }
  6498. else {
  6499. BING_MAPS_CANVAS.style.visibility = "hidden";
  6500. console.log("Bing Canvas hidden");
  6501. }
  6502. }
  6503. else
  6504. {
  6505. setTimeout(Bing, 500)
  6506. }
  6507. }
  6508.  
  6509. function Mapbox()
  6510. {
  6511. let MAPBOX_CANVAS = document.querySelector("sat-map");
  6512. //let MAPBOX_CANVAS = document.getElementById("mapbox-player");
  6513. let switchCovergeButton = document.getElementById("switch");
  6514. if (MAPBOX_CANVAS != null)
  6515. {
  6516. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6517. // console.log("Mapillary canvas");
  6518. MAPBOX_CANVAS.style.position = "absolute";
  6519. if (nextPlayer === "Mapbox Satellite") {
  6520. MAPBOX_CANVAS.style.visibility = "";
  6521. switchCovergeButton.useGoogle = false;
  6522. console.log("Mapbox Satellite Canvas loaded");
  6523.  
  6524. }
  6525. else {
  6526. MAPBOX_CANVAS.style.visibility = "hidden";
  6527. // console.log("Mapillary Canvas hidden");
  6528. }
  6529. }
  6530. else
  6531. {
  6532. setTimeout(Mapbox, 250);
  6533. }
  6534.  
  6535. }
  6536.  
  6537. function Mapy() {
  6538. let MAPY_MAPS_CANVAS = document.getElementById("mapy-player");
  6539. let switchCovergeButton = document.getElementById("switch");
  6540. // console.log("Kakao canvas");
  6541. if (MAPY_MAPS_CANVAS != null)
  6542. {
  6543. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6544. MAPY_MAPS_CANVAS.style.position = "absolute";
  6545. if (nextPlayer === "Mapy") {
  6546. MAPY_MAPS_CANVAS.style.visibility = "";
  6547. switchCovergeButton.useGoogle = false;
  6548. console.log("Mapy Canvas loaded");
  6549. }
  6550. else {
  6551. MAPY_MAPS_CANVAS.style.visibility = "hidden";
  6552. // console.log("Kakao Canvas hidden");
  6553. }
  6554. }
  6555. else
  6556. {
  6557. setTimeout(Mapy, 250);
  6558. }
  6559.  
  6560. }
  6561.  
  6562.  
  6563. /**
  6564. * Adjust button placement
  6565. */
  6566.  
  6567. function ZoomControls() {
  6568. let style = `
  6569. .ymaps-2-1-79-panorama-gotoymaps {display: none !important;}
  6570. .ymaps-2-1-79-panorama-control__zoom {top: 2rem !important; left: 2rem !important; z-Index: 0}
  6571. .mapillary-bearing-indicator-container {top: 2rem !important; left: 2rem !important;}
  6572. .mapillary-zoom-container {top: 6rem !important; left: 2.20rem !important;}
  6573. .NavBar_MapTypeButtonContainerWrapper {visibility: hidden !important;}
  6574. .bm_LocateMeControl {visibility: hidden !important;}
  6575. .NavBar_Container {top: -6rem !important; left: 2rem !important;}
  6576. .streetsideToolPanel {top: 4rem !important; left: 2rem !important;}
  6577. .NavBarButton_Container {visibility: hidden !important;}
  6578. .mapboxgl-ctrl-top-left {z-Index: 999}
  6579. `;
  6580.  
  6581. // let nav = document.querySelector('.NavBar_MapTypeButtonContainerWrapper');
  6582. // let locate = document.getElementById("LocateMeButton");
  6583. // let navAll = document.getElementById("MicrosoftNav");
  6584. // if (nav)
  6585. // {
  6586. // nav.style.visibility = "hidden";
  6587. // }
  6588. // if (locate)
  6589. // {
  6590. // locate.style.visibility = "hidden";
  6591. // }
  6592. // if (navAll)
  6593. // {
  6594. // navAll.style.top = "15em"
  6595. // }
  6596.  
  6597. let style_element = document.createElement("style");
  6598. style_element.innerHTML = style;
  6599. document.body.appendChild(style_element);
  6600. // document.getElementById("mapillary-bearing-indicator-container").style.top = "20em"
  6601. }
  6602.  
  6603. /**
  6604. * Updates the compass to match Yandex Panorama facing
  6605. */
  6606. function updateCompass() {
  6607. let direction = YandexPlayer.getDirection()[0] * -1;
  6608. if (!COMPASS) {
  6609. //let compass = document.querySelector("img.compass__indicator");
  6610. let compass = document.querySelector('[alt="compass" i]'); // EC made this
  6611. if (compass != null) {
  6612. COMPASS = compass;
  6613. // let direction = YandexPlayer.getDirection()[0] * -1;
  6614. // COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  6615. COMPASS.style.transform = `rotate(${direction}deg)`;
  6616. return;
  6617. }
  6618. setTimeout(function(){
  6619. addCustomYandexCompass();
  6620. updateCompass();
  6621. }, 2000);
  6622. }
  6623. else {
  6624. // let direction = YandexPlayer.getDirection()[0] * -1;
  6625. // COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  6626. COMPASS.style.transform = `rotate(${direction}deg)`;
  6627. }
  6628. }
  6629.  
  6630. function addCustomYandexCompass(){
  6631. if (COMPASS || document.querySelector('[alt="compass" i]')){
  6632. return;
  6633. }
  6634.  
  6635. let arrow = document.createElement('img');
  6636. arrow.src = 'https://www.geoguessr.com/_next/static/media/compass.f79e0d30.svg';
  6637. arrow.style.cssText = "position: absolute; bottom: 22%; left: 3%; height: 3rem; width: 0.75rem;";
  6638. arrow.setAttribute('alt', "Compass");
  6639. arrow.title = "Custom Yandex compass.";
  6640.  
  6641. let arrowBackground = document.createElement('img');
  6642. arrowBackground.src = "https://cdn.discordapp.com/attachments/1087972736485298276/1206196948965793882/Base2.png?ex=65db2172&is=65c8ac72&hm=9b05e064ed56c17b5d5c56ecaf8f41c91a72b711d6125e544339bc4b4290e728&";
  6643. arrowBackground.style.cssText = "position: absolute; bottom: 22%; left: 3%; width: calc(0.75rem * 5); translate: calc(-0.75rem *2) calc(0.4rem);";
  6644.  
  6645. let ymaps = document.querySelector('ymaps');
  6646.  
  6647. ymaps.parentElement.appendChild(arrowBackground)
  6648. ymaps.parentElement.appendChild(arrow)
  6649. }
  6650. /**
  6651. * Open next location in streetview player given next player and next coordinate
  6652. */
  6653.  
  6654. function wiki(cc, iframe, teleportMenu)
  6655. {
  6656. if (WikiXplore_map) {
  6657. wikiXplore(cc, iframe, teleportMenu, true);
  6658. return;
  6659. }
  6660.  
  6661. let url = `https://${cc}.wikipedia.org/w/api.php`;
  6662. let widthRight = 325;
  6663. // console.log(cc);
  6664. // if (cc == "fr")
  6665. // {
  6666. // widthRight = 1200;
  6667. // }
  6668.  
  6669. let params = {
  6670. action: "query",
  6671. list: "geosearch",
  6672. gscoord: `${global_lat}|${global_lng}`,
  6673. gsradius: "10000",
  6674. gslimit: "1",
  6675. format: "json"
  6676. };
  6677.  
  6678. url = url + "?origin=*";
  6679. Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
  6680. let GOOGLE_MAPS_CANVAS = gCanvas();
  6681.  
  6682. fetch(url)
  6683. .then(function(response){return response.json();})
  6684. .then(function(response) {
  6685. // console.log(response)
  6686. var pages = response.query.geosearch;
  6687. if (pages.length !== 0)
  6688. {
  6689. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  6690. let pageId = pages[0].pageid;
  6691. iframe.src = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  6692. wikiUrl = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  6693. iframe.style.visibility = "";
  6694. iframe.style.right = `-${widthRight}px`;
  6695. iframe.style.width = (window.innerWidth + widthRight) + 'px';
  6696. // console.log(iframe.style.width);
  6697. // iframe.style.visibility = "";
  6698. }
  6699. else
  6700. {
  6701. GOOGLE_MAPS_CANVAS.style.visibility = "";
  6702. teleportMenu.google = true;
  6703. iframe.style.right = '0px';
  6704. iframe.style.width = window.innerWidth + 'px';
  6705. }
  6706. }).catch(function(error){console.log(error);});
  6707. }
  6708.  
  6709. function wikiXplore(cc, iframe, teleportMenu, newLocation){
  6710. // Mode suggested by Alok.
  6711. // Created by EC.
  6712. const lc = localStorage["unity_wikiXplore_active"] || "false";
  6713.  
  6714. let wikiXplore_btn = document.getElementById("wikiXplore_btn");
  6715.  
  6716. let GOOGLE_MAPS_CANVAS = gCanvas();
  6717. GOOGLE_MAPS_CANVAS.style.visibility = "";
  6718.  
  6719. if (!wikiXplore_btn){
  6720. const wikiImgOpened = "https://upload.wikimedia.org/wikipedia/commons/6/63/Wikipedia-logo.png";
  6721. const wikiImgClosed = "https://upload.wikimedia.org/wikipedia/commons/d/de/Wikipedia-logo_%28inverse%29.png";
  6722.  
  6723. wikiXplore_btn = document.createElement("Button");
  6724. wikiXplore_btn.classList.add("unity-btn", "full", "horizontal-1", "vertical-2");
  6725. 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);";
  6726. wikiXplore_btn.id = "wikiXplore_btn";
  6727. wikiXplore_btn.title = "Open or close Wikipedia article.";
  6728. wikiXplore_btn.state = lc === 'true'? true: false;
  6729. wikiXplore_btn.lang = cc;
  6730.  
  6731. wikiXplore_btn.innerHTML = `<img style="width: 1.7em; margin-top: 4px;" src="${lc === 'true'? wikiImgOpened: wikiImgClosed}" alt="Wiki logo" >`;
  6732.  
  6733. wikiXplore_btn.addEventListener("click", () => {
  6734. const wikiLocalLang = document.getElementById("local language")
  6735. GOOGLE_MAPS_CANVAS.style.visibility = "";
  6736.  
  6737. if (wikiXplore_btn.state === false){
  6738. wikiLocalLang.style.visibility = "";
  6739.  
  6740. wikiXplore_btn.state = true;
  6741. wikiXplore_btn.innerHTML = `<img style="width: 1.7em; margin-top: 2px;" src="${wikiImgOpened}" alt="Wiki logo" >`;
  6742.  
  6743. GOOGLE_MAPS_CANVAS.style.left = "calc(100vw * 0.25)";
  6744. GOOGLE_MAPS_CANVAS.style.width = "75vw";
  6745.  
  6746. localStorage["unity_wikiXplore_active"] = "true";
  6747.  
  6748. setIframe();
  6749. } else {
  6750. iframe.style.visibility = "hidden";
  6751. iframe.style.width = '0px';
  6752.  
  6753. wikiLocalLang.style.visibility = "hidden";
  6754.  
  6755. wikiXplore_btn.state = false;
  6756. wikiXplore_btn.innerHTML = `<img style="width: 1.7em; margin-top: 4px;" src="${wikiImgClosed}" alt="Wiki logo" >`;
  6757.  
  6758. GOOGLE_MAPS_CANVAS.style.left = "";
  6759. GOOGLE_MAPS_CANVAS.style.width = "";
  6760.  
  6761. localStorage["unity_wikiXplore_active"] = "false";
  6762. }
  6763. });
  6764.  
  6765. document.body.appendChild(wikiXplore_btn);
  6766. let inter = setInterval(()=>{
  6767. // Deal with menu buttons being hidden and unhidden.
  6768.  
  6769. const mainMenuBtn = document.getElementById("Show Buttons");
  6770.  
  6771. if (!mainMenuBtn) return;
  6772. if (mainMenuBtn.wikXplore) return;
  6773.  
  6774. mainMenuBtn.wikXplore = true;
  6775.  
  6776. mainMenuBtn.addEventListener('click', ()=>{
  6777. // Listen for mainMenuBtn click which will hide or unhide the buttons.
  6778. setTimeout(()=>{
  6779. if (mainMenuBtn.hide === true) return;
  6780.  
  6781. wikiXplore_btn.style.visibility = "";
  6782.  
  6783. if (wikiXplore_btn.state === true){
  6784. let wikiLocalLang = document.getElementById("local language")
  6785. wikiLocalLang.style.visibility = "";
  6786. };
  6787. }, 500);
  6788. });
  6789. }, 2000);
  6790.  
  6791. }
  6792.  
  6793. const mainMenuBtn = document.getElementById("Show Buttons");
  6794. if (mainMenuBtn && mainMenuBtn.hide === true) {
  6795. wikiXplore_btn.style.visibility = "hidden";
  6796. } else {
  6797. wikiXplore_btn.style.visibility = "";
  6798. }
  6799. if (wikiXplore_btn.lang !== cc || newLocation || lc === "true"){
  6800. if (wikiXplore_btn.state == false) return;
  6801.  
  6802. let wikiLocalLang = document.getElementById("local language")
  6803. wikiLocalLang.style.visibility = "";
  6804.  
  6805. iframe.style.right = ``;
  6806. iframe.style.width = "calc(100vw * 0.25)";
  6807.  
  6808. wikiXplore_btn.lang = cc;
  6809.  
  6810. GOOGLE_MAPS_CANVAS.style.left = "calc(100vw * 0.25)";
  6811. GOOGLE_MAPS_CANVAS.style.width = "75vw";
  6812.  
  6813. setIframe();
  6814. }
  6815.  
  6816. function setIframe(){
  6817. let url = `https://${cc}.wikipedia.org/w/api.php`;
  6818. let widthRight = 325;
  6819.  
  6820. let params = {
  6821. action: "query",
  6822. list: "geosearch",
  6823. gscoord: `${global_lat}|${global_lng}`,
  6824. gsradius: "10000",
  6825. gslimit: "1",
  6826. format: "json"
  6827. };
  6828.  
  6829. url = url + "?origin=*";
  6830. Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
  6831. let GOOGLE_MAPS_CANVAS = gCanvas();
  6832.  
  6833. fetch(url)
  6834. .then(function(response){return response.json();})
  6835. .then(function(json) {
  6836.  
  6837. let pages = json.query.geosearch;
  6838.  
  6839. if (pages.length !== 0) {
  6840. let pageId = pages[0].pageid;
  6841.  
  6842. iframe.src = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  6843. wikiUrl = `https://${cc}.wikipedia.org/?curid=${pageId}`;
  6844.  
  6845. iframe.style.visibility = "";
  6846. iframe.style.right = ``;
  6847. iframe.style.width = "calc(100vw * 0.25)";
  6848. } else {
  6849. GOOGLE_MAPS_CANVAS.style.visibility = "";
  6850.  
  6851. teleportMenu.google = true;
  6852.  
  6853. iframe.style.right = '0px';
  6854. iframe.style.width = window.innerWidth + 'px';
  6855. }
  6856.  
  6857. }).catch(function(error){console.log(error);});
  6858. }
  6859. }
  6860.  
  6861. function handleSpecialColor()
  6862. {
  6863. document.getElementById("Circus Sky").style.background = skySpecial ? "#ff1493cc" : "#ff69b4cc";
  6864. document.getElementById("Circus Soil").style.background = soilSpecial ? "#ff1493cc" : "#ff69b4cc";
  6865. document.getElementById("Circus Skewed").style.background = skewedSpecial ? "#ff1493cc" : "#ff69b4cc";
  6866. document.getElementById("Circus Zoom").style.background = zoomSpecial ? "#ff1493cc" : "#ff69b4cc";
  6867. document.getElementById("Circus Random").style.background = randomSpecial ? "#ff1493cc" : "#ff69b4cc";
  6868. document.getElementById("Circus NMPZ").style.background = nmpzSpecial ? "#ff1493cc" : "#ff69b4cc";
  6869. }
  6870.  
  6871. let yandexIntervalFailedToLoadMessage = null;
  6872. let __t = 0;
  6873. let goToLocationTimerHack = Date.now();
  6874.  
  6875. async function goToLocation(cond) {
  6876. let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  6877. console.log("Going to location");
  6878. console.log(nextPlayer);
  6879.  
  6880. // Added by EC - I can't figure out how to show unity buttons on new round.
  6881. setMenuBtnsUnhidden();
  6882.  
  6883. // if (nextPlayer === "Yandex" && !document.querySelector("ymaps")){
  6884. // // Hack by EC to fix yandex not showing when starting a new game.
  6885. // location.reload();
  6886. // }
  6887.  
  6888. let mosaicBtn = document.getElementById("Mosaic Enable");
  6889. if (mosaicPre)
  6890. {
  6891. if (mosaicPre && mosaicBtn.grid == 0)
  6892. {
  6893. mosaicBtn.grid = 5;
  6894. document.getElementById("Mosaic Menu").click();
  6895. }
  6896. else if (mosaicBtn.grid !== 0)
  6897. {
  6898. document.getElementById("Mosaic Menu").click();
  6899. }
  6900. loadGridBtn(mosaicBtn.grid);
  6901. }
  6902.  
  6903. if (restrictMovement)
  6904. {
  6905. // if (teleportMenu.style.visibility == "hidden")
  6906. // {
  6907. // document.getElementById("Teleport Menu").click();
  6908. // }
  6909. RestrictBoundsEnableBtn.innerHTML = "Disable Limit";
  6910. if (RestrictBoundsBtn.innerHTML == "No Escape Mode Disabled")
  6911. {
  6912. RestrictBoundsBtn.innerHTML = "No Escape Mode Enabled";
  6913. }
  6914. }
  6915.  
  6916. if (skySpecial || soilSpecial || skewedSpecial || zoomSpecial || randomSpecial || nmpzSpecial)
  6917. {
  6918. if (nmpzSpecial && !document.getElementById("specialNMPZ"))
  6919. {
  6920. loadNMPZ();
  6921. }
  6922. handleSpecialColor();
  6923. }
  6924.  
  6925. let OverlayBtn = document.getElementById("Overlay Button");
  6926. if (nextPlayer !== "Planets" && (spaceList.some(className => OverlayBtn.current.includes(className))))
  6927. {
  6928. document.getElementById("Earth").click();
  6929. }
  6930.  
  6931. if (nextPlayer === "Yandex") {
  6932. // Everything between these curly braces is just stupid.
  6933.  
  6934. const _ymaps = document.querySelector("ymaps");
  6935. console.log("yandex 1")
  6936. if (!document.querySelector("ymaps")){
  6937. // Hack by EC to fix yandex not showing when starting a new game.
  6938. location.reload();
  6939. return;
  6940. }
  6941.  
  6942. clearInterval(yandexIntervalFailedToLoadMessage);
  6943. __t = 100;// For a wierd bug.
  6944.  
  6945. const map_name = global_data.mapName;
  6946. let panosAtThisLocation = null;
  6947.  
  6948. if (map_name.includes('Goodex') || map_name.includes('Yangle')){
  6949. // Apparently if the panoid is not length 22 then it isn't official?
  6950. console.log('includes goodex')
  6951. let pano = GooglePlayer.getPano();
  6952.  
  6953. // TODO EC: check if global_data pano is same as GooglePlayer.getPano().
  6954. pano = !checkFailedToLoadRoundMsg() ? pano : "Failed Pano message";
  6955.  
  6956.  
  6957. let unofficial = pano? pano.length !== 22 : true;
  6958. panosAtThisLocation = await ymaps.panorama.locate([global_lat, global_lng]).then(ret => ret);
  6959.  
  6960. if (!unofficial || panosAtThisLocation.length == 0){
  6961.  
  6962. if (panosAtThisLocation.length === 0){
  6963. console.log("No yandex panos, panos == 0")
  6964. //let spacey = document.getElementById('SpOver Button');
  6965. let unityAlert = document.querySelector('.unity_alert');
  6966. let _unityAlert = unityAlert.innerHTML;
  6967. unityAlert.innerHTML = "Couldn't find any panoramas for Yandex here!";
  6968. unityAlert.style.visibility = 'visible';
  6969. setTimeout(()=> {
  6970. unityAlert.style.visibility = 'hidden';
  6971. unityAlert.innerHTML = _unityAlert;
  6972. }, 5000);
  6973. }
  6974.  
  6975. console.log("official coverage or no yandex, resorting back to google sv - ", pano, pano?.length)
  6976. const GOOGLE_MAPS_CANVAS = gCanvas();
  6977. GOOGLE_MAPS_CANVAS.style.visibility = "visible";
  6978.  
  6979. _ymaps.style.display = "none";
  6980.  
  6981. return;
  6982. }
  6983. }
  6984.  
  6985. console.log("here is yandex")
  6986.  
  6987. const showYmapsTimer = setTimeout(function(){
  6988. const pano = GooglePlayer.getPano();
  6989. let unofficial = pano? pano.length !== 22 : true;
  6990. let failedToLoadRoundMsg = checkFailedToLoadRoundMsg();
  6991. console.log("showYmapsTimer: Checking if official coverage or failed round before hidding ymaps")
  6992. console.log("showYmapsTimer:", unofficial, failedToLoadRoundMsg, panosAtThisLocation?.length);
  6993. if (!failedToLoadRoundMsg && !unofficial && panosAtThisLocation?.length) return;
  6994. console.log("show maps timer hidden")
  6995.  
  6996. _ymaps.style.display = "";
  6997. // Hide google streetview that was un-hidden so it wouldn't blink,
  6998. // but now can be hidden again.
  6999. gCanvas().style.visibility = "hidden";
  7000.  
  7001. }, 750);
  7002.  
  7003. let options = {};
  7004. YandexPlayer.moveTo([global_lat, global_lng], options);
  7005. //YandexPlayer.setDirection([0, 16]);
  7006. //YandexPlayer.setDirection([-55, 0]); // Hopefully points down the road.
  7007. YandexPlayer.setDirection("auto"); // Hopefully points down the road.
  7008. // YandexPlayer.setSpan([10, 67]);
  7009. YandexPlayer.setSpan([-10, 67]);
  7010. console.log("yandex moveto location", [global_lat, global_lng])
  7011.  
  7012. __t = 0;
  7013. clearInterval(yandexIntervalFailedToLoadMessage); // Double make sure it's cleared
  7014. yandexIntervalFailedToLoadMessage = setInterval(async function(){
  7015. console.log("yandex interval", __t)
  7016. if (__t++ > 50) {
  7017. clearInterval(yandexIntervalFailedToLoadMessage);
  7018. return;
  7019. }
  7020.  
  7021. let failedToLoadRoundMsg = checkFailedToLoadRoundMsg();
  7022. if(failedToLoadRoundMsg){
  7023. clearInterval(yandexIntervalFailedToLoadMessage);
  7024.  
  7025. let panosAtThisLocation = await ymaps.panorama.locate([global_lat, global_lng]).then(ret => ret);
  7026. if (panosAtThisLocation.length == 0){
  7027. let spacey = document.getElementById('SpOver Button');
  7028. let _spacey = spacey.innerHTML;
  7029. spacey.innerHTML = "Couldn't find any panoramas for Yandex here spacey!";
  7030. spacey.style.visibility = 'visible';
  7031. setTimeout(()=> {
  7032. spacey.style.visibility = 'hidden';
  7033. spacey.innerHTML = _spacey;
  7034. }, 5000);
  7035.  
  7036. clearTimeout(showYmapsTimer);
  7037.  
  7038. _ymaps.style.display = "none";
  7039.  
  7040. return;
  7041. }
  7042.  
  7043. failedToLoadRoundMsg.style.display = 'none';
  7044. console.log("failed to load display none");
  7045. makeGuessMapHack({
  7046. markerIcon: {
  7047. // Path is just a filler for a 0 opacity marker.
  7048. 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",
  7049. fillColor: "#e52620",
  7050. scale: 0.5,
  7051. fillOpacity: 1,
  7052. strokeColor: "#e52620",
  7053. strokeOpacity: 1,
  7054. anchor: new google.maps.Point(31, 64),
  7055. },
  7056. guessBtnText:"Yandex Guess Button",
  7057. mapContainer: document.querySelector('ymaps'),
  7058. locationUrl: "https://yandex.com/maps/?&panorama%5Bdirection%5D=16%2C0&panorama%5Bpoint%5D=" + global_lng + "%2C" + global_lat
  7059. });
  7060. }
  7061. }, 500);
  7062. }
  7063. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Wikipedia" || nextPlayer === "Minecraft" || nextPlayer === "Carte") {
  7064. if (document.getElementById("i_container") !== null)
  7065. {
  7066. let iframe = document.getElementById("i_container");
  7067.  
  7068. if (nextPlayer === "Baidu")
  7069. {
  7070. if (!isFirefox)
  7071. {
  7072. iframe.style.top = '-60px';
  7073. iframe.style.height = (window.innerHeight + 200) + 'px';
  7074. }
  7075. else
  7076. {
  7077. iframe.style.top = '-60px';
  7078. iframe.style.height = (window.innerHeight + 219) + 'px';
  7079. }
  7080.  
  7081. if (!isFirefox)
  7082. {
  7083. iframe.style.right = '-55px';
  7084. iframe.style.width = (window.innerWidth + 55) + 'px';
  7085. }
  7086. else
  7087. {
  7088. iframe.style.right = '-15px';
  7089. iframe.style.width = (window.innerWidth + 15) + 'px';
  7090. }
  7091.  
  7092. let urlStr2 = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  7093. 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;
  7094.  
  7095. // Hack to change status bar z index
  7096. const statusBar = document.querySelector(`[class*="game_status"]`);
  7097. statusBar.style.zIndex = 3;
  7098.  
  7099. makeGuessMapHack({
  7100. guessBtnText:"Baidu Guess Button",
  7101. mapContainer: document.getElementById("i_container"),
  7102. locationUrl: urlStr2,
  7103. });
  7104.  
  7105. // console.log(urlStr)
  7106. if (global_BDAh != null)
  7107. {
  7108. iframe.src = urlStr;
  7109. }
  7110. else
  7111. {
  7112. iframe.src = urlStr2;
  7113. }
  7114. iframe.style.visibility = "";
  7115. }
  7116. else if (nextPlayer === "Youtube")
  7117. {
  7118. iframe.src = "";
  7119. if (!document.getElementById("mapbox-player"))
  7120. {
  7121. switchCovergeButton.style.visibility = "";
  7122. }
  7123. for (let yBtn of document.getElementsByClassName("youtube-btn")){
  7124. yBtn.style.visibility = "";
  7125. if (yBtn.id === "Youtube Button")
  7126. {
  7127. yBtn.innerHTML = "Check YouTube";
  7128. }
  7129. }
  7130. iframe.allow = "autoplay";
  7131. iframe.style.visibility = "hidden";
  7132. iframe.style.top = '-250px';
  7133. iframe.style.bottom = '250px';
  7134. iframe.style.height = (window.innerHeight + 500) + 'px';
  7135. iframe.style.right = '0px';
  7136. iframe.style.width = window.innerWidth + 'px';
  7137. }
  7138. else if (nextPlayer === "Image")
  7139. {
  7140. iframe.style.top = '0px';
  7141. iframe.style.height = (window.innerHeight) + 'px';
  7142. iframe.style.right = '0px';
  7143. iframe.style.width = window.innerWidth + 'px';
  7144. iframe.style.visibility = "";
  7145. iframe.src = iId;
  7146. }
  7147. else if (randomMapChallenge_map){
  7148. console.log("IS RANDOM")
  7149. }
  7150. else if (WikiXplore_map){
  7151. iframe.style.top = '0px';
  7152. iframe.style.height = (window.innerHeight) + 'px';
  7153. let fi = getLocalizationFromPathName();
  7154. wikiXplore(fi, iframe, teleportMenu, true);
  7155. }
  7156. else if (nextPlayer === "Wikipedia")
  7157. {
  7158. if (!WikiXplore_map && !document.getElementById("mapbox-player"))
  7159. {
  7160. switchCovergeButton.style.visibility = "";
  7161. }
  7162. let wikiLocalLang = document.getElementById("local language")
  7163. wikiLocalLang.style.visibility = "";
  7164. iframe.style.top = '0px';
  7165. iframe.style.height = (window.innerHeight) + 'px';
  7166. //let fi = "en";
  7167. let fi = getLocalizationFromPathName();
  7168. if (!wikiLocalLang.state && global_cc)
  7169. {
  7170. let cc = langDict[global_cc];
  7171. if (typeof cc !== typeof undefined)
  7172. {
  7173. fi = cc[Math.floor(Math.random() * cc.length)];
  7174. }
  7175. }
  7176. wiki(fi, iframe, teleportMenu);
  7177. }
  7178. else if (nextPlayer === "Minecraft")
  7179. {
  7180. iframe.style.top = '0px';
  7181. iframe.style.height = (window.innerHeight) + 'px';
  7182. iframe.style.right = '0px';
  7183. iframe.style.width = window.innerWidth + 'px';
  7184. iframe.style.visibility = "";
  7185. iframe.src = "https://classic.minecraft.net/?size=huge";
  7186. }
  7187. else if (nextPlayer === "Carte")
  7188. {
  7189. iframe.style.bottom = '190px';
  7190. if ((1.14 * window.innerHeight) >= window.innerWidth)
  7191. {
  7192. iframe.style.top = '-100px';
  7193. iframe.style.height = (window.innerHeight + 290) + 'px';
  7194. }
  7195. else
  7196. {
  7197. iframe.style.top = '-60px';
  7198. iframe.style.height = (window.innerHeight + 250) + 'px';
  7199. }
  7200. iframe.style.left = '-20px';
  7201. iframe.style.right = '20px';
  7202. iframe.style.width = (window.innerWidth + 40) + 'px';
  7203. iframe.style.visibility = "";
  7204. iframe.src = corsString + carteCity;
  7205. }
  7206. }
  7207.  
  7208. else
  7209. {
  7210.  
  7211. if ((Date.now() - goToLocationTimerHack) > 2000){
  7212. goToLocationTimerHack = Date.now();
  7213. localStorage['unity_reload_to_fix_error_attempt'] = 'false';
  7214. setTimeout(()=> goToLocation(true), 250);
  7215. } else {
  7216.  
  7217. if (localStorage['unity_reload_to_fix_error_attempt'] === "true"){
  7218. alert(`Attempted to reload page to fix error with Unity script but it didn't work.`);
  7219. localStorage['unity_reload_to_fix_error_attempt'] = 'false';
  7220. return;
  7221. }
  7222. localStorage['unity_reload_to_fix_error_attempt'] = 'true';
  7223. location.reload();
  7224. }
  7225. }
  7226. // let a = new BMap.Point(global_lng, global_lat);
  7227. // BaiduPlayer.setPov({ heading: -40, pitch: 6 });
  7228. // BaiduPlayer.setPosition(a);
  7229. }
  7230. else if (nextPlayer === "Kakao") {
  7231. var roadviewClient = new kakao.maps.RoadviewClient();
  7232. var position = new kakao.maps.LatLng(global_lat, global_lng);
  7233. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  7234. KakaoPlayer.setPanoId(panoId, position);
  7235. KakaoPlayer.setViewpoint({ pan: global_heading, tilt: global_pitch, zoom: -3 })
  7236. });
  7237. }
  7238. else if (nextPlayer === "Mapillary") {
  7239. MapillaryPlayer.resize()
  7240. MapillaryPlayer.moveTo(mmKey).then(
  7241. image => { //console.log(image);
  7242. },
  7243. error => { console.log(error); });
  7244. }
  7245. else if (nextPlayer === "Google" && !rtded) {
  7246. if (!bullseyeMapillary)
  7247. {
  7248. handleMapillary({lat: global_lat, lng: global_lng}, {meters: 500, limit: 500});
  7249. }
  7250. }
  7251. else if (nextPlayer === "Bing Streetside") {
  7252. let mTId = MSStreetPlayer.getMapTypeId();
  7253. if (mTId !== Microsoft.Maps.MapTypeId.streetside && mTId !== Microsoft.Maps.MapTypeId.road)
  7254. {
  7255. console.log("Reset Bing map type to Streetside")
  7256. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  7257. }
  7258. MSStreetPlayer.setOptions({disableStreetside: false});
  7259. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.streetside,
  7260. zoom: 18,
  7261. streetsideOptions: {
  7262. overviewMapMode: Microsoft.Maps.OverviewMapMode.hidden,
  7263. showCurrentAddress: false,
  7264. showProblemReporting: false,
  7265. showExitButton: false,
  7266. },
  7267. center: new Microsoft.Maps.Location(global_lat, global_lng),
  7268. heading: 90,
  7269. pitch: -30});
  7270. }
  7271. else if (nextPlayer === "Planets") {
  7272. // console.log("Bing Satellite Player")
  7273.  
  7274. if (randomPlanets)
  7275. {
  7276. let tempSL = spaceList.slice(0, -1);
  7277. planetType = tempSL[Math.floor(Math.random() * tempSL.length)];
  7278. setMapstylePlanet(planetType);
  7279. }
  7280.  
  7281. let mTId = MSStreetPlayer.getMapTypeId();
  7282. if (mTId !== Microsoft.Maps.MapTypeId.aerial && mTId !== Microsoft.Maps.MapTypeId.road)
  7283. {
  7284. console.log("Reset Bing map type to Satellite")
  7285. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  7286. }
  7287. // MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  7288. let ctr = new Microsoft.Maps.Location(global_lat, global_lng)
  7289. let loc_centre = {lat: global_lat, lng: global_lng};
  7290. for (var i = MSStreetPlayer.entities.getLength() - 1; i >= 0; i--) {
  7291. var pushpin = MSStreetPlayer.entities.get(i);
  7292. if (pushpin instanceof Microsoft.Maps.Pushpin) {
  7293. MSStreetPlayer.entities.removeAt(i);
  7294. }
  7295. }
  7296. // console.log("Satellite radius: " + (ms_radius / 1000).toString() + "km");
  7297.  
  7298. let maxZoomNum = 20;
  7299. if (planetType == "Mars")
  7300. {
  7301. maxZoomNum = 5;
  7302. }
  7303. else if (planetType == "Moon")
  7304. {
  7305. maxZoomNum = 6;
  7306. }
  7307.  
  7308. if (ms_radius < 1500000)
  7309. {
  7310. ms_radius = 1500000;
  7311. }
  7312.  
  7313. if (ms_radius > 6000000)
  7314. {
  7315. ms_radius = 6000000;
  7316. }
  7317.  
  7318. // console.log(ms_radius);
  7319.  
  7320. let latlngBounds = getBBox2(loc_centre, ms_radius);
  7321. // console.log(latlngBounds)
  7322. let bounds = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(latlngBounds[0], latlngBounds[1]), new Microsoft.Maps.Location(latlngBounds[2], latlngBounds[3]));
  7323. MSStreetPlayer.setOptions({maxBounds: bounds, maxZoom: maxZoomNum})
  7324.  
  7325. MSStreetPlayer.setOptions({disableStreetside: true});
  7326. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.mercator,
  7327. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  7328. center: ctr,
  7329. zoom: 1,
  7330. })
  7331. var weatherTileSource = new Microsoft.Maps.TileSource({
  7332. uriConstructor: getTMSTilePath
  7333. });
  7334. var weatherTileLayer = new Microsoft.Maps.TileLayer({
  7335. mercator: weatherTileSource,
  7336. });
  7337. if (planetType == "Moon")
  7338. {
  7339. document.getElementById("Moon (Labels)").click();
  7340. }
  7341. else if (planetType == "Mars")
  7342. {
  7343. document.getElementById("Mars (Labels)").click();
  7344. }
  7345. else
  7346. {
  7347. // console.log(planetType);
  7348. // console.log(document.getElementById(planetType));
  7349. document.getElementById(planetType).click();
  7350. }
  7351. MSStreetPlayer.layers.insert(weatherTileLayer);
  7352.  
  7353. var pin = new Microsoft.Maps.Pushpin(ctr, {});
  7354. MSStreetPlayer.entities.push(pin);
  7355.  
  7356. // FixLink(); // DOM BASED SOLUTION
  7357. }
  7358. else if (nextPlayer === "Mapbox Satellite") {
  7359. console.log("goToLocation: Mapbox Satellite");
  7360. // MapboxPlayer.resize();
  7361. let satelliteStyleBtn = document.getElementById("Satellite Style Button");
  7362. let satelliteTypeBtn = document.getElementById("Satellite Type Button");
  7363. function waitSky()
  7364. {
  7365. try
  7366. {
  7367. let l = [];
  7368. for (let element of MapboxPlayer.getStyle().layers)
  7369. {
  7370. l.push(element.id);
  7371. }
  7372. if (l.includes('sky'))
  7373. {
  7374. styleMapboxAll("All", true);
  7375. }
  7376. else
  7377. {
  7378. setTimeout(waitSky, 250);
  7379. }
  7380. }
  7381. catch(error)
  7382. {
  7383. console.log(error)
  7384. setTimeout(waitSky, 250);
  7385. }
  7386. }
  7387. waitSky();
  7388. //
  7389. // Satellite mode should still work even with no panorama - EC.
  7390. //
  7391.  
  7392. setTimeout(()=>{
  7393. if (document.querySelector('.baidu_guess_map')){
  7394. // Remove duplicate or old guess map and button.
  7395. let baiduGuessMap = document.querySelector('.baidu_guess_map');
  7396. baiduGuessMap._remove();
  7397. }
  7398.  
  7399. let failedToLoadRoundMsg = checkFailedToLoadRoundMsg();
  7400. if (failedToLoadRoundMsg){
  7401. // The streetview was created but for some reason it's blank.
  7402. // Manually set a random position to start the webgl procesfor some reason it's blanks.
  7403. const fenway = { lat: 42.345573, lng: -71.098326 };
  7404.  
  7405. GooglePlayer.setPosition(fenway) ;
  7406.  
  7407. failedToLoadRoundMsg.style.display = 'none';
  7408. setTimeout(() => {
  7409. // Wait a while incase geoguessr map guess button appears late.
  7410. makeGuessMapHack({
  7411. guessBtnText: "Satellite Guess Button",
  7412. mapContainer: document.querySelector('sat-map'),
  7413. locationUrl: '',
  7414. });
  7415. }, 2000);
  7416. }
  7417. }, 500);
  7418. }
  7419. else if (nextPlayer === "Mapy")
  7420. {
  7421. if (global_BDID)
  7422. {
  7423. SMap.Pano.get(parseInt(global_BDID)).then(function(place) {
  7424. // console.log(place)
  7425. MapyPlayer.show(place);
  7426. }, function() {
  7427. alert("Panorama se nepodařilo zobrazit !");
  7428. });
  7429. }
  7430. else
  7431. {
  7432. let mpcz = SMap.Coords.fromWGS84(global_lng, global_lat);
  7433. // zobrazime panorama dle ID
  7434. SMap.Pano.getBest(mpcz, 200).then(function(place) {
  7435. MapyPlayer.show(place);
  7436. }, function() {
  7437. alert("Panorama se nepodařilo zobrazit !");
  7438. });
  7439. }
  7440. }
  7441. if (nextPlayer === "Google" && fire1)
  7442. {
  7443. window.dispatchEvent(new Event('resize'));
  7444. if (rtded)
  7445. {
  7446. document.getElementById("Clear").click();
  7447. }
  7448. fire1 = false;
  7449. }
  7450.  
  7451. if (cond)
  7452. {
  7453. switchCovergeButton.lat = global_lat;
  7454. switchCovergeButton.lng = global_lng;
  7455. RestrictBoundsBtn.lat = global_lat;
  7456. RestrictBoundsBtn.lng = global_lng;
  7457. }
  7458.  
  7459. }
  7460.  
  7461. function checkFailedToLoadRoundMsg(){
  7462. let loadingSpinner = document.body.querySelector(`[class*="fullscreen-spinner"]`);
  7463. let panoMsg = document.body.querySelector(`[class*="game_panoramaMessage"]`);
  7464. return loadingSpinner || panoMsg;
  7465. }
  7466.  
  7467. /**
  7468. * Handle undo using the location history of the current round
  7469. */
  7470.  
  7471. function goToUndoMove(data) {
  7472. /* console.log(global_lat);
  7473. console.log(global_lng); */
  7474. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  7475. let teleportMenu = document.getElementById("Teleport Button");
  7476. let switchCovergeButton = document.getElementById("switch");
  7477. let options = {};
  7478. let prevStep = null;
  7479. if (locHistory.length === 1) {
  7480. prevStep = locHistory[0];
  7481. }
  7482. else {
  7483. prevStep = locHistory.pop();
  7484. }
  7485. // console.log(prevStep);
  7486. // console.log(locHistory)
  7487. if (nextPlayer === "Yandex") {
  7488. defaultPanoIdChange = false;
  7489. YandexPlayer.moveTo([prevStep[0], prevStep[1]], options);
  7490. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  7491. YandexPlayer.setSpan([10, 67]);
  7492. switchCovergeButton.lat = prevStep[0];
  7493. switchCovergeButton.lng = prevStep[1];
  7494. }
  7495. else if (nextPlayer === "Kakao") {
  7496. let btn = document.querySelector("button[data-qa='undo-move']");
  7497. btn.disabled = false;
  7498. btn.classList.remove('styles_disabled__2YdHD');
  7499. defaultPanoIdChange = false;
  7500. let position = new kakao.maps.LatLng(prevStep[0], prevStep[1]);
  7501. KakaoPlayer.setPanoId(prevStep[2], position);
  7502. switchCovergeButton.lat = prevStep[0];
  7503. switchCovergeButton.lng = prevStep[1];
  7504. switchCovergeButton.useGoogle = false;
  7505. teleportMenu.google = false;
  7506. // console.log("Undo 1 step");
  7507. // console.log(locHistory);
  7508. }
  7509. else if (nextPlayer === "Mapillary" ) {
  7510. // console.log(prevStep[1]);
  7511.  
  7512. MapillaryPlayer.moveTo(prevStep[2]).then(
  7513. image => {
  7514. //console.log(image);
  7515. switchCovergeButton.lat = prevStep[1];
  7516. switchCovergeButton.lng = prevStep[0];
  7517. },
  7518. error => { console.log(error); });
  7519. }
  7520. else if (nextPlayer === "Bing Streetside") {
  7521. defaultPanoIdChange = false;
  7522. // console.log(locHistory);
  7523. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(prevStep[0], prevStep[1]),});
  7524. switchCovergeButton.lat = prevStep[0];
  7525. switchCovergeButton.lng = prevStep[1];
  7526. switchCovergeButton.heading = prevStep[2];
  7527. }
  7528. else if (nextPlayer === "Mapy") {
  7529. defaultPanoIdChange = false;
  7530. let mapyCords = SMap.Coords.fromWGS84(prevStep[1], prevStep[0]);
  7531. SMap.Pano.getBest(mapyCords, 200).then(function(place) {
  7532. MapyPlayer.show(place,{
  7533. yaw: DegreesToRadians(prevStep[2]),
  7534. });
  7535. }, function() {
  7536. alert("Panorama se nepodařilo zobrazit !");
  7537. });
  7538. // console.log(locHistory);
  7539. switchCovergeButton.lat = prevStep[0];
  7540. switchCovergeButton.lng = prevStep[1];
  7541. switchCovergeButton.heading = prevStep[2];
  7542. }
  7543.  
  7544. }
  7545.  
  7546. function handleTeleport()
  7547. {
  7548. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  7549. let teleportMenu = document.getElementById("Teleport Button");
  7550. let switchCovergeButton = document.getElementById("switch");
  7551. if (teleportMenu)
  7552. {
  7553. function tpt(direction)
  7554. {
  7555. if (!teleportMenu.google)
  7556. {
  7557. // console.log("non-Google Teleport");
  7558. function forwardReverse(heading)
  7559. {
  7560. if (direction)
  7561. {
  7562. return heading;
  7563. }
  7564. else
  7565. {
  7566. return (heading + 180) % 360;
  7567. }
  7568. }
  7569.  
  7570. let prevStep = null;
  7571. if (locHistory.length === 1) {
  7572. prevStep = locHistory[0];
  7573. }
  7574. else {
  7575. prevStep = locHistory[locHistory.length - 1];
  7576. }
  7577. // console.log(locHistory);
  7578.  
  7579. let options = {};
  7580. let place, position, pID;
  7581. if (nextPlayer === "Yandex") {
  7582.  
  7583. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  7584. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  7585. YandexPlayer.moveTo([place.lat, place.lng], options);
  7586. YandexPlayer.setSpan([10, 67]);
  7587. switchCovergeButton.lat = place.lat;
  7588. switchCovergeButton.lng = place.lng;
  7589. }
  7590. else if (nextPlayer === "Kakao") {
  7591. var roadviewClient = new kakao.maps.RoadviewClient();
  7592. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[3])), teleportMenu.distance * 0.001);
  7593. position = new kakao.maps.LatLng(place.lat, place.lng);
  7594. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  7595. KakaoPlayer.setPanoId(panoId, position);
  7596. });
  7597. switchCovergeButton.lat = place.lat;
  7598. switchCovergeButton.lng = place.lng;
  7599. }
  7600. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  7601. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  7602. handleMapillary(place, {meters: 500, limit: 500});
  7603. switchCovergeButton.lat = place.lat;
  7604. switchCovergeButton.lng = place.lng;
  7605. // locHistory.push([place.lat, place.lng, prevStep[2], prevStep[3]]);
  7606. }
  7607. else if (nextPlayer === "Bing Streetside") {
  7608. // console.log("teleport")
  7609. // console.log(prevStep);
  7610. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(forwardReverse(prevStep[2])), teleportMenu.distance * 0.001);
  7611. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(place.lat, place.lng), 1, 1);
  7612. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  7613. function onSuccess(panoramaInfo) {
  7614. // console.log("Coverage")
  7615. // console.log([panoramaInfo.la, panoramaInfo.lo])
  7616. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  7617. });
  7618. }
  7619. function onMissingCoverage() {
  7620. console.log("No Coverage")
  7621. }
  7622. }
  7623. else if (nextPlayer === "Mapy") {
  7624. place = FindPointAtDistanceFrom(MapyPlayer.getPlace()._data.mark.lat, MapyPlayer.getPlace()._data.mark.lon, MapyPlayer.getCamera().yaw, teleportMenu.distance * 0.001);
  7625. let mapyCords = SMap.Coords.fromWGS84(place.lng, place.lat);
  7626. SMap.Pano.getBest(mapyCords, 200).then(function(placeN) {
  7627. MapyPlayer.show(placeN,{
  7628. yaw: MapyPlayer.getCamera().yaw,
  7629. });
  7630. }, function() {
  7631. alert("Panorama se nepodařilo zobrazit !");
  7632. });
  7633. }
  7634.  
  7635. if (teleportMenu.distance > 150)
  7636. {
  7637. teleportMenu.distance = 100;
  7638. teleportMenu.innerHTML = "Teleport: " + teleportMain.distance + " m";
  7639. }
  7640. }
  7641. }
  7642. document.getElementById("Teleport Forward").addEventListener("click", () => {
  7643. tpt(true);
  7644.  
  7645. });
  7646. document.getElementById("Teleport Reverse").addEventListener("click", () => {
  7647. tpt(false);
  7648.  
  7649. });
  7650. }
  7651. }
  7652.  
  7653. function SyncListener()
  7654. {
  7655. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  7656. let switchCovergeButton = document.getElementById("switch");
  7657. switchCovergeButton.addEventListener("click", () => {
  7658. if (switchCovergeButton.useGoogle == false) {
  7659. // switchCovergeButton.useGoogle = true;
  7660. console.log(nextPlayer)
  7661. if (nextPlayer === "Yandex") {
  7662. let options = {};
  7663. YandexPlayer.moveTo([switchCovergeButton.lat, switchCovergeButton.lng], options);
  7664. YandexPlayer.setDirection([switchCovergeButton.heading, 0]);
  7665.  
  7666. // nextPlayer = "Yandex";
  7667. }
  7668. else if (nextPlayer === "Kakao") {
  7669. let roadviewClient = new kakao.maps.RoadviewClient();
  7670. // console.log(switchCovergeButton.lat);
  7671. let position = new kakao.maps.LatLng(switchCovergeButton.lat, switchCovergeButton.lng);
  7672. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  7673. KakaoPlayer.setPanoId(panoId, position);
  7674. });
  7675. KakaoPlayer.setViewpoint({
  7676. pan: switchCovergeButton.heading,
  7677. tilt: 0,
  7678. zoom: -3
  7679. });
  7680. // nextPlayer = "Kakao";
  7681. }
  7682. else if (nextPlayer === "Mapy") {
  7683. let mapyCords = SMap.Coords.fromWGS84(switchCovergeButton.lng, switchCovergeButton.lat);
  7684. SMap.Pano.getBest(mapyCords, 200).then(function(place) {
  7685. MapyPlayer.show(place,{
  7686. yaw: DegreesToRadians(switchCovergeButton.heading),
  7687. });
  7688. }, function() {
  7689. alert("Panorama se nepodařilo zobrazit !");
  7690. });
  7691. }
  7692. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  7693. // nextPlayer = "Kakao";
  7694. handleMapillary({lat: switchCovergeButton.lat, lng: switchCovergeButton.lng}, {meters: 100, limit: 100});
  7695. }
  7696. else if (nextPlayer === "Bing Streetside") {
  7697. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(switchCovergeButton.lat, switchCovergeButton.lng), 0.01, 0.01);
  7698. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  7699. function onSuccess(panoramaInfo) {
  7700. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  7701. heading: switchCovergeButton.heading
  7702. });
  7703. }
  7704. function onMissingCoverage() {
  7705. console.log("No Coverage")
  7706. }
  7707. }
  7708. }
  7709. });
  7710.  
  7711. }
  7712.  
  7713. /**
  7714. * Gets the seed data for the current game
  7715. *
  7716. * @returns Promise with seed data as object
  7717. */
  7718. function getSeed() {
  7719.  
  7720. console.log("get seed");
  7721. // myHighlight("Get Seed");
  7722. return new Promise((resolve, reject) => {
  7723. let token = getToken();
  7724. let URL;
  7725. let cred = ""
  7726.  
  7727. const PATHNAME = getPathName();
  7728. if (PATHNAME.startsWith("/game/")) {
  7729. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  7730. }
  7731. else if (PATHNAME.startsWith("/results/")) {
  7732. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  7733. }
  7734. else if (PATHNAME.startsWith("/challenge/")) {
  7735. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  7736. }
  7737. else if (PATHNAME.startsWith("/battle-royale/")) {
  7738. URL = `https://game-server.geoguessr.com/api/battle-royale/${token}`;
  7739. }
  7740. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  7741. URL = `https://game-server.geoguessr.com/api/duels/${token}`;
  7742. }
  7743. else if (PATHNAME.startsWith("/bullseye/")) {
  7744. URL = `https://game-server.geoguessr.com/api/bullseye/${token}`;
  7745. }
  7746. else if (PATHNAME.startsWith("/live-challenge/")) {
  7747. URL = `https://game-server.geoguessr.com/api/live-challenge/${token}`;
  7748. }
  7749.  
  7750. if (getSeed.prevReqURL === URL && Date.now() - getSeed.prevReqDate < 1000){
  7751. // Added by EC.
  7752. return resolve(getSeed.prevReq);
  7753. }
  7754.  
  7755. if (isBattleRoyale) {
  7756. fetch(URL, {
  7757. // Include credentials to GET from the endpoint
  7758. credentials: 'include'
  7759. })
  7760. .then((response) => response.json())
  7761. .then((data) => {
  7762. getSeed.prevReqURL = URL
  7763. getSeed.prevReq = data;
  7764. getSeed.prevReqDate = Date.now();
  7765. resolve(data);
  7766. })
  7767. .catch((error) => {
  7768. reject(error);
  7769. });
  7770. }
  7771. else {
  7772. fetch(URL)
  7773. .then((response) => response.json())
  7774. .then((data) => {
  7775. getSeed.prevReqURL = URL
  7776. getSeed.prevReq = data;
  7777. getSeed.prevReqDate = Date.now();
  7778.  
  7779. resolve(data);
  7780. })
  7781. .catch((error) => {
  7782. reject(error);
  7783. });
  7784. }
  7785. });
  7786. }
  7787. getSeed.prevReq = null;
  7788. getSeed.prevReqDate = null;
  7789.  
  7790. /**
  7791. * Gets the token from the current URL
  7792. *
  7793. * @returns token
  7794. */
  7795. function getToken() {
  7796.  
  7797. const PATHNAME = getPathName();
  7798. if (PATHNAME.startsWith("/game/")) {
  7799. return PATHNAME.replace("/game/", "");
  7800. }
  7801. else if (PATHNAME.startsWith("/results/")) {
  7802. return PATHNAME.replace("/results/", "");
  7803. }
  7804. else if (PATHNAME.startsWith("/challenge/")) {
  7805. return PATHNAME.replace("/challenge/", "");
  7806. }
  7807. else if (PATHNAME.startsWith("/battle-royale/")) {
  7808. return PATHNAME.replace("/battle-royale/", "");
  7809. }
  7810. else if (PATHNAME.startsWith("/duels/")) {
  7811. return PATHNAME.replace("/duels/", "");
  7812. }
  7813. else if (PATHNAME.startsWith("/team-duels/")) {
  7814. return PATHNAME.replace("/team-duels/", "");
  7815. }
  7816. else if (PATHNAME.startsWith("/bullseye/")) {
  7817. return PATHNAME.replace("/bullseye/", "");
  7818. }
  7819. else if (PATHNAME.startsWith("/live-challenge/")) {
  7820. return PATHNAME.replace("/live-challenge/", "");
  7821. }
  7822. }
  7823.  
  7824. /**
  7825. * Gets the round number from the ongoing game from the page itself
  7826. *
  7827. * @returns Round number
  7828. */
  7829. function getRoundFromPage() {
  7830. const roundData = document.querySelector("div[data-qa='round-number']");
  7831. if (roundData) {
  7832. let roundElement = roundData.querySelector("div:last-child");
  7833. if (roundElement) {
  7834. let round = parseInt(roundElement.innerText.charAt(0));
  7835. if (!isNaN(round) && round >= 1 && round <= 5) {
  7836. return round;
  7837. }
  7838. }
  7839. }
  7840. else {
  7841. return ROUND;
  7842. }
  7843. }
  7844.  
  7845.  
  7846. /**
  7847. * Injects Yandex Script
  7848. */
  7849. function injectYandexScript() {
  7850.  
  7851. return new Promise((resolve, reject) => {
  7852. if (!YANDEX_INJECTED) {
  7853. if (YANDEX_API_KEY === "") {
  7854. console.log("No Yandex Key")
  7855. reject();
  7856. }
  7857. else {
  7858. if (!partialCreateYandex)
  7859. {
  7860. let spacey = document.getElementById('SpOver Button');
  7861. let _spacey = spacey.innerHTML;
  7862.  
  7863. const SCRIPT = document.createElement("script");
  7864. SCRIPT.type = "text/javascript";
  7865.  
  7866. SCRIPT.async = true;
  7867. SCRIPT.src = `https://api-maps.yandex.ru/2.1/?lang=en_US&apikey=${YANDEX_API_KEY}`;
  7868. document.body.appendChild(SCRIPT);
  7869. SCRIPT.onload = () => {
  7870. let timer = setTimeout(function(){
  7871. spacey.style.visibility = 'visible';
  7872. spacey.innerHTML = "Initializing Yandex, This Could Take Awhile!";
  7873. }, 2000);
  7874. console.log(ymaps);
  7875. ymaps.ready(() => {
  7876. spacey.innerHTML = _spacey;
  7877. spacey.style.visibility = 'hidden';
  7878. clearTimeout(timer);
  7879. YANDEX_INJECTED = true;
  7880. myHighlight("Yandex API Loaded");
  7881. resolve();
  7882. });
  7883. }
  7884. }
  7885. else
  7886. {
  7887. YANDEX_INJECTED = true;
  7888. resolve();
  7889. }
  7890. }
  7891. }
  7892. else {
  7893. resolve();
  7894. }
  7895. });
  7896. }
  7897.  
  7898. /**
  7899. * Injects Yandex Player and calls handleReturnToStart
  7900. */
  7901. function injectYandexPlayer() {
  7902. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  7903. let switchCovergeButton = document.getElementById("switch");
  7904.  
  7905. let lng = 33.722662 ;//41.321861;
  7906. let lat = 44.402915; //69.212920;
  7907.  
  7908. let options = {
  7909. "direction": [0, 16],
  7910. "span": [10, 67],
  7911. "controls": ["zoomControl"],
  7912. //"scrollZoomBehavior": scrollZoom,
  7913. };
  7914.  
  7915. ymaps.panorama.createPlayer("player", [lat, lng], options)
  7916. .done((player) => {
  7917. let __ymaps = document.querySelector('ymaps');
  7918. __ymaps.style.display = "none";
  7919.  
  7920. // Remove markers and arrows then check for forbidmoving.
  7921. player.getPanorama().__proto__.getMarkers = function(){}
  7922.  
  7923. let trys = 0;
  7924. let t = setInterval(function(){
  7925. if (trys++ < 20 && !global_data?.token) return;
  7926. let _ymaps = document.querySelector('ymaps');
  7927.  
  7928. clearInterval(t);
  7929.  
  7930. if (_ymaps && global_data?.forbidZooming && global_data?.forbidMoving && global_data?.forbidRotating){
  7931. // NMPZ
  7932. _ymaps.style.pointerEvents = 'none';
  7933. return;
  7934. }
  7935.  
  7936. if (global_data?.forbidMoving){
  7937. // Don't do anything because the arrows are alread removed.
  7938. return;
  7939. }
  7940.  
  7941. // Remove pesky markers
  7942. player.getPanorama().__proto__.getMarkers = function(){ return []; }
  7943. }, 100);
  7944.  
  7945. YandexPlayer = player;
  7946. YandexPlayer.events.add("directionchange", (e) => {
  7947. updateCompass();
  7948. let pov = YandexPlayer.getDirection();
  7949. if (locHistory.length > 0 && nextPlayer == "Yandex") {
  7950. switchCovergeButton.heading = pov[0];
  7951. locHistory[locHistory.length - 1][2] = pov[0];
  7952. locHistory[locHistory.length - 1][3] = pov[1];
  7953. }
  7954. });
  7955.  
  7956. YandexPlayer.events.add("panoramachange", (e) => {
  7957. if (defaultPanoIdChange) {
  7958. let num = YandexPlayer.getPanorama().getPosition();
  7959. let pov = YandexPlayer.getDirection();
  7960. // console.log(num);
  7961. // console.log(pov);
  7962. if (nextPlayer == "Yandex")
  7963. {
  7964. locHistory.push([num[0], num[1], pov[0], pov[1]]);
  7965. switchCovergeButton.lat = num[0];
  7966. switchCovergeButton.lng = num[1];
  7967. }
  7968. let btn = document.querySelector("button[data-qa='undo-move']");
  7969. if (locHistory.length > 1) {
  7970. btn.disabled = false;
  7971. btn.classList.remove('styles_disabled__2YdHD');
  7972. }
  7973. // console.log(locHistory);
  7974. }
  7975. defaultPanoIdChange = true;
  7976.  
  7977. });
  7978.  
  7979. YandexPlayer.events.add("error", (e) => {
  7980. console.error("Yandex error:", e);
  7981. });
  7982. console.log("Yandex Player injected");
  7983. });
  7984.  
  7985. }
  7986.  
  7987.  
  7988. /**
  7989. * Injects Baidu script
  7990. */
  7991.  
  7992. function reportWindowSize() {
  7993. // console.log("report window size");
  7994. let iframeC = document.getElementById("i_container");
  7995. if (iframeC)
  7996. {
  7997. if (nextPlayer == "Baidu")
  7998. {
  7999. iframeC.style.top = '-60px';
  8000. iframeC.style.height = (window.innerHeight + 200) + 'px';
  8001. // TODO
  8002. iframeC.style.right = '-55px';
  8003. iframeC.style.width = (window.innerWidth + 55) + 'px';
  8004. }
  8005. else if (nextPlayer == "Youtube")
  8006. {
  8007. iframeC.style.top = '-250px';
  8008. iframeC.style.bottom = '250px';
  8009. iframeC.style.height = (window.innerHeight + 500) + 'px';
  8010. iframeC.style.right = '0px';
  8011. iframeC.style.width = window.innerWidth + 'px';
  8012. }
  8013. else if (nextPlayer == "Image" || nextPlayer === "Minecraft")
  8014. {
  8015. iframeC.style.top = '0px';
  8016. iframeC.style.height = (window.innerHeight) + 'px';
  8017. iframeC.style.right = '0px';
  8018. iframeC.style.width = (window.innerWidth) + 'px';
  8019. }
  8020. else if (nextPlayer === "Wikipedia")
  8021. {
  8022. iframeC.style.top = '0px';
  8023. iframeC.style.height = (window.innerHeight) + 'px';
  8024. iframeC.style.right = '-325px';
  8025. iframeC.style.width = (window.innerWidth + 325) + 'px';
  8026. }
  8027. else if (nextPlayer === "Carte")
  8028. {
  8029. // console.log([window.innerHeight, window.innerWidth])
  8030. iframeC.style.bottom = '190px';
  8031. if ((1.14 * window.innerHeight) >= window.innerWidth)
  8032. {
  8033. iframeC.style.top = '-100px';
  8034. iframeC.style.height = (window.innerHeight + 290) + 'px';
  8035. }
  8036. else
  8037. {
  8038. iframeC.style.top = '-60px';
  8039. iframeC.style.height = (window.innerHeight + 250) + 'px';
  8040. }
  8041. iframeC.style.left = '-20px';
  8042. iframeC.style.right = '20px';
  8043. iframeC.style.width = (window.innerWidth + 40) + 'px';
  8044. iframeC.style.visibility = "";
  8045. iframeC.src = carteCity;
  8046. }
  8047.  
  8048.  
  8049. }
  8050. }
  8051.  
  8052. window.onresize = reportWindowSize;
  8053.  
  8054.  
  8055.  
  8056. function injectContainer() {
  8057. myHighlight("iframe container loaded")
  8058. const iframe = document.createElement('iframe');
  8059. iframe.frameBorder = 0;
  8060. iframe.style.position = "absolute";
  8061. iframe.style.zIndex = "2";
  8062. iframe.id = "i_container";
  8063.  
  8064. if (isBattleRoyale) {
  8065. if (isDuel)
  8066. {
  8067. iframe.className = "inactive";
  8068. }
  8069. else if (isBullseye)
  8070. {
  8071. iframe.className = "game-panorama_panorama__ncMwh";
  8072. }
  8073. else if (isLiveChallenge)
  8074. {
  8075. iframe.className = "game-panorama_panorama__IuPsO";
  8076. }
  8077. else
  8078. {
  8079. iframe.className = "br-game-layout__panorama";
  8080. }
  8081. }
  8082. else {
  8083. iframe.className = "game-layout__panorama";
  8084. }
  8085. var div = document.getElementById("player");
  8086. if (div)
  8087. {
  8088. div.style.overflow = "hidden";
  8089. if (isBullseye || isLiveChallenge)
  8090. {
  8091. div.prepend(iframe);
  8092. }
  8093. else
  8094. {
  8095. div.appendChild(iframe);
  8096. }
  8097. }
  8098.  
  8099. }
  8100.  
  8101. /**
  8102. * Injects Kakao script
  8103. */
  8104.  
  8105. function injectKakaoScript() {
  8106. return new Promise((resolve, reject) => {
  8107. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  8108. let switchCovergeButton = document.getElementById("switch");
  8109. if (!KAKAO_INJECTED) {
  8110. if (KAKAO_API_KEY === "") {
  8111. console.log("No Kakao Key")
  8112. }
  8113. else {
  8114.  
  8115. let canvas = document.createElement("kmap");
  8116. if (isBattleRoyale) {
  8117. if (isDuel)
  8118. {
  8119. canvas.innerHTML = `
  8120. <div id="roadview" class="inactive" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  8121. `;
  8122. }
  8123. else if (isBullseye)
  8124. {
  8125. canvas.innerHTML = `
  8126. <div id="roadview" class="game-panorama_panorama__ncMwh" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  8127. `;
  8128. }
  8129. else if (isLiveChallenge)
  8130. {
  8131. canvas.innerHTML = `
  8132. <div id="roadview" class="game-panorama_panorama__IuPsO" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  8133. `;
  8134. }
  8135. else
  8136. {
  8137. canvas.innerHTML = `
  8138. <div id="roadview" class="br-game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  8139. `;
  8140. }
  8141. }
  8142. else {
  8143. canvas.innerHTML = `
  8144. <div id="roadview" class="game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  8145. `;
  8146. }
  8147.  
  8148.  
  8149. var div = document.getElementById("player");
  8150. if (isBullseye || isLiveChallenge)
  8151. {
  8152. div.prepend(canvas);
  8153. }
  8154. else
  8155. {
  8156. div.appendChild(canvas);
  8157. }
  8158.  
  8159. let SCRIPT;
  8160. if (!partialCreateKakao)
  8161. {
  8162. SCRIPT = document.createElement("script");
  8163. SCRIPT.async = true;
  8164. // SCRIPT.type = "text/javascript";
  8165. SCRIPT.src = `//dapi.kakao.com/v2/maps/sdk.js?appkey=${KAKAO_API_KEY}&autoload=false`;
  8166. document.body.appendChild(SCRIPT);
  8167. }
  8168.  
  8169. function drawmapKakao()
  8170. {
  8171. kakao.maps.load(function () {
  8172. var position = new kakao.maps.LatLng(33.450701, 126.560667);
  8173. let roadviewContainer = document.getElementById('roadview');
  8174. KakaoPlayer = new kakao.maps.Roadview(roadviewContainer);
  8175. var panoId = 1023434522;
  8176. KakaoPlayer.setPanoId(panoId, position);
  8177. KAKAO_INJECTED = true;
  8178. // Remove the compass from Kakao
  8179. kakao.maps.event.addListener(KakaoPlayer, 'init', () => {
  8180. const compassContainer = roadviewContainer.querySelector('div[id*="_box_util_"]');
  8181. if (compassContainer) compassContainer.style.display = 'none';
  8182. });
  8183. kakao.maps.event.addListener(KakaoPlayer, 'panoid_changed', function() {
  8184. if (defaultPanoIdChange && KakaoPlayer) {
  8185. let latlng = KakaoPlayer.getPosition();
  8186. let lat = latlng.getLat();
  8187. let lng = latlng.getLng();
  8188. let pID = KakaoPlayer.getViewpointWithPanoId();
  8189. if (nextPlayer == "Kakao" && lat != 33.45047613915499)
  8190. {
  8191. // console.log("push");
  8192. locHistory.push([lat, lng, pID.panoId, pID.pan]);
  8193. switchCovergeButton.lat = lat;
  8194. switchCovergeButton.lng = lng;
  8195. switchCovergeButton.heading = pID.pan;
  8196. }
  8197. let btn = document.querySelector("button[data-qa='undo-move']");
  8198. if (locHistory.length > 1 && (btn != null)) {
  8199. btn.disabled = false;
  8200. btn.classList.remove('styles_disabled__2YdHD');
  8201. }
  8202. // console.log(locHistory);
  8203. }
  8204. defaultPanoIdChange = true;
  8205. });
  8206. kakao.maps.event.addListener(KakaoPlayer, 'viewpoint_changed', function() {
  8207. // console.log("pov_listener attached");
  8208. let pID = KakaoPlayer.getViewpointWithPanoId();
  8209. if (locHistory.length > 0 && nextPlayer == "Kakao") {
  8210. switchCovergeButton.heading = pID.pan;
  8211. locHistory[locHistory.length - 1][3] = pID.pan;
  8212. }
  8213. if (GooglePlayer) {
  8214. const { heading, pitch } = GooglePlayer.getPov()
  8215. if ((!almostEqual(pID.pan, heading) || !almostEqual(pID.tilt, pitch)) && nextPlayer == "Kakao") {
  8216. // Updating the google street view POV will update the compass
  8217. GooglePlayer.setPov({ heading: pID.pan, pitch: pID.tilt })
  8218. }
  8219. }
  8220. // console.log(locHistory);
  8221. })
  8222. });
  8223. }
  8224.  
  8225. if (partialCreateKakao)
  8226. {
  8227. drawmapKakao();
  8228. }
  8229. else
  8230. {
  8231. SCRIPT.onload = () => {
  8232. drawmapKakao();
  8233. myHighlight("Kakao API Loaded");
  8234. resolve();
  8235. };
  8236. }
  8237.  
  8238. }
  8239. }
  8240. else {
  8241. resolve();
  8242. }
  8243. });
  8244. }
  8245.  
  8246. function getTMSTilePath(tile) {
  8247. var yN = Math.pow(2, tile.zoom) - tile.y - 1;
  8248. // console.log([tile.zoom,tile.x,yN]);
  8249. if (planetType == "Moon")
  8250. {
  8251. // document.getElementById("Moon (Labels)").click();
  8252. return "https://s3.amazonaws.com/opmbuilder/301_moon/tiles/w/hillshaded-albedo/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  8253. }
  8254. else if (planetType == "Mars")
  8255. {
  8256. // document.getElementById("Mars (Labels)").click();
  8257. return "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  8258. }
  8259. else
  8260. {
  8261. return handleSpURL(document.getElementById(planetType).url, tile.x, tile.y, tile.zoom);
  8262. }
  8263. // else if (planetType == "GTAV")
  8264. // {
  8265. // return "https://tiles.mapgenie.io/games/gta5/los-santos/satellite/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  8266. // // https://tiles.mapgenie.io/games/gta5/los-santos/road/4/2/5.png
  8267. // }
  8268. // else if (planetType == "GTASA")
  8269. // {
  8270. // return "https://tiles.mapgenie.io/games/grand-theft-auto-san-andreas/san-andreas/satellite-v1/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  8271. // // "https://tiles.mapgenie.io/games/grand-theft-auto-san-andreas/san-andreas/atlas-v1/" + tile.zoom + "/" + tile.x + "/" + yN + ".png";
  8272. // }
  8273. }
  8274.  
  8275. function injectMSPlayer() {
  8276. return new Promise((resolve, reject) => {
  8277. if (!MS_INJECTED) {
  8278. if (MS_API_KEY === "") {
  8279. let canvas = document.getElementById("player");
  8280. console.log("No MS Key")
  8281. }
  8282. else {
  8283.  
  8284. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  8285. let switchCovergeButton = document.getElementById("switch");
  8286. let SCRIPT;
  8287. if (!partialCreateMS)
  8288. {
  8289. SCRIPT = document.createElement("script");
  8290. SCRIPT.type = "text/javascript";
  8291. SCRIPT.async = true;
  8292. SCRIPT.src = `https://www.bing.com/api/maps/mapcontrol?key=${MS_API_KEY}`;
  8293. document.body.appendChild(SCRIPT);
  8294. }
  8295. let canvas = document.createElement("msmap");
  8296. if (isBattleRoyale) {
  8297. if (isDuel)
  8298. {
  8299. canvas.innerHTML = `<div id="ms-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  8300. }
  8301. else if (isBullseye)
  8302. {
  8303. 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>`;
  8304. }
  8305. else if (isLiveChallenge)
  8306. {
  8307. 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>`;
  8308. }
  8309. else
  8310. {
  8311. 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>`;
  8312. }
  8313. }
  8314. else {
  8315. canvas.innerHTML = `<div id="ms-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  8316. }
  8317.  
  8318. var div = document.getElementById("player");
  8319. if (isBullseye || isLiveChallenge)
  8320. {
  8321. div.prepend(canvas);
  8322. }
  8323. else
  8324. {
  8325. div.appendChild(canvas);
  8326. }
  8327. function drawmapMS()
  8328. {
  8329. try
  8330. {
  8331. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  8332. MS_INJECTED = true;
  8333. // MSStreetPlayer.setOptions({
  8334. // minZoom: 13
  8335. // });
  8336. Microsoft.Maps.Events.addHandler(MSStreetPlayer, 'viewchangeend', function () { updateView(MSStreetPlayer); });
  8337. function updateView(map) {
  8338. let ctrm = map.getCenter();
  8339. if (nextPlayer == "Bing Streetside" && (switchCovergeButton.lat !== ctrm.latitude && switchCovergeButton.lng !== ctrm.longitude))
  8340. {
  8341. let heading2 = bearing(switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude)
  8342. // console.log("moved");
  8343. // console.log([switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude])
  8344. // console.log(heading2);
  8345. locHistory.push([ctrm.latitude, ctrm.longitude, heading2]);
  8346. switchCovergeButton.lat = ctrm.latitude;
  8347. switchCovergeButton.lng = ctrm.longitude;
  8348. switchCovergeButton.heading = heading2;
  8349. let btn = document.querySelector("button[data-qa='undo-move']");
  8350. if (locHistory.length > 1 && (btn != null)) {
  8351. btn.disabled = false;
  8352. btn.classList.remove('styles_disabled__2YdHD');
  8353. }
  8354. }
  8355. }
  8356. }
  8357. catch(error)
  8358. {
  8359. console.log(error);
  8360. alert("Bing Maps API Loading Failed, please refresh");
  8361. // setTimeout(drawmapMS(), 1000);
  8362. }
  8363.  
  8364. }
  8365.  
  8366. if (partialCreateMS)
  8367. {
  8368. // drawmapMS();
  8369. if (isBullseye)
  8370. {
  8371. setTimeout(drawmapMS(), 1000);
  8372. }
  8373. else
  8374. {
  8375. drawmapMS();
  8376. }
  8377. resolve();
  8378. }
  8379. else
  8380. {
  8381. SCRIPT.addEventListener('load', () => {
  8382. myHighlight("Bing Maps API loaded");
  8383. let timeout = 0;
  8384. let interval = setInterval(() => {
  8385. // console.log(timeout);
  8386. if (timeout >= 40) {
  8387. reject();
  8388. clearInterval(interval);
  8389. }
  8390. if (document.getElementById('ms-player') !== null && Microsoft.Maps.Map !== typeof undefined) {
  8391. drawmapMS();
  8392. resolve();
  8393. clearInterval(interval);
  8394. }
  8395. timeout += 1;
  8396. }, 1000);
  8397. })
  8398. }
  8399. }
  8400. }
  8401. else {
  8402. resolve();
  8403. }
  8404. });
  8405. }
  8406.  
  8407.  
  8408.  
  8409. function injectMapillaryPlayer() {
  8410. return new Promise((resolve, reject) => {
  8411. if (!MAPILLARY_INJECTED) {
  8412. if (MAPILLARY_API_KEY === "") {
  8413. let canvas = document.getElementById("player");
  8414. console.log("No Mapillary Key")
  8415. }
  8416. else {
  8417. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  8418. let switchCovergeButton = document.getElementById("switch");
  8419. let SCRIPT;
  8420. if (!partialCreateMapillary)
  8421. {
  8422. SCRIPT = document.createElement("script");
  8423. SCRIPT.type = "text/javascript";
  8424. SCRIPT.async = true;
  8425. SCRIPT.src = `https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.js`;
  8426. document.body.appendChild(SCRIPT);
  8427. document.querySelector('head').innerHTML += '<link href="https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.css" rel="stylesheet"/>';
  8428. }
  8429. let canvas = document.createElement("mmap");
  8430. if (isBattleRoyale) {
  8431. if (isDuel)
  8432. {
  8433.  
  8434. canvas.innerHTML = `<div id="mapillary-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  8435. }
  8436. else if (isBullseye)
  8437. {
  8438. 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>`;
  8439. }
  8440. else if (isLiveChallenge)
  8441. {
  8442. 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>`;
  8443. }
  8444. else
  8445. {
  8446. 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>`;
  8447. }
  8448. }
  8449. else {
  8450. canvas.innerHTML = `<div id="mapillary-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  8451. }
  8452.  
  8453. var div = document.getElementById("player");
  8454. if (isBullseye || isLiveChallenge)
  8455. {
  8456. div.prepend(canvas);
  8457. // setTimeout(drawmapMS(), 1000);
  8458. }
  8459. else
  8460. {
  8461. div.appendChild(canvas);
  8462. }
  8463.  
  8464. function drawMapML()
  8465. {
  8466. var {Viewer} = mapillary;
  8467.  
  8468. MapillaryPlayer = new Viewer({
  8469. accessToken: MAPILLARY_API_KEY,
  8470. container: 'mapillary-player', // the ID of our container defined in the HTML body
  8471. });
  8472.  
  8473. MapillaryPlayer.on('image', async (event) => {
  8474. // cnt = cnt + 1;
  8475. // console.log(cnt);
  8476. let image = event.image;
  8477. let pos = image.originalLngLat;
  8478. let cond = true;
  8479. for (const element of locHistory) {
  8480. if (element[2] == image.id)
  8481. {
  8482. cond = false;
  8483. }
  8484. }
  8485. if (cond)
  8486. {
  8487. switchCovergeButton.lat = pos.lat;
  8488. switchCovergeButton.lng = pos.lng;
  8489. switchCovergeButton.heading = image.compassAngle;
  8490. // console.log(pos);
  8491. locHistory.push([pos.lat, pos.lng, image.id, image.compassAngle]);
  8492. }
  8493. let btn = document.querySelector("button[data-qa='undo-move']");
  8494. if (btn !== null && locHistory.length > 1)
  8495. {
  8496. btn.disabled = false;
  8497. btn.classList.remove('styles_disabled__2YdHD');
  8498. }
  8499. });
  8500.  
  8501. MAPILLARY_INJECTED = true;
  8502. }
  8503. if (partialCreateMapillary)
  8504. {
  8505. drawMapML();
  8506. }
  8507. else
  8508. {
  8509.  
  8510. SCRIPT.addEventListener('load', () => {
  8511. myHighlight("Mapillary API Loaded");
  8512. // resolve(BMap);
  8513. drawMapML();
  8514. resolve();
  8515. })
  8516. }
  8517. }
  8518. }
  8519. else {
  8520. resolve();
  8521. }
  8522. });
  8523. }
  8524.  
  8525. function changeInnerHTML(canvas1, init)
  8526. {
  8527. canvas1.style.display = "";
  8528. var div = document.getElementById("player");
  8529. if (isBullseye || isLiveChallenge)
  8530. {
  8531. div.prepend(canvas1);
  8532. }
  8533. else
  8534. {
  8535. div.appendChild(canvas1);
  8536. }
  8537.  
  8538. let canvas;
  8539. if (init)
  8540. {
  8541. canvas = document.createElement("div");
  8542. canvas.id = "mapbox-player";
  8543. canvas.style.cssText = `overflow: visible; zIndex: 1; position: 'absolute'; top: 0; left: 0; width: 100%; height: 100%;`;
  8544. setTimeout(()=> {
  8545. canvas.style.overFlow = 'visible';
  8546. // canvas.style.width = '100%';
  8547. // canvas.style.height = '100%';
  8548. }
  8549. , 1000);
  8550. canvas1.appendChild(canvas);
  8551. }
  8552. else
  8553. {
  8554. 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");
  8555. }
  8556. canvas = document.getElementById("mapbox-player");
  8557. if (isBattleRoyale) {
  8558. if (isDuel)
  8559. {
  8560. canvas.classList.add("inactive");
  8561. }
  8562. else if (isBullseye)
  8563. {
  8564. canvas.classList.add("game-panorama_panorama__ncMwh");
  8565. }
  8566. else if (isLiveChallenge)
  8567. {
  8568. canvas.classList.add("game-panorama_panorama__IuPsO");
  8569. }
  8570. else
  8571. {
  8572. canvas.classList.add("br-game-layout__panorama");
  8573. }
  8574. }
  8575. else {
  8576. canvas.classList.add("game-layout__panorama");
  8577. }
  8578. if (rainLayer)
  8579. {
  8580. MapboxPlayer.resize();
  8581. }
  8582. // console.log(canvas);
  8583.  
  8584. }
  8585.  
  8586. function updateSunPosition(sunPos) {
  8587. MapboxPlayer.setPaintProperty('sky', 'sky-atmosphere-sun', sunPos);
  8588. }
  8589.  
  8590. function getSunPosition(date) {
  8591. const center = MapboxPlayer.getCenter();
  8592. const sunPos = SunCalc.getPosition(
  8593. date || Date.now(),
  8594. center.lat,
  8595. center.lng
  8596. );
  8597. const sunAzimuth = 180 + (sunPos.azimuth * 180) / Math.PI;
  8598. const sunAltitude = 90 - (sunPos.altitude * 180) / Math.PI;
  8599. return [sunAzimuth, sunAltitude];
  8600. }
  8601.  
  8602. // function handleRainLayer()
  8603. // {
  8604. // if (typeof RainLayer !== typeof undefined)
  8605. // {
  8606.  
  8607. // MapboxPlayer.addLayer(rainLayer);
  8608.  
  8609. // console.log("Rain Layer loaded");
  8610. // }
  8611. // else
  8612. // {
  8613. // setTimeout(handleRainLayer, 1000);
  8614. // }
  8615. // }
  8616.  
  8617. function skyLayer(reset, time, style)
  8618. {
  8619. try
  8620. {
  8621. if (reset.includes("reset"))
  8622. {
  8623. if (time == "")
  8624. {
  8625. time = [360, 30];
  8626. }
  8627. MapboxPlayer.addLayer({
  8628. 'id': 'sky',
  8629. 'type': 'sky',
  8630. 'paint': {
  8631. 'sky-opacity': [
  8632. 'interpolate',
  8633. ['linear'],
  8634. ['zoom'],
  8635. 0,
  8636. 0,
  8637. 5,
  8638. 0.3,
  8639. 8,
  8640. 1
  8641. ],
  8642. // set up the sky layer for atmospheric scattering
  8643. 'sky-type': 'atmosphere',
  8644. // explicitly set the position of the sun rather than allowing the sun to be attached to the main light source
  8645. 'sky-atmosphere-sun': time,
  8646. // set the intensity of the sun as a light source (0-100 with higher values corresponding to brighter skies)
  8647. 'sky-atmosphere-sun-intensity': 5
  8648. }
  8649. });
  8650.  
  8651. // handleRainLayer();
  8652.  
  8653.  
  8654. // Reset Fog
  8655. }
  8656. let percentage;
  8657. // console.log(time);
  8658.  
  8659. if (time[1] <= 75)
  8660. {
  8661. percentage = 0;
  8662. }
  8663. else if (time[1] > 75 && time[1] <= 90)
  8664. {
  8665. percentage = (90 - time[1]) / 20;
  8666. }
  8667. else
  8668. {
  8669. percentage = 1;
  8670. }
  8671.  
  8672. // console.log(MapboxPlayer.getStyle());
  8673.  
  8674. if (style)
  8675. {
  8676. MapboxPlayer.setPaintProperty(
  8677. 'heatmap',
  8678. 'heatmap-opacity',
  8679. percentage * 0.35
  8680. );
  8681. MapboxPlayer.setPaintProperty(
  8682. 'satellite',
  8683. 'raster-brightness-max',
  8684. 0.25 + (1 - percentage) * 0.75
  8685. );
  8686. MapboxPlayer.setPaintProperty(
  8687. 'road-simple',
  8688. 'line-opacity',
  8689. percentage * 0.25
  8690. );
  8691. MapboxPlayer.setPaintProperty(
  8692. 'bridge-case-simple',
  8693. 'line-opacity',
  8694. percentage * 0.25
  8695. );
  8696. MapboxPlayer.setPaintProperty(
  8697. 'bridge-simple',
  8698. 'line-opacity',
  8699. percentage * 0.25
  8700. );
  8701. }
  8702. let fogVal = 100 - percentage * 100;
  8703. // console.log(`rgba(${parseInt(fogVal)}, ${parseInt(fogVal)}, ${parseInt(fogVal)}, 1.0)`)
  8704. let val = [0, 5, 0.1];
  8705. if (ms_radius < 10000)
  8706. {
  8707. val[1] = ms_radius / 10000 * 4 + 1;
  8708. }
  8709. MapboxPlayer.setFog({ 'color': `hsl(0, 0, ${fogVal}%)` , 'range': [val[0], val[1]],'horizon-blend': val[2]});
  8710. // console.log(MapboxPlayer.getStyle());
  8711. }
  8712. catch (error) {
  8713. console.error(error);
  8714. // expected output: ReferenceError: nonExistentFunction is not defined
  8715. // Note - error messages will vary depending on browser
  8716. }
  8717. }
  8718.  
  8719.  
  8720. // function fetchTime(lat, lng)
  8721. // {
  8722. // return new Promise((resolve, reject) => {
  8723. // fetch(`https://api.timezonedb.com/v2.1/get-time-zone?key=D95ISGQ041BQ&format=json&by=position&lat=${lat}&lng=${lng}`)
  8724. // .then((response) => {resolve(response.json())})
  8725. // .catch((error) => {console.log(error);});
  8726. // });
  8727. // }
  8728. // fetchTime(global_lat, global_lng).then((data) => {
  8729.  
  8730. function styleMapboxAll(changeAttr, attrVal)
  8731. {
  8732. let satelliteStyleBtn = document.getElementById("Satellite Type Button");
  8733. const sunPositions = SunCalc.getTimes(
  8734. Date.now(),
  8735. global_lat,
  8736. global_lng
  8737. );
  8738.  
  8739. if (changeAttr === "Dimension" || changeAttr === "All" )
  8740. {
  8741. if (changeAttr === "All")
  8742. {
  8743. attrVal = Dimension;
  8744. }
  8745. // console.log(["arrval", attrVal]);
  8746.  
  8747. let tempRadius;
  8748. if (attrVal)
  8749. {
  8750. // 3D mode = 1/2 radius + pitch.
  8751. // From Unity Script documentation: https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit#heading=h.wce3rggpxz7i
  8752. // "*In 3D, radius is reduced by 50% but maximum viewing area with pitch is ~110%."
  8753. tempRadius = ms_radius * 0.5;
  8754. }
  8755. else
  8756. {
  8757. // 2D mode = full radius.
  8758. tempRadius = ms_radius;
  8759. }
  8760.  
  8761. let loc_centre = {lat: global_lat, lng: global_lng};
  8762. let latlngBounds = getBBox2(loc_centre, tempRadius);
  8763. // console.log([latlngBounds[0], latlngBounds[1]], [latlngBounds[2], latlngBounds[3]])
  8764. let mpBounds = [
  8765. [latlngBounds[1], latlngBounds[2]], // Southwest coordinates
  8766. [latlngBounds[3], latlngBounds[0]] // Northeast coordinates
  8767. ];
  8768.  
  8769. MapboxPlayer.setMaxBounds(mpBounds);
  8770.  
  8771. MapboxPlayer.once("moveend", (x) => {
  8772. setTimeout(()=>{
  8773. // Wait for the map to load a bit and then reset the map.
  8774.  
  8775. MapboxMarker.setLngLat([global_lng, global_lat])
  8776. .addTo(MapboxPlayer);
  8777.  
  8778. MapboxPlayer.easeTo({
  8779. bearing: 0,
  8780. pitch: 0,
  8781. zoom: 0,
  8782. duration: 1,
  8783. });
  8784. }, 1);
  8785. });
  8786.  
  8787. setTimeout(()=>{
  8788. // Added by EC waiting a bit seems to make the the animation
  8789. // more reliable. Sometimes it won't set the center properly.
  8790. MapboxPlayer.setCenter([global_lng, global_lat]);
  8791. }, 1);
  8792.  
  8793. if (attrVal)
  8794. {
  8795. MapboxPlayer.dragRotate.enable();
  8796. MapboxPlayer.touchZoomRotate.enableRotation();
  8797. }
  8798. else
  8799. {
  8800. MapboxPlayer.setPitch(0);
  8801. MapboxPlayer.dragRotate.disable();
  8802. MapboxPlayer.touchZoomRotate.disableRotation();
  8803. }
  8804. }
  8805. if (changeAttr === "SunPos")
  8806. {
  8807. // if (changeAttr === "All")
  8808. // {
  8809. // attrVal = satelliteStyleBtn.currentTime;
  8810. // }
  8811. let sunPos = getSunPosition(sunPositions[attrVal]);
  8812. updateSunPosition(sunPos);
  8813. skyLayer("", sunPos, mapSty);
  8814. }
  8815. if (changeAttr === "mapSty")
  8816. {
  8817. if (attrVal)
  8818. {
  8819. MapboxPlayer.setStyle("mapbox://styles/jupaoqq/cl0xjs63k003a15ml3essawbk");
  8820. }
  8821. else
  8822. {
  8823. MapboxPlayer.setStyle("mapbox://styles/jupaoqq/cl0ro0tm0001l14nyi17a91rs");
  8824. }
  8825.  
  8826. // MapboxPlayer.addLayer(rainLayer);
  8827. setTimeout(() => {
  8828. skyLayer("reset", getSunPosition(sunPositions[satelliteStyleBtn.currentTime]), mapSty);
  8829. if (!MapboxPlayer.getSource('mapbox-dem')) {
  8830. MapboxPlayer.addSource('mapbox-dem', {
  8831. 'type': 'raster-dem',
  8832. 'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',
  8833. 'tileSize': 512,
  8834. 'maxzoom': 14
  8835. });
  8836. // add the DEM source as a terrain layer with exaggerated height
  8837. MapboxPlayer.setTerrain({ 'source': 'mapbox-dem', 'exaggeration': 1.5 });
  8838. }
  8839. MapboxPlayer.addLayer(rainLayer);
  8840. }, 1000);
  8841. }
  8842. if (changeAttr === "Building" || changeAttr === "All")
  8843. {
  8844. if (changeAttr === "All")
  8845. {
  8846. attrVal = Building;
  8847. console.log("building")
  8848. }
  8849. if (attrVal)
  8850. {
  8851. MapboxPlayer.setPaintProperty(
  8852. 'building-extrusion',
  8853. 'fill-extrusion-opacity',
  8854. 0.8
  8855. );
  8856. }
  8857. else
  8858. {
  8859. MapboxPlayer.setPaintProperty(
  8860. 'building-extrusion',
  8861. 'fill-extrusion-opacity',
  8862. 0
  8863. );
  8864. }
  8865.  
  8866. }
  8867. if (changeAttr === "Weather" || changeAttr === "All")
  8868. {
  8869. if (changeAttr === "All")
  8870. {
  8871. attrVal = Weather;
  8872. }
  8873. if (attrVal)
  8874. {
  8875. rainLayer.setMeshOpacity(0.1);
  8876. rainLayer.setRainColor("rgba(204, 204, 255, 1)");
  8877. }
  8878. else
  8879. {
  8880. rainLayer.setMeshOpacity(0);
  8881. rainLayer.setRainColor("rgba(204, 204, 255, 0)");
  8882. }
  8883. }
  8884. }
  8885.  
  8886. function injectMapboxPlayer() {
  8887. return new Promise((resolve, reject) => {
  8888. if (!MAPBOX_INJECTED) {
  8889. if (MAPBOX_API_KEY === "") {
  8890. let canvas = document.getElementById("player");
  8891. console.log("No Mapbox Key")
  8892. }
  8893. else {
  8894. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  8895. let switchCovergeButton = document.getElementById("switch");
  8896.  
  8897. let canvas = document.createElement("sat-map");
  8898. canvas.id = "sat_map";
  8899. canvas.style.cssText = `z-index: 1; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%;`;
  8900. canvas.classList.add("sat_map");
  8901. changeInnerHTML(canvas, true);
  8902.  
  8903.  
  8904. // mapbox://styles/jupaoqq/cl0rnlwp9001914mz2vpinynt
  8905. // mapbox://styles/jupaoqq/cl0ro0tm0001l14nyi17a91rs
  8906.  
  8907. let SCRIPT;
  8908. if (!partialCreateMapbox)
  8909. {
  8910. const SCRIPT2 = document.createElement("script");
  8911. SCRIPT2.type = "text/javascript";
  8912. SCRIPT2.async = true;
  8913. SCRIPT2.src = `https://cdnjs.cloudflare.com/ajax/libs/suncalc/1.8.0/suncalc.min.js`;
  8914. document.body.appendChild(SCRIPT2);
  8915.  
  8916. SCRIPT = document.createElement("script");
  8917. SCRIPT.type = "text/javascript";
  8918. SCRIPT.async = true;
  8919. //SCRIPT.src = `https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.js`;
  8920. SCRIPT.src = `https://api.mapbox.com/mapbox-gl-js/v3.2.0/mapbox-gl.js`;
  8921. document.body.appendChild(SCRIPT);
  8922. //document.querySelector('head').innerHTML += '<link href="https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.css" rel="stylesheet"/>';
  8923. document.querySelector('head').innerHTML += '<link href="https://api.mapbox.com/mapbox-gl-js/v2.7.0/mapbox-gl.css" rel="stylesheet"/>';
  8924. handleSatColor(true, true);
  8925. SCRIPT.addEventListener('load', () => {
  8926. const SCRIPT3 = document.createElement("script");
  8927. SCRIPT3.type = "text/javascript";
  8928. SCRIPT3.async = true;
  8929. SCRIPT3.src = `https://cdn.jsdelivr.net/npm/mapbox-gl-rain-layer@latest/dist/mapbox-gl-rain-layer.min.js`;
  8930. document.body.appendChild(SCRIPT3);
  8931. SCRIPT3.addEventListener('load', () => {
  8932. myHighlight("Mapbox API and Rainlayer Loaded");
  8933. // resolve(BMap);
  8934. mapboxgl.accessToken = MAPBOX_API_KEY;
  8935.  
  8936. // jsfiddle for flickering panning issue with map: https://jsfiddle.net/api/post/library/pure/
  8937.  
  8938. MapboxPlayer = new mapboxgl.Map({
  8939. container: 'mapbox-player', // container ID
  8940. // Using this style appears to cause flickering when used with the mapbox-dem source below.
  8941. style: 'mapbox://styles/jupaoqq/cl0xjs63k003a15ml3essawbk', // style URL
  8942. center: [0, 0], // starting position [lng, lat]
  8943. zoom: 13, // starting zoom
  8944. pitch: 0,
  8945. //bearing: 200
  8946. bearing: 0
  8947. });
  8948.  
  8949. console.log("New Mapbox API Call");
  8950.  
  8951. MapboxMarker = new mapboxgl.Marker()
  8952. // .setLngLat([0, 0])
  8953. // .addTo(MapboxPlayer);
  8954. MapboxPlayer.addControl(new mapboxgl.NavigationControl(), 'top-left');
  8955. MapboxPlayer.addControl(new mapboxgl.ScaleControl({}));
  8956. MapboxPlayer.on('load', () => {
  8957. MapboxPlayer.addSource('mapbox-dem', {
  8958. 'type': 'raster-dem',
  8959. 'url': 'mapbox://mapbox.mapbox-terrain-dem-v1',
  8960. 'tileSize': 512,
  8961. 'maxzoom': 14
  8962. });
  8963.  
  8964. // add the DEM source as a terrain layer with exaggerated height
  8965. MapboxPlayer.setTerrain({ 'source': 'mapbox-dem', 'exaggeration': 1.5 });
  8966.  
  8967. rainLayer = new RainLayer({
  8968. id: 'rain',
  8969. source: 'rainviewer',
  8970. scale: 'noaa'
  8971. });
  8972. //MapboxPlayer.addLayer(rainLayer); // Players don't seem to like rain.
  8973.  
  8974. // TODO
  8975. // MapboxPlayer.setFog({'range': [-1, 1.5], 'color': `rgba(255, 255, 255, 1.0)`,'horizon-blend': 0.1});
  8976. //styleMapboxAll("All", true);
  8977.  
  8978. skyLayer("reset", "", true);
  8979.  
  8980. });
  8981.  
  8982. });
  8983. });
  8984.  
  8985. MAPBOX_INJECTED = true;
  8986. resolve();
  8987.  
  8988. }
  8989. else
  8990. {
  8991. resolve();
  8992. }
  8993. }
  8994. }
  8995. else {
  8996. resolve();
  8997. }
  8998. });
  8999. }
  9000.  
  9001.  
  9002.  
  9003. function handleMapillary(latlng, options)
  9004. {
  9005. console.log("handleMapillary")
  9006. return;// Added by EC
  9007. handleMapillaryHelper(latlng, options).then((data) => {
  9008. //console.log(data.data)
  9009. let idToSet = 0;
  9010. let curDist = 100000000;
  9011. for (const element of data.data) {
  9012. // console.log(element)
  9013. if (element.hasOwnProperty("computed_geometry"))
  9014. {
  9015. try {
  9016. let rCord = element.computed_geometry["coordinates"];
  9017. let dist = distance(latlng.lat,latlng.lng,rCord[1],rCord[0])
  9018. if (dist < curDist)
  9019. {
  9020. idToSet = element.id;
  9021. curDist = dist
  9022. }
  9023. } catch (e) {
  9024. console.log("Error")
  9025. }
  9026. }
  9027. }
  9028. if (idToSet !== 0)
  9029. {
  9030. MapillaryPlayer.moveTo(idToSet).then(
  9031. image => { //console.log(image);
  9032. },
  9033. error => { console.log(error); });
  9034. }}).catch((error) => {
  9035. console.log(error);
  9036. });
  9037. }
  9038.  
  9039. function handleMapillaryHelper(latlng, options)
  9040. {
  9041. return new Promise((resolve, reject) => {
  9042. // console.log("1")
  9043. let bbox = getBBox(latlng, options.meters);
  9044. 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)
  9045. // console.log(URL)
  9046. fetch(URL)
  9047. .then((response) => {resolve(response.json())})
  9048. .catch((error) => {console.log(error);});
  9049. });
  9050. }
  9051.  
  9052. function injectMapyPlayer() {
  9053. return new Promise((resolve, reject) => {
  9054. if (!MAPY_INJECTED) {
  9055. if (MAPY_API_KEY === "") {
  9056. let canvas = document.getElementById("player");
  9057. MAPY_INJECTED = true;
  9058. console.log("No Mapy Key")
  9059. }
  9060. else {
  9061.  
  9062. // let [teleportBtn, teleportReverse, teleportMenu, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, TeleportArisBtn, satelliteSwitchButton, RestrictBoundsBtn, RestrictBoundsDistBtn, RestrictMoreBtn, RestrictLessBtn, RestrictBoundsEnableBtn, RestrictResetBtn ] = setButtons();
  9063. let switchCovergeButton = document.getElementById("switch");
  9064. let SCRIPT;
  9065. if (!partialCreateMapy)
  9066. {
  9067. SCRIPT = document.createElement("script");
  9068. SCRIPT.type = "text/javascript";
  9069. SCRIPT.async = true;
  9070. SCRIPT.src = `https://api.mapy.cz/loader.js`;
  9071. document.body.appendChild(SCRIPT);
  9072. }
  9073. let canvas = document.createElement("czmap");
  9074. if (isBattleRoyale) {
  9075. if (isDuel)
  9076. {
  9077.  
  9078. canvas.innerHTML = `<div id="mapy-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  9079. }
  9080. else if (isBullseye)
  9081. {
  9082. 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>`;
  9083. }
  9084. else if (isLiveChallenge)
  9085. {
  9086. 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>`;
  9087. }
  9088. else
  9089. {
  9090. 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>`;
  9091. }
  9092. }
  9093. else {
  9094. canvas.innerHTML = `<div id="mapy-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  9095. }
  9096.  
  9097. var div = document.getElementById("player");
  9098. if (isBullseye || isLiveChallenge)
  9099. {
  9100. div.prepend(canvas);
  9101. // setTimeout(drawmapMS(), 1000);
  9102. }
  9103. else
  9104. {
  9105. div.appendChild(canvas);
  9106. }
  9107.  
  9108. var mapyPanoChange = function (signal) {
  9109. if (defaultPanoIdChange) {
  9110. let mapyLat = MapyPlayer.getPlace()._data.mark.lat;
  9111. let mapyLng = MapyPlayer.getPlace()._data.mark.lon;
  9112. let mapyHeading = toDegrees(MapyPlayer.getCamera().yaw);
  9113. switchCovergeButton.lat = mapyLat;
  9114. switchCovergeButton.lng = mapyLng;
  9115. switchCovergeButton.heading = mapyHeading;
  9116.  
  9117. if (locHistory.length > 0)
  9118. {
  9119. let toPush = true;
  9120. for (let locHy of locHistory)
  9121. {
  9122. if (mapyLat === locHy[0] && mapyLng === locHy[1])
  9123. {
  9124. toPush = false;
  9125. }
  9126. }
  9127. if (toPush)
  9128. {
  9129. locHistory.push([mapyLat, mapyLng, mapyHeading]);
  9130. }
  9131. }
  9132. else
  9133. {
  9134. locHistory.push([mapyLat, mapyLng, mapyHeading]);
  9135. }
  9136. let btn = document.querySelector("button[data-qa='undo-move']");
  9137. if (locHistory.length > 1 && btn) {
  9138. btn.disabled = false;
  9139. btn.classList.remove('styles_disabled__2YdHD');
  9140. }
  9141. }
  9142. else
  9143. {
  9144. defaultPanoIdChange = true;
  9145. }
  9146. }
  9147.  
  9148. function crMap()
  9149. {
  9150. MapyPlayer = new SMap.Pano.Scene(document.getElementById("mapy-player"));
  9151. var signals = MapyPlayer.getSignals();
  9152. signals.addListener(window, "pano-change", mapyPanoChange);
  9153. }
  9154. if (partialCreateMapy)
  9155. {
  9156. crMap();
  9157. MAPY_INJECTED = true;
  9158. }
  9159. else
  9160. {
  9161. SCRIPT.addEventListener('load', () => {
  9162. myHighlight("Mapy API Loaded");
  9163. MAPY_INJECTED = true;
  9164. Loader.async = true;
  9165. Loader.load(null, {pano: true}, crMap);
  9166. resolve();
  9167. })
  9168. }
  9169. }
  9170. }
  9171. else {
  9172. resolve();
  9173. }
  9174. });
  9175. }
  9176.  
  9177.  
  9178. /**
  9179. * Minimap presets
  9180. */
  9181.  
  9182.  
  9183.  
  9184. 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;
  9185.  
  9186. (function makeMiniMapPresets(){
  9187. //setTimeout(function makeMiniMapPresets(){
  9188. // Made by EC
  9189. // Trying to make this script load faster, by delaying unnecessary stuff.
  9190.  
  9191. water_name_only =
  9192. [
  9193. {
  9194. "elementType": "geometry",
  9195. "stylers": [
  9196. {
  9197. "visibility": "off"
  9198. }
  9199. ]
  9200. },
  9201. {
  9202. "featureType": "administrative",
  9203. "stylers": [
  9204. {
  9205. "visibility": "off"
  9206. }
  9207. ]
  9208. },
  9209. {
  9210. "featureType": "landscape",
  9211. "stylers": [
  9212. {
  9213. "visibility": "off"
  9214. }
  9215. ]
  9216. },
  9217. {
  9218. "featureType": "poi",
  9219. "stylers": [
  9220. {
  9221. "visibility": "off"
  9222. }
  9223. ]
  9224. },
  9225. {
  9226. "featureType": "road",
  9227. "stylers": [
  9228. {
  9229. "visibility": "off"
  9230. }
  9231. ]
  9232. },
  9233. {
  9234. "featureType": "transit",
  9235. "stylers": [
  9236. {
  9237. "visibility": "off"
  9238. }
  9239. ]
  9240. }
  9241. ]
  9242.  
  9243. country_name_only =
  9244. [
  9245. {
  9246. "elementType": "geometry",
  9247. "stylers": [
  9248. {
  9249. "visibility": "off"
  9250. }
  9251. ]
  9252. },
  9253. {
  9254. "featureType": "administrative",
  9255. "stylers": [
  9256. {
  9257. "visibility": "off"
  9258. }
  9259. ]
  9260. },
  9261. {
  9262. "featureType": "administrative.country",
  9263. "elementType": "labels",
  9264. "stylers": [
  9265. {
  9266. "visibility": "on"
  9267. }
  9268. ]
  9269. },
  9270. {
  9271. "featureType": "landscape",
  9272. "stylers": [
  9273. {
  9274. "visibility": "off"
  9275. }
  9276. ]
  9277. },
  9278. {
  9279. "featureType": "poi",
  9280. "stylers": [
  9281. {
  9282. "visibility": "off"
  9283. }
  9284. ]
  9285. },
  9286. {
  9287. "featureType": "road",
  9288. "stylers": [
  9289. {
  9290. "visibility": "off"
  9291. }
  9292. ]
  9293. },
  9294. {
  9295. "featureType": "transit",
  9296. "stylers": [
  9297. {
  9298. "visibility": "off"
  9299. }
  9300. ]
  9301. },
  9302. {
  9303. "featureType": "water",
  9304. "stylers": [
  9305. {
  9306. "visibility": "off"
  9307. }
  9308. ]
  9309. }
  9310. ]
  9311.  
  9312. no_label_or_terrain =
  9313. [
  9314. {
  9315. "elementType": "geometry",
  9316. "stylers": [
  9317. {
  9318. "visibility": "off"
  9319. }
  9320. ]
  9321. },
  9322. {
  9323. "featureType": "administrative",
  9324. "stylers": [
  9325. {
  9326. "visibility": "off"
  9327. }
  9328. ]
  9329. },
  9330. {
  9331. "featureType": "landscape",
  9332. "stylers": [
  9333. {
  9334. "visibility": "off"
  9335. }
  9336. ]
  9337. },
  9338. {
  9339. "featureType": "poi",
  9340. "stylers": [
  9341. {
  9342. "visibility": "off"
  9343. }
  9344. ]
  9345. },
  9346. {
  9347. "featureType": "road",
  9348. "stylers": [
  9349. {
  9350. "visibility": "off"
  9351. }
  9352. ]
  9353. },
  9354. {
  9355. "featureType": "transit",
  9356. "stylers": [
  9357. {
  9358. "visibility": "off"
  9359. }
  9360. ]
  9361. },
  9362. {
  9363. "featureType": "water",
  9364. "stylers": [
  9365. {
  9366. "visibility": "on"
  9367. }
  9368. ]
  9369. },
  9370. {
  9371. "featureType": "water",
  9372. "elementType": "labels",
  9373. "stylers": [
  9374. {
  9375. "visibility": "off"
  9376. }
  9377. ]
  9378. }
  9379. ]
  9380.  
  9381. no_label =
  9382. [
  9383. {
  9384. "elementType": "labels",
  9385. "stylers": [
  9386. {
  9387. "visibility": "off"
  9388. }
  9389. ]
  9390. },
  9391. {
  9392. "featureType": "administrative",
  9393. "stylers": [
  9394. {
  9395. "visibility": "off"
  9396. }
  9397. ]
  9398. }
  9399. ]
  9400.  
  9401. blank =
  9402.  
  9403. [
  9404. {
  9405. "stylers": [
  9406. {
  9407. "visibility": "off"
  9408. }
  9409. ]
  9410. }
  9411. ]
  9412.  
  9413. thick_border =
  9414.  
  9415. [
  9416. {
  9417. "featureType": "administrative.country",
  9418. "elementType": "geometry.stroke",
  9419. "stylers": [
  9420. {
  9421. "weight": 1.5
  9422. }
  9423. ]
  9424. },
  9425. {
  9426. "featureType": "administrative.province",
  9427. "elementType": "geometry.stroke",
  9428. "stylers": [
  9429. {
  9430. "weight": 3.5
  9431. }
  9432. ]
  9433. }
  9434. ]
  9435.  
  9436. Indonesia =
  9437. [
  9438. {
  9439. "featureType": "administrative",
  9440. "stylers": [
  9441. {
  9442. "visibility": "off"
  9443. }
  9444. ]
  9445. },
  9446. {
  9447. "featureType": "landscape",
  9448. "elementType": "labels",
  9449. "stylers": [
  9450. {
  9451. "visibility": "off"
  9452. }
  9453. ]
  9454. },
  9455. {
  9456. "featureType": "poi.park",
  9457. "elementType": "labels",
  9458. "stylers": [
  9459. {
  9460. "visibility": "off"
  9461. }
  9462. ]
  9463. },
  9464. {
  9465. "featureType": "road",
  9466. "elementType": "labels",
  9467. "stylers": [
  9468. {
  9469. "visibility": "off"
  9470. }
  9471. ]
  9472. },
  9473. {
  9474. "featureType": "transit",
  9475. "elementType": "labels",
  9476. "stylers": [
  9477. {
  9478. "visibility": "off"
  9479. }
  9480. ]
  9481. },
  9482. {
  9483. "featureType": "water",
  9484. "elementType": "labels",
  9485. "stylers": [
  9486. {
  9487. "visibility": "off"
  9488. }
  9489. ]
  9490. }
  9491. ];
  9492.  
  9493. dark = [
  9494. {
  9495. "elementType": "geometry",
  9496. "stylers": [
  9497. {
  9498. "color": "#212121"
  9499. }
  9500. ]
  9501. },
  9502. {
  9503. "elementType": "labels.icon",
  9504. "stylers": [
  9505. {
  9506. "visibility": "off"
  9507. }
  9508. ]
  9509. },
  9510. {
  9511. "elementType": "labels.text.fill",
  9512. "stylers": [
  9513. {
  9514. "color": "#757575"
  9515. }
  9516. ]
  9517. },
  9518. {
  9519. "elementType": "labels.text.stroke",
  9520. "stylers": [
  9521. {
  9522. "color": "#212121"
  9523. }
  9524. ]
  9525. },
  9526. {
  9527. "featureType": "administrative",
  9528. "elementType": "geometry",
  9529. "stylers": [
  9530. {
  9531. "color": "#757575"
  9532. }
  9533. ]
  9534. },
  9535. {
  9536. "featureType": "administrative.country",
  9537. "elementType": "labels.text.fill",
  9538. "stylers": [
  9539. {
  9540. "color": "#9e9e9e"
  9541. }
  9542. ]
  9543. },
  9544. {
  9545. "featureType": "administrative.land_parcel",
  9546. "stylers": [
  9547. {
  9548. "visibility": "off"
  9549. }
  9550. ]
  9551. },
  9552. {
  9553. "featureType": "administrative.locality",
  9554. "elementType": "labels.text.fill",
  9555. "stylers": [
  9556. {
  9557. "color": "#bdbdbd"
  9558. }
  9559. ]
  9560. },
  9561. {
  9562. "featureType": "poi",
  9563. "elementType": "labels.text.fill",
  9564. "stylers": [
  9565. {
  9566. "color": "#757575"
  9567. }
  9568. ]
  9569. },
  9570. {
  9571. "featureType": "poi.park",
  9572. "elementType": "geometry",
  9573. "stylers": [
  9574. {
  9575. "color": "#181818"
  9576. }
  9577. ]
  9578. },
  9579. {
  9580. "featureType": "poi.park",
  9581. "elementType": "labels.text.fill",
  9582. "stylers": [
  9583. {
  9584. "color": "#616161"
  9585. }
  9586. ]
  9587. },
  9588. {
  9589. "featureType": "poi.park",
  9590. "elementType": "labels.text.stroke",
  9591. "stylers": [
  9592. {
  9593. "color": "#1b1b1b"
  9594. }
  9595. ]
  9596. },
  9597. {
  9598. "featureType": "road",
  9599. "elementType": "geometry.fill",
  9600. "stylers": [
  9601. {
  9602. "color": "#2c2c2c"
  9603. }
  9604. ]
  9605. },
  9606. {
  9607. "featureType": "road",
  9608. "elementType": "labels.text.fill",
  9609. "stylers": [
  9610. {
  9611. "color": "#8a8a8a"
  9612. }
  9613. ]
  9614. },
  9615. {
  9616. "featureType": "road.arterial",
  9617. "elementType": "geometry",
  9618. "stylers": [
  9619. {
  9620. "color": "#373737"
  9621. }
  9622. ]
  9623. },
  9624. {
  9625. "featureType": "road.highway",
  9626. "elementType": "geometry",
  9627. "stylers": [
  9628. {
  9629. "color": "#3c3c3c"
  9630. }
  9631. ]
  9632. },
  9633. {
  9634. "featureType": "road.highway.controlled_access",
  9635. "elementType": "geometry",
  9636. "stylers": [
  9637. {
  9638. "color": "#4e4e4e"
  9639. }
  9640. ]
  9641. },
  9642. {
  9643. "featureType": "road.local",
  9644. "elementType": "labels.text.fill",
  9645. "stylers": [
  9646. {
  9647. "color": "#616161"
  9648. }
  9649. ]
  9650. },
  9651. {
  9652. "featureType": "transit",
  9653. "elementType": "labels.text.fill",
  9654. "stylers": [
  9655. {
  9656. "color": "#757575"
  9657. }
  9658. ]
  9659. },
  9660. {
  9661. "featureType": "water",
  9662. "elementType": "geometry",
  9663. "stylers": [
  9664. {
  9665. "color": "#000000"
  9666. }
  9667. ]
  9668. },
  9669. {
  9670. "featureType": "water",
  9671. "elementType": "labels.text.fill",
  9672. "stylers": [
  9673. {
  9674. "color": "#3d3d3d"
  9675. }
  9676. ]
  9677. }
  9678. ];
  9679.  
  9680. neon = [
  9681. {
  9682. "stylers": [
  9683. {
  9684. "saturation": 100
  9685. },
  9686. {
  9687. "gamma": 0.6
  9688. }
  9689. ]
  9690. }
  9691. ];
  9692.  
  9693. default_preset = []
  9694.  
  9695. presetMinimap = [[default_preset, "Default"],
  9696. [blank, "Blank"],
  9697. [water_name_only, "Oceanman"],
  9698. [country_name_only, "Impossible"],
  9699. [no_label_or_terrain, "Streaks"],
  9700. [no_label, "Easy 5K"],
  9701. [Indonesia, "POI only"],
  9702. [dark, "Dark Mode"],
  9703. [thick_border, "Borders"],
  9704. [default_preset, "Satellite"],
  9705. [default_preset, "Terrain"],
  9706. [default_preset, "Hybrid"],
  9707. [custom, "Custom"],
  9708. [neon, "Neon"],
  9709. [default_preset, "Country Streak"],
  9710. [default_preset, "RMC"]]
  9711.  
  9712. GEOJSON_INVISIBLE =
  9713. {
  9714. strokeOpacity: 0,
  9715. fillOpacity: 0,
  9716. clickable: false,
  9717. }
  9718.  
  9719. presetOverlay = [["Clear",""],
  9720. ["Coverage",""],
  9721. ["Official",""],
  9722. ["OSM",""],
  9723. ["City Lights",""],
  9724. ["Watercolor",""],
  9725. ["Toner",""],
  9726. ["Fire",""],
  9727. ["Longitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/lonl.json"],
  9728. ["Latitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/latl.json"],
  9729. ["US County","https://raw.githubusercontent.com/CodeForCary/CountyDataUSA5m/master/cb_2017_us_county_5m.json"],
  9730. ["France","https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements.geojson"],
  9731. ["Time Zone", "https://raw.githubusercontent.com/treyerl/timezones/master/timezones_wVVG8.geojson"],
  9732. ["UK Parliament", "https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/electoral/gb/wpc.json"],
  9733. ["Custom", YOUR_URL]]
  9734.  
  9735. spaceMinimap = [["Earth",""],
  9736. ["Moon", "https://s3.amazonaws.com/opmbuilder/301_moon/tiles/w/hillshaded-albedo/"],
  9737. ["Moon (Labels)", "https://cartocdn-gusc.global.ssl.fastly.net/opmbuilder/api/v1/map/named/opm-moon-basemap-v0-1/all/"],
  9738. ["Mars", "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/celestia_mars-shaded-16k_global/"],
  9739. ["Mars (Labels)", "https://cartocdn-gusc.global.ssl.fastly.net/opmbuilder/api/v1/map/named/opm-mars-basemap-v0-2/all/"],
  9740. ["Mars-Viking", "http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/viking_mdim21_global/"],
  9741. ]
  9742.  
  9743. spaceMinimap2 = [["Mercury", "mercury/mercury_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=MESSENGER_May2013"],
  9744. ["Venus", "venus/venus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=MAGELLAN_color"],
  9745. ["Phobos", "mars/phobos_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=VIKING"],
  9746. ["Deimos", "mars/deimos_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=VIKING"],
  9747. ["Ceres", "asteroid_belt/ceres_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Ceres_FC_global"],
  9748. ["Vesta", "asteroid_belt/vesta_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=Dawn_HAMO_global"],
  9749. ["Jupiter", "jupiter/jupiter_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  9750. ["Callisto", "jupiter/callisto_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=GALILEO_VOYAGER"],
  9751. ["Europa", "jupiter/europa_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=GALILEO_VOYAGER"],
  9752. ["Ganymede", "jupiter/ganymede_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=GALILEO_VOYAGER"],
  9753. ["Io", "jupiter/io_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=SSI_VGR_color"]
  9754. ]
  9755.  
  9756. spaceMinimap3 = [["Saturn", "saturn/saturn_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  9757. ["Dione", "saturn/dione_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_VOYAGER"],
  9758. ["Enceladus", "saturn/enceladus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  9759. ["Iapetus", "saturn/iapetus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_VOYAGER"],
  9760. ["Mimas", "saturn/mimas_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_MIMAS_MOSAIC"],
  9761. ["Rhea", "saturn/rhea_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI_VOYAGER"],
  9762. ["Tethys", "saturn/tethys_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  9763. ["Titan", "saturn/titan_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=CASSINI"],
  9764. ["Uranus", "uranus/uranus_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=JHT_VOYAGER_HST"],
  9765. ["Neptune", "neptune/neptune_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=JHT_VOYAGER"],
  9766. ["Pluto", "pluto/pluto_simp_cyl.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=NEWHORIZONS_PLUTO_MOSAIC"],
  9767. ]
  9768.  
  9769. spaceList = ["Moon", "Mars", "Mercury", "Venus", "Phobos", "Deimos", "Ceres", "Vesta", "Jupiter", "Callisto", "Europa", "Ganymede", "Io",
  9770. "Saturn", "Dione", "Enceladus", "Iapetus", "Mimas", "Rhea", "Tethys", "Titan", "Uranus", "Neptune", "Pluto", "Solar System"];
  9771. })();
  9772.  
  9773. function handleSpURL(url, x1, y1, z1)
  9774. {
  9775. function tile2long(x,z) {
  9776. return (x/Math.pow(2,z)*360-180);
  9777. }
  9778. function tile2lat(y,z) {
  9779. var n=Math.PI-2*Math.PI*y/Math.pow(2,z);
  9780. return (180/Math.PI*Math.atan(0.5*(Math.exp(n)-Math.exp(-n))));
  9781. }
  9782.  
  9783. let NWlon = tile2long(x1,z1)
  9784. let NWlat = tile2lat(y1,z1)
  9785. let SElon = tile2long(x1 + 1,z1)
  9786. let SElat = tile2lat(y1 + 1,z1)
  9787. 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}`;
  9788. }
  9789.  
  9790. // return `https://tiles.mapgenie.io/games/gta5/los-santos/satellite/${z}/${x}/${y}.png`
  9791. // return `https://mapsv0.bdimg.com/tile/?udt=20200825&qt=tile&styles=pl&x=${x}&y=${y}&z=${z+2}`
  9792.  
  9793. let langDict = {
  9794. "sn": ["fr"],
  9795. "za": ["af"],
  9796. "mg": ["mg", "fr"],
  9797. "tn": ["ar"],
  9798. "bd": ["bn"],
  9799. "kh": ["km"],
  9800. "in": ["hi"],
  9801. "cn": ["zh"],
  9802. "hk": ["zh"],
  9803. "id": ["id"],
  9804. "ir": ["fa"],
  9805. "il": ["he"],
  9806. "jp": ["ja"],
  9807. "jo": ["ar"],
  9808. "ky": ["ru", "ky"],
  9809. "la": ["lo"],
  9810. "my": ["ms"],
  9811. "mn": ["mn"],
  9812. "np": ["ne"],
  9813. "ru": ["ru"],
  9814. "sg": ["zh"],
  9815. "kr": ["ko"],
  9816. "lk": ["ta"],
  9817. "tw": ["zh"],
  9818. "th": ["th"],
  9819. "ae": ["ar"],
  9820. "vn": ["vi"],
  9821. "al": ["sq"],
  9822. "ad": ["es", "fr"],
  9823. "at": ["de"],
  9824. "be": ["nl", "fr"],
  9825. "bg": ["bg"],
  9826. "hr": ["hr"],
  9827. "cy": ["el"],
  9828. "cz": ["cs"],
  9829. "dk": ["da"],
  9830. "ee": ["et"],
  9831. "fo": ["fo"],
  9832. "fi": ["fi"],
  9833. "fr": ["fr"],
  9834. "de": ["de"],
  9835. "gr": ["el"],
  9836. "hu": ["hu"],
  9837. "is": ["is"],
  9838. "ie": ["ga"],
  9839. "it": ["it"],
  9840. "lv": ["lv"],
  9841. "lt": ["lt"],
  9842. "lu": ["lb", "fr", "de"],
  9843. "mc": ["fr"],
  9844. "nl": ["nl"],
  9845. "mk": ["mk"],
  9846. "no": ["no"],
  9847. "pl": ["pl"],
  9848. "pt": ["pt"],
  9849. "ro": ["ro"],
  9850. "sm": ["it"],
  9851. "rs": ["sr"],
  9852. "sk": ["sk"],
  9853. "si": ["sl"],
  9854. "es": ["es"],
  9855. "se": ["sv"],
  9856. "ch": ["de", "fr"],
  9857. "tr": ["tr"],
  9858. "ua": ["uk"],
  9859. "cw": ["nl"],
  9860. "do": ["es"],
  9861. "gt": ["es"],
  9862. "mx": ["es"],
  9863. "pr": ["es"],
  9864. "ar": ["es"],
  9865. "bo": ["es"],
  9866. "br": ["pt"],
  9867. "cl": ["es"],
  9868. "ec": ["es"],
  9869. "pe": ["es"],
  9870. "uy": ["es"]
  9871. };
  9872.  
  9873. // ch, lu, be, ad
  9874.  
  9875. let carteDict = {
  9876. "AG": "agadir",
  9877. "AS": "asilah",
  9878. "CA": "casablanca",
  9879. "ER": "errachidia",
  9880. "ES": "essaouira",
  9881. "FE": "fes",
  9882. "IR": "ifrane",
  9883. "MA": "marrakech",
  9884. "ME": "meknes",
  9885. "RA": "rabat",
  9886. };
  9887.  
  9888. let satType = [["Weather", "Weather: On", "Weather: Off"],
  9889. ["Building", "Building: On", "Building: Off"],
  9890. ["Dimension", "3D", "2D"],
  9891. ["mapSty", "Satellite", "Road"]];
  9892.  
  9893. let satStyle = [["solarNoon","Noon"],
  9894. ["sunriseEnd","Sunrise"],
  9895. ["goldenHourEnd","Morning"],
  9896. ["goldenHour","Evening"],
  9897. ["sunsetStart","Sunset"],
  9898. ["nadir","Midnight"],
  9899. ["getlocal","Local Time"],
  9900. ];
  9901.  
  9902.  
  9903.  
  9904. let HUD_ZINDEX_UPDATER = setInterval(()=>{
  9905. // Added by EC
  9906. let huds = document.querySelectorAll(`div[class*="Hud"i]`);
  9907.  
  9908. huds.forEach((hudEl)=>{
  9909. if (hudEl._zindexSet) return;
  9910. hudEl.style.zIndex = '2';
  9911. hudEl._zindexSet = true;
  9912. })
  9913.  
  9914. }, 2000);
  9915.  
  9916.  
  9917. setInterval(function () {
  9918. const guessmap = document.querySelector("div[data-qa='guess-map']");
  9919. //const canvas = document.querySelector("#satMapContainer");
  9920. const canvass = document.querySelectorAll("canvas");
  9921.  
  9922. if (guessmap && !guessmap.__n) {
  9923. // Sometimes the guess map doesn't open back up.
  9924.  
  9925. guessmap.addEventListener("mouseover", function (e) {
  9926. if (!guessmap.activeClass) {
  9927. setTimeout(()=>{
  9928. guessmap.activeClass = Array.from(guessmap.classList).reduce( (x, a) => x + (/active/i.test(a) ? a : ""), "",);
  9929. }, 100);
  9930. return;
  9931. }
  9932. guessmap.classList.add(guessmap.activeClass);
  9933. });
  9934. guessmap.__n = true;
  9935. }
  9936.  
  9937. canvass.forEach(canvas =>{
  9938. if (canvas && canvas.__n) return;
  9939.  
  9940. canvas.addEventListener("mousedown", function () {
  9941. const guessmap = document.querySelector("div[data-qa='guess-map']");
  9942. if (!guessmap) return;
  9943. if (!guessmap.activeClass) {
  9944. guessmap.activeClass = Array.from(guessmap.classList).reduce( (x, a) => x + (/active/i.test(a) ? a : ""), "",);
  9945. }
  9946. guessmap.classList.remove(guessmap.activeClass);
  9947. });
  9948.  
  9949. canvas.__n = true;
  9950. });
  9951. }, 2000);
  9952.  
  9953. function makeGuessMapHack(options){
  9954. const guessButton = document.querySelector('[data-qa="perform-guess"]');
  9955. if (guessButton){
  9956. console.log(guessButton);
  9957.  
  9958. // Geoguessr guess map is loaded.
  9959. return;
  9960. }
  9961.  
  9962. if (document.querySelector('.baidu_guess_map')){
  9963. // Remove duplicate or old guess map and button.
  9964. // Timing out is one issue that could cause duplicate guess map and button.
  9965. let baiduGuessMap = document.querySelector('.baidu_guess_map');
  9966. baiduGuessMap._remove();
  9967. }
  9968.  
  9969. const geoGuessContainer = document.querySelector(`[class*="game_guessMap"]`);
  9970. geoGuessContainer.style.flexDirection = "column";
  9971.  
  9972. let closeMiniMapTimer = null;
  9973.  
  9974. options.mapContainer.addEventListener("mouseover", () =>{
  9975. clearTimeout(closeMiniMapTimer);
  9976. closeMiniMapTimer = setTimeout(function(){
  9977. mapContainer.classList.remove(`baidu_guess_map_active`)
  9978. }, 500);
  9979. });
  9980.  
  9981. const mapContainer = document.createElement("div");
  9982. mapContainer.classList.add("baidu_guess_map");
  9983. mapContainer._remove = ()=>{
  9984. let baiduGuessMap = document.querySelector('.baidu_guess_map');
  9985. baiduGuessMap.parentElement.removeChild(baiduGuessMap);
  9986.  
  9987. let baiduGuessButton = document.querySelector('.baidu_guess_button');
  9988. if (baiduGuessButton){
  9989. baiduGuessButton.parentElement.removeChild(baiduGuessButton);
  9990. }
  9991. };
  9992. mapContainer.addEventListener("mouseover", () =>{
  9993. clearTimeout(closeMiniMapTimer);
  9994. mapContainer.classList.add(`baidu_guess_map_active`)
  9995. });
  9996. mapContainer.geoguessrGuessButtonWatcher = setInterval(()=>{
  9997. // Remove mapContainer if geoguessr guess button appears out of the blue.
  9998. const guessButton = document.querySelector('[data-qa="perform-guess"]');
  9999. if (!guessButton) return;
  10000. clearInterval(mapContainer.geoguessrGuessButtonWatcher);
  10001. mapContainer._remove();
  10002. }, 2000);
  10003.  
  10004. geoGuessContainer.appendChild(mapContainer);
  10005.  
  10006. let map = new google.maps.Map(mapContainer, {
  10007. center: { lat: 0, lng: 0 },
  10008. zoom: 5,
  10009. disableDefaultUI: true,
  10010. clickableIcons: false,
  10011. draggableCursor: "crosshair",
  10012. });
  10013.  
  10014. const bounds = new google.maps.LatLngBounds();
  10015. bounds.extend(global_bounds.min);
  10016. bounds.extend(global_bounds.max);
  10017.  
  10018. map.fitBounds(bounds)
  10019. setTimeout(()=> (map.getZoom() === 0) && map.setZoom(1), 100);
  10020.  
  10021. let marker = new google.maps.Marker({
  10022. map,
  10023. // label:{
  10024. // text: "5",
  10025. // color: "#ffffff",
  10026. // fontSize: "20px",
  10027. // fontWeight: "bold"
  10028. // }
  10029. });
  10030.  
  10031. let latLng = null;
  10032.  
  10033. const clickHandler = map.addListener("click", playClick);
  10034.  
  10035. function playClick(evt) {
  10036. console.log(evt);
  10037. latLng = evt.latLng.toJSON();
  10038. guessBtn.disabled = false;
  10039. guessBtn.classList.add('baidu_guess_button_enabled');
  10040. marker.setPosition(evt.latLng);
  10041. };
  10042.  
  10043. const guessBtnContainer = document.createElement("div");
  10044. const guessBtn = document.createElement("button");
  10045. guessBtn.classList.add('baidu_guess_button');
  10046. guessBtn.innerHTML = options.guessBtnText; //"Baidu Guess Button";
  10047. guessBtn.style.cssText =
  10048. "background: #368ce7; border-radius: 0px 0px 10px 10px; width: 100%; padding: 1em; cursor: pointer; font-family: var(--default-font); transistion: 100ms ease;";
  10049. guessBtn.disabled = true;
  10050. guessBtn.addEventListener("click", (evt) => {
  10051. if (guessBtn._doReload){
  10052. location.reload();
  10053. return;
  10054. }
  10055. const mapId = location.href.replace(/.*\/(.*)/, "$1");
  10056.  
  10057. fetch(`https://www.geoguessr.com/api/v3/games/${global_data.token}`, {
  10058. headers: {
  10059. accept: "*/*",
  10060. "accept-language": "en-US,en;q=0.9",
  10061. "cache-control": "no-cache",
  10062. "content-type": "application/json",
  10063. pragma: "no-cache",
  10064. "sec-ch-ua":
  10065. '"Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"',
  10066. "sec-ch-ua-mobile": "?0",
  10067. "sec-ch-ua-platform": '"Linux"',
  10068. "sec-fetch-dest": "empty",
  10069. "sec-fetch-mode": "cors",
  10070. "sec-fetch-site": "same-origin",
  10071. "x-client": "web",
  10072. },
  10073. referrer: location.href, // "https://www.geoguessr.com/game/rks2XFcZOIQlZQg9",
  10074. referrerPolicy: "strict-origin-when-cross-origin",
  10075. body: `{"token":"${mapId}","lat\":${latLng.lat},"lng\":${latLng.lng},"timedOut":false, "skipRound": false}`,
  10076. method: "POST",
  10077. mode: "cors",
  10078. credentials: "include",
  10079. }).then(res => {
  10080. return res.json();
  10081. }).then(jSon => {
  10082. console.log("jSon", jSon);
  10083.  
  10084. const len = jSon.round;
  10085. const PATHNAME = getPathName();
  10086. if (PATHNAME.startsWith("/challenge/") || len === 5){
  10087. location.reload();
  10088. return;
  10089. }
  10090.  
  10091. const locationMarker = new google.maps.Marker({
  10092. map,
  10093. position: {lat: global_lat, lng: global_lng},
  10094. icon: options.markerIcon || 'http://maps.gstatic.com/mapfiles/ms2/micons/flag.png'
  10095. });
  10096.  
  10097. locationMarker.addListener('click', (e)=>{
  10098.  
  10099. window.open(options.locationUrl, '_blank');
  10100. }) ;
  10101.  
  10102. if (!options.markerIcon){
  10103. let markerShadow = new google.maps.Marker({
  10104. clickable: false,
  10105. position: {lat: global_lat, lng: global_lng},
  10106. map: map,
  10107. icon:{
  10108. url: 'http://maps.google.com/mapfiles/ms/micons/flag.shadow.png',
  10109. //The size image file.
  10110. // size: new google.maps.Size(225, 120),
  10111. //The point on the image to measure the anchor from. 0, 0 is the top left.
  10112. // origin: new google.maps.Point(150, 0),
  10113. //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.
  10114. anchor: new google.maps.Point(15, 32)
  10115. },
  10116. zIndex: (Math.round(global_lat*-100000)<<5)-1
  10117. });
  10118. }
  10119.  
  10120. mapContainer.classList.remove("baidu_guess_map_active");
  10121. mapContainer.classList.add("baidu_guess_map_between_rounds");
  10122.  
  10123. const interpolated = google.maps.geometry.spherical.interpolate({lat: global_lat, lng: global_lng}, marker.position, 0.5);
  10124.  
  10125. const dist = jSon.player.guesses[len-1].distance.meters;
  10126.  
  10127. const contentString = `
  10128. <div id="content_string" style="color: rgb(40, 40, 40); font-size: 1.3rem; font-family: var(--default-font); font-style:italic; padding: 1rem;">
  10129. <div>
  10130. <span style="font-size:1.1rem;">Points:</span> <span style="font-weight: 700">${jSon.player.guesses[len-1].roundScoreInPoints.toLocaleString()}</span>
  10131. </div>
  10132. <div>
  10133. <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>
  10134. </div>
  10135. </div>`;
  10136.  
  10137. const infowindow = new google.maps.InfoWindow({
  10138. content: contentString,
  10139. ariaLabel: "Uluru",
  10140. map: map,
  10141. position: interpolated,
  10142. });
  10143.  
  10144. setTimeout(()=>{
  10145. // Hack to hide scroll bars by painting them white.
  10146. // It's a wierd bug that doens't happen to everyone.
  10147. let el = document.getElementById('content_string');
  10148. el.parentElement.parentElement.style.scrollbarColor = "white white";
  10149. }, 100);
  10150.  
  10151. const line= new google.maps.Polyline({
  10152. path: [{lat: global_lat, lng: global_lng}, marker.position],
  10153. geodesic: true,
  10154. strokeColor: '#FF0000',
  10155. strokeOpacity: 1.0,
  10156. strokeWeight: 2,
  10157. //geodesic: false, // If true infowindow won't be in middle of line.
  10158. });
  10159.  
  10160. line.setMap(map);
  10161.  
  10162. const bounds = new google.maps.LatLngBounds();
  10163. bounds.extend({lat: global_lat, lng: global_lng});
  10164. bounds.extend( marker.position);
  10165.  
  10166. google.maps.event.addListenerOnce(map, 'idle', function() {
  10167. map.fitBounds(bounds, 100)
  10168. });
  10169.  
  10170. guessBtn.innerHTML = "Click to reload page for next round!";
  10171. guessBtn._doReload = true;
  10172.  
  10173. localStorage['unity_immediate_load'] = true;
  10174.  
  10175. google.maps.event.removeListener(clickHandler);
  10176.  
  10177. });
  10178. });
  10179.  
  10180. guessBtnContainer.appendChild(guessBtn);
  10181.  
  10182. geoGuessContainer.appendChild(guessBtnContainer);
  10183.  
  10184. document.head.insertAdjacentHTML(
  10185. "beforeend",
  10186. `<style>
  10187. .baidu_guess_map {
  10188. --active-height: 4vh;
  10189. --active-width: 4vw;
  10190. width: max(15vw, var(--active-width));
  10191. height: max(20vh, var(--active-height));
  10192. border-radius: 10px 10px 0px 0px;
  10193. position: relative;
  10194. overflow: hidden;
  10195. transition: 0.08s all ease;
  10196. }
  10197.  
  10198. .baidu_guess_map_active {
  10199. --active-height: 75vh !important;
  10200. --active-width: 60vw !important;
  10201. }
  10202.  
  10203. .baidu_guess_map_between_rounds {
  10204. --parent-right-offset: 2rem;
  10205. --active-height: 100vh !important;
  10206. --active-width: calc(100vw - var(--parent-right-offset) * 2) !important;
  10207. }
  10208.  
  10209. .baidu_guess_button_enabled:hover {
  10210. color: white;
  10211. scale: 1.0 1.1;
  10212. background-color: #1666ba !important;
  10213. }
  10214. .baidu_guess_button_enabled:active {
  10215. scale: 1.0 1.0;
  10216. }
  10217.  
  10218. .baidu_guess_button_clicked {
  10219. scale: 1.0 0.99 !important;
  10220. }
  10221.  
  10222. div[class*="game_panoramaMessage"] { visibility: hidden; z-index: 1; }
  10223.  
  10224. div[class*="game_panoramaMessage"]::after {
  10225. content: "UAC - You are awsome and you know it!";
  10226. color: white;
  10227. visibility: visible;
  10228. position: absolute;
  10229. width: 100%;
  10230. text-align: center;
  10231. translate: 0px 50vh;
  10232. }
  10233. </style>`);
  10234.  
  10235. setTimeout(function(){
  10236. let clockTimerEl = document.querySelector('[class*="clock-timer"]');
  10237. if (clockTimerEl){
  10238. clockTimerEl.parentElement.style.zIndex = '3';
  10239. }
  10240. }, 2000);
  10241. return
  10242. }
  10243.  
  10244.  
  10245.  
  10246. // ==UserScript==
  10247. // @name GeoNoCar test
  10248. // @description Redacts the car from geoguessr. Shift-K to toggle compass.
  10249. // @namespace GeoNoCar
  10250. // @version 0.1.9
  10251. // @author drparse
  10252. // @match https://www.geoguessr.com/*
  10253. // @grant unsafeWindow
  10254. // @run-at document-start
  10255. // @updateURL https://openuserjs.org/meta/drparse/GeoNoCar.meta.js
  10256. // @copyright 2020, drparse
  10257. // @license GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
  10258. // @noframes
  10259. // ==/UserScript==
  10260.  
  10261. let globalGL = null;
  10262. (function() {
  10263. 'use strict';
  10264.  
  10265. function injected() {
  10266.  
  10267. const OPTIONS = {
  10268. colorR: 0.5,
  10269. colorG: 0.5,
  10270. colorB: 0.5,
  10271. };
  10272.  
  10273. // If the script breaks, search devtools for "BINTULU" and replace these lines with the new one
  10274. 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);}";
  10275. 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;}";
  10276.  
  10277. const vertexNew = `
  10278. const float f=3.1415926;
  10279. varying vec3 a;
  10280. varying vec3 potato;
  10281. uniform vec4 b;
  10282. attribute vec3 c;
  10283. attribute vec2 d;
  10284. uniform mat4 e;
  10285. void main(){
  10286. vec4 g=vec4(c,1);
  10287. gl_Position=e*g;
  10288. a = vec3(d.xy * b.xy + b.zw,1);
  10289. a *= length(c);
  10290.  
  10291. potato = vec3(d.xy, 1.0) * length(c);
  10292. }`;
  10293. const fragNew = `precision highp float;
  10294. const float h=3.1415926;
  10295. varying vec3 a;
  10296. varying vec3 potato;
  10297. uniform vec4 b;
  10298. uniform float f;
  10299. uniform sampler2D g;
  10300.  
  10301. uniform float theArray1[4];
  10302. uniform float theArray2[4];
  10303.  
  10304.  
  10305. uniform float isNoob;
  10306. uniform float theArray[8];
  10307. uniform float transition;
  10308.  
  10309. uniform sampler2D sampler2d_logoImg;
  10310. uniform float u_showCustomPano;
  10311.  
  10312. void main(){
  10313.  
  10314. vec2 aD = potato.xy / a.z;
  10315. float thetaD = aD.y;
  10316.  
  10317. float thresholdD1 = 0.6;
  10318. float thresholdD2 = 0.7;
  10319.  
  10320. float x = aD.x;
  10321. float y = abs(4.0*x - 2.0);
  10322. float phiD = smoothstep(0.0, 1.0, y > 1.0 ? 2.0 - y : y);
  10323.  
  10324. float x1 = theArray[0];
  10325. float y1 = theArray[1];
  10326. float x2 = theArray[2];
  10327. float y2 = theArray[3];
  10328.  
  10329. vec4 gold = vec4(1.0,0.8431,0.0,1.0);
  10330. vec4 blue = vec4(0.0,0.3412,0.7176,1.0);
  10331.  
  10332. float r = smoothstep(-1.0, 1.0, transition);
  10333. vec4 theColor = mix(gold, blue, r);
  10334.  
  10335. if (x2 > x1){
  10336. if (aD.x > x1 && aD.y > y1 && aD.x < x2 && aD.y < y2){
  10337. if (isNoob == 1.0){
  10338. float lineWidth = 0.0025;
  10339. if ((aD.x < x1 + lineWidth)
  10340. || (aD.y < y1 + lineWidth)
  10341. || (aD.x > x2 - lineWidth)
  10342. || (aD.y > y2 - lineWidth)){
  10343.  
  10344. gl_FragColor = theColor;
  10345. //gl_FragColor = vec4(0.0,0.3412,0.7176,1.0);
  10346. return;
  10347. }
  10348. } else {
  10349. gl_FragColor = vec4(0.0,0.3412,0.7176,1.0);
  10350. return;
  10351. }
  10352. }
  10353. } else {
  10354. // x1 is greater than x2.
  10355. if ((aD.y > y1 && aD.y < y2) && (aD.x > x1 || aD.x < x2)){
  10356. if (isNoob == 1.0){
  10357. float lineWidth = 0.0025;
  10358. if (((aD.x < x1+lineWidth) && (aD.x > x1))
  10359. || (aD.x < x2 && aD.x > x2-lineWidth)
  10360. || (x2 == 0.0 && aD.x > 1.0-lineWidth)
  10361. || (aD.y < y1 + lineWidth)
  10362. || (aD.y > y2 - lineWidth)
  10363. ){
  10364. gl_FragColor = theColor; //vec4(0.0,0.3412,0.7176,1.0);
  10365. return;
  10366. }
  10367. } else {
  10368. gl_FragColor = vec4(0.0,0.3412,0.7176,1.0);
  10369. return;
  10370. }
  10371. }
  10372. }
  10373.  
  10374. x1 = theArray[4];
  10375. y1 = theArray[5];
  10376. x2 = theArray[6];
  10377. y2 = theArray[7];
  10378.  
  10379. if (x2 > x1){
  10380. if (aD.x > x1 && aD.y > y1 && aD.x < x2 && aD.y < y2){
  10381. if (isNoob == 1.0){
  10382. float lineWidth = 0.0025;
  10383. if ((aD.x < x1 + lineWidth)
  10384. || (aD.y < y1 + lineWidth)
  10385. || (aD.x > x2 - lineWidth)
  10386. || (aD.y > y2 - lineWidth)){
  10387. gl_FragColor = theColor; //mix(gold, blue, r);
  10388. //gl_FragColor = vec4(1.0,0.8431,0.0,1.0);
  10389. return;
  10390. }
  10391. } else {
  10392. gl_FragColor = vec4(1.0,0.8431,0.0,1.0);
  10393. return;
  10394. }
  10395. }
  10396. } else {
  10397. // x1 is greater than x2.
  10398. if ((aD.y > y1 && aD.y < y2) && (aD.x > x1 || aD.x < x2)){
  10399. if (isNoob == 1.0){
  10400. float lineWidth = 0.0025;
  10401. if (((aD.x < x1+lineWidth) && (aD.x > x1))
  10402. || (aD.x < x2 && aD.x > x2-lineWidth)
  10403. || (x2 == 0.0 && aD.x > 1.0-lineWidth)
  10404. || (aD.y < y1 + lineWidth)
  10405. || (aD.y > y2 - lineWidth)
  10406. ){
  10407. gl_FragColor = theColor; //vec4(1.0,0.8431,0.0,1.0);
  10408. return;
  10409. }
  10410. } else {
  10411. gl_FragColor = vec4(1.0,0.8431,0.0,1.0);
  10412. return;
  10413. }
  10414. }
  10415. }
  10416.  
  10417. //vec4 i = vec4(
  10418. // thetaD > mix(thresholdD1, thresholdD2, phiD)
  10419. // ? vec3(float(${OPTIONS.colorR}), float(${OPTIONS.colorG}), float(${OPTIONS.colorB})) // texture2DProj(g,a).rgb * 0.25
  10420. // : texture2DProj(g,a).rgb
  10421. //,f);
  10422. //gl_FragColor=i;
  10423. vec4 t = texture2DProj(g,a).rgba;
  10424.  
  10425. if (u_showCustomPano == 1.0){
  10426. if ((aD.y > 0.99 && aD.y < 1.0) && (aD.x > 0.99 || aD.x < 1.0)){
  10427. // Draw circle at bottom to let player know script worked.
  10428. gl_FragColor = vec4(1.0,0.8431,0.0,1.0);
  10429. return;
  10430. }
  10431. vec4 logo = texture2DProj(sampler2d_logoImg, potato).rgba;
  10432. //t = mix(t, logo, 1.0);
  10433. t = logo; // mix(t, logo, 1.0);
  10434. }
  10435.  
  10436. //gl_FragColor=vec4(t.rgb,f);
  10437.  
  10438. gl_FragColor=vec4(t.rgb,f);
  10439.  
  10440. }`;
  10441.  
  10442. function installShaderSource(ctx) {
  10443. const g = ctx.shaderSource;
  10444. function shaderSource() {
  10445. if (typeof arguments[1] === 'string') {
  10446. let glsl = arguments[1];
  10447. // console.log('BINTULU shader', glsl);
  10448. if (glsl === vertexOld){
  10449. glsl = vertexNew;
  10450. globalGL = ctx;
  10451.  
  10452. console.log("ctx assigned to globalGL");
  10453.  
  10454. let oldCtx = ctx.linkProgram;
  10455. ctx.linkProgram = function(...args){
  10456. let p = oldCtx.call(this, args[0]);
  10457.  
  10458. initWebGl(args[0]);
  10459.  
  10460. return p;
  10461. }
  10462. }
  10463. else if (glsl === fragOld) glsl = fragNew;
  10464. return g.call(this, arguments[0], glsl);
  10465. }
  10466. return g.apply(this, arguments);
  10467. }
  10468. shaderSource.bestcity = 'bintulu';
  10469. ctx.shaderSource = shaderSource;
  10470. }
  10471.  
  10472. function installGetContext(el) {
  10473. const g = el.getContext;
  10474. el.getContext = function() {
  10475. if (arguments[0] === 'webgl' || arguments[0] === 'webgl2') {
  10476. const ctx = g.apply(this, arguments);
  10477. if (ctx && ctx.shaderSource && ctx.shaderSource.bestcity !== 'bintulu') {
  10478. installShaderSource(ctx);
  10479. }
  10480. return ctx;
  10481. }
  10482. return g.apply(this, arguments);
  10483. };
  10484. }
  10485.  
  10486. const f = document.createElement;
  10487.  
  10488. document.createElement = function() {
  10489. if (arguments[0] === 'canvas' || arguments[0] === 'CANVAS') {
  10490. const el = f.apply(this, arguments);
  10491. installGetContext(el);
  10492. return el;
  10493. }
  10494. return f.apply(this, arguments);
  10495. };
  10496.  
  10497. window.theArray = [];
  10498. window.unityNerdTimer = null;
  10499. window.ignoreUnityNerd = true;
  10500. window.ignoreUnityNoob = true;
  10501. window.isOkToShowCustomPano = false;
  10502.  
  10503. async function initWebGl(program){
  10504. let ell = document.querySelector('[aria-label="Street View"]');
  10505. let eventt;
  10506.  
  10507. triggerEvent(ell, "mouseup", eventt);
  10508.  
  10509. let _trans = 0;
  10510. window.unityNerdTimer = setInterval(function(){
  10511. // webgl main loop
  10512. if (window.ignoreUnityNerd && window.ignoreUnityNoob){
  10513. let uu_showCustomPano = globalGL.getUniformLocation(program, 'u_showCustomPano');
  10514. globalGL.uniform1f(uu_showCustomPano, window.isOkToShowCustomPano ? 1.0 : 0.0);
  10515. return;
  10516. }
  10517.  
  10518. let _theArray = globalGL.getUniformLocation(program, 'theArray');
  10519.  
  10520. if (!_theArray) {
  10521. clearInterval(window.unityNerdTimer)
  10522. return;
  10523. }
  10524.  
  10525. let location = globalGL.getUniformLocation(program, "sampler2d_logoImg");
  10526. globalGL.uniform1i(location, 1);
  10527.  
  10528. let isNoob = globalGL.getUniformLocation(program, 'isNoob');
  10529. let transition = globalGL.getUniformLocation(program, 'transition');
  10530. let uu_showCustomPano = globalGL.getUniformLocation(program, 'u_showCustomPano');
  10531. globalGL.uniform1fv(_theArray, new Float32Array(window.theArray.slice(0,8)));//[/*Nw*//*x*/0.40,/*y*/0.30, /*Se*//*x*/0.50, /*y*/0.40]));
  10532. globalGL.uniform1f(isNoob, window.ignoreUnityNoob ? 0.0 : 1.0);
  10533. globalGL.uniform1f(uu_showCustomPano, window.isOkToShowCustomPano ? 1.0 : 0.0);
  10534.  
  10535. _trans += 0.1;
  10536.  
  10537. globalGL.uniform1f(transition, Math.sin(_trans));
  10538.  
  10539. triggerEvent(ell, "mouseout", eventt);
  10540.  
  10541. globalGL.flush();
  10542. }, 100);
  10543.  
  10544. return;
  10545.  
  10546. }
  10547.  
  10548. function triggerRefresh(){
  10549. let el = document.querySelector('[aria-label="Street View"]');
  10550. let event;
  10551. triggerEvent(el, "mouseout", event);
  10552. }
  10553.  
  10554. function triggerEvent( elem, type, event ) {
  10555. // From stack overflow can't remember where.
  10556. event = document.createEvent("MouseEvents");
  10557. event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
  10558. 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  10559. elem.dispatchEvent( event );
  10560. }
  10561.  
  10562. function loadImg(_src, maskBool, callback){
  10563. // https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL
  10564. const gl = globalGL;
  10565.  
  10566. if (!gl){
  10567. setTimeout(function(){
  10568. loadImg(_src, maskBool, callback);
  10569. }, 500);
  10570. return;
  10571. }
  10572.  
  10573. const level = 0;
  10574. const internalFormat = gl.RGBA;
  10575. const width = 1;
  10576. const height = 1;
  10577. const border = 0;
  10578. const srcFormat = gl.RGBA;
  10579. const srcType = gl.UNSIGNED_BYTE;
  10580. const pixel = new Uint8Array([0, 0, 255, 255]); // opaque blue
  10581.  
  10582. const image = new Image();
  10583.  
  10584. image.onload = () => {
  10585. const texture = gl.createTexture();
  10586.  
  10587. gl.bindTexture(gl.TEXTURE_2D, texture);
  10588. gl.texImage2D(
  10589. gl.TEXTURE_2D,
  10590. level,
  10591. internalFormat,
  10592. srcFormat,
  10593. srcType,
  10594. image
  10595. );
  10596.  
  10597. // WebGL1 has different requirements for power of 2 images
  10598. // vs. non power of 2 images so check if the image is a
  10599. // power of 2 in both dimensions.
  10600. if (isPowerOf2(image.width) && isPowerOf2(image.height)) {
  10601. // Yes, it's a power of 2. Generate mips.
  10602. gl.generateMipmap(gl.TEXTURE_2D);
  10603. } else {
  10604. // No, it's not a power of 2. Turn off mips and set
  10605. // wrapping to clamp to edge
  10606. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  10607. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  10608. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  10609. }
  10610. // Tell WebGL we want to affect texture unit 1
  10611. //gl.activeTexture(gl.TEXTURE1);
  10612. gl.activeTexture(maskBool? gl.TEXTURE2: gl.TEXTURE1);
  10613.  
  10614. // gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
  10615.  
  10616. // Bind the texture to texture unit 1
  10617. gl.bindTexture(gl.TEXTURE_2D, texture);
  10618.  
  10619. gl.activeTexture(gl.TEXTURE0);
  10620. console.log('loadImg onload');
  10621. callback();
  10622. };
  10623. image.onerror = function(e){
  10624. console.log(e);
  10625. alert("UAC panorama didn't load, try again later? Maybe refreshing the page will fix it?");
  10626. }
  10627.  
  10628. image.src = _src;
  10629. // 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";
  10630. // image.src = "https://i.imgur.com/ZONu5JU.jpeg";
  10631. //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";
  10632.  
  10633. function isPowerOf2(value) {
  10634. // Might not be necessary
  10635. return (value & (value - 1)) === 0;
  10636. }
  10637. }
  10638. window.loadImg = loadImg;
  10639. }
  10640.  
  10641. eval(`(${injected.toString()})()`);
  10642.  
  10643. })();
  10644.  
  10645. function unityNerdFn(data){
  10646.  
  10647. // Reset theArray to hide rectangles.
  10648. window.theArray = [0.1, 0.4, 0.3, 0.2, 0.5, 0.8, 0.7, 0.6];
  10649. window.isOkToShowCustomPano = false;
  10650.  
  10651. const isNerd = (/\[unity nerd/i.test(data.mapName));
  10652. const isNoob = (/\[unity noob/i.test(data.mapName));
  10653. const isTimed = (/\[.*timed/i.test(data.mapName));
  10654. const isUnhackable = (/\[.*UAC/i.test(data.mapName));
  10655.  
  10656. console.log("isunhackable", isUnhackable);
  10657.  
  10658. if (isUnhackable){
  10659. let _url = hex2a(global_panoID);
  10660.  
  10661. if (/http/i.test(_url) === false) {
  10662. console.log("Didn't find url for unhackable.");
  10663. window.isOkToShowCustomPano = false;
  10664. // deactivateUnityNerd();
  10665. return;
  10666. }
  10667.  
  10668. if (unityNerdFn.UAC_URLS[_url]){
  10669. alert('Was there an error? Is this a repeat? Maybe refreshing the page will fix it?');
  10670. }
  10671.  
  10672. unityNerdFn.UAC_URLS[_url] = true;
  10673.  
  10674. // Setting this to true hides the default street view panorama.
  10675. window.isOkToShowCustomPano = true;
  10676.  
  10677. fetch(_url)
  10678. .then((r) => {
  10679. return r.blob();
  10680. })
  10681. .then(async (blob) => {
  10682. let srcUrl = "";
  10683.  
  10684. if (/\.enc$/.test(_url)){
  10685. srcUrl = await blob.text().then(text => {
  10686. return new Promise((res, rej)=>{
  10687. let script = document.createElement('script');
  10688. script.src = "https://echandler.github.io/test-geo-noob-script/misc/CryptoJS_AES.js";
  10689. script.addEventListener('load', async function(){
  10690. console.log('CryptoJS_AES.js loaded');
  10691.  
  10692. if (!unityNerdFn.UAC_PassPhrase){
  10693. //unityNerdFn.UAC_PassPhrase = prompt("Enter UAC passphrase here:");
  10694. unityNerdFn.UAC_PassPhrase = await new Promise((res, rej) =>{
  10695. let unityAlert = document.querySelector('.unity_alert');
  10696. let _unityAlert = unityAlert.innerHTML;
  10697. unityAlert.innerHTML = "";
  10698. let container = document.createElement('div');
  10699. let textBox = document.createElement('input');
  10700. textBox.placeholder = "Type AES passphrase here!";
  10701. textBox.addEventListener('keydown', (e)=>{
  10702. // Prevent space bar from deleting unity buttons.
  10703. e.stopImmediatePropagation();
  10704. e.stopPropagation();
  10705. });
  10706. textBox.addEventListener('keyup', (e)=>{
  10707. // Prevent f from making full screen.
  10708. e.stopImmediatePropagation();
  10709. e.stopPropagation();
  10710. });
  10711. let btn = document.createElement('button');
  10712. btn.style.cssText = `padding: 5px; background: white; margin-left: 1em; border-radius: 5px; cursor: pointer;`;
  10713. btn.innerText = "Update";
  10714. btn.addEventListener('click', function(e){
  10715. //unityNerdFn.UAC_PassPhrase = textBox.value;
  10716. unityAlert.style.visibility = 'hidden';
  10717. unityAlert.innerHTML = _unityAlert;
  10718. res(textBox.value);
  10719. });
  10720. container.appendChild(textBox);
  10721. container.appendChild(btn);
  10722. unityAlert.appendChild(container);
  10723.  
  10724. unityAlert.style.visibility = 'visible';
  10725. })
  10726.  
  10727. if (!unityNerdFn.UAC_PassPhrase) {
  10728. alert("Passphrase is blank, refresh screen and try again.");
  10729. }
  10730. }
  10731.  
  10732. let decrypted = null;
  10733.  
  10734. try {
  10735. decrypted = CryptoJS.AES.decrypt(text, unityNerdFn.UAC_PassPhrase).toString(CryptoJS.enc.Utf8);
  10736. } catch(error){
  10737. 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.");
  10738. console.error(error);
  10739. return;
  10740. }
  10741.  
  10742. res(decrypted);
  10743. });
  10744. document.body.appendChild(script) ;
  10745. });
  10746. }).then((text)=> text);
  10747. } else {
  10748. srcUrl = URL.createObjectURL(blob);
  10749. }
  10750. let failedToLoadRoundMsg = checkFailedToLoadRoundMsg();
  10751. if (failedToLoadRoundMsg){
  10752. // The streetview was created but for some reason it's blank.
  10753. // Manually set a random position to start the webgl procesfor some reason it's blanks.
  10754. const fenway = { lat: 42.345573, lng: -71.098326 };
  10755.  
  10756. GooglePlayer.setPosition(fenway) ;
  10757.  
  10758. failedToLoadRoundMsg.style.display = 'none';
  10759. makeGuessMapHack({
  10760. guessBtnText:"UAC Guess Button",
  10761. mapContainer: document.querySelector('canvas'),
  10762. locationUrl: '',
  10763. });
  10764. }
  10765. const noGlReloadTimer = setTimeout(()=>{
  10766. if (globalGL) return;
  10767. location.reload();
  10768. }, 2000);
  10769.  
  10770. window.loadImg(srcUrl, false, () => {
  10771. setTimeout(()=>{
  10772. clearTimeout(noGlReloadTimer);
  10773.  
  10774. GoogleMapsObj.setCenter({lat:0,lng:0})
  10775. GoogleMapsObj.setZoom(2)
  10776.  
  10777. console.log("Resized map in loadImg callback.")
  10778. }, 1000);
  10779. });
  10780. });
  10781.  
  10782. activateUnityNerd();
  10783. }
  10784.  
  10785. if (!isNerd && !isNoob) return;
  10786.  
  10787. if (isTimed){
  10788. let p = setInterval(function () {
  10789. const el = document.elementFromPoint(2, 2);
  10790. const ariaLabel = el.parentElement.getAttribute("aria-label");
  10791.  
  10792. if (!ariaLabel || ariaLabel !== "Street View") {
  10793. return;
  10794. }
  10795.  
  10796. clearInterval(p);
  10797.  
  10798. const timedWait = +data.mapName.replace(/.*\[.*timed.*?(\d+.?\d*)s.*/i, "$1");
  10799.  
  10800. if (!timedWait){
  10801. doUnityNerd(data, 0);
  10802. } else {
  10803. console.log('timed wait', timedWait);
  10804. doUnityNerd(data, timedWait);
  10805. }
  10806.  
  10807. }, 10);
  10808. return;
  10809. }
  10810.  
  10811. doUnityNerd(data, 0);
  10812. }
  10813. unityNerdFn.UAC_URLS = [];
  10814. unityNerdFn.UAC_PassPhrase = null;
  10815.  
  10816. let unityNerdTimer = null;
  10817.  
  10818. function doUnityNerd(data, waitTimeSeconds){
  10819.  
  10820. let curRound = data.rounds[data.rounds.length -1];
  10821.  
  10822. console.log('timed wait', waitTimeSeconds);
  10823. console.time('timer');
  10824.  
  10825. clearTimeout(unityNerdTimer);
  10826.  
  10827. unityNerdTimer = setTimeout(() => {
  10828. //console.log.bind(console, "1 second"), 1000);
  10829. let t = [];
  10830. let lat = curRound.lat.toFixed(14);
  10831. let lng = curRound.lng.toFixed(14);
  10832.  
  10833. t[3] = +(lat[lat.length - 1 - 1] + lat[lat.length - 1 - 0]) / 100;
  10834. t[2] = +(lat[lat.length - 1 - 3] + lat[lat.length - 1 - 2]) / 100;
  10835. t[1] = +(lat[lat.length - 1 - 5] + lat[lat.length - 1 - 4]) / 100;
  10836. t[0] = +(lat[lat.length - 1 - 7] + lat[lat.length - 1 - 6]) / 100;
  10837.  
  10838. t[7] = +(lng[lng.length - 1 - 1] + lng[lng.length - 1 - 0]) / 100;
  10839. t[6] = +(lng[lng.length - 1 - 3] + lng[lng.length - 1 - 2]) / 100;
  10840. t[5] = +(lng[lng.length - 1 - 5] + lng[lng.length - 1 - 4]) / 100;
  10841. t[4] = +(lng[lng.length - 1 - 7] + lng[lng.length - 1 - 6]) / 100;
  10842.  
  10843.  
  10844. window.theArray = t.map(el => el === 0? 1.0: el);
  10845.  
  10846. console.log(t, window.theArray);
  10847. console.timeEnd('timer');
  10848. }, waitTimeSeconds * 1000);
  10849. }
  10850.  
  10851. function activateUnityNerd(){
  10852. window.ignoreUnityNerd = false;
  10853. }
  10854.  
  10855. function deactivateUnityNerd(){
  10856. window.theArray = [];
  10857. // setTimeout(()=>{
  10858. window.ignoreUnityNerd = true;
  10859. // }, 500);
  10860. }
  10861.  
  10862. function activateUnityNoob(){
  10863. window.ignoreUnityNoob = false;
  10864. }
  10865.  
  10866. function deactivateUnityNoob(){
  10867. window.theArray = [];
  10868. setTimeout(()=>{
  10869. window.ignoreUnityNoob = true;
  10870. }, 500);
  10871. }
  10872.  
  10873. function download(filename, text) {
  10874. // https://stackoverflow.com/questions/3665115/how-to-create-a-file-in-memory-for-user-to-download-but-not-through-server
  10875. var element = document.createElement('a');
  10876. element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  10877. element.setAttribute('download', filename);
  10878. element.style.display = 'none';
  10879. document.body.appendChild(element);
  10880. element.click();
  10881. document.body.removeChild(element);
  10882. }
  10883.  
  10884. function getOverlayView(map){
  10885. var ov = new google.maps.OverlayView();
  10886. ov.onAdd = function(){};
  10887. ov.draw = function(){};
  10888. ov.onRemove = function(){};
  10889. ov.setMap(map);
  10890. return ov;
  10891. }
  10892.  
  10893. function showUACAnswerBtn(json = null){
  10894. let unity_alert = document.querySelector('.unity_alert');
  10895. let msg = document.createElement('div');
  10896. msg.style.cssText = `color: white;`;
  10897. msg.innerText = "Click here for UAC answers.";
  10898. msg.onclick = function(e){
  10899. if (!json) {
  10900. unhackableAnsswersShowPrompt();
  10901. } else {
  10902. unhackableAnswers(json);
  10903. }
  10904. unity_alert.innerHTML = "";
  10905. unity_alert.style.visibility = "hidden";
  10906. };
  10907.  
  10908. unity_alert.innerHTML = "";
  10909. unity_alert.appendChild(msg);
  10910. unity_alert.style.visibility = 'visible'
  10911. setTimeout(()=>{
  10912. unity_alert.style.visibility = 'hidden';
  10913. unity_alert.innerHTML = "";
  10914. }, 5000);
  10915. }
  10916.  
  10917. function unhackableAnsswersShowPrompt() {
  10918.  
  10919. let _prompt = prompt("Paste UAC answer info. here:")
  10920.  
  10921. if (!_prompt) return;
  10922.  
  10923. unhackableAnswers(_prompt);
  10924. }
  10925. async function unhackableAnswers(json = null){
  10926. let data = null;
  10927.  
  10928. const PATHNAME = window.location.pathname;
  10929. const token = getToken();
  10930. const bounds = new google.maps.LatLngBounds();
  10931.  
  10932. if (!global_data?.rounds || global_data.token !== token){
  10933. let URL = null;
  10934.  
  10935. if (PATHNAME.startsWith("/game/")) {
  10936. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  10937. }
  10938. else if (PATHNAME.startsWith("/results/" )) {
  10939. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  10940. // URL = `https://www.geoguessr.com/api/v3/results/highscores/${token}"`;
  10941. // URL = `https://www.geoguessr.com/api/v3/results/highscores/${token}?friends=false&limit=26&minRounds=5`;
  10942. }
  10943.  
  10944. global_data = await fetch(URL).then((response) => response.json());
  10945.  
  10946. if (!global_data){
  10947. alert('An unkown error happened.');
  10948. return;
  10949. }
  10950. }
  10951.  
  10952. try {
  10953. data = JSON.parse(json);
  10954. } catch (e){
  10955. alert(e.message);
  10956. console.log("From prompt", e.message);
  10957. return
  10958. }
  10959.  
  10960. // Lower opacity for correct location overlays for effect.
  10961. document.querySelectorAll("[data-qa=\"correct-location-marker\"]").forEach(el=> el.style.opacity = 0.2);
  10962.  
  10963. let thisRoundData = {};
  10964.  
  10965. for (let n = 0; n < global_data.rounds.length; n++){
  10966. let panoId = global_data.rounds[n].panoId;
  10967.  
  10968. if (!panoId) continue;
  10969.  
  10970. let url = hex2a(panoId);
  10971.  
  10972. if (!data[url]) continue;
  10973.  
  10974. let latLng = data[url].latLng.split(',');
  10975. latLng = {lat: +latLng[0], lng: +latLng[1]};
  10976.  
  10977. thisRoundData[url] = data[url];
  10978.  
  10979. global_data.rounds[n]._unhackable_answer = latLng;
  10980.  
  10981. bounds.extend(latLng);
  10982.  
  10983. const svgMarker = {
  10984. // Path is just a filler for a 0 opacity marker.
  10985. 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",
  10986. fillColor: "rgb(0, 102, 204)",
  10987. scale: 0.75,
  10988. fillOpacity: 1,
  10989. strokeColor: "rgb(0, 102, 204)",
  10990. strokeOpacity: 1,
  10991. anchor: new google.maps.Point(0, -20),
  10992. labelOrigin: new google.maps.Point(0, -25)
  10993. };
  10994.  
  10995. let marker = new google.maps.Marker({
  10996. position: latLng,
  10997. map: GoogleMapsObj,
  10998. icon: svgMarker,
  10999. label:{
  11000. text: `${n+1}`,
  11001. color: "#ffffff",
  11002. fontSize: "20px",
  11003. fontWeight: "bold"
  11004. }
  11005. });
  11006.  
  11007. marker.addListener('click', function(){
  11008. //window.open(`http://maps.google.com/maps?q=&layer=c&cbll=${latLng.lat},${latLng.lng}`, "_blank")
  11009. window.open(data[url].locationUrl, "_blank")
  11010. });
  11011.  
  11012. unhackableAnswers.markers.push(marker);
  11013. }
  11014.  
  11015. if (Object.keys(thisRoundData).length === 0){
  11016. alert("No answers found for this game.");
  11017. return;
  11018. }
  11019. let resultRows = document.querySelectorAll('div[class*="results_row"]');
  11020. resultRows.forEach(row =>{
  11021. if (/selected/i.test(row.getAttribute('class'))){
  11022. row.click();
  11023. }
  11024. })
  11025.  
  11026. GoogleMapsObj.fitBounds(bounds)
  11027.  
  11028. hideDottedConnectingLinesOnMap();
  11029.  
  11030. if (!google.maps.OverlayView.prototype._setMap){
  11031. // Listen for new overlays being made and use the latlng coordinates from them to
  11032. // draw the connecting polylines.
  11033. google.maps.OverlayView.prototype._setMap = google.maps.OverlayView.prototype.setMap;
  11034. google.maps.OverlayView.prototype.setMap = function(...args){
  11035. setTimeout(()=>{
  11036. if (this.to && this.from) {
  11037. queOverlaysForUnhackable(this);
  11038. return;
  11039. }
  11040. if (!this.position) return;
  11041.  
  11042. this.div.firstElementChild.addEventListener('mouseover', (e)=>{
  11043. const dMarker = newDistanceMarker(this);
  11044. setTimeout(()=> {
  11045. dMarker.setMap(null);
  11046. dMarker._msgDiv.remove();
  11047. }, 2500);
  11048. })
  11049. }, 100);
  11050.  
  11051. google.maps.OverlayView.prototype._setMap.apply(this, args);
  11052. };
  11053. }
  11054.  
  11055. if (Object.keys(data).length <= 5) return;
  11056.  
  11057. let _confirm = confirm("Do you want to download the answers for this game only, filtering out all other answers?");
  11058.  
  11059. if (!_confirm) return;
  11060.  
  11061. try {
  11062. thisRoundData = JSON.stringify(thisRoundData);
  11063. } catch(e){
  11064. alert("Couldn't convert this game's answers for some reason.");
  11065. console.log(e.message);
  11066. }
  11067.  
  11068. download("answers.json", thisRoundData);
  11069. }
  11070. unhackableAnswers.markers = [];
  11071.  
  11072. function queOverlaysForUnhackable(overlay, dataIsReady){
  11073. if (dataIsReady){
  11074. queOverlaysForUnhackable._overlaysWaiting.forEach((overlay) =>{
  11075. makePolylinesForUnhackable(overlay);
  11076. });
  11077. queOverlaysForUnhackable._overlaysWaiting = [];
  11078. return;
  11079. }
  11080.  
  11081. let hasAnswers = global_data?.rounds?.some((round) => round?._unhackable_answer);
  11082. if (!hasAnswers){
  11083. queOverlaysForUnhackable._overlaysWaiting.push(overlay);
  11084. return;
  11085. }
  11086. makePolylinesForUnhackable(overlay);
  11087. }
  11088.  
  11089. queOverlaysForUnhackable._overlaysWaiting = [];
  11090.  
  11091. function makePolylinesForUnhackable(toFromOverlay){
  11092. const _rounds = global_data.rounds;
  11093. const div = toFromOverlay.div;
  11094. const jsonFrom = toFromOverlay.from.toJSON();
  11095. const jsonTo = toFromOverlay.to.toJSON(); // Guess location.
  11096.  
  11097. let round = _rounds.filter( round =>{
  11098. if (jsonFrom.lat === round.lat && jsonFrom.lng === round.lng){
  11099. return true;
  11100. }
  11101. });
  11102. round = round.length > 0? round[0] : null;
  11103. if (round === null) return;
  11104.  
  11105. if (!round._unhackable_answer) return;
  11106. round._uacGuesses = round._uacGuesses? round._uacGuesses: [];
  11107. round._uacGuesses.push(jsonTo);
  11108.  
  11109. const answer = round._unhackable_answer;
  11110. const pos = jsonTo;
  11111.  
  11112. const line = new google.maps.Polyline({
  11113. path: [pos, answer],
  11114. geodesic: true,
  11115. strokeColor: "rgb(0, 102, 204)",
  11116. //strokeColor: '#FF0000',
  11117. strokeOpacity: 1.0,
  11118. strokeWeight: 2,
  11119. //geodesic: false, // If true infowindow won't be in middle of line.
  11120. });
  11121. line.setMap(GoogleMapsObj);
  11122.  
  11123. toFromOverlay.__to = toFromOverlay.to;
  11124.  
  11125. Object.defineProperty(toFromOverlay, "to", {
  11126. // Geoguessr re-uses old overlays instead of making a whole new overlay in some situations.
  11127. set : function (value) {
  11128. // Listen for changes to the "to" property and remove line if set with new value.
  11129. toFromOverlay.__to = value;
  11130. line.setMap(null);
  11131. if (toFromOverlay.div.children.length > 0){
  11132. makePolylinesForUnhackable(toFromOverlay);
  11133. }
  11134. },
  11135. get : function () { return toFromOverlay.__to }
  11136. });
  11137.  
  11138. const observer = new MutationObserver(
  11139. function (){
  11140. // Remove polyline if div is gutted.
  11141. if (toFromOverlay.div.children.length > 0) return;
  11142.  
  11143. line.setMap(null);
  11144. setTimeout(function(){
  11145. if (!location.pathname.startsWith("/results/")){
  11146. // Remove markers if not on results page.
  11147. observer.disconnect();
  11148. unhackableAnswers.markers.forEach((marker) => marker.setMap(null));
  11149. unhackableAnswers.markers = [];
  11150. }
  11151. }, 5000);
  11152. }
  11153. );
  11154. observer.observe(toFromOverlay.div, {childList: true, subtree: true });
  11155. }
  11156.  
  11157. function makeStreetViewCanvasHidden(){
  11158. document.head.insertAdjacentHTML("beforeend", `<style>${GENERAL_CANVAS} {visibility: hidden;}</style>`)
  11159. }
  11160. function hideDottedConnectingLinesOnMap(){
  11161. document.head.insertAdjacentHTML("beforeend", `<style> div[class*="map_line"] {visibility: hidden;}</style>`)
  11162. }
  11163.  
  11164. function newDistanceMarker(overlay){
  11165. const svgMarker = {
  11166. // Path is just a filler for a 0 opacity marker.
  11167. path: "M-1.547 12l6.563-6.609-1.406-1.406-5.156 5.203-2.063-2.109-1.406 1.406z",
  11168. fillOpacity: 0,
  11169. };
  11170.  
  11171. const pos = overlay.position.toJSON();
  11172. const _rounds = global_data.rounds;
  11173. let answer = _rounds.filter((round)=>{
  11174. if (!round._uacGuesses) return false;
  11175. return round._uacGuesses.some((guess) => guess.lat == pos.lat && guess.lng == pos.lng);
  11176. });
  11177. answer = answer[0]._unhackable_answer;
  11178.  
  11179. const interpolated = google.maps.geometry.spherical.interpolate(answer, pos, 0.5);
  11180. let distanceBetween = google.maps.geometry.spherical.computeDistanceBetween(pos, answer);
  11181.  
  11182. const units = distanceBetween > 1000 ? "km" : "m";
  11183.  
  11184. distanceBetween = distanceBetween >= 1000
  11185. ? (distanceBetween / 1000).toFixed(2)
  11186. : distanceBetween >= 100
  11187. ? distanceBetween.toFixed(2)
  11188. : distanceBetween.toFixed(3);
  11189.  
  11190.  
  11191. distanceBetween = (+distanceBetween).toLocaleString();// Add commas for large numbers.
  11192.  
  11193. document.head.insertAdjacentHTML("beforeend", `<style>.unhackableLabel {background: rgb(0, 102, 204); padding: 10px; border-radius: 5px;}</style>`)
  11194.  
  11195. const distanceMarker = new google.maps.Marker({
  11196. position: interpolated,
  11197. icon: svgMarker,
  11198. map: GoogleMapsObj,
  11199. label: {
  11200. text: `${distanceBetween} ${units}`,
  11201. color: "#ffffff",
  11202. fontSize: "15px",
  11203. fontWeight: "bold",
  11204. className: "unhackableLabel",
  11205. },
  11206. clickable: true,
  11207. });
  11208.  
  11209. distanceMarker._msgDiv = document.createElement('div');
  11210. distanceMarker._msgDiv.innerHTML = `${distanceBetween} ${units}`;
  11211. distanceMarker._msgDiv.style.cssText = "position: absolute; bottom: 5px; left: 5px; color: rgba(100,100,100,0.1); font-size: 13px;";
  11212. document.body.appendChild(distanceMarker._msgDiv);
  11213.  
  11214. return distanceMarker;
  11215. };
  11216. UnityInitiate.callbacks.push(function(){
  11217. if (sessionStorage['unity_streak']){
  11218. initCountryStreakCounter();
  11219. }
  11220. });
  11221.  
  11222.  
  11223. async function initCountryStreakCounter(){
  11224. // TODO EC: Refactor this to a Object or class, this is just a test to see if it works.
  11225.  
  11226. let PATHNAME = getPathName();
  11227. if (PATHNAME.startsWith(`/play-along/`)){
  11228. // Only map is showing in play-along mode.
  11229. // Get reference to websocket for sending messages.
  11230. window._unity_fetch_ = (function () {
  11231. let _fetch = window._unity_fetch_;
  11232. return async function (...args) {
  11233. if (!PATHNAME.startsWith(`/play-along/`)) {
  11234. return _fetch.apply(window, args);
  11235. }
  11236.  
  11237. if (/geoguessr.com.api.v4.*result/i.test(args[0])) {
  11238.  
  11239. let v3APIRes = await _fetch.apply(window, args);
  11240.  
  11241. let resJSON = await v3APIRes.clone().json();
  11242.  
  11243. const round = resJSON?.rounds? resJSON.rounds[resJSON.rounds.length-1]: resJSON?.round;
  11244.  
  11245. if (round) {
  11246. global_lat = round.location.lat;
  11247. global_lng = round.location.lng;
  11248. }
  11249.  
  11250. versionEl.guessBtnClickListener();
  11251.  
  11252. return new Promise((res) => {
  11253. res(v3APIRes);
  11254. });
  11255. } else if (/geoguessr.com.api.v4/i.test(args[0]) && args[1]?.method === "POST") {
  11256. let json = JSON.parse(args[1].body);
  11257.  
  11258. if (json?.lat && json?.lng) {
  11259. setScoreBoardLastLagLng(json);
  11260. }
  11261. }
  11262.  
  11263. return _fetch.apply(window, args);
  11264. };
  11265. })();
  11266. // for (let element of document.getElementsByClassName("preset-minimap")){
  11267. // element.addEventListener('click', function(e){
  11268. // sendWSMsg({presetId: element.id});
  11269. // });
  11270. // }
  11271. }
  11272.  
  11273. const versionEl = document.getElementById("unity_version");
  11274. if (versionEl._outerHTML){
  11275. versionEl.outerHTML = versionEl._outerHTML;
  11276. versionEl._outerHTML = null;
  11277. delete sessionStorage['unity_streak'];
  11278. google.maps.event.removeListener(versionEl.mapsClickListener);
  11279. guessButtonCallback.removeCallback(versionEl.guessBtnClickListener);
  11280. clearInterval( versionEl._interval );
  11281. clearInterval( versionEl.noClickOnMapInterval );
  11282. return;
  11283. }
  11284.  
  11285. const scoreBoard = document.createElement('font');
  11286. scoreBoard.title = "Use mouse wheel to change score!";
  11287.  
  11288. versionEl._outerHTML = versionEl.outerHTML;
  11289. versionEl.innerHTML = '';
  11290. versionEl.appendChild(scoreBoard);
  11291.  
  11292. scoreBoard.style.color = "rgb(0, 102, 204)";
  11293. scoreBoard.style.fontWeight = "bold";
  11294. scoreBoard.setAttribute('size', '2');
  11295.  
  11296. if (!scoreBoard.score){
  11297. scoreBoard.score = 0;
  11298. }
  11299.  
  11300. if (sessionStorage['unity_streak']){
  11301. scoreBoard.score = +sessionStorage['unity_streak'];
  11302. } else {
  11303. sessionStorage['unity_streak'] = scoreBoard.score;
  11304. }
  11305.  
  11306. scoreBoard.innerHTML = scoreBoard.score;
  11307.  
  11308. // Create simple reverse geocoding object.
  11309. eval(await fetch('https://echandler.github.io/Simple-Reverse-Geocoding-Script/reverseGeocodingScript.user.js').then(x => x.text()).catch(x => console.log(x)));
  11310. scoreBoard.lastLatLng = null;
  11311. let mapsObj = null;
  11312. versionEl._interval = setInterval(()=>{
  11313. // Let this run until counter is turned off by player.
  11314. if (!GoogleMapsObj || mapsObj === GoogleMapsObj) return;
  11315. mapsObj = GoogleMapsObj;
  11316. google.maps.event.removeListener(versionEl.mapsClickListener);
  11317. versionEl.mapsClickListener = GoogleMapsObj.addListener("click", mapsClicker);
  11318. }, 1000);
  11319. async function mapsClicker(e) {
  11320. if (versionEl._outerHTML == null) return;
  11321.  
  11322. const latLng = e.latLng.toJSON();
  11323.  
  11324. let PATHNAME = getPathName();
  11325. if (!PATHNAME.startsWith(`/play-along/`)){
  11326. setScoreBoardLastLagLng(latLng);
  11327. debugger;
  11328. tempLastLatLng = latLng;// delete soon used to test 5k country streak scores
  11329. }
  11330.  
  11331. const l = await sgs.reverse(latLng).then(e => e);
  11332. console.log(l.country);
  11333. showFlag(l.country.country_code);
  11334. };
  11335. async function setScoreBoardLastLagLng(latLng){
  11336. const l = await sgs.reverse(latLng).then(e => e);
  11337.  
  11338. scoreBoard.lastLatLng = l;
  11339. console.log(l.country);
  11340. showFlag(l.country.country_code);
  11341.  
  11342. }
  11343. versionEl.guessBtnClickListener = async function(){
  11344. const curRoundLatLng = {lat: global_lat, lng: global_lng};
  11345. const cur = await sgs.reverse(curRoundLatLng).then(e => e);
  11346. let unityAlert = document.querySelector('.unity_alert');
  11347. let _unityAlert = unityAlert.innerHTML;
  11348. let svgFlag = sgs.countryFlags[cur.country.admin_country_code.toUpperCase()];
  11349. svgFlag = svgFlag.replace("<svg", `<svg style="position: relative; top: 1px; border-radius: 3px;"`);
  11350.  
  11351. if (scoreBoard.lastLatLng && (cur.country.admin_country_code == scoreBoard.lastLatLng.country.admin_country_code)){
  11352. 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>!`;
  11353. scoreBoard.score += 1;
  11354. tempChangeScore = true;
  11355. } else {
  11356. 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>`;
  11357. scoreBoard.score = 0;
  11358. }
  11359.  
  11360. scoreBoard.innerHTML = scoreBoard.score;
  11361.  
  11362. sessionStorage['unity_streak'] = scoreBoard.score;
  11363.  
  11364. unityAlert.style.minWidth = '22.75em';
  11365. unityAlert.style.width = 'fit-content';
  11366. unityAlert.style.padding = '0px 10px';
  11367. unityAlert.style.visibility = 'visible';
  11368. unityAlert._streakShowing = true;
  11369.  
  11370. let guessBtn = document.querySelector("[data-qa='perform-guess']");
  11371. if (!scoreBoard.waitIntervals){
  11372. scoreBoard.waitIntervals = [];
  11373. }
  11374.  
  11375. scoreBoard.waitIntervals.push(setInterval(() => {
  11376. const resultLayout = document.querySelector('div[class*="result-layout"]');
  11377. if (document.body.contains(guessBtn) || resultLayout) return;
  11378. guessBtn = null;// Now waiting for resultLayout to be removed.
  11379. scoreBoard.waitIntervals.forEach( x => clearInterval(x));
  11380. setTimeout(()=>{
  11381. unityAlert.style.visibility = 'hidden';
  11382. unityAlert._streakShowing = false;
  11383. tempLastLatLng = null;// delete soon used to test 5k country streak scores
  11384. }, 2000);
  11385. tempChangeScore = false;
  11386. }, 500));
  11387. scoreBoard.lastLatLng = null;
  11388.  
  11389. } // End guessbuttonListener.
  11390. guessButtonCallback.callbacks.push(versionEl.guessBtnClickListener);
  11391.  
  11392. let showFlagTimer = null;
  11393. function showFlag(code){
  11394. clearTimeout(showFlagTimer);
  11395. const svgFlag = sgs.countryFlags[code.toUpperCase()];
  11396.  
  11397. scoreBoard.innerHTML = svgFlag.replace("<svg", `<svg style="position: relative; top: 2px; height: 1em; overflow: visible; border-radius: 3px;"`);
  11398. showFlagTimer = setTimeout(()=>{
  11399. scoreBoard.innerHTML = scoreBoard.score;
  11400. scoreBoard._flagInnerHTML = null;
  11401. }, 900);
  11402. }
  11403. let d = Date.now();
  11404. scoreBoard.addEventListener('wheel', (e)=>{
  11405. if (Date.now() - d < 50) return;
  11406. d = Date.now();
  11407.  
  11408. e.preventDefault();
  11409. e.stopPropagation();
  11410. e.stopImmediatePropagation();
  11411.  
  11412. if (e.wheelDelta > 0){
  11413. scoreBoard.score += 1;
  11414. } else {
  11415. scoreBoard.score -= 1;
  11416. }
  11417. sessionStorage['unity_streak'] = scoreBoard.score;
  11418. scoreBoard.innerHTML = scoreBoard.score;
  11419. console.log(e.wheelDelta, e.deltaY);
  11420. });
  11421.  
  11422. versionEl.noClickOnMapInterval = setInterval(() => {
  11423. // Incase Player doesn't click on map.
  11424. const resultLayout = document.querySelector('div[class*="result-layout"]');
  11425. if (!resultLayout) return;
  11426. const unityAlert = document.querySelector('.unity_alert');
  11427. //if (unityAlert.style.visibility !== 'hidden') return;
  11428. if (unityAlert._streakShowing) return;
  11429. // Alert should have been shown by now, if not then player didn't click on guess button.
  11430. versionEl.guessBtnClickListener();
  11431. }, 1000);
  11432. }
  11433.  
  11434.  
  11435.  
  11436. /// -------------------------------------- RANDOM MAP CHALLENGE ---------------------------------------------------------------------
  11437.  
  11438. async function randomMapChallenge_map_init(mapInfo){
  11439. let info = await fetch(`https://www.geoguessr.com/api/maps/${mapInfo.map}`).then(res => res.json());
  11440. let gameJSONUrl = info.description.match(/{\[(.*)]}/);
  11441.  
  11442. if (!gameJSONUrl.length != 2 && gameJSONUrl[1][0] != "h") {
  11443. alert("Can't find Random Map Challenge Information is description.");
  11444. return;
  11445. }
  11446. let _json = await fetch(gameJSONUrl[1]).then(res=> res.json());
  11447.  
  11448. loadRandomMapChallenge(()=>{
  11449. window.playFinishedGame(_json);
  11450. });
  11451. }
  11452. function checkForRanomMapChallenge(){
  11453. if (localStorage["RandomMapChallenge"]){
  11454. loadRandomMapChallenge(()=>{
  11455. setTimeout(()=>{
  11456. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11457. if (!rmcMenuBtn) return;
  11458. rmcMenuBtn.doShow = true;
  11459. }, 500);
  11460. });
  11461. }
  11462. if (localStorage["RandomMapChallenge_onHomePage"]){
  11463. setTimeout(()=>{
  11464. showRandomMapChallengeBtnOnHomePage(true);
  11465. }, 1000);
  11466. }
  11467. }
  11468. let showRandomMapChallengeBtnOnHomePageTimer = null;
  11469. function showRandomMapChallengeBtnOnHomePage(trueFalse){
  11470. if (trueFalse === false){
  11471. clearInterval(showRandomMapChallengeBtnOnHomePageTimer);
  11472. return;
  11473. }
  11474. showRandomMapChallengeBtnOnHomePageTimer = setInterval(()=>{
  11475. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11476. if (!/^\/\w?\w?$/.test(getPathName())) {
  11477. if (rmcMenuBtn?.doShow) return;
  11478.  
  11479. if (rmcMenuBtn){
  11480. rmcMenuBtn.style.display = "none";
  11481. }
  11482. return;
  11483. }
  11484.  
  11485. if (rmcMenuBtn){
  11486. rmcMenuBtn.style.display = "";
  11487. return;
  11488. }
  11489. loadRandomMapChallenge(()=>{
  11490. setTimeout(()=>{
  11491. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11492. if (!rmcMenuBtn) return;
  11493. rmcMenuBtn.style.display = "";
  11494. }, 1000);
  11495. });
  11496. }, 1000);
  11497. }
  11498.  
  11499. function initRandomMapChallenge(){
  11500. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11501. if (rmcMenuBtn?.style?.display === "none"){
  11502. rmcMenuBtn.style.display = '';
  11503. rmcMenuBtn.doShow = true;
  11504. rmcMenuBtn.click();
  11505. return;
  11506. }
  11507.  
  11508. if (rmcMenuBtn){
  11509. if (localStorage["RandomMapChallenge"] && !confirm("This will end your Random Map Challenge?")){
  11510. return;
  11511. }
  11512. delete localStorage["RandomMapChallenge"];
  11513. location.reload();
  11514. return;
  11515. }
  11516. loadRandomMapChallenge(()=>{
  11517. setTimeout(()=>{
  11518. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11519. if (!rmcMenuBtn) return;
  11520. rmcMenuBtn.style.display = '';
  11521. rmcMenuBtn.doShow = true;
  11522. rmcMenuBtn.click();
  11523. }, 500);
  11524. });
  11525. }
  11526. function loadRandomMapChallenge(fn){
  11527. const s = document.createElement( 'script' );
  11528. s.addEventListener('load', fn);
  11529. s.setAttribute( 'src', `https://echandler.github.io/test-geo-noob-script/misc/test1.js` );
  11530. document.body.appendChild( s );
  11531. checkForRMCButtonOnWrongPage();
  11532. }
  11533.  
  11534. function checkForRMCButtonOnWrongPage(){
  11535. if (checkForRMCButtonOnWrongPage.isChecking) return;
  11536.  
  11537. checkForRMCButtonOnWrongPage.isChecking = true;
  11538. setInterval(()=>{
  11539. const pathname = getPathName();
  11540. const rmcMenuBtn = document.getElementById('RMC_menu_button');
  11541. const onHomePage = /^\/\w?\w?$/.test(pathname);
  11542. const onGameMapsPage = /game\/|maps\//.test(pathname);
  11543.  
  11544. if (rmcMenuBtn && !onHomePage && !onGameMapsPage) {
  11545. rmcMenuBtn.style.display = 'none';
  11546. } else if (rmcMenuBtn?.doShow){
  11547. rmcMenuBtn.style.display = '';
  11548. }
  11549. }, 1000)
  11550. }
  11551. checkForRMCButtonOnWrongPage.isChecking = null;
  11552.  
  11553. /// -------------------------------------- PLAY ALONG WEBSOCKET STUFF ---------------------------------------------------------------------
  11554.  
  11555. const mapStylesCodes = {
  11556. "oool": { id: 'Default', fn : function(id){ document.getElementById(this.id)?.click(); } },
  11557. "oolo": { id: 'Oceanman', fn : function(id){ document.getElementById(this.id)?.click(); } },
  11558. "ooll": { id: 'Satellite', fn : function(id){ document.getElementById(this.id)?.click(); } },
  11559. "oloo": { id: "Easy 5K", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11560. "olol": { id: "Neon", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11561. "ollo": { id: "Impossible", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11562. "olll": { id: "Choekaas.no",
  11563. fn : function(id){
  11564. const coverageLayer = new google.maps.ImageMapType({
  11565. getTileUrl({ x, y }, z) {
  11566. return `https://echandler.github.io/test-geo-noob-script/misc/geoguessr%20artwork%20map%20tiles/${z}/${x}/${y}.png`;
  11567. },
  11568. maxZoom: 20,
  11569. tileSize: new google.maps.Size(256, 256),
  11570. });
  11571.  
  11572. GoogleMapsObj.overlayMapTypes.push(coverageLayer);
  11573. }
  11574. },
  11575. "looo": { id: "Fire", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11576. "lool": { id: "City Lights", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11577. "lolo": { id: "show menu",
  11578. fn : function(id){
  11579. const PATHNAME = getPathName();
  11580. //if (code === "lolo" && !PATHNAME.startsWith("/play-along/")/*is player not streamer*/){
  11581. if (PATHNAME.startsWith("/play-along/") /*player has play-along in url*/) return;
  11582. unity.play_along.showOptions;
  11583. }
  11584. },
  11585. "loll": { id: "Hybrid", fn : function(id){ document.getElementById(this.id)?.click(); } },
  11586. "llll": { id: "CG's 📸travel-pics-game",
  11587. fn : function(id){
  11588. const coverageLayer = new google.maps.ImageMapType({
  11589. getTileUrl({ x, y }, z) {
  11590. return `https://echandler.github.io/a/misc/tiles/${z}/${x}/${y}.webp`
  11591. },
  11592. maxZoom: 20,
  11593. tileSize: new google.maps.Size(256, 256),
  11594. })
  11595.  
  11596. GoogleMapsObj.overlayMapTypes.push(coverageLayer);
  11597. }
  11598. },
  11599. };
  11600.  
  11601. function playAlongWebSocketInit(){
  11602. console.log("Play along websoket listener initiated")
  11603. let old_WS_Send = window.WebSocket.prototype.send;
  11604. let msgCode = [];
  11605. let msgCodeTimer = null;
  11606.  
  11607. window.WebSocket.prototype.send = async function (...args) {
  11608. if (this._unity_message_listener_added === undefined) {
  11609. this.addEventListener('message', function (e) {
  11610. if (!e.data) return;
  11611. onMsg(JSON.parse(e.data));
  11612. });
  11613. sendWSMsg._this = this;
  11614. this._unity_message_listener_added = true;
  11615. }
  11616. return old_WS_Send.apply(this, args);
  11617. }
  11618.  
  11619. function onMsg(json) {
  11620. if (json?.code !== "PlayAlongGameUpdated") return;
  11621.  
  11622. if (msgCodeTimer === null) {
  11623. msgCodeTimer = setTimeout(() => {
  11624. if (msgCode.length === 4) {
  11625. _delay = null;
  11626.  
  11627. const code = msgCode.join("");
  11628. console.log("code", code);
  11629. // Clear the overlays before doing anything else.
  11630. document.getElementById('Clear').click();
  11631.  
  11632. mapStylesCodes[code].fn();
  11633. }
  11634.  
  11635. msgCodeTimer = null;
  11636. msgCode = [];
  11637. }, 2000);
  11638. }
  11639.  
  11640. let payload = JSON.parse(json.payload);
  11641.  
  11642. if (payload.status.toLowerCase() === 'lockedround') {
  11643. msgCode.push("l");
  11644. } else if (payload.status.toLowerCase() === 'ongoinground') {
  11645. msgCode.push("o");
  11646. }
  11647. }
  11648.  
  11649. function sendWSMsg(msg) {
  11650. if (sendWSMsg._this === null) return;
  11651. sendWSMsg._this.send(JSON.stringify(
  11652. {
  11653. "code": "ChatMessage",
  11654. "topic": "chat:Friend:TextMessages:5dc13f46e9473f1aa89d8f24",
  11655. "payload": "Ignore this also lol",
  11656. "client": "web"
  11657. }));
  11658. // sendWSMsg._this.send(JSON.stringify({
  11659. // unity:true,
  11660. // msg: msg,
  11661. // }));
  11662. };
  11663. sendWSMsg._this = null;
  11664. }
  11665. playAlongWebSocketInit();
  11666.  
  11667. let _delay = null;
  11668. function playAlongSendMsg(str){
  11669. if (_delay !== null) {
  11670. console.log("Need to wait!");
  11671. return;
  11672. }
  11673. const keyObj = {
  11674. 'l': "LockedRound",
  11675. 'o': "OngoingRound"
  11676. };
  11677.  
  11678. _delay = true;
  11679.  
  11680. setTimeout(()=> _delay = null, 2500 );
  11681.  
  11682. const nextData = JSON.parse(document.getElementById('__NEXT_DATA__').innerHTML);
  11683. const gameId = location.href.replace(/.*\/(.*)/, "$1");
  11684. const token = nextData?.query?.token || gameId || null;
  11685. //let userId = nextData?.props?.accountProps?.account?.user?.userId || null;
  11686.  
  11687. if (token === null) {
  11688. console.log("Next data query token not found");
  11689. return;
  11690. }
  11691.  
  11692. for(let n = 0, fetchDelay = 0; n < str.length + 1; n++){
  11693. let gameStatus = keyObj[str[n]];
  11694.  
  11695. if (n === str.length){
  11696. // Make sure game is in unlock state once code is sent.
  11697. fetchDelay += 2000;
  11698. gameStatus = keyObj["o"];
  11699. }
  11700.  
  11701. setTimeout(()=>{
  11702. fetch(`https://www.geoguessr.com/api/v4/play-along/streamer/${token}/3/update`, {
  11703. "headers": {
  11704. "accept": "*/*",
  11705. "accept-language": "en-US,en;q=0.9",
  11706. "cache-control": "no-cache",
  11707. "content-type": "application/json",
  11708. "pragma": "no-cache",
  11709. "x-client": "web"
  11710. },
  11711. "referrer": location.href,
  11712. "referrerPolicy": "strict-origin-when-cross-origin",
  11713. "body": `{\"status\":\"${gameStatus}\"}`,
  11714. "method": "POST",
  11715. "mode": "cors",
  11716. "credentials": "include"
  11717. });
  11718. }, fetchDelay);
  11719. fetchDelay += 250;
  11720. }
  11721. }
  11722.  
  11723. window.unity = {
  11724. play_along: {
  11725. get showOptions(){
  11726. const keys = Object.keys(mapStylesCodes);
  11727. let optionsTxt = "";
  11728.  
  11729. let idx = 1;
  11730. keys.forEach((k)=>{
  11731. let _id_ = mapStylesCodes[k].id;
  11732. if (_id_ == "show menu"){
  11733. idx += 1; // Lazy fix for menu item numbers being one off after this is skipped.
  11734. return;
  11735. }
  11736. optionsTxt += `\n ${idx++}. ${_id_}`;
  11737. });
  11738.  
  11739. const num = prompt(` Unity Script Play Along Options:${optionsTxt}`);
  11740.  
  11741. if (num === null) return;
  11742.  
  11743. const code = keys[parseInt(num)-1];
  11744.  
  11745. try {
  11746. playAlongSendMsg(code);
  11747. } catch (e) {
  11748. alert("Ooops, try again!")
  11749. }
  11750. }
  11751. }
  11752. };
  11753.  
  11754.  
  11755. },1)