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-26 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

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