Geoguessr Unity Script

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

目前為 2022-02-17 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Geoguessr Unity Script
  3. // @description For a full list of features included in this script, see this document https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing
  4. // @version 5.1.1
  5. // @author Jupaoqq
  6. // @include https://www.geoguessr.com/*
  7. // @run-at document-start
  8. // @license MIT
  9. // @namespace https://greasyfork.org/users/838374
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. /**
  14. * Custom your minimap here!
  15. */
  16.  
  17. /**
  18. * 1: replace "roadmap" in the customMode field with any of the options below:
  19. * "roadmap" displays the default road map view. This is the default map type.
  20. * "satellite" displays Google Earth satellite images.
  21. * "hybrid" displays a mixture of normal and satellite views.
  22. * "terrain" displays a physical map based on terrain information.
  23. */
  24.  
  25. let customMode = "roadmap";
  26.  
  27. /**
  28. * 2: Go to https://mapstyle.withgoogle.com/ first click "No thanks, take me to the old style wizard"
  29. * then click "MORE OPTIONS" to hide or reveal certain features.
  30. * When you are done, click "FINISH", then "COPY JSON", and replace my settings in custom with your settings below.
  31. */
  32.  
  33. let custom =
  34.  
  35. [
  36. {
  37. "featureType": "administrative",
  38. "stylers": [
  39. {
  40. "visibility": "off"
  41. }
  42. ]
  43. },
  44. {
  45. "featureType": "landscape",
  46. "stylers": [
  47. {
  48. "visibility": "off"
  49. }
  50. ]
  51. },
  52. {
  53. "featureType": "poi.park",
  54. "stylers": [
  55. {
  56. "visibility": "off"
  57. }
  58. ]
  59. },
  60. {
  61. "featureType": "road",
  62. "elementType": "labels",
  63. "stylers": [
  64. {
  65. "visibility": "off"
  66. }
  67. ]
  68. },
  69. {
  70. "featureType": "transit",
  71. "stylers": [
  72. {
  73. "visibility": "off"
  74. }
  75. ]
  76. }
  77. ]
  78.  
  79. /**
  80. * End of Minimap customization instruction section
  81. */
  82.  
  83. /**
  84. * Overlay anything on the minimap here!
  85. * 1. overlay an GeoJSON object
  86. * 2. overlay a custom image
  87. */
  88.  
  89. /**
  90. * Overlay an GeoJSON object:
  91. */
  92.  
  93. // change the GeoJson display style.
  94. // strokeOpacity, strokeWeight, fillOpacity takes a value between 0 and 1.
  95. // strokeColor and fillColor supports Hexadecimal color (#00FF00 is green)
  96. // If clickable is set to true, you would not be able to make a guess within the shape
  97.  
  98. let GEOJSON_STYLE =
  99. {
  100. strokeColor: "black",
  101. strokeOpacity: 1,
  102. strokeWeight: 0.2,
  103. fillColor: "#00FF00",
  104. fillOpacity: 0,
  105. clickable: false,
  106. }
  107.  
  108. // replace the URL with your desired link
  109. // For example, search "Germany GeoJson" on Github, find this link (https://github.com/isellsoap/deutschlandGeoJSON/blob/main/4_kreise/4_niedrig.geo.json)
  110. // Then click "Download" to get the raw.githubusercontent.com link (https://raw.githubusercontent.com/isellsoap/deutschlandGeoJSON/main/4_kreise/4_niedrig.geo.json)
  111. // and replace the URL below with that URL.
  112. // State zipcode: see this site https://github.com/OpenDataDE/State-zip-code-GeoJSON
  113.  
  114. let YOUR_URL = "https://raw.githubusercontent.com/severinlandolt/map-switzerland/main/02%20GeoJSON/CH_Kantonsgrenzen_100_geo.json"
  115.  
  116. // set it to true to add your custom GeoJSON by copy it to the code below (this is for
  117.  
  118. let GeoJsonCustomUser = false
  119.  
  120. // replace with your custom GeoJson, go to https://geojson.io/ to customize it then copy the Json to here
  121.  
  122. let CUSTOM_GEOJSON =
  123.  
  124. {
  125. "type": "FeatureCollection",
  126. "features": [
  127. {
  128. "type": "Feature",
  129. "properties": {},
  130. "geometry": {
  131. "type": "LineString",
  132. "coordinates": [
  133. [
  134. 2.493896484375,
  135. 52.7163309360463
  136. ],
  137. [
  138. 2.4609375,
  139. 53.15994678846807
  140. ],
  141. [
  142. 3.2025146484375,
  143. 53.179703893605385
  144. ],
  145. [
  146. 3.2080078125,
  147. 52.96518371955126
  148. ],
  149. [
  150. 2.48291015625,
  151. 52.948637884883205
  152. ]
  153. ]
  154. }
  155. },
  156. {
  157. "type": "Feature",
  158. "properties": {},
  159. "geometry": {
  160. "type": "LineString",
  161. "coordinates": [
  162. [
  163. 3.218994140625,
  164. 52.05586831074774
  165. ],
  166. [
  167. 3.218994140625,
  168. 52.13685974852633
  169. ],
  170. [
  171. 2.515869140625,
  172. 52.1267438596429
  173. ],
  174. [
  175. 2.515869140625,
  176. 51.77803705914517
  177. ],
  178. [
  179. 3.2354736328125,
  180. 51.78993084774129
  181. ],
  182. [
  183. 3.228607177734375,
  184. 51.96119237712624
  185. ],
  186. [
  187. 2.8571319580078125,
  188. 51.95230623740452
  189. ]
  190. ]
  191. }
  192. },
  193. {
  194. "type": "Feature",
  195. "properties": {
  196. "stroke": "#555555",
  197. "stroke-width": 2,
  198. "stroke-opacity": 1
  199. },
  200. "geometry": {
  201. "type": "LineString",
  202. "coordinates": [
  203. [
  204. 2.5048828125,
  205. 52.619725272670266
  206. ],
  207. [
  208. 2.5103759765625,
  209. 52.274880130680536
  210. ],
  211. [
  212. 2.867431640625,
  213. 52.284962354465726
  214. ],
  215. [
  216. 3.2299804687499996,
  217. 52.29504228453735
  218. ],
  219. [
  220. 3.2135009765625,
  221. 52.63973017532399
  222. ],
  223. [
  224. 2.5096893310546875,
  225. 52.621392697207625
  226. ]
  227. ]
  228. }
  229. }
  230. ]
  231. }
  232.  
  233. /**
  234. * Overlay a custom image:
  235. */
  236.  
  237. // set it to true to add your image overlay
  238.  
  239. let OverlayCustom = false
  240.  
  241. // replace the URL with your desired link
  242.  
  243. let OVERLAY_URL = "https://www.battleface.com/blog/wp-content/uploads/2020/10/patreon-profile-tom-geowizard.jpg"
  244.  
  245. // set the bounds for the image - latitude (North and South), longitude (North and South)
  246.  
  247. let OVERLAY_BOUNDS =
  248. {
  249. north: 53,
  250. west: -3,
  251. south: 51,
  252. east: 1,
  253. };
  254.  
  255. // change the image overlay display style.
  256.  
  257. let OVERLAY_STYLE =
  258. {
  259. fillOpacity: 0.2,
  260. clickable: false,
  261. }
  262.  
  263. /**
  264. * End of Minimap Overlay instruction section
  265. */
  266.  
  267. // API Keys
  268.  
  269. var MS_API_KEY = "AjWqExh5E9aZfgKKBrgJMM2tbBeJ_q9ET7__194VDfcpl8lEWYTYNRWoYE1kqy95";
  270. var YANDEX_API_KEY = "b704b5a9-3d67-4d19-b702-ec7807cecfc6";
  271. var KAKAO_API_KEY = "cbacbe41e3a223d794f321de4f3e247b";
  272. const MAPS_API_URL = "https://maps.googleapis.com/maps/api/js"; // removed "?" from the link
  273. var MAPILLARY_API_KEY_LIST =
  274. ["MLY|6723031704435203|5afd537469b114cf814881137ad74b7c",
  275. "MLY|6691659414239148|b45e7e82cde126044cbc2cf5d4a7c9b1",
  276. "MLY|5074369465929308|f7ad2802cbaf26c63f88046a292df68b",
  277. "MLY|7451643761528219|6477f2db0e3928b51e45ec9311983936",
  278. "MLY|4855256237866198|6d0464771831c8a4bf2be095e1e1aabc",
  279. "MLY|4772941976102161|8458d4f08d2e1970cdfe0a4e242c04ff",
  280. "MLY|4492067214235489|94c44703942362ad6f6b70b5d32c3a45",
  281. "MLY|4618251611628426|0cef71d6ec8b997a5ec06ecdeabf11ec",
  282. "MLY|4096846270415982|fa2ce29641503e6ef665f17459633570",
  283. "MLY|4231415756962414|fe353880fd246e8a4a6ae32152f7dbb0",]
  284.  
  285. var MAPILLARY_API_KEY = MAPILLARY_API_KEY_LIST[Math.floor(Math.random() * MAPILLARY_API_KEY_LIST.length)];
  286.  
  287. console.log("Geoguessr Unity Script v5.1.1 by Jupaoqq");
  288.  
  289. // Store each player instance
  290.  
  291. let YandexPlayer, KakaoPlayer, GooglePlayer, MapillaryPlayer, MSStreetPlayer;
  292. let YANDEX_INJECTED = false;
  293. let BAIDU_INJECTED = false;
  294. let KAKAO_INJECTED = false;
  295. let MAPILLARY_INJECTED = false;
  296. let MS_INJECTED = false;
  297.  
  298. // Game mode detection
  299.  
  300. let isBattleRoyale = false;
  301. let isDuel = false;
  302. let isBullseye = false;
  303.  
  304. // Player detection and coordinate conversion
  305.  
  306. let nextPlayer = "Google";
  307. let global_lat = 0;
  308. let global_lng = 0;
  309. let global_panoID = null;
  310. let global_BDID, global_BDAh, global_BDBh;
  311. let yId, yTime, yEnd, iId;
  312. let global_heading = null;
  313. let global_pitch = null;
  314.  
  315. let krCoordinates = [38.75292321084364, 124.2804539232574, 33.18509676203202, 129.597381999198]
  316. let global_radi = 100
  317.  
  318. // Callback variables
  319.  
  320. let eventListenerAttached = false;
  321. let povListenerAttached = false;
  322. let playerLoaded = false;
  323. let teleportLoaded = false;
  324. let syncLoaded = false;
  325.  
  326. // Minimize Yandex API use
  327.  
  328. let yandex_map = false;
  329. let Kakao_map = false;
  330.  
  331. // Mapillary Image Key
  332.  
  333. let mmKey = 0;
  334.  
  335. // Handle Yandex compass
  336.  
  337. let COMPASS = null;
  338.  
  339. // Handle undo
  340.  
  341. let locHistory = [];
  342. let defaultPanoIdChange = true;
  343.  
  344. // Round check
  345.  
  346. let ROUND = 0;
  347. let CURRENT_ROUND_DATA = null;
  348.  
  349. let switch_call = true;
  350. let one_reset = false;
  351. // let cnt = 0;
  352.  
  353. let cn_tips = false;
  354. var isFirefox = typeof InstallTrigger !== 'undefined';
  355.  
  356. let linksList = []
  357. let fire1 = true;
  358.  
  359. let CNBorder = false;
  360.  
  361. // Satellite Map Radius (in Meters)
  362. let ms_radius = 10000;
  363.  
  364. // Create the Maps, but not reload API
  365. let partialCreateYandex = false;
  366. let partialCreateKakao = false;
  367. let partialCreateMapillary = false;
  368. let partialCreateMS = false;
  369.  
  370. // let NEW_ROUND_LOADED = false;
  371.  
  372. // Geoguessr Canvas String Names
  373.  
  374. let GENERAL_CANVAS = ".game-layout__panorama-canvas";
  375. let BR_CANVAS = ".br-game-layout__panorama-canvas";
  376. let FAIL_TO_LOAD_CANVAS = ".game-layout__panorama-message";
  377. let DUEL_LAYOUT = ".game_layout__TO_jf";
  378. let DUELS_CANVAS = ".game-panorama_panorama__rdhFg";
  379. let DUELS_CANVAS2 = ".game-panorama_panoramaCanvas__PNKve";
  380. let BULLSEYE_CANVAS = ".game-panorama_panorama__ncMwh";
  381. let BULLSEYE_CANVAS2 = ".game-panorama_panoramaCanvas__r_5ea";
  382. let DUELS_POPUP = ".overlay_overlay__AR02x"
  383. let BR_POPUP = ".popup__content"
  384.  
  385. let BR_LOAD_KAKAO = false;
  386. let BR_LOAD_YANDEX = false;
  387. let BR_LOAD_MS = false;
  388.  
  389. let ms_sat_map = false;
  390. let rtded = false;
  391. let NM = false;
  392. let NP = false;
  393. let NZ = false;
  394.  
  395. /**
  396. * Helper Functions
  397. */
  398.  
  399. // Highlight API Load Message
  400.  
  401. function myHighlight(...args) {
  402. console.log(`%c${[...args]}`, "color: dodgerblue; font-size: 24px;");
  403. }
  404.  
  405. // Hex to number conversion for Baidu coordinate conversion
  406.  
  407. function hex2a(hexx) {
  408. var hex = hexx.toString();
  409. var str = '';
  410. for (var i = 0; i < hex.length; i += 2)
  411. {
  412. str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
  413. }
  414. return str;
  415. }
  416.  
  417. // Coordinate computation given heading, distance and current coordinates for teleport
  418.  
  419. function FindPointAtDistanceFrom(lat, lng, initialBearingRadians, distanceKilometres) {
  420. const radiusEarthKilometres = 6371.01;
  421. var distRatio = distanceKilometres / radiusEarthKilometres;
  422. var distRatioSine = Math.sin(distRatio);
  423. var distRatioCosine = Math.cos(distRatio);
  424.  
  425. var startLatRad = DegreesToRadians(lat);
  426. var startLonRad = DegreesToRadians(lng);
  427.  
  428. var startLatCos = Math.cos(startLatRad);
  429. var startLatSin = Math.sin(startLatRad);
  430.  
  431. var endLatRads = Math.asin((startLatSin * distRatioCosine) + (startLatCos * distRatioSine * Math.cos(initialBearingRadians)));
  432.  
  433. var endLonRads = startLonRad
  434. + Math.atan2(
  435. Math.sin(initialBearingRadians) * distRatioSine * startLatCos,
  436. distRatioCosine - startLatSin * Math.sin(endLatRads));
  437.  
  438. return { lat: RadiansToDegrees(endLatRads), lng: RadiansToDegrees(endLonRads) };
  439. }
  440.  
  441. function DegreesToRadians(degrees) {
  442. const degToRadFactor = Math.PI / 180;
  443. return degrees * degToRadFactor;
  444. }
  445.  
  446. function RadiansToDegrees(radians) {
  447. const radToDegFactor = 180 / Math.PI;
  448. return radians * radToDegFactor;
  449. }
  450.  
  451. function toRadians(degrees) {
  452. return degrees * Math.PI / 180;
  453. };
  454.  
  455. // Converts from radians to degrees.
  456. function toDegrees(radians) {
  457. return radians * 180 / Math.PI;
  458. }
  459.  
  460. function bearing(start_latitude, start_longitude, stop_latitude, stop_longitude){
  461. let y = Math.sin(stop_longitude-start_longitude) * Math.cos(stop_latitude);
  462. let x = Math.cos(start_latitude)*Math.sin(stop_latitude) -
  463. Math.sin(start_latitude)*Math.cos(stop_latitude)*Math.cos(stop_longitude-start_longitude);
  464. let brng = Math.atan2(y, x) * 180 / Math.PI;
  465. return brng
  466. }
  467.  
  468. // Check if two floating point numbers are really really really really close to each other (to 10 decimal points)
  469. function almostEqual (a, b) {
  470. return a.toFixed(10) === b.toFixed(10)
  471. }
  472.  
  473. function almostEqual2 (a, b) {
  474. return a.toFixed(3) === b.toFixed(3)
  475. }
  476.  
  477. function moveFrom(coords, angle, distance){
  478. const R_EARTH = 6378.137;
  479. const M = (1 / ((2 * Math.PI / 360) * R_EARTH)) / 1000;
  480. let radianAngle = -angle * Math.PI / 180;
  481. let x = 0 + (distance * Math.cos(radianAngle));
  482. let y = 0 + (distance * Math.sin(radianAngle));
  483.  
  484. let newLat = coords.lat + (y * M);
  485. let newLng = coords.lng + (x * M) / Math.cos(coords.lat * (Math.PI / 180));
  486. return { lat: newLat, lng: newLng };
  487. }
  488.  
  489. function getBBox(coordinates, meters){
  490. let SW = moveFrom(coordinates, 135, meters);
  491. let NE = moveFrom(coordinates, 315, meters);
  492. return `${SW.lng},${SW.lat},${NE.lng},${NE.lat}`;
  493. }
  494.  
  495. function getBBox2(coordinates, meters){
  496. let SW = moveFrom(coordinates, 135, meters);
  497. let NE = moveFrom(coordinates, 315, meters);
  498. return [NE.lat,SW.lng,SW.lat,NE.lng];
  499. }
  500.  
  501. function distance(lat1, lon1, lat2, lon2) {
  502. var p = 0.017453292519943295; // Math.PI / 180
  503. var c = Math.cos;
  504. var a = 0.5 - c((lat2 - lat1) * p)/2 +
  505. c(lat1 * p) * c(lat2 * p) *
  506. (1 - c((lon2 - lon1) * p))/2;
  507.  
  508. return 1000 * 12742 * Math.asin(Math.sqrt(a)); // 2 * R; R = 6371 km
  509. }
  510.  
  511. // Script injection, extracted from extenssr:
  512. // https://gitlab.com/nonreviad/extenssr/-/blob/main/src/injected_scripts/maps_api_injecter.ts
  513.  
  514. function overrideOnLoad(googleScript, observer, overrider) {
  515. const oldOnload = googleScript.onload
  516. googleScript.onload = (event) => {
  517. const google = window.google
  518. if (google) {
  519. observer.disconnect()
  520. overrider(google)
  521. }
  522. if (oldOnload) {
  523. oldOnload.call(googleScript, event)
  524. }
  525. }
  526. }
  527.  
  528. function grabGoogleScript(mutations) {
  529. for (const mutation of mutations) {
  530. for (const newNode of mutation.addedNodes) {
  531. const asScript = newNode
  532. if (asScript && asScript.src && asScript.src.startsWith('https://maps.googleapis.com/')) {
  533. //asScript.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyDqRTXlnHXELLKn7645Q1L_5oc4CswKZK4&v=3&libraries=places,drawing&language=ja&region=JP"
  534. return asScript
  535. }
  536. }
  537. }
  538. return null
  539. }
  540.  
  541. function injecter(overrider) {
  542. if (document.documentElement)
  543. {
  544. injecterCallback(overrider);
  545. }
  546. else
  547. {
  548. alert("Script didn't load, refresh to try loading the script");
  549. }
  550. }
  551.  
  552.  
  553. function injecterCallback(overrider)
  554. {
  555. new MutationObserver((mutations, observer) => {
  556. const googleScript = grabGoogleScript(mutations)
  557. if (googleScript) {
  558. overrideOnLoad(googleScript, observer, overrider)
  559. }
  560. }).observe(document.documentElement, { childList: true, subtree: true })
  561. }
  562.  
  563. // Getter function for the button elements
  564.  
  565. function setButtons()
  566. {
  567. return [document.getElementById("Teleport Button"), document.getElementById("plus"), document.getElementById("minus"), document.getElementById("reset"), document.getElementById("switch"), document.getElementById("Show Buttons"), document.getElementById("Date Button"), document.getElementById("minus year"), document.getElementById("plus year"), document.getElementById("Minimap Button"), document.getElementById("Overlay Button"), document.getElementById("Help Button"), document.getElementById("Teleport Options Button")];
  568. }
  569.  
  570. // Store default position for the button elements
  571.  
  572. function resetBtnPos()
  573. {
  574. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  575. teleportBtn.style.top = "8.5em";
  576. teleportMoreBtn.style.top = "8.5em";
  577. teleportLessBtn.style.top = "8.5em";
  578. teleportDistResetBtn.style.top = "11em";
  579. switchCovergeButton.style.top = "6em";
  580. mainMenuBtn.style.top = "6em";
  581. timeMachineBtn.style.top = "13.5em";
  582. timeMachineOlderBtn.style.top = "13.5em";
  583. timeMachineNewerBtn.style.top = "13.5em";
  584. MinimapBtn.style.top = "16em";
  585. OverlayBtn.style.top = "16em";
  586. HelpBtn.style.top = "6em";
  587. TeleportArisBtn.style.top = "11em";
  588. document.getElementById("Youtube Button").style.top = "13.5em";
  589.  
  590. teleportBtn.style.right = "9.5em";
  591. teleportMoreBtn.style.right = "7em";
  592. teleportLessBtn.style.right = "20em";
  593. teleportDistResetBtn.style.right = "13em";
  594. switchCovergeButton.style.right = "7em";
  595. mainMenuBtn.style.right = "0.5em";
  596. timeMachineBtn.style.right = "9.5em";
  597. timeMachineOlderBtn.style.right = "20em";
  598. timeMachineNewerBtn.style.right = "7em";
  599. MinimapBtn.style.right = "14.75em";
  600. OverlayBtn.style.right = "7em";
  601. HelpBtn.style.right = "16em";
  602. TeleportArisBtn.style.right = "7em";
  603. document.getElementById("Youtube Button").style.right = "0.5em";
  604.  
  605. let hC = 0
  606. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  607. mapDiv.style.top = (18.1 + (hC * 1.6)).toString() + "em";
  608. mapDiv.style.right = "14.75em";
  609. hC++;
  610. }
  611. let hC2 = 0
  612. for (let mapDiv2 of document.getElementsByClassName("overlay-minimap")){
  613. mapDiv2.style.top = (18.1 + (hC2 * 1.6)).toString() + "em";
  614. mapDiv2.style.right = "7em";
  615. hC2++;
  616. }
  617. }
  618.  
  619. // Adjust Buttons for different game modes
  620.  
  621. function AdjustBtnPos(top, right)
  622. {
  623. resetBtnPos();
  624. for (let element of document.getElementsByClassName("unity-btn")){
  625. let eTop = element.style.top;
  626. let eRight = element.style.right;
  627. element.style.top = "calc(" + top.toString() + " + " + eTop + ")";
  628. element.style.right = "calc(" + right.toString() + " + " + eRight + ")";
  629. // console.log(element.style.top)
  630. }
  631. }
  632.  
  633. /**
  634. * Creates Unity buttons
  635. *
  636. * @returns Promise
  637. */
  638.  
  639. function UnityInitiate() {
  640. const google = window.google;
  641. let curPosition;
  642. let kakao_enabled = true;
  643.  
  644. function svCheck(data, status) {
  645. if (status === 'OK') {
  646. // console.log("STATUS OK");
  647. let l = data.location.latLng.toString().split(',');
  648. let lat = l[0].replaceAll('(', '');
  649. let lng = l[1].replaceAll(')', '');
  650. if (lat == curPosition.lat && lng == curPosition.lng && !switch_call)
  651. {
  652. console.log("Trying more distance");
  653. teleportBtn.distance += 100;
  654. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  655. }
  656. else
  657. {
  658. console.log("Teleport Success");
  659. GooglePlayer.setPosition(data.location.latLng);
  660. GooglePlayer.setPov({
  661. heading: switchCovergeButton.heading,
  662. pitch: 0,
  663. })
  664. if (teleportBtn.distance > 150)
  665. {
  666. teleportBtn.distance = 100;
  667. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  668. }
  669. }
  670. switch_call = false;
  671. }
  672. else {
  673. console.log("STATUS NOT OK");
  674. teleportBtn.distance += 100;
  675. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  676. }
  677. }
  678.  
  679. google.maps.Map = class extends google.maps.Map {
  680. constructor(...args) {
  681. super(...args);
  682. if (GeoJsonCustomUser)
  683. {
  684. if (GeoJsonCustomUser)
  685. {
  686. this.data.addGeoJson(CUSTOM_GEOJSON);
  687. }
  688. this.data.setStyle(function(feature) {
  689. return GEOJSON_STYLE
  690. });
  691. }
  692. if (OverlayCustom)
  693. {
  694. let customOverlay = new google.maps.GroundOverlay(OVERLAY_URL, OVERLAY_BOUNDS, OVERLAY_STYLE);
  695. customOverlay.setMap(this);
  696. }
  697.  
  698. if (CNBorder)
  699. {
  700. this.data.loadGeoJson("https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/10DD.json");
  701. this.data.setStyle(function(feature) {
  702. return {
  703. clickable: false,
  704. strokeWeight: 1
  705. }
  706. });
  707.  
  708. const imageBounds3 = {
  709. north: NW[0],
  710. west: NW[1],
  711. south: NW[2],
  712. east: NW[3],
  713. };
  714.  
  715. SEOverlay3 = new google.maps.GroundOverlay(
  716. "https://www.countryflags.com/wp-content/uploads/china-flag-png-large.png",
  717. imageBounds3, {clickable: false, opacity: 1}
  718. );
  719. SEOverlay3.setMap(this);
  720.  
  721. this.addListener("zoom_changed", () => {
  722. let zoomLevel = this.getZoom();
  723. let opacity = 1;
  724. if (SEOverlay)
  725. {
  726. SEOverlay.setMap(null);
  727. NWOverlay.setMap(null);
  728. }
  729. let borderSE = TW[0]
  730. let borderNW = TS[0]
  731. if (zoomLevel > 7 && zoomLevel < 14)
  732. {
  733. borderSE = TW[zoomLevel - 7];
  734. borderNW = TS[1];
  735. }
  736. if (zoomLevel >= 14)
  737. {
  738. opacity = 0;
  739. }
  740. const imageBounds = {
  741. north: borderSE[0],
  742. west: borderSE[1],
  743. south: borderSE[2],
  744. east: borderSE[3],
  745. };
  746. SEOverlay = new google.maps.GroundOverlay(
  747. "https://www.countryflags.com/wp-content/uploads/china-flag-png-large.png",
  748. imageBounds, {clickable: false, opacity: opacity}
  749. );
  750. SEOverlay.setMap(this);
  751. const imageBounds2 = {
  752. north: borderNW[0],
  753. west: borderNW[1],
  754. south: borderNW[2],
  755. east: borderNW[3],
  756. };
  757. NWOverlay = new google.maps.GroundOverlay(
  758. "https://www.countryflags.com/wp-content/uploads/china-flag-png-large.png",
  759. imageBounds2, {clickable: false, opacity: 1}
  760. );
  761. NWOverlay.setMap(this);
  762. });
  763. }
  764. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  765. google.maps.event.addDomListener(mapDiv, "click", () => {
  766. MinimapBtn.current = mapDiv.id;
  767. if (mapDiv.id == "Hybrid")
  768. {
  769. this.setMapTypeId('hybrid');
  770. }
  771. else if (mapDiv.id == "Terrain")
  772. {
  773. this.setMapTypeId('terrain');
  774. }
  775. else if (mapDiv.id == "Satellite")
  776. {
  777. this.setMapTypeId('satellite');
  778. }
  779. else if (mapDiv.id == "Custom")
  780. {
  781. this.setMapTypeId(customMode);
  782. }
  783. else
  784. {
  785. this.setMapTypeId('roadmap');
  786. }
  787. // this.setTilt(45);
  788. for (let ar of presetMinimap)
  789. {
  790. if (ar[1] == mapDiv.id)
  791. {
  792. this.set('styles', ar[0]);
  793. }
  794. }
  795. for (let element of document.getElementsByClassName("preset-minimap")){
  796. if (element.id == MinimapBtn.current)
  797. {
  798. element.style.background = "#ff1493";
  799. }
  800. else
  801. {
  802. element.style.background = "#ff69b4";
  803. }
  804. if (rtded) {
  805. if (element.id == "Borders" || element.id == "Satellite" || element.id == "Terrain" || element.id == "Hybrid" || element.id == "Custom")
  806. {
  807. element.style.backgroundColor = "red";
  808. element.disabled = true;
  809. }
  810. }
  811. }
  812. });
  813. }
  814. for (let mapDiv of document.getElementsByClassName("overlay-minimap")){
  815. google.maps.event.addDomListener(mapDiv, "click", () => {
  816. OverlayBtn.current = mapDiv.id;
  817. // console.log(mapDiv.url)
  818. // console.log(mapDiv.id)
  819. // console.log(mapDiv.loaded)
  820. if (!mapDiv.loaded)
  821. {
  822. this.data.loadGeoJson(mapDiv.url, {
  823. id: mapDiv.id
  824. });
  825. mapDiv.loaded = true;
  826. }
  827. if (mapDiv.id == "Clear")
  828. {
  829. this.overlayMapTypes.clear();
  830. this.data.setStyle(function(feature) {
  831. return GEOJSON_INVISIBLE
  832. });
  833. for (let element of document.getElementsByClassName("overlay-minimap")){
  834. if (element.id === "Clear")
  835. {
  836. element.style.background = "#ff1493";
  837. }
  838. else
  839. {
  840. element.style.background = "#ff69b4";
  841. }
  842. }
  843. }
  844. else
  845. {
  846. if (mapDiv.id == "Coverage" || mapDiv.id == "Official")
  847. {
  848. this.overlayMapTypes.clear();
  849. const coverageLayer = new google.maps.ImageMapType({
  850. getTileUrl ({ x, y }, z) {
  851. // Omits photospheres
  852. // return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:apiv3&style=5,8&x=${x}&y=${y}&z=${z}`
  853.  
  854. // Omits unofficial and trekker, but also half of mongolia
  855. if (mapDiv.id == "Official")
  856. {
  857. return `https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv|cb_client:app&style=5,8&x=${x}&y=${y}&z=${z}`
  858. }
  859. // 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`
  860.  
  861. // Includes everything
  862. else
  863. {
  864. 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`
  865. }
  866. },
  867. maxZoom: 20,
  868. tileSize: new google.maps.Size(256, 256),
  869. })
  870. this.overlayMapTypes.push(coverageLayer);
  871.  
  872. let other = "Official";
  873. if (mapDiv.id == "Official")
  874. {
  875. other = "Coverage"
  876. }
  877.  
  878. mapDiv.style.background = "#ff1493";
  879.  
  880. for (let element of document.getElementsByClassName("overlay-minimap")){
  881. if (element.id === "Clear" || element.id === other)
  882. {
  883. element.style.background = "#ff69b4";
  884. }
  885. }
  886. }
  887. else
  888. {
  889. this.data.setStyle(function(feature) {
  890. return GEOJSON_STYLE
  891. });
  892. for (let element of document.getElementsByClassName("overlay-minimap")){
  893. if (element.id !== "Coverage" && element.id !== "Official")
  894. {
  895. if (element.id !== "Clear" && element.loaded)
  896. {
  897. element.style.background = "#ff1493";
  898. }
  899. else
  900. {
  901. element.style.background = "#ff69b4";
  902. }
  903. }
  904. }
  905. }
  906. }
  907. });
  908. }
  909. }
  910.  
  911. }
  912.  
  913. const svService = new google.maps.StreetViewService();
  914. google.maps.StreetViewPanorama = class extends google.maps.StreetViewPanorama {
  915. constructor(...args) {
  916. super(...args);
  917. GooglePlayer = this;
  918.  
  919. const isGamePage = () => location.pathname.startsWith("/challenge/") || location.pathname.startsWith("/results/") || location.pathname.startsWith("/game/")|| location.pathname.startsWith("/battle-royale/") || location.pathname.startsWith("/duels/") || location.pathname.startsWith("/team-duels/") || location.pathname.startsWith("/bullseye/");
  920.  
  921. this.addListener('position_changed', () => {
  922. // Maybe this could be used to update the position in the other players
  923. // so that they are always in sync
  924. try {
  925. if (!isGamePage()) return;
  926. // timeMachineBtn.panoId = GooglePlayer.pano;
  927. // timeMachineBtn.index = -1;
  928. const lat = this.getPosition().lat();
  929. const lng = this.getPosition().lng();
  930. const { heading } = this.getPov();
  931.  
  932. curPosition = { lat, lng, heading };
  933.  
  934. if (switchCovergeButton.useGoogle)
  935. {
  936. switchCovergeButton.lng = lng;
  937. switchCovergeButton.lat = lat;
  938. switchCovergeButton.heading = heading;
  939. if (!timeMachineBtn.list.some(row => row.includes(GooglePlayer.pano)))
  940. {
  941. timeMachineBtn.innerHTML = "Time Machine";
  942. timeMachineBtn.panoId = GooglePlayer.pano;
  943. timeMachineBtn.index = -1;
  944. timeMachineBtn.plusminusLock = true;
  945. timeMachineNewerBtn.style.backgroundColor = "red";
  946. timeMachineNewerBtn.disabled = true;
  947. timeMachineOlderBtn.style.backgroundColor = "red";
  948. timeMachineOlderBtn.disabled = true;
  949. }
  950. }
  951. switchCovergeButton.useGoogle = true;
  952. teleportBtn.google = true;
  953. // console.log("also run");
  954.  
  955. // switchCovergeButton.heading = position.lat;
  956. // console.log(position.heading);
  957. // console.log(switchCovergeButton.lng);
  958. }
  959. catch (e) {
  960. console.error("GeoGuessr Path Logger Error:", e);
  961. }
  962. });
  963. this.addListener('pov_changed', () => {
  964. const { heading, pitch } = this.getPov();
  965. if (KakaoPlayer) {
  966. if (typeof KakaoPlayer !== 'string' )
  967. {
  968. const vp = KakaoPlayer.getViewpoint();
  969. // Prevent a recursive loop: only update kakao's viewpoint if it got out of sync with google's
  970. if ((!almostEqual(vp.pan, heading) || !almostEqual(vp.tilt, pitch)) && nextPlayer == "Kakao") {
  971. KakaoPlayer.setViewpoint({ pan: heading, tilt: pitch, zoom: vp.zoom });
  972. }
  973. }
  974. }
  975. });
  976. }
  977. };
  978.  
  979.  
  980. var mainMenuBtn = document.createElement("Button");
  981. mainMenuBtn.classList.add("unity-btn");
  982. mainMenuBtn.id = "Show Buttons"
  983. mainMenuBtn.innerHTML = "Geoguessr Unity Script<br><font size=1>by Jupaoqq<br>v5.1.1</font>";
  984. mainMenuBtn.style =
  985. "visibility:hidden;width:6em;height:7em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  986. // document.querySelector(".game-layout__status").appendChild(mainMenuBtn)
  987. document.body.appendChild(mainMenuBtn);
  988. mainMenuBtn.addEventListener("click", () => {
  989. if (hide) {
  990. for (let element of document.getElementsByClassName("unity-btn")){
  991. if (!element.classList.contains("preset-minimap") && !element.classList.contains("overlay-minimap"))
  992. {
  993. element.style.visibility = "";
  994. if ((nextPlayer != "Youtube") && element.id == "Youtube Button")
  995. {
  996. element.style.visibility = "hidden";
  997. }
  998. }
  999. }
  1000. hide = false;
  1001. }
  1002. else {
  1003. for (let element of document.getElementsByClassName("unity-btn")){
  1004. if (element.id !== "Show Buttons")
  1005. {
  1006. element.style.visibility = "hidden";
  1007. }
  1008. }
  1009. hide = true;
  1010. }
  1011. });
  1012.  
  1013. var teleportBtn = document.createElement("Button");
  1014. teleportBtn.classList.add("unity-btn");
  1015. teleportBtn.teleType = "default";
  1016. teleportBtn.id = "Teleport Button";
  1017. teleportBtn.distance = 100;
  1018. teleportBtn.google = true;
  1019. teleportBtn.innerHTML = "Teleport 100m";
  1020. teleportBtn.style =
  1021. "visibility:hidden;width:10em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1022. document.body.appendChild(teleportBtn);
  1023. teleportBtn.addEventListener("click", () => {
  1024. // console.log("Google Teleport");
  1025. if (switchCovergeButton.init)
  1026. {
  1027. // console.log("run");
  1028. switchCovergeButton.init = false;
  1029. if (teleportBtn.google)
  1030. {
  1031. switchCovergeButton.useGoogle = true;
  1032. teleportBtn.google = true;
  1033. }
  1034. else
  1035. {
  1036. switchCovergeButton.useGoogle = false;
  1037. teleportBtn.google = false;
  1038. }
  1039. }
  1040. else
  1041. {
  1042. // console.log(teleportBtn.google)
  1043. if (teleportBtn.google && GooglePlayer != null)
  1044. {
  1045. let heading = GooglePlayer.getPov().heading;
  1046. let place = FindPointAtDistanceFrom(curPosition.lat, curPosition.lng , DegreesToRadians(heading), teleportBtn.distance * 0.001)
  1047. svService.getPanorama({ location: place, radius: 1000, source: teleportBtn.teleType}, svCheck);
  1048. }
  1049. }
  1050. });
  1051.  
  1052. var teleportMoreBtn = document.createElement("Button");
  1053. teleportMoreBtn.classList.add("unity-btn");
  1054. teleportMoreBtn.id = "plus"
  1055. teleportMoreBtn.innerHTML = "+";
  1056. teleportMoreBtn.style =
  1057. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1058. document.body.appendChild(teleportMoreBtn);
  1059. teleportMoreBtn.addEventListener("click", () => {
  1060. if (teleportBtn.distance > 21 && teleportBtn.distance < 149) {
  1061. teleportBtn.distance = teleportBtn.distance + 25;
  1062. }
  1063. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  1064. });
  1065.  
  1066. var teleportLessBtn = document.createElement("Button");
  1067. teleportLessBtn.classList.add("unity-btn");
  1068. teleportLessBtn.id = "minus"
  1069. teleportLessBtn.innerHTML = "-";
  1070. teleportLessBtn.style =
  1071. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1072. document.body.appendChild(teleportLessBtn);
  1073. teleportLessBtn.addEventListener("click", () => {
  1074. if (teleportBtn.distance > 26) {
  1075. teleportBtn.distance = teleportBtn.distance - 25;
  1076. }
  1077. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  1078. });
  1079.  
  1080. var teleportDistResetBtn = document.createElement("Button");
  1081. teleportDistResetBtn.classList.add("unity-btn");
  1082. teleportDistResetBtn.id = "reset"
  1083. teleportDistResetBtn.innerHTML = "Reset Distance";
  1084. teleportDistResetBtn.style =
  1085. "visibility:hidden;width:9em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1086. document.body.appendChild(teleportDistResetBtn);
  1087. teleportDistResetBtn.addEventListener("click", () => {
  1088. teleportBtn.distance = 100;
  1089. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  1090. });
  1091.  
  1092. var switchCovergeButton = document.createElement("Button");
  1093. switchCovergeButton.classList.add("unity-btn");
  1094. switchCovergeButton.id = "switch";
  1095. switchCovergeButton.init = false;
  1096. switchCovergeButton.nextPlayer = "Google";
  1097. switchCovergeButton.useGoogle = false;
  1098. switchCovergeButton.lng = 0
  1099. switchCovergeButton.lat = 0
  1100. switchCovergeButton.heading = 0
  1101. switchCovergeButton.innerHTML = "Switch Coverage";
  1102. switchCovergeButton.small_canvas = false;
  1103. switchCovergeButton.style =
  1104. "visibility:hidden;width:8.5em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1105. document.body.appendChild(switchCovergeButton);
  1106. switchCovergeButton.addEventListener("click", () => {
  1107. let GOOGLE_MAPS_CANVAS1 = document.querySelector(".game-layout__panorama-canvas");
  1108. let GOOGLE_MAPS_CANVAS2 = document.querySelector(".br-game-layout__panorama-canvas");
  1109. let GOOGLE_MAPS_CANVAS3 = document.querySelector(".inactive");
  1110. let GOOGLE_MAPS_CANVAS4 = document.querySelector(".game-panorama_panoramaCanvas__r_5ea");
  1111. let duel = false;
  1112.  
  1113. let GOOGLE_MAPS_CANVAS = null;
  1114. if (GOOGLE_MAPS_CANVAS1 !== null)
  1115. {
  1116. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS1;
  1117. }
  1118. else if (GOOGLE_MAPS_CANVAS2 !== null)
  1119. {
  1120. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS2;
  1121. }
  1122. else if (GOOGLE_MAPS_CANVAS4 !== null)
  1123. {
  1124. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS4;
  1125. }
  1126. if (GOOGLE_MAPS_CANVAS3 !== null)
  1127. {
  1128. duel = true;
  1129. }
  1130.  
  1131. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  1132. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  1133. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player")
  1134. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  1135. let MS_MAPS_CANVAS = document.getElementById("ms-player");
  1136. // if (switchCovergeButton.nextPlayer !== "Baidu") {
  1137. if (switchCovergeButton.useGoogle == false) {
  1138. if (duel)
  1139. {
  1140. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  1141. if (switchCovergeButton.nextPlayer == "Kakao")
  1142. {
  1143. KAKAO_MAPS_CANVAS.className = "inactive";
  1144. }
  1145. else if (switchCovergeButton.nextPlayer == "MS Satellite" || switchCovergeButton.nextPlayer == "MS Streetside")
  1146. {
  1147. MS_MAPS_CANVAS.className = "inactive";
  1148. }
  1149. else
  1150. {
  1151. MAPILLARY_MAPS_CANVAS.className = "inactive";
  1152. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  1153. }
  1154. }
  1155. else
  1156. {
  1157. GOOGLE_MAPS_CANVAS.style.visibility = "";
  1158. if (switchCovergeButton.nextPlayer == "Kakao")
  1159. {
  1160. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  1161. }
  1162. else if (switchCovergeButton.nextPlayer == "Yandex")
  1163. {
  1164. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  1165. }
  1166. else if (switchCovergeButton.nextPlayer == "Baidu")
  1167. {
  1168. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  1169. }
  1170. else if (switchCovergeButton.nextPlayer == "Mapillary" || switchCovergeButton.nextPlayer == "Google")
  1171. {
  1172. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  1173. }
  1174. else if (switchCovergeButton.nextPlayer == "MS Satellite" || switchCovergeButton.nextPlayer == "MS Streetside")
  1175. {
  1176. MS_MAPS_CANVAS.style.visibility = "hidden";
  1177. }
  1178.  
  1179. }
  1180. const lat = GooglePlayer.getPosition().lat();
  1181. const lng = GooglePlayer.getPosition().lng();
  1182. switch_call = true;
  1183. if (!almostEqual2(lat, switchCovergeButton.lat) || !almostEqual2(lat, switchCovergeButton.lng)) {
  1184. svService.getPanorama({ location: { lat: switchCovergeButton.lat, lng: switchCovergeButton.lng }, radius: 1000 }, svCheck);
  1185. }
  1186. switchCovergeButton.useGoogle = true;
  1187. teleportBtn.google = true;
  1188. switchCovergeButton.init = false;
  1189. console.log("use Google");
  1190. }
  1191. else {
  1192. if (duel)
  1193. {
  1194. document.getElementById("default_player").className = "inactive";
  1195. if (switchCovergeButton.nextPlayer == "Kakao")
  1196. {
  1197. KAKAO_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  1198. }
  1199. else if (switchCovergeButton.nextPlayer == "MS Satellite" || switchCovergeButton.nextPlayer == "MS Streetside")
  1200. {
  1201. MS_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  1202. }
  1203. else
  1204. {
  1205. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  1206. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  1207. MapillaryPlayer.resize();
  1208. //window.dispatchEvent(new Event('resize'));
  1209. // document.querySelector(".mapillary-canvas").style.;
  1210. // mapillary-canvas
  1211. }
  1212.  
  1213. }
  1214. else
  1215. {
  1216. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  1217. if (switchCovergeButton.nextPlayer == "Kakao")
  1218. {
  1219. KAKAO_MAPS_CANVAS.style.visibility = "";
  1220. }
  1221. else if (switchCovergeButton.nextPlayer == "Yandex")
  1222. {
  1223. YANDEX_MAPS_CANVAS.style.visibility = "";
  1224. }
  1225. else if (switchCovergeButton.nextPlayer == "Baidu")
  1226. {
  1227. BAIDU_MAPS_CANVAS.style.visibility = "";
  1228. }
  1229. else if (switchCovergeButton.nextPlayer == "Mapillary" || switchCovergeButton.nextPlayer == "Google" )
  1230. {
  1231. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  1232. }
  1233. else if (switchCovergeButton.nextPlayer == "MS Satellite" || switchCovergeButton.nextPlayer == "MS Streetside")
  1234. {
  1235. MS_MAPS_CANVAS.style.visibility = "";
  1236. }
  1237. }
  1238. switchCovergeButton.useGoogle = false;
  1239. teleportBtn.google = false;
  1240. switchCovergeButton.init = true;
  1241. console.log("use Others");
  1242. }
  1243. // }
  1244. // else {
  1245. // switchCovergeButton.useGoogle = false;
  1246. // teleportBtn.google = false;
  1247. // console.log("use Others");
  1248. // }
  1249.  
  1250. });
  1251.  
  1252. var timeMachineNewerBtn = document.createElement("Button");
  1253. timeMachineNewerBtn.classList.add("unity-btn");
  1254. timeMachineNewerBtn.id = "plus year"
  1255. timeMachineNewerBtn.innerHTML = "+";
  1256. timeMachineNewerBtn.style =
  1257. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1258. document.body.appendChild(timeMachineNewerBtn);
  1259. timeMachineNewerBtn.addEventListener("click", () => {
  1260. if (timeMachineBtn.index < timeMachineBtn.list.length - 1 && !timeMachineBtn.plusminusLock) {
  1261. timeMachineBtn.index = timeMachineBtn.index + 1;
  1262. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  1263. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1264. // console.log(timeMachineBtn.index)
  1265. }
  1266. GenBtnColor();
  1267.  
  1268. });
  1269.  
  1270. var timeMachineOlderBtn = document.createElement("Button");
  1271. timeMachineOlderBtn.classList.add("unity-btn");
  1272. timeMachineOlderBtn.id = "minus year"
  1273. timeMachineOlderBtn.innerHTML = "-";
  1274. timeMachineOlderBtn.style =
  1275. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1276. document.body.appendChild(timeMachineOlderBtn);
  1277. timeMachineOlderBtn.addEventListener("click", () => {
  1278. if (timeMachineBtn.index > 0 && !timeMachineBtn.plusminusLock) {
  1279. timeMachineBtn.index = timeMachineBtn.index - 1;
  1280. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  1281. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1282. // console.log(timeMachineBtn.index)
  1283. }
  1284. GenBtnColor();
  1285. });
  1286.  
  1287. function svCheck2(data, status) {
  1288. let l = []
  1289. if (status === 'OK') {
  1290. // console.log("OK for " + data.location.latLng + " at ID " + data.location.pano);
  1291. // console.log(data.time)
  1292. for (const alt of data.time) {
  1293. let date = Object.values(alt).find((value) => value instanceof Date)
  1294.  
  1295. l.push([alt.pano, date.toDateString()]);
  1296. }
  1297. // console.log(l);
  1298. timeMachineBtn.list = l
  1299. timeMachineBtn.index = l.length - 1;
  1300. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1301. GenBtnColor();
  1302. timeMachineBtn.plusminusLock = false;
  1303. // timeMachineOlderBtn.click()
  1304. // timeMachineBtn.innerHTML = "Default Date";
  1305. }
  1306. }
  1307.  
  1308. var timeMachineBtn = document.createElement("Button");
  1309. timeMachineBtn.classList.add("unity-btn");
  1310. timeMachineBtn.id = "Date Button";
  1311. timeMachineBtn.plusminusLock = true;
  1312. timeMachineBtn.panoId = 0;
  1313. timeMachineBtn.index = -1;
  1314. timeMachineBtn.list = [];
  1315. timeMachineBtn.innerHTML = "Time Machine";
  1316. timeMachineBtn.style =
  1317. "visibility:hidden;width:10em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1318. document.body.appendChild(timeMachineBtn);
  1319. timeMachineBtn.addEventListener("click", () => {
  1320. // console.log(timeMachineBtn.index)
  1321. if (timeMachineBtn.panoId != 0)
  1322. {
  1323. if(timeMachineBtn.index == -1)
  1324. {
  1325. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  1326. }
  1327. else
  1328. {
  1329. timeMachineBtn.index = timeMachineBtn.list.length - 1;
  1330. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  1331. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1332. GenBtnColor();
  1333. }
  1334. }
  1335. else
  1336. {
  1337. timeMachineBtn.panoId = GooglePlayer.pano;
  1338. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  1339. }
  1340. });
  1341.  
  1342. // Battle Royale UI optimization
  1343.  
  1344. let hide = true;
  1345.  
  1346. var MinimapBtn = document.createElement("Button");
  1347. MinimapBtn.classList.add("unity-btn");
  1348. MinimapBtn.id = "Minimap Button";
  1349. MinimapBtn.innerHTML = "Minimap Style";
  1350. MinimapBtn.current = "Default";
  1351. MinimapBtn.childVisible = false;
  1352. MinimapBtn.style =
  1353. "visibility:hidden;width:7.25em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1354. document.body.appendChild(MinimapBtn);
  1355. MinimapBtn.addEventListener("click", () => {
  1356. if (MinimapBtn.childVisible)
  1357. {
  1358. for (let element of document.getElementsByClassName("preset-minimap")){
  1359. element.style.visibility="hidden";
  1360. }
  1361. MinimapBtn.childVisible = false;
  1362. }
  1363. else
  1364. {
  1365. for (let element of document.getElementsByClassName("preset-minimap")){
  1366. element.style.visibility="";
  1367. }
  1368. MinimapBtn.childVisible = true;
  1369. }
  1370.  
  1371. });
  1372.  
  1373.  
  1374. let HeightCount = 0
  1375. for (let a of presetMinimap)
  1376. {
  1377. let aButton = document.createElement("Button");
  1378. aButton.id = a[1];
  1379. aButton.classList.add("preset-minimap");
  1380. aButton.classList.add("unity-btn");
  1381. aButton.innerHTML = a[1];
  1382. aButton.style =
  1383. "visibility:hidden;width:7.25em;height:1.5em;position:absolute;z-index:99999;background-color: #ff69b4;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1384. document.body.appendChild(aButton);
  1385. HeightCount++;
  1386. }
  1387.  
  1388. var OverlayBtn = document.createElement("Button");
  1389. OverlayBtn.classList.add("unity-btn");
  1390. OverlayBtn.id = "Overlay Button";
  1391. OverlayBtn.innerHTML = "Overlay";
  1392. OverlayBtn.current = "Clear";
  1393. OverlayBtn.childVisible = false;
  1394. OverlayBtn.style =
  1395. "visibility:hidden;width:7.25em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1396. document.body.appendChild(OverlayBtn);
  1397.  
  1398. OverlayBtn.addEventListener("click", () => {
  1399. if (OverlayBtn.childVisible)
  1400. {
  1401. for (let element of document.getElementsByClassName("overlay-minimap")){
  1402. element.style.visibility = "hidden";
  1403. }
  1404. OverlayBtn.childVisible = false;
  1405. }
  1406. else
  1407. {
  1408. for (let element of document.getElementsByClassName("overlay-minimap")){
  1409. element.style.visibility = "";
  1410. }
  1411. OverlayBtn.childVisible = true;
  1412. }
  1413.  
  1414. });
  1415.  
  1416. let HeightCount2 = 0
  1417. for (let b of presetOverlay)
  1418. {
  1419. let bButton = document.createElement("Button");
  1420. bButton.id = b[0];
  1421. bButton.url = b[1];
  1422. bButton.loaded = false;
  1423. bButton.classList.add("overlay-minimap");
  1424. bButton.classList.add("unity-btn");
  1425. bButton.innerHTML = b[0];
  1426. bButton.style =
  1427. "visibility:hidden;width:7.25em;height:1.5em;position:absolute;z-index:99999;background-color: #ff69b4;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1428. if (bButton.id == "Clear")
  1429. {
  1430. bButton.loaded = true;
  1431. bButton.style.background = "#ff1493";
  1432. }
  1433. document.body.appendChild(bButton);
  1434. HeightCount2++;
  1435. }
  1436.  
  1437. var HelpBtn = document.createElement("Button");
  1438. HelpBtn.classList.add("unity-btn");
  1439. HelpBtn.id = "Help Button";
  1440. HelpBtn.innerHTML = "Script Help";
  1441. HelpBtn.style =
  1442. "visibility:hidden;width:6em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1443. document.body.appendChild(HelpBtn);
  1444. HelpBtn.addEventListener("click", () => {
  1445. window.open('https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing');
  1446. });
  1447.  
  1448. var TeleportArisBtn = document.createElement("Button");
  1449. TeleportArisBtn.classList.add("unity-btn");
  1450. TeleportArisBtn.id = "Teleport Options Button";
  1451. TeleportArisBtn.innerHTML = "Default";
  1452. TeleportArisBtn.style =
  1453. "visibility:hidden;width:5.5em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1454. document.body.appendChild(TeleportArisBtn);
  1455. TeleportArisBtn.addEventListener("click", () => {
  1456. if (teleportBtn.teleType == "default")
  1457. {
  1458. teleportBtn.teleType = "outdoor"
  1459. TeleportArisBtn.innerHTML = "Official";
  1460. }
  1461. else
  1462. {
  1463. teleportBtn.teleType = "default"
  1464. TeleportArisBtn.innerHTML = "Default";
  1465. }
  1466. });
  1467.  
  1468. var playYoutubeBtn = document.createElement("Button");
  1469. playYoutubeBtn.classList.add("unity-btn");
  1470. playYoutubeBtn.id = "Youtube Button";
  1471. playYoutubeBtn.innerHTML = "Play video";
  1472. playYoutubeBtn.style =
  1473. "visibility:hidden;width:6em;height:4.5em;position:absolute;z-index:999999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1474. document.body.appendChild(playYoutubeBtn);
  1475. playYoutubeBtn.addEventListener("click", () => {
  1476. let iframe = document.getElementById("i_container");
  1477. iframe.style.position = "absolute";
  1478. iframe.allow = "autoplay";
  1479. let srcString = "https://www.youtube.com/embed/" + yId + "?&playlist=" + yId + "&autoplay=1&modestbranding=1&controls=0&start=";
  1480. if (yTime == "0" && yEnd == "0")
  1481. {
  1482. }
  1483. else
  1484. {
  1485. srcString += yTime + "&end=" + yEnd;
  1486. }
  1487. iframe.src = srcString;
  1488. iframe.style.visibility = "";
  1489. playYoutubeBtn.innerHTML = "Play video from start";
  1490. });
  1491.  
  1492.  
  1493. console.log("Script buttons Loaded");
  1494. }
  1495.  
  1496. function GenBtnColor()
  1497. {
  1498. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1499. if (timeMachineBtn.index == timeMachineBtn.list.length - 1)
  1500. {
  1501. timeMachineNewerBtn.style.backgroundColor = "red";
  1502. timeMachineNewerBtn.disabled = true;
  1503. }
  1504. else
  1505. {
  1506. timeMachineNewerBtn.style.backgroundColor = "#BF40BF";
  1507. timeMachineNewerBtn.disabled = false;
  1508. }
  1509. if (timeMachineBtn.index == 0)
  1510. {
  1511. timeMachineOlderBtn.style.backgroundColor = "red";
  1512. timeMachineOlderBtn.disabled = true;
  1513. }
  1514. else
  1515. {
  1516. timeMachineOlderBtn.style.backgroundColor = "#BF40BF";
  1517. timeMachineOlderBtn.disabled = false;
  1518. }
  1519. }
  1520.  
  1521. /**
  1522. * Handle Keyboard inputs
  1523. */
  1524.  
  1525. function kBoard()
  1526. {
  1527. document.addEventListener('keydown', logKey);
  1528. }
  1529.  
  1530. function logKey(e) {
  1531. // console.log(e.code);
  1532. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1533. if (e.code == "Space")
  1534. {
  1535. setHidden(true);
  1536. }
  1537. if (e.code == "Digit3")
  1538. {
  1539. teleportBtn.click();
  1540. }
  1541. else if (e.code == "Digit4")
  1542. {
  1543. timeMachineOlderBtn.click();
  1544. }
  1545. else if (e.code == "Digit5")
  1546. {
  1547. timeMachineBtn.click();
  1548. }
  1549. else if (e.code == "Digit6")
  1550. {
  1551. timeMachineNewerBtn.click();
  1552. }
  1553. else if (e.code == "Digit7")
  1554. {
  1555. if (mainMenuBtn.style.visibility == "hidden")
  1556. {
  1557. mainMenuBtn.style.visibility = "";
  1558. }
  1559. else
  1560. {
  1561. mainMenuBtn.style.visibility = "hidden";
  1562. }
  1563. }
  1564. }
  1565.  
  1566.  
  1567. /**
  1568. * Hide or reveal the buttons, and disable buttons if such feature is not available
  1569. */
  1570.  
  1571. function setHidden(cond)
  1572. {
  1573. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1574. if (cond)
  1575. {
  1576. if (mainMenuBtn != null)
  1577. {
  1578. if (teleportBtn != null)
  1579. {
  1580. for (let element of document.getElementsByClassName("unity-btn")){
  1581. element.style.visibility = "hidden";
  1582. }
  1583. }
  1584. let iframe = document.getElementById("i_container");
  1585. if (iframe != null)
  1586. {
  1587. if (!isBattleRoyale)
  1588. {
  1589. iframe.src = ""
  1590. }
  1591. else
  1592. {
  1593. // TODO
  1594. }
  1595. }
  1596. }
  1597. }
  1598. else
  1599. {
  1600. if (mainMenuBtn != null)
  1601. {
  1602. mainMenuBtn.style.visibility = "";
  1603. }
  1604. }
  1605. }
  1606.  
  1607. function setDisable(cond) {
  1608. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1609. function setAll(cond1, cond2)
  1610. {
  1611. teleportMoreBtn.style.backgroundColor = cond1;
  1612. teleportMoreBtn.disabled = cond2;
  1613. teleportLessBtn.style.backgroundColor = cond1;
  1614. teleportLessBtn.disabled = cond2;
  1615. teleportDistResetBtn.style.backgroundColor = cond1;
  1616. teleportDistResetBtn.disabled = cond2;
  1617. switchCovergeButton.style.backgroundColor = cond1;
  1618. switchCovergeButton.disabled = cond2;
  1619. teleportBtn.style.backgroundColor = cond1;
  1620. teleportBtn.disabled = cond2;
  1621. TeleportArisBtn.style.backgroundColor = cond1;
  1622. TeleportArisBtn.disabled = cond2;
  1623. timeMachineBtn.style.backgroundColor = cond1;
  1624. timeMachineBtn.disabled = cond2;
  1625. }
  1626.  
  1627. function setMapstyle(cond1, cond2)
  1628. {
  1629. for (let mapDiv of document.getElementsByClassName("preset-minimap"))
  1630. {
  1631. if (mapDiv.id == "Borders" || mapDiv.id == "Satellite" || mapDiv.id == "Terrain" || mapDiv.id == "Hybrid" || mapDiv.id == "Custom")
  1632. {
  1633. mapDiv.style.backgroundColor = cond1;
  1634. mapDiv.disabled = cond2;
  1635. }
  1636. }
  1637. for (let mapDiv2 of document.getElementsByClassName("overlay-minimap"))
  1638. {
  1639. if (mapDiv2.id == "Coverage" || mapDiv2.id == "Official")
  1640. {
  1641. mapDiv2.style.backgroundColor = cond1;
  1642. mapDiv2.disabled = cond2;
  1643. }
  1644. }
  1645. }
  1646.  
  1647. if (teleportBtn != null) {
  1648. if (rtded) {
  1649. setAll("red", true);
  1650. setMapstyle("red", true)
  1651. }
  1652. else
  1653. {
  1654. setMapstyle("#ff69b4", false)
  1655. if (cond == "NMPZ") {
  1656. setAll("red", true);
  1657. timeMachineBtn.style.backgroundColor = "#BF40BF";
  1658. timeMachineBtn.disabled = false;
  1659. }
  1660. else if (cond == "Google") {
  1661. setAll("#BF40BF", false);
  1662. }
  1663. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  1664. setAll("red", true);
  1665. switchCovergeButton.style.backgroundColor = "#BF40BF";
  1666. switchCovergeButton.disabled = false;
  1667. }
  1668. else if (cond == "Kakao" || cond == "Yandex" || cond == "Mapillary" || cond == "MS Streetside") {
  1669. setAll("#BF40BF", false);
  1670. timeMachineBtn.style.backgroundColor = "red";
  1671. timeMachineBtn.disabled = true;
  1672. }
  1673. else if (cond == "MS Satellite") {
  1674. setAll("red", true);
  1675. }
  1676. }
  1677. timeMachineNewerBtn.style.backgroundColor = "red";
  1678. timeMachineNewerBtn.disabled = true;
  1679. timeMachineOlderBtn.style.backgroundColor = "red";
  1680. timeMachineOlderBtn.disabled = true;
  1681. }
  1682. }
  1683.  
  1684.  
  1685. /**
  1686. * This observer stays alive while the script is running
  1687. */
  1688.  
  1689. function launchObserver() {
  1690. UnityInitiate();
  1691. handleTeleport();
  1692. SyncListener();
  1693. kBoard();
  1694. console.log("Main Observer");
  1695. const OBSERVER = new MutationObserver((mutations, observer) => {
  1696. detectGamePage();
  1697. });
  1698. observerCallback(OBSERVER)
  1699. }
  1700. function observerCallback(obs)
  1701. {
  1702. if (obs)
  1703. {
  1704. obs.observe(document.head, { attributes: true, childList: true, subtree: true });
  1705. }
  1706. else
  1707. {
  1708. setTimeout(observerCallback, 250);
  1709. }
  1710. }
  1711.  
  1712. /**
  1713. * Once the Google Maps API was loaded we can do more stuff
  1714. */
  1715.  
  1716. window.addEventListener('DOMContentLoaded', (event) => {
  1717. injecter(() => {
  1718. launchObserver();
  1719. })
  1720. });
  1721.  
  1722. const base62 = {
  1723. charset: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  1724. .split(''),
  1725. encode: integer => {
  1726. if (integer === 0) {
  1727. return 0;
  1728. }
  1729. let s = [];
  1730. while (integer > 0) {
  1731. s = [base62.charset[integer % 62], ...s];
  1732. integer = Math.floor(integer / 62);
  1733. }
  1734. return s.join('');
  1735. },
  1736. decode: chars => chars.split('').reverse().reduce((prev, curr, i) =>
  1737. prev + (base62.charset.indexOf(curr) * (62 ** i)), 0)
  1738. };
  1739.  
  1740.  
  1741. /**
  1742. * Check whether the current page is a game, if so which game mode
  1743. */
  1744.  
  1745. function detectGamePage() {
  1746. if (document.querySelector(".game-layout__panorama-message") !== null && !one_reset)
  1747. {
  1748. one_reset = true;
  1749. console.log("Hide fail to load panorama canvas");
  1750. document.querySelector(".game-layout__panorama-message").style.visibility = "hidden";
  1751. }
  1752. function loadModule()
  1753. {
  1754. if (toLoad) {
  1755. initializeCanvas();
  1756. }
  1757. waitLoad();
  1758. }
  1759. let toLoad = !playerLoaded && !YandexPlayer && !KakaoPlayer && !MapillaryPlayer && !MSStreetPlayer && !YANDEX_INJECTED && !KAKAO_INJECTED && !MAPILLARY_INJECTED && !MS_INJECTED
  1760. const PATHNAME = window.location.pathname;
  1761. if (PATHNAME.startsWith("/game/") || PATHNAME.startsWith("/challenge/")) {
  1762. // console.log("Game page");
  1763. isBattleRoyale = false;
  1764. isDuel = false;
  1765. loadModule();
  1766. }
  1767. else if (PATHNAME.startsWith("/battle-royale/")) {
  1768. if (document.querySelector(".br-game-layout") == null) {
  1769. // console.log("Battle Royale Lobby");
  1770. rstValues();
  1771. }
  1772. else {
  1773. // console.log("Battle Royale");
  1774. isBattleRoyale = true;
  1775. isDuel = false;
  1776. loadModule();
  1777. }
  1778. }
  1779. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  1780. if (document.querySelector(".game_layout__TO_jf") == null) {
  1781. // console.log("Battle Royale Lobby");
  1782. rstValues();
  1783. }
  1784. else {
  1785. // console.log("Duels");
  1786. isBattleRoyale = true;
  1787. isDuel = true;
  1788. loadModule();
  1789. }
  1790. }
  1791. else if (PATHNAME.startsWith("/bullseye/")) {
  1792. if (document.querySelector(".game_layout__0vAWj") == null) {
  1793. // console.log("Battle Royale Lobby");
  1794. rstValues();
  1795. }
  1796. else {
  1797. // console.log("bullseye");
  1798. isBattleRoyale = true;
  1799. isBullseye = true;
  1800. loadModule();
  1801. }
  1802. }
  1803. else {
  1804. rstValues();
  1805. //console.log("Not a Game page");
  1806. }
  1807. }
  1808.  
  1809. function rstValues()
  1810. {
  1811. ROUND = 0;
  1812. YandexPlayer = null;
  1813. KakaoPlayer = null;
  1814. MapillaryPlayer = null;
  1815. MSStreetPlayer = null;
  1816.  
  1817. BAIDU_INJECTED = false;
  1818. YANDEX_INJECTED = false;
  1819. KAKAO_INJECTED = false;
  1820. MAPILLARY_INJECTED = false;
  1821. MS_INJECTED = false;
  1822.  
  1823. nextPlayer = "Google"
  1824. global_lat = 0;
  1825. global_lng = 0;
  1826. global_panoID = null;
  1827. global_BDAh = null;
  1828. global_BDBh = null;
  1829. global_BDID = null;
  1830. yId = null;
  1831. yTime = null;
  1832. yEnd = null;
  1833. iId = null;
  1834.  
  1835. COMPASS = null;
  1836. eventListenerAttached = false;
  1837. povListenerAttached = false;
  1838. playerLoaded = false;
  1839. locHistory = [];
  1840. one_reset = false;
  1841. setHidden(true);
  1842. yandex_map = false;
  1843. Kakao_map = false;
  1844. mmKey = 0;
  1845. CURRENT_ROUND_DATA = null;
  1846. ms_radius = 10000;
  1847.  
  1848. isDuel = false;
  1849. isBattleRoyale = false;
  1850. isBullseye = false;
  1851.  
  1852. BR_LOAD_KAKAO = false;
  1853. BR_LOAD_YANDEX = false;
  1854. BR_LOAD_MS = false;
  1855.  
  1856. ms_sat_map = false;
  1857. rtded = false;
  1858.  
  1859. linksList = [];
  1860.  
  1861. NM = false;
  1862. NP = false;
  1863. NZ = false;
  1864. }
  1865.  
  1866. /**
  1867. * Wait for various players to load
  1868. */
  1869.  
  1870. function waitLoad() {
  1871. if (!YandexPlayer || !KakaoPlayer || !MapillaryPlayer || !MSStreetPlayer || !YANDEX_INJECTED || !KAKAO_INJECTED || !MAPILLARY_INJECTED || !MS_INJECTED) {
  1872. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1873.  
  1874. if (document.querySelector(".ticket-bar_root__H8RcX") != null)
  1875. {
  1876. if (document.querySelector(".br-game-layout__panorama-canvas") != null)
  1877. {
  1878. AdjustBtnPos("-2em + 2px", "300px");
  1879. }
  1880. else if (document.querySelector(".game-panorama_panorama__rdhFg") != null)
  1881. {
  1882. AdjustBtnPos("6em", "0em");
  1883. }
  1884. else if (document.querySelector(".game-panorama_panorama__ncMwh") != null)
  1885. {
  1886. AdjustBtnPos("5em", "18.5em");
  1887. }
  1888. else
  1889. {
  1890. AdjustBtnPos("4em", "0em");
  1891. }
  1892. }
  1893. else
  1894. {
  1895. if (document.querySelector(".br-game-layout__panorama-canvas") != null)
  1896. {
  1897. AdjustBtnPos("-6em + 2px", "300px");
  1898. }
  1899. else if (document.querySelector(".game-panorama_panorama__rdhFg") != null)
  1900. {
  1901. AdjustBtnPos("2em", "0em");
  1902. }
  1903. else if (document.querySelector(".game-panorama_panorama__ncMwh") != null)
  1904. {
  1905. AdjustBtnPos("1em", "18.5em");
  1906. }
  1907. else
  1908. {
  1909. AdjustBtnPos("0em", "0em");
  1910. }
  1911. }
  1912. setTimeout(waitLoad, 250);
  1913. } else {
  1914. checkRound();
  1915. }
  1916. }
  1917.  
  1918. /**
  1919. * Checks for round changes
  1920. */
  1921.  
  1922. function checkRound() {
  1923. // console.log("Check Round");
  1924. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1925.  
  1926. if (!isBattleRoyale) {
  1927. // console.log("Check Round");
  1928. let currentRound = getRoundFromPage();
  1929. if (ROUND != currentRound) {
  1930. fire1 = true;
  1931. switchCovergeButton.init = true;
  1932. console.log("New round");
  1933. ROUND = currentRound;
  1934. // NEW_ROUND_LOADED = true;
  1935. COMPASS = null;
  1936. locHistory = [];
  1937. one_reset = false;
  1938. getMapData();
  1939. nextButtonCallback();
  1940. }
  1941. }
  1942. else {
  1943. getMapData();
  1944. }
  1945. }
  1946.  
  1947. /**
  1948. * Add listeners if buttons have been created
  1949. */
  1950.  
  1951. function finalDetail()
  1952. {
  1953. let target = document.querySelector("a[data-qa='play-same-map']");
  1954. if (target)
  1955. {
  1956. var div = document.createElement("div");
  1957. div.classList.add("buttons_buttons__0B3SB")
  1958. document.querySelector('.result-layout_content__jAHfP').appendChild(div);
  1959. for (var rd of linksList)
  1960. {
  1961. // console.log(rd)
  1962. let cl = target.cloneNode( true );
  1963. let tx = "View R" + rd[0] + " in " + rd[1];
  1964. cl.querySelector('.button_label__kpJrA').innerHTML = tx;
  1965. cl.removeAttribute('data-qa');
  1966. cl.removeAttribute('href');
  1967. cl.urlStr = rd[2];
  1968. cl.addEventListener("click", (e) => {
  1969. window.open(cl.urlStr);
  1970. })
  1971. cl.style = "top:10px;right:-10px;";
  1972. div.appendChild(cl);
  1973. }
  1974. }
  1975. else
  1976. {
  1977. setTimeout(finalDetail, 500);
  1978. }
  1979. }
  1980.  
  1981. function nextButtonCallback()
  1982. {
  1983. let nextButton = document.querySelector("button[data-qa='close-round-result']");
  1984. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  1985. if (nextButton != null && fire1)
  1986. {
  1987. fire1 = false;
  1988. nextButton.addEventListener("click", (e) => {
  1989. if (mainMenuBtn != null && !cn_tips && ROUND !== 5)
  1990. {
  1991. // console.log("try to show show buttons")
  1992. mainMenuBtn.style.visibility = "";
  1993. }
  1994. if (ROUND == 5)
  1995. {
  1996. console.log("Game Finished")
  1997. if (linksList)
  1998. {
  1999. finalDetail();
  2000. }
  2001. }
  2002. })
  2003. let urlStr = ""
  2004.  
  2005. if (nextPlayer !== "Google")
  2006. {
  2007. console.log("Clone buttons");
  2008. let clone = document.querySelector("button[data-qa='close-round-result']").cloneNode( true );
  2009. let tx = "View Location in " + nextPlayer;
  2010. clone.querySelector('.button_label__kpJrA').innerHTML = tx;
  2011. clone.setAttribute('id', "LinkBtn");
  2012. clone.removeAttribute('data-qa');
  2013. if (nextPlayer == "Baidu")
  2014. {
  2015. urlStr = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  2016. }
  2017. else if (nextPlayer == "Youtube")
  2018. {
  2019. urlStr = "https://www.youtube.com/watch?v=" + yId;
  2020. }
  2021. else if (nextPlayer == "Image")
  2022. {
  2023. urlStr = iId;
  2024. }
  2025. else if (nextPlayer == "Kakao")
  2026. {
  2027. urlStr = "https://map.kakao.com/link/roadview/" + global_lat + "," + global_lng;
  2028. }
  2029. else if (nextPlayer == "Mapillary")
  2030. {
  2031. urlStr = "https://www.mapillary.com/app/?pKey=" + mmKey + "&focus=photo";
  2032. }
  2033. else if (nextPlayer == "Yandex")
  2034. {
  2035. urlStr = "https://yandex.com/maps/?&panorama%5Bdirection%5D=16%2C0&panorama%5Bpoint%5D=" + global_lng + "%2C" + global_lat;
  2036. }
  2037. else if (nextPlayer == "MS Satellite" || nextPlayer == "MS Streetside")
  2038. {
  2039. urlStr = "https://bing.com/maps/default.aspx?cp=" + global_lat + "~" + global_lng + "&lvl=20&style=r";
  2040. }
  2041. clone.addEventListener("click", (e) => {
  2042. window.open(urlStr);
  2043. })
  2044. if (ROUND == 5)
  2045. {
  2046. clone.style = "top:10px;";
  2047. }
  2048. else
  2049. {
  2050. clone.style = "right:-10px;";
  2051. }
  2052. linksList.push([ROUND, nextPlayer, urlStr]);
  2053. document.querySelector('.round-result_actions__5j26U').appendChild(clone);
  2054. }
  2055. }
  2056. else
  2057. {
  2058. setTimeout(nextButtonCallback, 500);
  2059. }
  2060. }
  2061.  
  2062. function guessButtonCallback()
  2063. {
  2064. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2065. let guessButton = document.querySelector("button[data-qa='perform-guess']");
  2066. if (guessButton != null)
  2067. {
  2068.  
  2069. guessButton.addEventListener("click", (e) => {
  2070. if (mainMenuBtn != null)
  2071. {
  2072. console.log("try to hide show buttons")
  2073. mainMenuBtn.style.visibility = "hidden";
  2074. setHidden(true);
  2075. }
  2076. })
  2077. }
  2078. else
  2079. {
  2080. setTimeout(guessButtonCallback, 500);
  2081. }
  2082. }
  2083.  
  2084. /**
  2085. * Load different streetview players
  2086. */
  2087.  
  2088. function loaderChecker(data)
  2089. {
  2090. // console.log(data);
  2091. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2092. if (data.includes("A United World") || data.includes("A Unity World") || data.includes("Unity Test"))
  2093. {
  2094. console.log("Complete Map");
  2095. data = "Yandex Bing Streetside Kakao";
  2096. }
  2097.  
  2098. if (data.includes("Yandex"))
  2099. {
  2100. console.log("Yandex Map");
  2101. yandex_map = true;
  2102. injectYandexScript().then(() => {
  2103. console.log("Ready to inject Yandex player");
  2104. injectYandexPlayer();
  2105. }).catch((error) => {
  2106. console.log(error);
  2107. });
  2108. BR_LOAD_YANDEX = true;
  2109. }
  2110. else
  2111. {
  2112. console.log("Not Yandex map");
  2113. YANDEX_INJECTED = true;
  2114. YandexPlayer = "YD";
  2115. }
  2116.  
  2117. if (data.includes("Bing Streetside"))
  2118. {
  2119. console.log("Bing Streetside Map");
  2120. injectMSPlayer();
  2121. BR_LOAD_MS = true;
  2122. }
  2123. else if (data.includes("Bing Satellite"))
  2124. {
  2125. ms_sat_map = true;
  2126. console.log("Bing Satellite Map");
  2127. let tempRad = data.split("Bing Satellite")[1];
  2128. if (/\d/.test(tempRad))
  2129. {
  2130. ms_radius = parseInt(tempRad.replace(/\D/g,'')) * 1000;
  2131. }
  2132. injectMSPlayer();
  2133. BR_LOAD_MS = true;
  2134. }
  2135. else
  2136. {
  2137. console.log("Not Bing map");
  2138. MS_INJECTED = true;
  2139. MSStreetPlayer = "MS";
  2140. }
  2141.  
  2142. if (data.includes("Kakao"))
  2143. {
  2144. console.log("Kakao Map");
  2145. Kakao_map = true;
  2146. injectKakaoScript().then(() => {
  2147. console.log("Ready to inject Kakao player");
  2148. }).catch((error) => {
  2149. console.log(error);
  2150. });
  2151. BR_LOAD_KAKAO = true;
  2152. }
  2153. else{
  2154. KAKAO_INJECTED = true;
  2155. KakaoPlayer = "KK";
  2156. console.log("Not Kakao map");
  2157. }
  2158.  
  2159. if (!data.includes("China Tips for each province"))
  2160. {
  2161. cn_tips = false;
  2162. mainMenuBtn.style.visibility = "";
  2163. setHidden(false);
  2164. }
  2165. else
  2166. {
  2167. cn_tips = true;
  2168. guaranteeUI();
  2169. }
  2170.  
  2171. }
  2172.  
  2173. function loadPlayers() {
  2174. playerLoaded = true;
  2175. injectContainer();
  2176. getSeed().then((data) => {
  2177. // console.log(data)
  2178. let map_name = "Default"
  2179. if (typeof data.isRated !== 'undefined')
  2180. {
  2181. rtded = data.isRated;
  2182. }
  2183. if (rtded)
  2184. {
  2185. map_name = "Public Game";
  2186. }
  2187. else
  2188. {
  2189. if (!isBattleRoyale)
  2190. {
  2191. map_name = data.mapName;
  2192. }
  2193. else
  2194. {
  2195. if (isBullseye)
  2196. {
  2197. map_name = data.mapName;
  2198. }
  2199. else if (isDuel)
  2200. {
  2201. map_name = data.options.map.name;
  2202. }
  2203. else
  2204. {
  2205. map_name = "Unity Test";
  2206. }
  2207. }
  2208. }
  2209. loaderChecker(map_name)
  2210.  
  2211. }).catch((error) => {
  2212. console.log(error);
  2213. });
  2214.  
  2215. }
  2216.  
  2217. function guaranteeUI()
  2218. {
  2219. // console.log("UI")
  2220. if (document.getElementById("GH-ui") !== null)
  2221. {
  2222. document.getElementById("GH-ui").style.display = "block";
  2223. }
  2224. else
  2225. {
  2226. setTimeout(guaranteeUI, 500);
  2227. }
  2228. }
  2229.  
  2230. /**
  2231. * Handles Return to start and undo
  2232. */
  2233.  
  2234. function handleReturnToStart() {
  2235. let rtsButton = document.querySelector("button[data-qa='return-to-start']");
  2236. console.log("Handle Return to start");
  2237. rtsButton.addEventListener("click", (e) => {
  2238. if (nextPlayer !== "Baidu")
  2239. {
  2240. goToLocation();
  2241. }
  2242. else
  2243. {
  2244. document.getElementById("i_container").src = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  2245. }
  2246. const elementClicked = e.target;
  2247. elementClicked.setAttribute('listener', 'true');
  2248. console.log("Return to start");
  2249. });
  2250. guessButtonCallback();
  2251. // setTimeout(function () {goToLocation();}, 1000);
  2252.  
  2253.  
  2254. }
  2255.  
  2256. function handleUndo() {
  2257. let undoButton = document.querySelector("button[data-qa='undo-move']");
  2258. console.log("Handle undo");
  2259. undoButton.addEventListener("click", (e) => {
  2260. if (locHistory.length > 0) {
  2261. goToUndoMove();
  2262. console.log("Undo Move");
  2263. }
  2264. })
  2265. }
  2266.  
  2267. /**
  2268. * Load game information
  2269. */
  2270.  
  2271. function getMapData() {
  2272. // myHighlight("Seed data");
  2273.  
  2274. function modularget(data)
  2275. {
  2276. locationCheck(data);
  2277. if (data.currentRoundNumber == 1 && nextPlayer == "Kakao")
  2278. {
  2279. setTimeout(function () {goToLocation();}, 3000);
  2280. }
  2281. else
  2282. {
  2283. goToLocation();
  2284. }
  2285.  
  2286. handleMinimapCallback();
  2287. handleButtons();
  2288. }
  2289. getSeed().then((data) => {
  2290. // myHighlight("Seed data");
  2291. // console.log(data);
  2292. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2293. if (isBattleRoyale) {
  2294. if (data.status == "Finished" || typeof data.gameId == typeof undefined) {
  2295. // console.log("Battle Royale Lobby");
  2296. }
  2297. else
  2298. {
  2299. let origin = false;
  2300. if (!CURRENT_ROUND_DATA) {
  2301. CURRENT_ROUND_DATA = data
  2302. origin = true;
  2303. }
  2304.  
  2305. if (origin || !(data.currentRoundNumber === CURRENT_ROUND_DATA.currentRoundNumber)) {
  2306. // myHighlight("Battle Royale New round");
  2307. switchCovergeButton.init = true;
  2308. // NEW_ROUND_LOADED = true;
  2309. COMPASS = null;
  2310. locHistory = [];
  2311. one_reset = false;
  2312. setHidden(false);
  2313. if (!origin) {
  2314. CURRENT_ROUND_DATA = data;
  2315. }
  2316. modularget(data);
  2317. }
  2318. }
  2319. }
  2320. else {
  2321. if (!cn_tips)
  2322. {
  2323. mainMenuBtn.style.visibility = "";
  2324. }
  2325. else
  2326. {
  2327. mainMenuBtn.style.visibility = "hidden";
  2328. AdjustBtnPos("14em", "0em");
  2329. }
  2330. modularget(data);
  2331. }
  2332.  
  2333. }).catch((error) => {
  2334. console.log(error);
  2335. });
  2336. }
  2337.  
  2338. function handleMinimapCallback()
  2339. {
  2340. let trueCond = true;
  2341. let timeoutTime = 250;
  2342. if (isBattleRoyale) {
  2343. if (isDuel)
  2344. {
  2345. if (document.querySelector(".overlay_overlay__AR02x"))
  2346. {
  2347. trueCond = false;
  2348. }
  2349. else
  2350. {
  2351. trueCond = true;
  2352. }
  2353. }
  2354. else
  2355. {
  2356. if (document.querySelector(".popup__content"))
  2357. {
  2358. trueCond = false;
  2359. }
  2360. else
  2361. {
  2362. trueCond = true;
  2363. }
  2364. }
  2365. timeoutTime = 2500;
  2366. }
  2367.  
  2368. if (trueCond)
  2369. {
  2370. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2371. let cur = MinimapBtn.current;
  2372. // console.log(cur)
  2373. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  2374. if (cur == mapDiv.id)
  2375. {
  2376. setTimeout(function () {mapDiv.click();}, 500);
  2377. setTimeout(function () {mapDiv.click();}, 1000);
  2378. setTimeout(function () {mapDiv.click();}, 3000);
  2379. }
  2380. }
  2381. }
  2382. else
  2383. {
  2384. setTimeout(handleMinimapCallback, timeoutTime);
  2385. }
  2386. }
  2387.  
  2388. /**
  2389. * Hide unnecessary buttons for non-Google coverages
  2390. */
  2391.  
  2392. function handleButtons() {
  2393. let CHECKPOINT = document.querySelector("button[data-qa='set-checkpoint']");
  2394. let ZOOM_IN = document.querySelector("button[data-qa='pano-zoom-in']");
  2395. let ZOOM_OUT = document.querySelector("button[data-qa='pano-zoom-out']");
  2396. let UNDO_MOVE = document.querySelector("button[data-qa='undo-move']");
  2397. let DEFAULT_COMPASS = document.querySelector(".compass");
  2398. let NEW_COMPASS = document.querySelector(".panorama-compass_compassContainer__MEnh0");
  2399. let RETURN_TO_START = document.querySelector("button[data-qa='return-to-start']");
  2400.  
  2401. let C1 = (CHECKPOINT !== null);
  2402. let C2 = (ZOOM_IN !== null);
  2403. let C3 = (ZOOM_OUT !== null);
  2404. let C4 = (UNDO_MOVE !== null);
  2405. let C5 = (DEFAULT_COMPASS !== null);
  2406. let C6 = (NEW_COMPASS !== null);
  2407. let C7 = (RETURN_TO_START !== null);
  2408.  
  2409. let waitCond = C5 || C6;
  2410. let cpCond = true;
  2411. let comCond = true;
  2412. if (!NM)
  2413. {
  2414. cpCond = C1 && C4 && C7
  2415. }
  2416. if (!NZ)
  2417. {
  2418. comCond = C2 && C3
  2419. }
  2420.  
  2421. function moduleButtons(cond)
  2422. {
  2423.  
  2424. if (!NM)
  2425. {
  2426. CHECKPOINT.style.visibility = cond;
  2427. UNDO_MOVE.style.visibility = cond;
  2428. }
  2429. if (!NZ)
  2430. {
  2431. ZOOM_IN.style.visibility = cond;
  2432. ZOOM_OUT.style.visibility = cond;
  2433. }
  2434. if (C5)
  2435. {
  2436. DEFAULT_COMPASS.style.visibility = cond;
  2437. }
  2438. if (C6)
  2439. {
  2440. NEW_COMPASS.style.visibility = cond;
  2441. }
  2442. }
  2443.  
  2444. if (waitCond && cpCond && comCond)
  2445. {
  2446. console.log("Handle Buttons");
  2447. if (nextPlayer === "Google") {
  2448. moduleButtons("");
  2449. }
  2450. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "MS Satellite")
  2451. {
  2452. moduleButtons("hidden");
  2453. }
  2454. else if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Mapillary" || nextPlayer === "MS Streetside")
  2455. {
  2456. moduleButtons("hidden");
  2457. if (nextPlayer === "Yandex" || nextPlayer === "Kakao")
  2458. {
  2459. if (C5)
  2460. {
  2461. DEFAULT_COMPASS.style.visibility = "";
  2462. }
  2463. if (C6)
  2464. {
  2465. NEW_COMPASS.style.visibility = "";
  2466. }
  2467. }
  2468. if (!NM)
  2469. {
  2470. UNDO_MOVE.style.visibility = "";
  2471. handleUndo();
  2472. }
  2473. }
  2474. if (!NM)
  2475. {
  2476. handleReturnToStart();
  2477. }
  2478. }
  2479. else
  2480. {
  2481. setTimeout(handleButtons, 250);
  2482. }
  2483. }
  2484.  
  2485. /**
  2486. * Check which player to use for the next location
  2487. */
  2488.  
  2489. function locationCheck(data) {
  2490. // console.log(data);
  2491. let round;
  2492. if (isBattleRoyale) {
  2493. if (isDuel || isBullseye)
  2494. {
  2495. round = data.rounds[data.currentRoundNumber - 1].panorama;
  2496. }
  2497. else
  2498. {
  2499. round = data.rounds[data.currentRoundNumber - 1];
  2500. }
  2501. }
  2502. else {
  2503. round = data.rounds[data.round - 1];
  2504. }
  2505. global_lat = round.lat;
  2506. global_lng = round.lng;
  2507. global_panoID = round.panoId;
  2508. global_heading = round.heading;
  2509. global_pitch = round.pitch;
  2510.  
  2511. nextPlayer = "Google";
  2512.  
  2513. if (ms_sat_map)
  2514. {
  2515. nextPlayer = "MS Satellite";
  2516. }
  2517.  
  2518. if (global_panoID) {
  2519. let locInfo;
  2520. if (isBullseye)
  2521. {
  2522. locInfo = global_panoID;
  2523. }
  2524. else
  2525. {
  2526. locInfo = hex2a(global_panoID);
  2527. }
  2528. // console.log(locInfo)
  2529. if (locInfo.substring(0, 3) == "YTB")
  2530. {
  2531. nextPlayer = "Youtube";
  2532. let lengths = [3, 11, 4, 4];
  2533. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2534. let fullID = locInfo.substring(3).split('START');
  2535. yId = toPiece[1];
  2536. yTime = Number(toPiece[2]);
  2537. yEnd = Number(toPiece[3]);
  2538. }
  2539. else
  2540. {
  2541. let mapType = locInfo.substring(0, 5);
  2542.  
  2543. // panoId unchanged
  2544.  
  2545. if (mapType === "YDMAP" ) {
  2546. nextPlayer = "Yandex";
  2547. }
  2548. else if (mapType === "KKMAP" ) {
  2549. nextPlayer = "Kakao";
  2550. }
  2551.  
  2552. // New panoId formats
  2553.  
  2554. else if (mapType === "BAIDU" ) {
  2555. nextPlayer = "Baidu";
  2556. let lengths = [5, 7, 7, 3];
  2557. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2558. let panoId1 = base62.decode(toPiece[1]).toString().substring(1);
  2559. let panoId2 = base62.decode(toPiece[2]).toString().substring(1);
  2560. global_BDID = panoId1 + panoId2 + toPiece[3]
  2561. }
  2562. else if (mapType === "MAPIL")
  2563. {
  2564. nextPlayer = "Mapillary";
  2565. mmKey = locInfo.substring(5).replace(/\D/g,'');
  2566. }
  2567. else if (mapType === "IMAGE")
  2568. {
  2569. nextPlayer = "Image";
  2570. let lengths = [5, 4, 4, 7, 2];
  2571. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2572. iId = "https://i.ibb.co/" + toPiece[3] + "/" + toPiece[1] + "." + toPiece[2].replace(/[^0-9a-z]/gi, '')
  2573. }
  2574. else if (mapType === "BINGM" ) {
  2575. nextPlayer = "MS Streetside";
  2576. }
  2577. else if (mapType === "SATEL" ) {
  2578. nextPlayer = "MS Satellite";
  2579. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  2580. }
  2581.  
  2582. // legacy panoId formats support
  2583.  
  2584. else if (mapType === "BDMAP") {
  2585. nextPlayer = "Baidu";
  2586. let coord = locInfo.substring(5);
  2587.  
  2588. if(coord.includes('BDAh'))
  2589. {
  2590. global_BDID = coord.split('BDAh')[0].replace("panoId","");
  2591. let tem = coord.split('BDAh')[1];
  2592. global_BDAh = tem.split('BDBh')[0];
  2593. global_BDBh = tem.split('BDBh')[1];
  2594. }
  2595. else
  2596. {
  2597. global_BDID = coord.replace("panoId","");
  2598. }
  2599. }
  2600. else if (mapType === "MLMAP") {
  2601. nextPlayer = "Mapillary";
  2602. mmKey = locInfo.substring(5);
  2603. }
  2604. }
  2605. }
  2606. else
  2607. {
  2608. if (Kakao_map)
  2609. {
  2610. nextPlayer = "Kakao";
  2611. }
  2612. else if (yandex_map)
  2613. {
  2614. nextPlayer = "Yandex";
  2615. }
  2616. }
  2617.  
  2618. // if ( krCoordinates[0] > global_lat && krCoordinates[2] < global_lat && krCoordinates[1] < global_lng && krCoordinates[3] > global_lng)
  2619. // {
  2620. // nextSecondaryPlayer = "Kakao";
  2621. // }
  2622. // else if (nextPlayer = "Mapillary")
  2623. // {
  2624. // nextSecondaryPlayer = "Google";
  2625. // }
  2626. // else
  2627. // {
  2628. // nextSecondaryPlayer = "Mapillary";
  2629. // }
  2630.  
  2631. // Disable buttons if NM, NMPZ
  2632.  
  2633. if(!isBattleRoyale)
  2634. {
  2635. NM = data.forbidMoving;
  2636. NP = data.forbidRotating;
  2637. NZ = data.forbidZooming;
  2638. }
  2639. else
  2640. {
  2641. // console.log(data)
  2642. if (isBullseye)
  2643. {
  2644. NM = data.options.movementOptions.forbidMoving;
  2645. NP = data.options.movementOptions.forbidRotating;
  2646. NZ = data.options.movementOptions.forbidZooming;
  2647. }
  2648. else
  2649. {
  2650. NM = data.movementOptions.forbidMoving;
  2651. NP = data.movementOptions.forbidRotating;
  2652. NZ = data.movementOptions.forbidZooming;
  2653. }
  2654. }
  2655. if (NM || NP || NZ)
  2656. {
  2657. setDisable("NMPZ");
  2658. }
  2659. else
  2660. {
  2661. setDisable(nextPlayer);
  2662. }
  2663.  
  2664.  
  2665. console.log(nextPlayer);
  2666. injectCanvas();
  2667. }
  2668.  
  2669.  
  2670. /**
  2671. * setID for canvas
  2672. */
  2673.  
  2674. function initializeCanvas() {
  2675. let GAME_CANVAS = "";
  2676. let DUEL_CANVAS = "";
  2677. //console.log("Is duels");
  2678. //console.log(duels);
  2679.  
  2680. if (isBattleRoyale) {
  2681. if (isDuel) {
  2682. GAME_CANVAS = document.querySelector(".game-panorama_panorama__rdhFg");
  2683. DUEL_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__PNKve");
  2684. }
  2685. else if (isBullseye) {
  2686. GAME_CANVAS = document.querySelector(".game-panorama_panorama__ncMwh");
  2687. DUEL_CANVAS = "dummy";
  2688. }
  2689. else
  2690. {
  2691. GAME_CANVAS = document.querySelector(".br-game-layout__panorama-wrapper");
  2692. DUEL_CANVAS = "dummy";
  2693. }
  2694. }
  2695. else {
  2696. GAME_CANVAS = document.querySelector(".game-layout__canvas");
  2697. DUEL_CANVAS = "dummy";
  2698. }
  2699. if (GAME_CANVAS && DUEL_CANVAS)
  2700. {
  2701. // console.log("Canvas injected");
  2702. GAME_CANVAS.id = "player";
  2703.  
  2704. if (isDuel) {
  2705. DUEL_CANVAS.id = "default_player";
  2706. }
  2707. partialCreateMapillary = (typeof mapillary !== typeof undefined)
  2708. partialCreateYandex = (typeof ymaps !== typeof undefined)
  2709. partialCreateKakao = (typeof kakao !== typeof undefined)
  2710. partialCreateMS = (typeof Microsoft !== typeof undefined);
  2711. loadPlayers();
  2712. injectMapillaryPlayer();
  2713. }
  2714. else
  2715. {
  2716. setTimeout(initializeCanvas, 250);
  2717. }
  2718.  
  2719. }
  2720.  
  2721. /**
  2722. * Hide or show players based on where the next location is
  2723. */
  2724.  
  2725. function injectCanvas() {
  2726. if (isDuel)
  2727. {
  2728. canvasSwitch();
  2729. }
  2730. else
  2731. {
  2732. Google();
  2733. Baidu();
  2734. if (BR_LOAD_KAKAO)
  2735. {
  2736. Kakao();
  2737. }
  2738. if (BR_LOAD_YANDEX)
  2739. {
  2740. Yandex();
  2741. }
  2742. if (BR_LOAD_MS)
  2743. {
  2744. Bing();
  2745. }
  2746. Mapillary();
  2747. }
  2748. ZoomControls();
  2749. }
  2750.  
  2751. // for duels (class ID change)
  2752.  
  2753. function canvasSwitch()
  2754. {
  2755. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2756. let GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__PNKve");
  2757. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  2758. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  2759. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  2760. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  2761. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  2762.  
  2763. if (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))
  2764. {
  2765. document.getElementById("default_player").style.position = "absolute";
  2766. document.getElementById("default_player").className = "inactive";
  2767. BAIDU_MAPS_CANVAS.style.position = "absolute";
  2768. BAIDU_MAPS_CANVAS.className = "inactive";
  2769. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  2770. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  2771. MAPILLARY_MAPS_CANVAS.className = "inactive";
  2772. if (BR_LOAD_KAKAO)
  2773. {
  2774. KAKAO_MAPS_CANVAS.style.position = "absolute";
  2775. KAKAO_MAPS_CANVAS.className = "inactive";
  2776. }
  2777. if (BR_LOAD_YANDEX)
  2778. {
  2779. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  2780. YANDEX_MAPS_CANVAS.style.position = "absolute";
  2781. }
  2782. if (BR_LOAD_MS)
  2783. {
  2784. BING_MAPS_CANVAS.style.position = "absolute";
  2785. BING_MAPS_CANVAS.className = "inactive";
  2786. }
  2787. switchCovergeButton.nextPlayer = nextPlayer;
  2788. teleportBtn.google = false;
  2789. switchCovergeButton.useGoogle = false;
  2790.  
  2791. if (nextPlayer === "Google") {
  2792. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  2793. teleportBtn.google = true;
  2794. switchCovergeButton.useGoogle = true;
  2795. console.log("Google Duel Canvas loaded");
  2796. }
  2797. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image")
  2798. {
  2799. BAIDU_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  2800. console.log("Container Duel Canvas loaded");
  2801. }
  2802. else if (nextPlayer === "Kakao")
  2803. {
  2804. if (BR_LOAD_KAKAO)
  2805. {
  2806. KAKAO_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  2807. }
  2808. console.log("Kakao Duel Canvas loaded");
  2809. }
  2810. else if (nextPlayer === "Yandex")
  2811. {
  2812. if (BR_LOAD_YANDEX)
  2813. {
  2814. YANDEX_MAPS_CANVAS.style.visibility = "";
  2815. }
  2816. console.log("Yandex Duel Canvas loaded");
  2817. }
  2818. else if (nextPlayer === "Mapillary")
  2819. {
  2820. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  2821. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  2822. // MapillaryPlayer.resize();
  2823. console.log("Mapillary Duel Canvas loaded");
  2824. }
  2825. else if (nextPlayer === "MS Streetside" || nextPlayer === "MS Satellite")
  2826. {
  2827. if (BR_LOAD_MS)
  2828. {
  2829. BING_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  2830. }
  2831. console.log("MS Duel Canvas loaded");
  2832. }
  2833. }
  2834. else
  2835. {
  2836. setTimeout(canvasSwitch, 250);
  2837. }
  2838. }
  2839.  
  2840. // for Battle Royale and classic (change visibility)
  2841.  
  2842. function Google() {
  2843. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2844. let GOOGLE_MAPS_CANVAS = ""
  2845. if (isBattleRoyale) {
  2846. if (!isBullseye)
  2847. {
  2848. GOOGLE_MAPS_CANVAS = document.querySelector(".br-game-layout__panorama-canvas");
  2849. }
  2850. else
  2851. {
  2852. GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__r_5ea");
  2853. }
  2854. }
  2855. else {
  2856. GOOGLE_MAPS_CANVAS = document.querySelector(".game-layout__panorama-canvas");
  2857. }
  2858. if (nextPlayer === "Google") {
  2859. GOOGLE_MAPS_CANVAS.style.visibility = "";
  2860. teleportBtn.google = true;
  2861. switchCovergeButton.nextPlayer = "Google";
  2862. switchCovergeButton.useGoogle = true;
  2863. console.log("Google Canvas loaded");
  2864. }
  2865. else {
  2866. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  2867. teleportBtn.google = false;
  2868. // console.log("Google Canvas hidden");
  2869. }
  2870. }
  2871.  
  2872. function Baidu() {
  2873. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2874. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  2875. // console.log("Baidu canvas");
  2876. if (BAIDU_MAPS_CANVAS !== null)
  2877. {
  2878. BAIDU_MAPS_CANVAS.style.position = "absolute";
  2879. if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  2880. BAIDU_MAPS_CANVAS.style.visibility = "";
  2881. switchCovergeButton.nextPlayer = "Baidu";
  2882. switchCovergeButton.useGoogle = false;
  2883. console.log("Container Canvas loaded");
  2884. }
  2885. else {
  2886. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  2887. // console.log("Container Canvas hidden");
  2888. }
  2889. }
  2890. else
  2891. {
  2892. setTimeout(Baidu, 250);
  2893. }
  2894.  
  2895. }
  2896.  
  2897. function Kakao() {
  2898. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2899. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  2900. // console.log("Kakao canvas");
  2901. if (KAKAO_MAPS_CANVAS != null)
  2902. {
  2903. KAKAO_MAPS_CANVAS.style.position = "absolute";
  2904. if (nextPlayer === "Kakao") {
  2905. KAKAO_MAPS_CANVAS.style.visibility = "";
  2906. switchCovergeButton.nextPlayer = "Kakao";
  2907. switchCovergeButton.useGoogle = false;
  2908. console.log("Kakao Canvas loaded");
  2909. }
  2910. else {
  2911. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  2912. // console.log("Kakao Canvas hidden");
  2913. }
  2914. }
  2915. else
  2916. {
  2917. setTimeout(Kakao, 250);
  2918. }
  2919.  
  2920. }
  2921.  
  2922. function Yandex() {
  2923. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2924. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  2925. if (YANDEX_MAPS_CANVAS != null)
  2926. {
  2927. if (isBullseye)
  2928. {
  2929. let div = document.getElementById("player");
  2930. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__ncMwh");
  2931. div.prepend(YANDEX_MAPS_CANVAS);
  2932. }
  2933. // console.log("Yandex canvas");
  2934. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  2935. // console.log("Yandex canvas");
  2936. /* console.log(YANDEX_MAPS_CANVAS); */
  2937. if (nextPlayer === "Yandex") {
  2938. YANDEX_MAPS_CANVAS.style.visibility = "";
  2939. switchCovergeButton.nextPlayer = "Yandex";
  2940. switchCovergeButton.useGoogle = false;
  2941. console.log("Yandex Canvas loaded");
  2942. }
  2943. else {
  2944. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  2945. // console.log("Yandex Canvas hidden");
  2946. }
  2947. }
  2948. else
  2949. {
  2950. setTimeout(Yandex, 250);
  2951. }
  2952.  
  2953. }
  2954.  
  2955. function Mapillary()
  2956. {
  2957. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2958. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  2959. if (MAPILLARY_MAPS_CANVAS != null)
  2960. {
  2961. // console.log("Mapillary canvas");
  2962. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  2963. if (nextPlayer === "Mapillary") {
  2964. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  2965. switchCovergeButton.nextPlayer = "Mapillary";
  2966. switchCovergeButton.useGoogle = false;
  2967. console.log("Mapillary Canvas loaded");
  2968.  
  2969. }
  2970. else {
  2971. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  2972. // console.log("Mapillary Canvas hidden");
  2973. }
  2974. }
  2975. else
  2976. {
  2977. setTimeout(Mapillary, 250);
  2978. }
  2979.  
  2980. }
  2981.  
  2982. function Bing() {
  2983. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  2984. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  2985. if (BING_MAPS_CANVAS != null)
  2986. {
  2987. // console.log("Mapillary canvas");
  2988. BING_MAPS_CANVAS.style.position = "absolute";
  2989. if (nextPlayer === "MS Satellite" || nextPlayer === "MS Streetside") {
  2990. BING_MAPS_CANVAS.style.visibility = "";
  2991. switchCovergeButton.nextPlayer = nextPlayer;
  2992. switchCovergeButton.useGoogle = false;
  2993. console.log("Bing Canvas loaded");
  2994. }
  2995. else {
  2996. BING_MAPS_CANVAS.style.visibility = "hidden";
  2997. // console.log("Bing Canvas hidden");
  2998. }
  2999. }
  3000. else
  3001. {
  3002. setTimeout(Bing, 250);
  3003. }
  3004. }
  3005.  
  3006.  
  3007. /**
  3008. * Adjust button placement
  3009. */
  3010.  
  3011. function ZoomControls() {
  3012. let style = `
  3013. .ymaps-2-1-79-panorama-gotoymaps {display: none !important;}
  3014. .ymaps-2-1-79-panorama-control__zoom {top: 2rem !important; left: 2rem !important; z-Index: 0}
  3015. .mapillary-bearing-indicator-container {top: 2rem !important; left: 2rem !important;}
  3016. .mapillary-zoom-container {top: 6rem !important; left: 2.20rem !important;}
  3017. .NavBar_MapTypeButtonContainerWrapper {visibility: hidden !important;}
  3018. .bm_LocateMeControl {visibility: hidden !important;}
  3019. .NavBar_Container {top: -6rem !important; left: 2rem !important;}
  3020. .streetsideToolPanel {top: 4rem !important; left: 2rem !important;}
  3021. `;
  3022.  
  3023. // let nav = document.querySelector('.NavBar_MapTypeButtonContainerWrapper');
  3024. // let locate = document.getElementById("LocateMeButton");
  3025. // let navAll = document.getElementById("MicrosoftNav");
  3026. // if (nav)
  3027. // {
  3028. // nav.style.visibility = "hidden";
  3029. // }
  3030. // if (locate)
  3031. // {
  3032. // locate.style.visibility = "hidden";
  3033. // }
  3034. // if (navAll)
  3035. // {
  3036. // navAll.style.top = "15em"
  3037. // }
  3038.  
  3039. let style_element = document.createElement("style");
  3040. style_element.innerHTML = style;
  3041. document.body.appendChild(style_element);
  3042. // document.getElementById("mapillary-bearing-indicator-container").style.top = "20em"
  3043. }
  3044.  
  3045. /**
  3046. * Updates the compass to match Yandex Panorama facing
  3047. */
  3048. function updateCompass() {
  3049. if (!COMPASS) {
  3050. let compass = document.querySelector("img.compass__indicator");
  3051. if (compass != null) {
  3052. COMPASS = compass;
  3053. let direction = YandexPlayer.getDirection()[0] * -1;
  3054. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  3055. }
  3056. }
  3057. else {
  3058. let direction = YandexPlayer.getDirection()[0] * -1;
  3059. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  3060. }
  3061. }
  3062.  
  3063. /**
  3064. * Open next location in streetview player given next player and next coordinate
  3065. */
  3066.  
  3067. function goToLocation() {
  3068. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3069. console.log("Going to location");
  3070. if (nextPlayer === "Yandex") {
  3071. let options = {};
  3072. YandexPlayer.moveTo([global_lat, global_lng], options);
  3073. YandexPlayer.setDirection([0, 16]);
  3074. YandexPlayer.setSpan([10, 67]);
  3075. }
  3076. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  3077. if (document.getElementById("i_container") !== null)
  3078. {
  3079. let iframe = document.getElementById("i_container");
  3080. if (nextPlayer === "Baidu")
  3081. {
  3082. if (!isFirefox)
  3083. {
  3084. iframe.style.top = '-60px';
  3085. iframe.style.height = (window.innerHeight + 200) + 'px';
  3086. }
  3087. else
  3088. {
  3089. iframe.style.top = '-60px';
  3090. iframe.style.height = (window.innerHeight + 219) + 'px';
  3091. }
  3092.  
  3093. if (!isFirefox)
  3094. {
  3095. iframe.style.right = '-55px';
  3096. iframe.style.width = (window.innerWidth + 55) + 'px';
  3097. }
  3098. else
  3099. {
  3100. iframe.style.right = '-15px';
  3101. iframe.style.width = (window.innerWidth + 15) + 'px';
  3102. }
  3103. let urlStr2 = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  3104. 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;
  3105. // console.log(urlStr)
  3106. if (global_BDAh != null)
  3107. {
  3108. iframe.src = urlStr;
  3109. }
  3110. else
  3111. {
  3112. iframe.src = urlStr2;
  3113. }
  3114. iframe.style.visibility = "";
  3115. }
  3116. else if (nextPlayer === "Youtube")
  3117. {
  3118. document.getElementById("Youtube Button").style.visibility = "";
  3119. document.getElementById("Youtube Button").innerHTML = "Play video";
  3120. iframe.allow = "autoplay";
  3121. iframe.style.visibility = "hidden";
  3122. iframe.style.top = '-60px';
  3123. iframe.style.height = (window.innerHeight + 235) + 'px';
  3124. }
  3125. else if (nextPlayer === "Image")
  3126. {
  3127. iframe.style.top = '0px';
  3128. iframe.style.height = (window.innerHeight) + 'px';
  3129. iframe.style.visibility = "";
  3130. iframe.src = iId;
  3131. }
  3132. }
  3133. else
  3134. {
  3135. setTimeout(goToLocation, 250);
  3136. }
  3137. // let a = new BMap.Point(global_lng, global_lat);
  3138. // BaiduPlayer.setPov({ heading: -40, pitch: 6 });
  3139. // BaiduPlayer.setPosition(a);
  3140. }
  3141. else if (nextPlayer === "Kakao") {
  3142. var roadviewClient = new kakao.maps.RoadviewClient();
  3143. var position = new kakao.maps.LatLng(global_lat, global_lng);
  3144. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3145. KakaoPlayer.setPanoId(panoId, position);
  3146. KakaoPlayer.setViewpoint({ pan: global_heading, tilt: global_pitch, zoom: -3 })
  3147. });
  3148. }
  3149. else if (nextPlayer === "Mapillary") {
  3150. MapillaryPlayer.resize()
  3151. MapillaryPlayer.moveTo(mmKey).then(
  3152. image => { //console.log(image);
  3153. },
  3154. error => { console.log(error); });
  3155. }
  3156. else if (nextPlayer === "Google") {
  3157. handleMapillary({lat: global_lat, lng: global_lng}, {meters: 500, limit: 500});
  3158. }
  3159. else if (nextPlayer === "MS Streetside") {
  3160. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.streetside,
  3161. zoom: 18,
  3162. streetsideOptions: {
  3163. overviewMapMode: Microsoft.Maps.OverviewMapMode.hidden,
  3164. showCurrentAddress: false,
  3165. showProblemReporting: false,
  3166. showExitButton: false,
  3167. },
  3168. center: new Microsoft.Maps.Location(global_lat, global_lng),
  3169. heading: 90,
  3170. pitch: -30,
  3171. disableStreetside: false});
  3172. }
  3173. else if (nextPlayer === "MS Satellite") {
  3174. // console.log("MS Satellite Player")
  3175. let ctr = new Microsoft.Maps.Location(global_lat, global_lng)
  3176. let loc_centre = {lat: global_lat, lng: global_lng};
  3177. for (var i = MSStreetPlayer.entities.getLength() - 1; i >= 0; i--) {
  3178. var pushpin = MSStreetPlayer.entities.get(i);
  3179. if (pushpin instanceof Microsoft.Maps.Pushpin) {
  3180. MSStreetPlayer.entities.removeAt(i);
  3181. }
  3182. }
  3183. let latlngBounds = getBBox2(loc_centre, ms_radius);
  3184. // console.log(latlngBounds)
  3185. let bounds = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(latlngBounds[0], latlngBounds[1]), new Microsoft.Maps.Location(latlngBounds[2], latlngBounds[3]));
  3186. // console.log(bounds)
  3187. MSStreetPlayer.setOptions({maxBounds: bounds})
  3188. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.aerial,
  3189. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  3190. center: ctr,
  3191. zoom: 15,
  3192. })
  3193. var pin = new Microsoft.Maps.Pushpin(ctr, {});
  3194.  
  3195. //Add the pushpin to the map
  3196. MSStreetPlayer.entities.push(pin);
  3197. FixLink();
  3198. // hideNav();
  3199. }
  3200. switchCovergeButton.lat = global_lat;
  3201. switchCovergeButton.lng = global_lng;
  3202. }
  3203.  
  3204. function FixLink()
  3205. {
  3206. let ele = document.querySelector('[title="Microsoft Bing"]');
  3207. if (ele)
  3208. {
  3209. ele.href = "#";
  3210. }
  3211. else
  3212. {
  3213. setTimeout(FixLink, 250);
  3214. }
  3215. }
  3216.  
  3217. /**
  3218. * Handle undo using the location history of the current round
  3219. */
  3220.  
  3221. function goToUndoMove(data) {
  3222. /* console.log(global_lat);
  3223. console.log(global_lng); */
  3224. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3225. let options = {};
  3226. let prevStep = null;
  3227. if (locHistory.length === 1) {
  3228. prevStep = locHistory[0];
  3229. }
  3230. else {
  3231. prevStep = locHistory.pop();
  3232. }
  3233. // console.log(prevStep);
  3234. // console.log(locHistory)
  3235. if (nextPlayer === "Yandex") {
  3236. defaultPanoIdChange = false;
  3237. YandexPlayer.moveTo([prevStep[0], prevStep[1]], options);
  3238. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  3239. YandexPlayer.setSpan([10, 67]);
  3240. switchCovergeButton.lat = prevStep[0];
  3241. switchCovergeButton.lng = prevStep[1];
  3242. }
  3243. else if (nextPlayer === "Kakao") {
  3244. let btn = document.querySelector("button[data-qa='undo-move']");
  3245. btn.disabled = false;
  3246. btn.classList.remove('styles_disabled__2YdHD');
  3247. defaultPanoIdChange = false;
  3248. let position = new kakao.maps.LatLng(prevStep[0], prevStep[1]);
  3249. KakaoPlayer.setPanoId(prevStep[2], position);
  3250. switchCovergeButton.lat = prevStep[0];
  3251. switchCovergeButton.lng = prevStep[1];
  3252. switchCovergeButton.useGoogle = false;
  3253. teleportBtn.google = false;
  3254. // console.log("Undo 1 step");
  3255. // console.log(locHistory);
  3256. }
  3257. else if (nextPlayer === "Mapillary" ) {
  3258. // console.log(prevStep[1]);
  3259.  
  3260. MapillaryPlayer.moveTo(prevStep[2]).then(
  3261. image => {
  3262. //console.log(image);
  3263. switchCovergeButton.lat = prevStep[1];
  3264. switchCovergeButton.lng = prevStep[0];
  3265. },
  3266. error => { console.log(error); });
  3267. }
  3268. else if (nextPlayer === "MS Streetside") {
  3269. defaultPanoIdChange = false;
  3270. // console.log(locHistory);
  3271. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(prevStep[0], prevStep[1]),});
  3272. switchCovergeButton.lat = prevStep[0];
  3273. switchCovergeButton.lng = prevStep[1];
  3274. switchCovergeButton.heading = prevStep[2];
  3275. }
  3276.  
  3277. }
  3278.  
  3279. function handleTeleport()
  3280. {
  3281. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3282. if (teleportBtn)
  3283. {
  3284. teleportBtn.addEventListener("click", () => {
  3285. if (!teleportBtn.google)
  3286. {
  3287. // console.log("non-Google Teleport");
  3288. let prevStep = null;
  3289. if (locHistory.length === 1) {
  3290. prevStep = locHistory[0];
  3291. }
  3292. else {
  3293. prevStep = locHistory[locHistory.length - 1];
  3294. }
  3295. // console.log(locHistory);
  3296. let options = {};
  3297. let place, position, pID;
  3298. if (nextPlayer === "Yandex") {
  3299. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3300. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  3301. YandexPlayer.moveTo([place.lat, place.lng], options);
  3302. YandexPlayer.setSpan([10, 67]);
  3303. switchCovergeButton.lat = place.lat;
  3304. switchCovergeButton.lng = place.lng;
  3305. }
  3306. else if (nextPlayer === "Kakao") {
  3307. var roadviewClient = new kakao.maps.RoadviewClient();
  3308. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[3]), teleportBtn.distance * 0.001);
  3309. position = new kakao.maps.LatLng(place.lat, place.lng);
  3310. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3311. KakaoPlayer.setPanoId(panoId, position);
  3312. });
  3313. switchCovergeButton.lat = place.lat;
  3314. switchCovergeButton.lng = place.lng;
  3315. }
  3316. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  3317. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3318. handleMapillary(place, {meters: 500, limit: 500});
  3319. switchCovergeButton.lat = place.lat;
  3320. switchCovergeButton.lng = place.lng;
  3321. // locHistory.push([place.lat, place.lng, prevStep[2], prevStep[3]]);
  3322. }
  3323. else if (nextPlayer === "MS Streetside") {
  3324. // console.log("teleport")
  3325. // console.log(prevStep);
  3326. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3327. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(place.lat, place.lng), 1, 1);
  3328. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  3329. function onSuccess(panoramaInfo) {
  3330. // console.log("Coverage")
  3331. // console.log([panoramaInfo.la, panoramaInfo.lo])
  3332. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  3333. });
  3334. }
  3335. function onMissingCoverage() {
  3336. console.log("No Coverage")
  3337. }
  3338. }
  3339.  
  3340. if (teleportBtn.distance > 150)
  3341. {
  3342. teleportBtn.distance = 100;
  3343. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  3344. }
  3345. }
  3346. });
  3347. }
  3348. }
  3349.  
  3350. function SyncListener()
  3351. {
  3352. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3353. switchCovergeButton.addEventListener("click", () => {
  3354. if (switchCovergeButton.useGoogle == false) {
  3355. // switchCovergeButton.useGoogle = true;
  3356. console.log(switchCovergeButton.nextPlayer)
  3357. if (switchCovergeButton.nextPlayer === "Yandex") {
  3358. let options = {};
  3359. YandexPlayer.moveTo([switchCovergeButton.lat, switchCovergeButton.lng], options);
  3360. YandexPlayer.setDirection([switchCovergeButton.heading, 0]);
  3361.  
  3362. // switchCovergeButton.nextPlayer = "Yandex";
  3363. }
  3364. else if (switchCovergeButton.nextPlayer === "Kakao") {
  3365. let roadviewClient = new kakao.maps.RoadviewClient();
  3366. // console.log(switchCovergeButton.lat);
  3367. let position = new kakao.maps.LatLng(switchCovergeButton.lat, switchCovergeButton.lng);
  3368. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3369. KakaoPlayer.setPanoId(panoId, position);
  3370. });
  3371. KakaoPlayer.setViewpoint({
  3372. pan: switchCovergeButton.heading,
  3373. tilt: 0,
  3374. zoom: -3
  3375. });
  3376. // switchCovergeButton.nextPlayer = "Kakao";
  3377. }
  3378. else if (switchCovergeButton.nextPlayer === "Mapillary" || switchCovergeButton.nextPlayer === "Google") {
  3379. // switchCovergeButton.nextPlayer = "Kakao";
  3380. handleMapillary({lat: switchCovergeButton.lat, lng: switchCovergeButton.lng}, {meters: 100, limit: 100});
  3381. }
  3382. else if (switchCovergeButton.nextPlayer === "MS Streetside") {
  3383. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(switchCovergeButton.lat, switchCovergeButton.lng), 0.01, 0.01);
  3384. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  3385. function onSuccess(panoramaInfo) {
  3386. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  3387. heading: switchCovergeButton.heading
  3388. });
  3389. }
  3390. function onMissingCoverage() {
  3391. console.log("No Coverage")
  3392. }
  3393. }
  3394. }
  3395. });
  3396.  
  3397. }
  3398.  
  3399. /**
  3400. * Gets the seed data for the current game
  3401. *
  3402. * @returns Promise with seed data as object
  3403. */
  3404. function getSeed() {
  3405. // console.log("getSeed called");
  3406. return new Promise((resolve, reject) => {
  3407. let token = getToken();
  3408. let URL;
  3409. let cred = ""
  3410.  
  3411. const PATHNAME = window.location.pathname;
  3412.  
  3413. if (PATHNAME.startsWith("/game/")) {
  3414. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  3415. }
  3416. else if (PATHNAME.startsWith("/challenge/")) {
  3417. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  3418. }
  3419. else if (PATHNAME.startsWith("/battle-royale/")) {
  3420. URL = `https://game-server.geoguessr.com/api/battle-royale/${token}`;
  3421. }
  3422. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  3423. URL = `https://game-server.geoguessr.com/api/duels/${token}`;
  3424. }
  3425. else if (PATHNAME.startsWith("/bullseye/")) {
  3426. URL = `https://game-server.geoguessr.com/api/bullseye/${token}`;
  3427. }
  3428. if (isBattleRoyale) {
  3429. fetch(URL, {
  3430. // Include credentials to GET from the endpoint
  3431. credentials: 'include'
  3432. })
  3433. .then((response) => response.json())
  3434. .then((data) => {
  3435. resolve(data);
  3436. })
  3437. .catch((error) => {
  3438. reject(error);
  3439. });
  3440. }
  3441. else {
  3442. fetch(URL)
  3443. .then((response) => response.json())
  3444. .then((data) => {
  3445. resolve(data);
  3446. })
  3447. .catch((error) => {
  3448. reject(error);
  3449. });
  3450. }
  3451. });
  3452. }
  3453.  
  3454. /**
  3455. * Gets the token from the current URL
  3456. *
  3457. * @returns token
  3458. */
  3459. function getToken() {
  3460. const PATHNAME = window.location.pathname;
  3461. if (PATHNAME.startsWith("/game/")) {
  3462. return PATHNAME.replace("/game/", "");
  3463. }
  3464. else if (PATHNAME.startsWith("/challenge/")) {
  3465. return PATHNAME.replace("/challenge/", "");
  3466. }
  3467. else if (PATHNAME.startsWith("/battle-royale/")) {
  3468. return PATHNAME.replace("/battle-royale/", "");
  3469. }
  3470. else if (PATHNAME.startsWith("/duels/")) {
  3471. return PATHNAME.replace("/duels/", "");
  3472. }
  3473. else if (PATHNAME.startsWith("/team-duels/")) {
  3474. return PATHNAME.replace("/team-duels/", "");
  3475. }
  3476. else if (PATHNAME.startsWith("/bullseye/")) {
  3477. return PATHNAME.replace("/bullseye/", "");
  3478. }
  3479. }
  3480.  
  3481. /**
  3482. * Gets the round number from the ongoing game from the page itself
  3483. *
  3484. * @returns Round number
  3485. */
  3486. function getRoundFromPage() {
  3487. const roundData = document.querySelector("div[data-qa='round-number']");
  3488. if (roundData) {
  3489. let roundElement = roundData.querySelector("div:last-child");
  3490. if (roundElement) {
  3491. let round = parseInt(roundElement.innerText.charAt(0));
  3492. if (!isNaN(round) && round >= 1 && round <= 5) {
  3493. return round;
  3494. }
  3495. }
  3496. }
  3497. else {
  3498. return ROUND;
  3499. }
  3500. }
  3501.  
  3502.  
  3503. /**
  3504. * Injects Yandex Script
  3505. */
  3506. function injectYandexScript() {
  3507. return new Promise((resolve, reject) => {
  3508. if (!YANDEX_INJECTED) {
  3509. if (YANDEX_API_KEY === "") {
  3510. console.log("No Yandex Key")
  3511. reject();
  3512. }
  3513. else {
  3514. if (!partialCreateYandex)
  3515. {
  3516. const SCRIPT = document.createElement("script");
  3517. SCRIPT.type = "text/javascript";
  3518. SCRIPT.async = true;
  3519. SCRIPT.src = `https://api-maps.yandex.ru/2.1/?lang=en_US&apikey=${YANDEX_API_KEY}`;
  3520. document.body.appendChild(SCRIPT);
  3521. SCRIPT.onload = () => {
  3522. ymaps.ready(() => {
  3523. YANDEX_INJECTED = true;
  3524. myHighlight("Yandex API Loaded");
  3525. resolve();
  3526. });
  3527. }
  3528. }
  3529. else
  3530. {
  3531. YANDEX_INJECTED = true;
  3532. resolve();
  3533. }
  3534. }
  3535. }
  3536. else {
  3537. resolve();
  3538. }
  3539. });
  3540. }
  3541.  
  3542. /**
  3543. * Injects Yandex Player and calls handleReturnToStart
  3544. */
  3545. function injectYandexPlayer() {
  3546. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3547. let lat = 41.321861;
  3548. let lng = 69.212920;
  3549.  
  3550. let options = {
  3551. "direction": [0, 16],
  3552. "span": [10, 67],
  3553. "controls": ["zoomControl"]
  3554. };
  3555. ymaps.panorama.createPlayer("player", [lat, lng], options)
  3556. .done((player) => {
  3557. YandexPlayer = player;
  3558. YandexPlayer.events.add("directionchange", (e) => {
  3559. updateCompass();
  3560. let pov = YandexPlayer.getDirection();
  3561. if (locHistory.length > 0 && nextPlayer == "Yandex") {
  3562. switchCovergeButton.heading = pov[0];
  3563. locHistory[locHistory.length - 1][2] = pov[0];
  3564. locHistory[locHistory.length - 1][3] = pov[1];
  3565. }
  3566. });
  3567. YandexPlayer.events.add("panoramachange", (e) => {
  3568. if (defaultPanoIdChange) {
  3569. let num = YandexPlayer.getPanorama().getPosition();
  3570. let pov = YandexPlayer.getDirection();
  3571. // console.log(num);
  3572. // console.log(pov);
  3573. if (nextPlayer == "Yandex")
  3574. {
  3575. locHistory.push([num[0], num[1], pov[0], pov[1]]);
  3576. switchCovergeButton.lat = num[0];
  3577. switchCovergeButton.lng = num[1];
  3578. }
  3579. let btn = document.querySelector("button[data-qa='undo-move']");
  3580. if (locHistory.length > 1) {
  3581. btn.disabled = false;
  3582. btn.classList.remove('styles_disabled__2YdHD');
  3583. }
  3584. // console.log(locHistory);
  3585. }
  3586. defaultPanoIdChange = true;
  3587.  
  3588. });
  3589. console.log("Yandex Player injected");
  3590. });
  3591.  
  3592. }
  3593.  
  3594.  
  3595. /**
  3596. * Injects Baidu script
  3597. */
  3598.  
  3599. function reportWindowSize() {
  3600. let iframeC = document.getElementById("i_container");
  3601. if (iframeC)
  3602. {
  3603. if (nextPlayer == "Baidu")
  3604. {
  3605. iframeC.style.top = '-60px';
  3606. iframeC.style.height = (window.innerHeight + 200) + 'px';
  3607. iframeC.style.right = '-55px';
  3608. iframeC.style.width = (window.innerWidth + 55) + 'px';
  3609. }
  3610. else if (nextPlayer == "Youtube")
  3611. {
  3612. iframeC.style.top = '-60px';
  3613. iframeC.style.height = (window.innerHeight + 235) + 'px';
  3614. }
  3615. else if (nextPlayer == "Image")
  3616. {
  3617. iframeC.style.top = '0px';
  3618. iframeC.style.height = (window.innerHeight) + 'px';
  3619. }
  3620.  
  3621. }
  3622. }
  3623.  
  3624. window.onresize = reportWindowSize;
  3625.  
  3626. function injectContainer() {
  3627. myHighlight("iframe container loaded")
  3628. const iframe = document.createElement('iframe');
  3629. iframe.frameBorder = 0;
  3630. iframe.style.position = "absolute";
  3631. iframe.id = "i_container";
  3632. if (isBattleRoyale) {
  3633. if (isDuel)
  3634. {
  3635. iframe.className = "inactive"
  3636. }
  3637. else if (isBullseye)
  3638. {
  3639. iframe.className = "game-panorama_panorama__ncMwh"
  3640. }
  3641. else
  3642. {
  3643. iframe.className = "br-game-layout__panorama"
  3644. }
  3645. }
  3646. else {
  3647. iframe.className = "game-layout__panorama"
  3648. }
  3649. var div = document.getElementById("player");
  3650. div.style.overflow = "hidden";
  3651. if (isBullseye)
  3652. {
  3653. div.prepend(iframe);
  3654. }
  3655. else
  3656. {
  3657. div.appendChild(iframe);
  3658. }
  3659. }
  3660.  
  3661. // function injectMedia() {
  3662. // myHighlight("Baidu API loaded")
  3663. // const iframe = document.createElement('iframe');
  3664. // iframe.allow = "autoplay"
  3665. // iframe.src = "https://www.youtube.com/embed/72kRM86V-dw?&autoplay=1&modestbranding=1&controls=0&start=10"
  3666. // iframe.frameBorder = 0;
  3667. // iframe.style.position = "absolute";
  3668. // iframe.id = "media-player";
  3669. // iframe.style="position:fixed; top: -60px; left:0; bottom: calc(100% + 175px); right:0; width:100%; height:calc(100% + 235px); border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"
  3670. // if (isBattleRoyale) {
  3671. // if (isDuel)
  3672. // {
  3673. // iframe.className = "inactive"
  3674. // }
  3675. // else
  3676. // {
  3677. // iframe.className = "br-game-layout__panorama"
  3678. // }
  3679. // }
  3680. // else {
  3681. // iframe.className = "game-layout__panorama"
  3682. // }
  3683. // var div = document.getElementById("player");
  3684. // div.style.overflow = "hidden";
  3685. // div.appendChild(iframe);
  3686. // }
  3687.  
  3688. /**
  3689. * Injects Kakao script
  3690. */
  3691.  
  3692. function injectKakaoScript() {
  3693. return new Promise((resolve, reject) => {
  3694. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3695. if (!KAKAO_INJECTED) {
  3696. if (KAKAO_API_KEY === "") {
  3697. console.log("No Kakao Key")
  3698. }
  3699. else {
  3700.  
  3701. let canvas = document.createElement("kmap");
  3702. if (isBattleRoyale) {
  3703. if (isDuel)
  3704. {
  3705. canvas.innerHTML = `
  3706. <div id="roadview" class="inactive" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  3707. `;
  3708. }
  3709. else if (isBullseye)
  3710. {
  3711. canvas.innerHTML = `
  3712. <div id="roadview" class="game-panorama_panorama__ncMwh" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  3713. `;
  3714. }
  3715. else
  3716. {
  3717. canvas.innerHTML = `
  3718. <div id="roadview" class="br-game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  3719. `;
  3720. }
  3721. }
  3722. else {
  3723. canvas.innerHTML = `
  3724. <div id="roadview" class="game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  3725. `;
  3726. }
  3727.  
  3728.  
  3729. var div = document.getElementById("player");
  3730. if (isBullseye)
  3731. {
  3732. div.prepend(canvas);
  3733. }
  3734. else
  3735. {
  3736. div.appendChild(canvas);
  3737. }
  3738.  
  3739. let SCRIPT;
  3740. if (!partialCreateKakao)
  3741. {
  3742. SCRIPT = document.createElement("script");
  3743. SCRIPT.async = true;
  3744. // SCRIPT.type = "text/javascript";
  3745. SCRIPT.src = `//dapi.kakao.com/v2/maps/sdk.js?appkey=${KAKAO_API_KEY}&autoload=false`;
  3746. document.body.appendChild(SCRIPT);
  3747. }
  3748.  
  3749. function drawmapKakao()
  3750. {
  3751. kakao.maps.load(function () {
  3752. var position = new kakao.maps.LatLng(33.450701, 126.560667);
  3753. let roadviewContainer = document.getElementById('roadview');
  3754. KakaoPlayer = new kakao.maps.Roadview(roadviewContainer);
  3755. var panoId = 1023434522;
  3756. KakaoPlayer.setPanoId(panoId, position);
  3757. KAKAO_INJECTED = true;
  3758. // Remove the compass from Kakao
  3759. kakao.maps.event.addListener(KakaoPlayer, 'init', () => {
  3760. const compassContainer = roadviewContainer.querySelector('div[id*="_box_util_"]');
  3761. if (compassContainer) compassContainer.style.display = 'none';
  3762. });
  3763. kakao.maps.event.addListener(KakaoPlayer, 'panoid_changed', function() {
  3764. if (defaultPanoIdChange && KakaoPlayer) {
  3765. let latlng = KakaoPlayer.getPosition();
  3766. let lat = latlng.getLat();
  3767. let lng = latlng.getLng();
  3768. let pID = KakaoPlayer.getViewpointWithPanoId();
  3769. if (nextPlayer == "Kakao" && lat != 33.45047613915499)
  3770. {
  3771. // console.log("push");
  3772. locHistory.push([lat, lng, pID.panoId, pID.pan]);
  3773. switchCovergeButton.lat = lat;
  3774. switchCovergeButton.lng = lng;
  3775. switchCovergeButton.heading = pID.pan;
  3776. }
  3777. let btn = document.querySelector("button[data-qa='undo-move']");
  3778. if (locHistory.length > 1 && (btn != null)) {
  3779. btn.disabled = false;
  3780. btn.classList.remove('styles_disabled__2YdHD');
  3781. }
  3782. // console.log(locHistory);
  3783. }
  3784. defaultPanoIdChange = true;
  3785. });
  3786. kakao.maps.event.addListener(KakaoPlayer, 'viewpoint_changed', function() {
  3787. // console.log("pov_listener attached");
  3788. let pID = KakaoPlayer.getViewpointWithPanoId();
  3789. if (locHistory.length > 0 && nextPlayer == "Kakao") {
  3790. switchCovergeButton.heading = pID.pan;
  3791. locHistory[locHistory.length - 1][3] = pID.pan;
  3792. }
  3793. if (GooglePlayer) {
  3794. const { heading, pitch } = GooglePlayer.getPov()
  3795. if ((!almostEqual(pID.pan, heading) || !almostEqual(pID.tilt, pitch)) && nextPlayer == "Kakao") {
  3796. // Updating the google street view POV will update the compass
  3797. GooglePlayer.setPov({ heading: pID.pan, pitch: pID.tilt })
  3798. }
  3799. }
  3800. // console.log(locHistory);
  3801. })
  3802. });
  3803. }
  3804.  
  3805. if (partialCreateKakao)
  3806. {
  3807. drawmapKakao();
  3808. }
  3809. else
  3810. {
  3811. SCRIPT.onload = () => {
  3812. drawmapKakao();
  3813. myHighlight("Kakao API Loaded");
  3814. resolve();
  3815. };
  3816. }
  3817.  
  3818. }
  3819. }
  3820. else {
  3821. resolve();
  3822. }
  3823. });
  3824. }
  3825.  
  3826.  
  3827. function injectMSPlayer() {
  3828. return new Promise((resolve, reject) => {
  3829. if (!MS_INJECTED) {
  3830. if (MS_API_KEY === "") {
  3831. let canvas = document.getElementById("player");
  3832. console.log("No MS Key")
  3833. }
  3834. else {
  3835.  
  3836. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3837. let SCRIPT;
  3838. if (!partialCreateMS)
  3839. {
  3840. SCRIPT = document.createElement("script");
  3841. SCRIPT.type = "text/javascript";
  3842. SCRIPT.async = true;
  3843. SCRIPT.src = `https://www.bing.com/api/maps/mapcontrol?key=${MS_API_KEY}`;
  3844. document.body.appendChild(SCRIPT);
  3845. }
  3846. let canvas = document.createElement("msmap");
  3847. if (isBattleRoyale) {
  3848. if (isDuel)
  3849. {
  3850. canvas.innerHTML = `<div id="ms-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  3851. }
  3852. else if (isBullseye)
  3853. {
  3854. 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>`;
  3855. }
  3856. else
  3857. {
  3858. 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>`;
  3859. }
  3860. }
  3861. else {
  3862. canvas.innerHTML = `<div id="ms-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  3863. }
  3864.  
  3865. var div = document.getElementById("player");
  3866. if (isBullseye)
  3867. {
  3868. div.prepend(canvas);
  3869. }
  3870. else
  3871. {
  3872. div.appendChild(canvas);
  3873. }
  3874.  
  3875. function drawmapMS()
  3876. {
  3877. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true});
  3878. MS_INJECTED = true;
  3879. // MSStreetPlayer.setOptions({
  3880. // minZoom: 13
  3881. // });
  3882. Microsoft.Maps.Events.addHandler(MSStreetPlayer, 'viewchange', function () { updateView(MSStreetPlayer); });
  3883. function updateView(map) {
  3884. let ctrm = map.getCenter();
  3885. if (nextPlayer == "MS Streetside" && (switchCovergeButton.lat !== ctrm.latitude && switchCovergeButton.lng !== ctrm.longitude))
  3886. {
  3887. let heading2 = bearing(switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude)
  3888. // console.log("moved");
  3889. // console.log([switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude])
  3890. // console.log(heading2);
  3891. locHistory.push([ctrm.latitude, ctrm.longitude, heading2]);
  3892. switchCovergeButton.lat = ctrm.latitude;
  3893. switchCovergeButton.lng = ctrm.longitude;
  3894. switchCovergeButton.heading = heading2;
  3895. let btn = document.querySelector("button[data-qa='undo-move']");
  3896. if (locHistory.length > 1 && (btn != null)) {
  3897. btn.disabled = false;
  3898. btn.classList.remove('styles_disabled__2YdHD');
  3899. }
  3900. }
  3901. }
  3902.  
  3903.  
  3904. }
  3905.  
  3906. if (partialCreateMS)
  3907. {
  3908. drawmapMS();
  3909. }
  3910. else
  3911. {
  3912. SCRIPT.addEventListener('load', () => {
  3913. myHighlight("Bing Maps API loaded");
  3914. let timeout = 0;
  3915. let interval = setInterval(() => {
  3916. if (timeout >= 40) {
  3917. reject();
  3918. clearInterval(interval);
  3919. }
  3920. if (document.getElementById('ms-player') !== null && typeof Microsoft.Maps.Map !== typeof undefined) {
  3921. drawmapMS();
  3922. resolve();
  3923. clearInterval(interval);
  3924. }
  3925. timeout += 1;
  3926. }, 1000);
  3927. })
  3928. }
  3929. }
  3930. }
  3931. else {
  3932. resolve();
  3933. }
  3934. });
  3935. }
  3936.  
  3937.  
  3938.  
  3939. function injectMapillaryPlayer() {
  3940. return new Promise((resolve, reject) => {
  3941. if (!MAPILLARY_INJECTED) {
  3942. if (MAPILLARY_API_KEY === "") {
  3943. let canvas = document.getElementById("player");
  3944. console.log("No Mapillary Key")
  3945. }
  3946. else {
  3947. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn] = setButtons();
  3948.  
  3949. let SCRIPT;
  3950. if (!partialCreateMapillary)
  3951. {
  3952. SCRIPT = document.createElement("script");
  3953. SCRIPT.type = "text/javascript";
  3954. SCRIPT.async = true;
  3955. SCRIPT.src = `https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.js`;
  3956. document.body.appendChild(SCRIPT);
  3957. document.querySelector('head').innerHTML += '<link href="https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.css" rel="stylesheet"/>';
  3958. }
  3959. let canvas = document.createElement("mmap");
  3960. if (isBattleRoyale) {
  3961. if (isDuel)
  3962. {
  3963.  
  3964. canvas.innerHTML = `<div id="mapillary-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  3965. }
  3966. else if (isBullseye)
  3967. {
  3968. 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>`;
  3969. }
  3970. else
  3971. {
  3972. 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>`;
  3973. }
  3974. }
  3975. else {
  3976. canvas.innerHTML = `<div id="mapillary-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  3977. }
  3978.  
  3979. var div = document.getElementById("player");
  3980. if (isBullseye)
  3981. {
  3982. div.prepend(canvas);
  3983. }
  3984. else
  3985. {
  3986. div.appendChild(canvas);
  3987. }
  3988.  
  3989. function drawMapML()
  3990. {
  3991. var {Viewer} = mapillary;
  3992.  
  3993. MapillaryPlayer = new Viewer({
  3994. accessToken: MAPILLARY_API_KEY,
  3995. container: 'mapillary-player', // the ID of our container defined in the HTML body
  3996. });
  3997.  
  3998. MapillaryPlayer.on('image', async (event) => {
  3999. // cnt = cnt + 1;
  4000. // console.log(cnt);
  4001. let image = event.image;
  4002. let pos = image.originalLngLat;
  4003. let cond = true;
  4004. for (const element of locHistory) {
  4005. if (element[2] == image.id)
  4006. {
  4007. cond = false;
  4008. }
  4009. }
  4010. if (cond)
  4011. {
  4012. switchCovergeButton.lat = pos.lat;
  4013. switchCovergeButton.lng = pos.lng;
  4014. switchCovergeButton.heading = image.compassAngle;
  4015. // console.log(pos);
  4016. locHistory.push([pos.lat, pos.lng, image.id, image.compassAngle]);
  4017. }
  4018. let btn = document.querySelector("button[data-qa='undo-move']");
  4019. if (btn !== null && locHistory.length > 1)
  4020. {
  4021. btn.disabled = false;
  4022. btn.classList.remove('styles_disabled__2YdHD');
  4023. }
  4024. });
  4025.  
  4026. MAPILLARY_INJECTED = true;
  4027. }
  4028. if (partialCreateMapillary)
  4029. {
  4030. drawMapML();
  4031. }
  4032. else
  4033. {
  4034.  
  4035. SCRIPT.addEventListener('load', () => {
  4036. myHighlight("Mapillary API Loaded");
  4037. // resolve(BMap);
  4038. drawMapML();
  4039. resolve();
  4040. })
  4041. }
  4042. }
  4043. }
  4044. else {
  4045. resolve();
  4046. }
  4047. });
  4048. }
  4049.  
  4050.  
  4051. function handleMapillary(latlng, options)
  4052. {
  4053. console.log("handleMapillary")
  4054. handleMapillaryHelper(latlng, options).then((data) => {
  4055. //console.log(data.data)
  4056. let idToSet = 0;
  4057. let curDist = 100000000;
  4058. for (const element of data.data) {
  4059. // console.log(element)
  4060. if (element.hasOwnProperty("computed_geometry"))
  4061. {
  4062. try {
  4063. let rCord = element.computed_geometry["coordinates"];
  4064. let dist = distance(latlng.lat,latlng.lng,rCord[1],rCord[0])
  4065. if (dist < curDist)
  4066. {
  4067. idToSet = element.id;
  4068. curDist = dist
  4069. }
  4070. } catch (e) {
  4071. console.log("Error")
  4072. }
  4073. }
  4074. }
  4075. if (idToSet !== 0)
  4076. {
  4077. MapillaryPlayer.moveTo(idToSet).then(
  4078. image => { //console.log(image);
  4079. },
  4080. error => { console.log(error); });
  4081. }}).catch((error) => {
  4082. console.log(error);
  4083. });
  4084. }
  4085.  
  4086. function handleMapillaryHelper(latlng, options)
  4087. {
  4088. return new Promise((resolve, reject) => {
  4089. // console.log("1")
  4090. let bbox = getBBox(latlng, options.meters);
  4091. 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)
  4092. // console.log(URL)
  4093. fetch(URL)
  4094. .then((response) => {resolve(response.json())})
  4095. .catch((error) => {console.log(error);});
  4096. });
  4097. }
  4098.  
  4099.  
  4100. /**
  4101. * Minimap presets
  4102. */
  4103.  
  4104. let water_name_only =
  4105. [
  4106. {
  4107. "elementType": "geometry",
  4108. "stylers": [
  4109. {
  4110. "visibility": "off"
  4111. }
  4112. ]
  4113. },
  4114. {
  4115. "featureType": "administrative",
  4116. "stylers": [
  4117. {
  4118. "visibility": "off"
  4119. }
  4120. ]
  4121. },
  4122. {
  4123. "featureType": "landscape",
  4124. "stylers": [
  4125. {
  4126. "visibility": "off"
  4127. }
  4128. ]
  4129. },
  4130. {
  4131. "featureType": "poi",
  4132. "stylers": [
  4133. {
  4134. "visibility": "off"
  4135. }
  4136. ]
  4137. },
  4138. {
  4139. "featureType": "road",
  4140. "stylers": [
  4141. {
  4142. "visibility": "off"
  4143. }
  4144. ]
  4145. },
  4146. {
  4147. "featureType": "transit",
  4148. "stylers": [
  4149. {
  4150. "visibility": "off"
  4151. }
  4152. ]
  4153. }
  4154. ]
  4155. let country_name_only =
  4156. [
  4157. {
  4158. "elementType": "geometry",
  4159. "stylers": [
  4160. {
  4161. "visibility": "off"
  4162. }
  4163. ]
  4164. },
  4165. {
  4166. "featureType": "administrative",
  4167. "stylers": [
  4168. {
  4169. "visibility": "off"
  4170. }
  4171. ]
  4172. },
  4173. {
  4174. "featureType": "administrative.country",
  4175. "elementType": "labels",
  4176. "stylers": [
  4177. {
  4178. "visibility": "on"
  4179. }
  4180. ]
  4181. },
  4182. {
  4183. "featureType": "landscape",
  4184. "stylers": [
  4185. {
  4186. "visibility": "off"
  4187. }
  4188. ]
  4189. },
  4190. {
  4191. "featureType": "poi",
  4192. "stylers": [
  4193. {
  4194. "visibility": "off"
  4195. }
  4196. ]
  4197. },
  4198. {
  4199. "featureType": "road",
  4200. "stylers": [
  4201. {
  4202. "visibility": "off"
  4203. }
  4204. ]
  4205. },
  4206. {
  4207. "featureType": "transit",
  4208. "stylers": [
  4209. {
  4210. "visibility": "off"
  4211. }
  4212. ]
  4213. },
  4214. {
  4215. "featureType": "water",
  4216. "stylers": [
  4217. {
  4218. "visibility": "off"
  4219. }
  4220. ]
  4221. }
  4222. ]
  4223.  
  4224. let no_label_or_terrain =
  4225. [
  4226. {
  4227. "elementType": "geometry",
  4228. "stylers": [
  4229. {
  4230. "visibility": "off"
  4231. }
  4232. ]
  4233. },
  4234. {
  4235. "featureType": "administrative",
  4236. "stylers": [
  4237. {
  4238. "visibility": "off"
  4239. }
  4240. ]
  4241. },
  4242. {
  4243. "featureType": "landscape",
  4244. "stylers": [
  4245. {
  4246. "visibility": "off"
  4247. }
  4248. ]
  4249. },
  4250. {
  4251. "featureType": "poi",
  4252. "stylers": [
  4253. {
  4254. "visibility": "off"
  4255. }
  4256. ]
  4257. },
  4258. {
  4259. "featureType": "road",
  4260. "stylers": [
  4261. {
  4262. "visibility": "off"
  4263. }
  4264. ]
  4265. },
  4266. {
  4267. "featureType": "transit",
  4268. "stylers": [
  4269. {
  4270. "visibility": "off"
  4271. }
  4272. ]
  4273. },
  4274. {
  4275. "featureType": "water",
  4276. "stylers": [
  4277. {
  4278. "visibility": "on"
  4279. }
  4280. ]
  4281. },
  4282. {
  4283. "featureType": "water",
  4284. "elementType": "labels",
  4285. "stylers": [
  4286. {
  4287. "visibility": "off"
  4288. }
  4289. ]
  4290. }
  4291. ]
  4292.  
  4293. let no_label =
  4294. [
  4295. {
  4296. "elementType": "labels",
  4297. "stylers": [
  4298. {
  4299. "visibility": "off"
  4300. }
  4301. ]
  4302. },
  4303. {
  4304. "featureType": "administrative",
  4305. "stylers": [
  4306. {
  4307. "visibility": "off"
  4308. }
  4309. ]
  4310. }
  4311. ]
  4312.  
  4313. let blank =
  4314.  
  4315. [
  4316. {
  4317. "stylers": [
  4318. {
  4319. "visibility": "off"
  4320. }
  4321. ]
  4322. }
  4323. ]
  4324.  
  4325. let thick_border =
  4326.  
  4327. [
  4328. {
  4329. "featureType": "administrative.country",
  4330. "elementType": "geometry.stroke",
  4331. "stylers": [
  4332. {
  4333. "weight": 1.5
  4334. }
  4335. ]
  4336. },
  4337. {
  4338. "featureType": "administrative.province",
  4339. "elementType": "geometry.stroke",
  4340. "stylers": [
  4341. {
  4342. "weight": 3.5
  4343. }
  4344. ]
  4345. }
  4346. ]
  4347.  
  4348. let Indonesia =
  4349.  
  4350. [
  4351. {
  4352. "featureType": "administrative",
  4353. "stylers": [
  4354. {
  4355. "visibility": "off"
  4356. }
  4357. ]
  4358. },
  4359. {
  4360. "featureType": "landscape",
  4361. "elementType": "labels",
  4362. "stylers": [
  4363. {
  4364. "visibility": "off"
  4365. }
  4366. ]
  4367. },
  4368. {
  4369. "featureType": "poi.park",
  4370. "elementType": "labels",
  4371. "stylers": [
  4372. {
  4373. "visibility": "off"
  4374. }
  4375. ]
  4376. },
  4377. {
  4378. "featureType": "road",
  4379. "elementType": "labels",
  4380. "stylers": [
  4381. {
  4382. "visibility": "off"
  4383. }
  4384. ]
  4385. },
  4386. {
  4387. "featureType": "transit",
  4388. "elementType": "labels",
  4389. "stylers": [
  4390. {
  4391. "visibility": "off"
  4392. }
  4393. ]
  4394. },
  4395. {
  4396. "featureType": "water",
  4397. "elementType": "labels",
  4398. "stylers": [
  4399. {
  4400. "visibility": "off"
  4401. }
  4402. ]
  4403. }
  4404. ]
  4405.  
  4406. let default_preset = []
  4407.  
  4408. let presetMinimap = [[default_preset, "Default"],
  4409. [blank, "Blank"],
  4410. [water_name_only, "Oceanman"],
  4411. [country_name_only, "Impossible"],
  4412. [no_label_or_terrain, "Streaks"],
  4413. [no_label, "Easy 5K"],
  4414. [Indonesia, "POI only"],
  4415. [thick_border, "Borders"],
  4416. [default_preset, "Satellite"],
  4417. [default_preset, "Terrain"],
  4418. [default_preset, "Hybrid"],
  4419. [custom, "Custom", customMode]]
  4420.  
  4421. let GEOJSON_INVISIBLE =
  4422. {
  4423. strokeOpacity: 0,
  4424. fillOpacity: 0,
  4425. }
  4426.  
  4427. let presetOverlay = [["Clear",""],
  4428. ["Coverage",""],
  4429. ["Official",""],
  4430. ["Longitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/lonl.json"],
  4431. ["Latitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/latl.json"],
  4432. ["US County","https://raw.githubusercontent.com/CodeForCary/CountyDataUSA5m/master/cb_2017_us_county_5m.json"],
  4433. ["France","https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements.geojson"],
  4434. ["Time Zone", "https://raw.githubusercontent.com/treyerl/timezones/master/timezones_wVVG8.geojson"],
  4435. ["UK Parliament", "https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/electoral/gb/wpc.json"],
  4436. ["Custom", YOUR_URL]]
  4437.  
  4438. /**
  4439. * Display map per local laws and regulations
  4440. */
  4441.  
  4442. let SEOverlay, NWOverlay, SEOverlay3;
  4443. let TW = [[24.80, 119.00, 22.00, 123.20],
  4444. [24.20, 119.90, 22.90, 121.85],
  4445. [24.00, 120.90, 23.80, 121.20],
  4446. [23.93, 121.03, 23.85, 121.15],
  4447. [23.92, 121.055, 23.89, 121.10],
  4448. [23.92, 121.055, 23.89, 121.10],
  4449. [23.92, 121.055, 23.89, 121.10],
  4450. ]
  4451.  
  4452. let TS = [[30.40, 93.40, 28, 97.20],
  4453. [29.40, 94.55, 28.20, 96.45]]
  4454.  
  4455. let NW = [36.20, 77.70, 34.40, 80.70]