Geoguessr Unity Script

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

Verze ze dne 26. 02. 2022. Zobrazit nejnovější verzi.

  1. // ==UserScript==
  2. // @name Geoguessr Unity Script
  3. // @description For a full list of features included in this script, see this document https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing
  4. // @version 5.2.1
  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.1 by Jupaoqq");
  288.  
  289. // Store each player instance
  290.  
  291. let YandexPlayer, KakaoPlayer, GooglePlayer, MapillaryPlayer, MSStreetPlayer;
  292. let YANDEX_INJECTED = false;
  293. let BAIDU_INJECTED = false;
  294. let KAKAO_INJECTED = false;
  295. let MAPILLARY_INJECTED = false;
  296. let MS_INJECTED = false;
  297.  
  298. // Game mode detection
  299.  
  300. let isBattleRoyale = false;
  301. let isDuel = false;
  302. let isBullseye = false;
  303. 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.1</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.1</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.1</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 (cond)
  1783. {
  1784. if (mainMenuBtn != null)
  1785. {
  1786. if (teleportBtn != null)
  1787. {
  1788. for (let element of document.getElementsByClassName("unity-btn")){
  1789. element.style.visibility = "hidden";
  1790. }
  1791. }
  1792. let iframe = document.getElementById("i_container");
  1793. if (iframe != null)
  1794. {
  1795. if (!isBattleRoyale)
  1796. {
  1797. iframe.src = ""
  1798. }
  1799. else
  1800. {
  1801. // TODO
  1802. }
  1803. }
  1804. }
  1805. }
  1806. else
  1807. {
  1808. if (mainMenuBtn != null)
  1809. {
  1810. mainMenuBtn.style.visibility = "";
  1811. mainMenuBtn.innerHTML = "<font size=2>Unity<br><font size=1>v5.2.1</font>";
  1812. mainMenuBtn.style.width = "3em"
  1813. mainMenuBtn.style.backgroundPosition = "";
  1814. mainMenuBtn.backgroundColor = ""
  1815. for (let element of document.getElementsByClassName("unity-btn")){
  1816. if (element.id !== "Show Buttons")
  1817. {
  1818. element.style.visibility = "hidden";
  1819. }
  1820. }
  1821. mainMenuBtn.hide = true;
  1822. }
  1823. }
  1824. }
  1825.  
  1826. function setDisable(cond) {
  1827. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  1828. function setAll(cond1, cond2)
  1829. {
  1830. teleportMoreBtn.style.backgroundColor = cond1;
  1831. teleportMoreBtn.disabled = cond2;
  1832. teleportLessBtn.style.backgroundColor = cond1;
  1833. teleportLessBtn.disabled = cond2;
  1834. teleportDistResetBtn.style.backgroundColor = cond1;
  1835. teleportDistResetBtn.disabled = cond2;
  1836. switchCovergeButton.style.backgroundColor = cond1;
  1837. switchCovergeButton.disabled = cond2;
  1838. teleportBtn.style.backgroundColor = cond1;
  1839. teleportBtn.disabled = cond2;
  1840. TeleportArisBtn.style.backgroundColor = cond1;
  1841. TeleportArisBtn.disabled = cond2;
  1842. timeMachineBtn.style.backgroundColor = cond1;
  1843. timeMachineBtn.disabled = cond2;
  1844. satelliteSwitchButton.style.backgroundColor = cond1;
  1845. satelliteSwitchButton.disabled = cond2;
  1846. }
  1847.  
  1848. function setMapstyle(cond1, cond2)
  1849. {
  1850. for (let mapDiv of document.getElementsByClassName("preset-minimap"))
  1851. {
  1852. if (mapDiv.id == "Borders" || mapDiv.id == "Satellite" || mapDiv.id == "Terrain" || mapDiv.id == "Hybrid" || mapDiv.id == "Custom")
  1853. {
  1854. mapDiv.style.backgroundColor = cond1;
  1855. mapDiv.disabled = cond2;
  1856. }
  1857. }
  1858. for (let mapDiv2 of document.getElementsByClassName("overlay-minimap"))
  1859. {
  1860. if (mapDiv2.id == "Coverage" || mapDiv2.id == "Official")
  1861. {
  1862. mapDiv2.style.backgroundColor = cond1;
  1863. mapDiv2.disabled = cond2;
  1864. }
  1865. }
  1866. }
  1867. // console.log(cond)
  1868.  
  1869. if (teleportBtn != null) {
  1870. if (rtded) {
  1871. setAll("red", true);
  1872. setMapstyle("red", true)
  1873. }
  1874. else
  1875. {
  1876. setMapstyle("#ff69b4", false)
  1877. if (cond == ms_sat_map)
  1878. {
  1879. setAll("red", true);
  1880. }
  1881. else if (cond == "NMPZ") {
  1882. setAll("red", true);
  1883. if (cond !== "Baidu")
  1884. {
  1885. satelliteSwitchButton.style.backgroundColor = "#BF40BF";
  1886. satelliteSwitchButton.disabled = false;
  1887. }
  1888. if (ms_radius > 1000)
  1889. {
  1890. ms_radius = 1000;
  1891. }
  1892. }
  1893. else if (cond == "Google") {
  1894. setAll("#BF40BF", false);
  1895. }
  1896. else if (cond === "Baidu" || cond === "Youtube" || cond === "Image" || cond == "Bing Satellite") {
  1897. setAll("red", true);
  1898. switchCovergeButton.style.backgroundColor = "#BF40BF";
  1899. switchCovergeButton.disabled = false;
  1900. if (cond !== "Baidu")
  1901. {
  1902. satelliteSwitchButton.style.backgroundColor = "#BF40BF";
  1903. satelliteSwitchButton.disabled = false;
  1904. }
  1905. }
  1906. else if (cond == "Kakao" || cond == "Yandex" || cond == "Mapillary" || cond == "Bing Streetside") {
  1907. setAll("#BF40BF", false);
  1908. timeMachineBtn.style.backgroundColor = "red";
  1909. timeMachineBtn.disabled = true;
  1910. }
  1911. // else if (cond == "Bing Satellite") {
  1912. // setAll("red", true);
  1913. // switchCovergeButton.style.backgroundColor = "#BF40BF";
  1914. // switchCovergeButton.disabled = false;
  1915. // satelliteSwitchButton.style.backgroundColor = "#BF40BF";
  1916. // satelliteSwitchButton.disabled = false;
  1917. // }
  1918. }
  1919. timeMachineNewerBtn.style.backgroundColor = "red";
  1920. timeMachineNewerBtn.disabled = true;
  1921. timeMachineOlderBtn.style.backgroundColor = "red";
  1922. timeMachineOlderBtn.disabled = true;
  1923. }
  1924. }
  1925.  
  1926.  
  1927. /**
  1928. * This observer stays alive while the script is running
  1929. */
  1930.  
  1931. function launchObserver() {
  1932. UnityInitiate();
  1933. handleTeleport();
  1934. SyncListener();
  1935. kBoard();
  1936. console.log("Main Observer");
  1937. const OBSERVER = new MutationObserver((mutations, observer) => {
  1938. detectGamePage();
  1939. });
  1940. observerCallback(OBSERVER)
  1941. }
  1942. function observerCallback(obs)
  1943. {
  1944. if (obs)
  1945. {
  1946. obs.observe(document.head, { attributes: true, childList: true, subtree: true });
  1947. }
  1948. else
  1949. {
  1950. setTimeout(observerCallback, 250);
  1951. }
  1952. }
  1953.  
  1954. /**
  1955. * Once the Google Maps API was loaded we can do more stuff
  1956. */
  1957.  
  1958. window.addEventListener('DOMContentLoaded', (event) => {
  1959. injecter(() => {
  1960. launchObserver();
  1961. })
  1962. });
  1963.  
  1964. const base62 = {
  1965. charset: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  1966. .split(''),
  1967. encode: integer => {
  1968. if (integer === 0) {
  1969. return 0;
  1970. }
  1971. let s = [];
  1972. while (integer > 0) {
  1973. s = [base62.charset[integer % 62], ...s];
  1974. integer = Math.floor(integer / 62);
  1975. }
  1976. return s.join('');
  1977. },
  1978. decode: chars => chars.split('').reverse().reduce((prev, curr, i) =>
  1979. prev + (base62.charset.indexOf(curr) * (62 ** i)), 0)
  1980. };
  1981.  
  1982.  
  1983. /**
  1984. * Check whether the current page is a game, if so which game mode
  1985. */
  1986.  
  1987. function detectGamePage() {
  1988. if (document.querySelector(".game-layout__panorama-message") !== null && !one_reset)
  1989. {
  1990. one_reset = true;
  1991. console.log("Hide fail to load panorama canvas");
  1992. document.querySelector(".game-layout__panorama-message").style.visibility = "hidden";
  1993. }
  1994. function loadModule()
  1995. {
  1996. if (toLoad) {
  1997. initializeCanvas();
  1998. }
  1999. waitLoad();
  2000. }
  2001. let toLoad = !playerLoaded && !YandexPlayer && !KakaoPlayer && !MapillaryPlayer && !MSStreetPlayer && !YANDEX_INJECTED && !KAKAO_INJECTED && !MAPILLARY_INJECTED && !MS_INJECTED
  2002. const PATHNAME = window.location.pathname;
  2003. if (PATHNAME.startsWith("/game/") || PATHNAME.startsWith("/challenge/")) {
  2004. // console.log("Game page");
  2005. isBattleRoyale = false;
  2006. isDuel = false;
  2007. loadModule();
  2008. }
  2009. else if (PATHNAME.startsWith("/battle-royale/")) {
  2010. if (document.querySelector(".br-game-layout") == null) {
  2011. // console.log("Battle Royale Lobby");
  2012. rstValues();
  2013. }
  2014. else {
  2015. // console.log("Battle Royale");
  2016. isBattleRoyale = true;
  2017. isDuel = false;
  2018. loadModule();
  2019. }
  2020. }
  2021. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  2022. if (document.querySelector(".game_layout__TO_jf") == null) {
  2023. // console.log("Battle Royale Lobby");
  2024. rstValues();
  2025. }
  2026. else {
  2027. // console.log("Duels");
  2028. isBattleRoyale = true;
  2029. isDuel = true;
  2030. loadModule();
  2031. }
  2032. }
  2033. else if (PATHNAME.startsWith("/bullseye/")) {
  2034. if (document.querySelector(".game_layout__0vAWj") == null) {
  2035. // console.log("Battle Royale Lobby");
  2036. rstValues();
  2037. }
  2038. else {
  2039. // console.log("bullseye");
  2040. isBattleRoyale = true;
  2041. isBullseye = true;
  2042. loadModule();
  2043. }
  2044. }
  2045. else if (PATHNAME.startsWith("/live-challenge/")) {
  2046. if (document.querySelector(".game_layout__p7CLf") == null) {
  2047. // console.log("Battle Royale Lobby");
  2048. rstValues();
  2049. }
  2050. else {
  2051. // console.log("bullseye");
  2052. isLiveChallenge = true;
  2053. isBattleRoyale = true;
  2054. loadModule();
  2055. }
  2056. }
  2057. else {
  2058. rstValues();
  2059. // console.log("Not a Game page");
  2060. }
  2061. }
  2062.  
  2063. function rstValues()
  2064. {
  2065. ROUND = 0;
  2066. YandexPlayer = null;
  2067. KakaoPlayer = null;
  2068. MapillaryPlayer = null;
  2069. MSStreetPlayer = null;
  2070.  
  2071. BAIDU_INJECTED = false;
  2072. YANDEX_INJECTED = false;
  2073. KAKAO_INJECTED = false;
  2074. MAPILLARY_INJECTED = false;
  2075. MS_INJECTED = false;
  2076.  
  2077. nextPlayer = "Google";
  2078. nextPlayer_save = "Google";
  2079. global_lat = 0;
  2080. global_lng = 0;
  2081. global_panoID = null;
  2082. global_BDAh = null;
  2083. global_BDBh = null;
  2084. global_BDID = null;
  2085. yId = null;
  2086. yTime = null;
  2087. yEnd = null;
  2088. iId = null;
  2089.  
  2090. COMPASS = null;
  2091. eventListenerAttached = false;
  2092. povListenerAttached = false;
  2093. playerLoaded = false;
  2094. locHistory = [];
  2095. one_reset = false;
  2096. setHidden(true);
  2097. yandex_map = false;
  2098. Kakao_map = false;
  2099. mmKey = 0;
  2100. CURRENT_ROUND_DATA = null;
  2101. ms_radius = 15000;
  2102. ms_random = false;
  2103. ms_birdseye = false;
  2104.  
  2105. isDuel = false;
  2106. isBattleRoyale = false;
  2107. isBullseye = false;
  2108. isLiveChallenge = false;
  2109.  
  2110. BR_LOAD_KAKAO = false;
  2111. BR_LOAD_YANDEX = false;
  2112. BR_LOAD_MS = false;
  2113.  
  2114. ms_sat_map = false;
  2115. rtded = false;
  2116.  
  2117. linksList = [];
  2118.  
  2119. NM = false;
  2120. NP = false;
  2121. NZ = false;
  2122. initBing = false;
  2123. }
  2124.  
  2125. /**
  2126. * Wait for various players to load
  2127. */
  2128.  
  2129. function waitLoad() {
  2130. if (!YandexPlayer || !KakaoPlayer || !MapillaryPlayer || !MSStreetPlayer || !YANDEX_INJECTED || !KAKAO_INJECTED || !MAPILLARY_INJECTED || !MS_INJECTED) {
  2131. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2132.  
  2133. if (document.querySelector(".ticket-bar_root__H8RcX") != null)
  2134. {
  2135. if (document.querySelector(".br-game-layout__panorama-canvas") != null)
  2136. {
  2137. AdjustBtnPos("-2em + 2px", "300px");
  2138. }
  2139. else if (document.querySelector(".game-panorama_panorama__rdhFg") != null)
  2140. {
  2141. AdjustBtnPos("6em", "0em");
  2142. }
  2143. else if (document.querySelector(".game-panorama_panorama__ncMwh") != null)
  2144. {
  2145. AdjustBtnPos("5em", "18.5em");
  2146. }
  2147. else if (document.querySelector(".game-panorama_panorama__6RmkO") != null)
  2148. {
  2149. AdjustBtnPos("4em", "15.5em");
  2150. }
  2151. else
  2152. {
  2153. AdjustBtnPos("4em", "0em");
  2154. }
  2155. }
  2156. else
  2157. {
  2158. if (document.querySelector(".br-game-layout__panorama-canvas") != null)
  2159. {
  2160. AdjustBtnPos("-6em + 2px", "300px");
  2161. }
  2162. else if (document.querySelector(".game-panorama_panorama__rdhFg") != null)
  2163. {
  2164. AdjustBtnPos("2em", "0em");
  2165. }
  2166. else if (document.querySelector(".game-panorama_panorama__ncMwh") != null)
  2167. {
  2168. AdjustBtnPos("1em", "18.5em");
  2169. }
  2170. else if (document.querySelector(".game-panorama_panorama__6RmkO") != null)
  2171. {
  2172. AdjustBtnPos("0em", "15.5em");
  2173. }
  2174. else
  2175. {
  2176. AdjustBtnPos("0em", "0em");
  2177. }
  2178. }
  2179. setTimeout(waitLoad, 250);
  2180. } else {
  2181. checkRound();
  2182. }
  2183. }
  2184.  
  2185. /**
  2186. * Checks for round changes
  2187. */
  2188.  
  2189. function checkRound() {
  2190. // console.log("Check Round");
  2191. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2192.  
  2193. if (!isBattleRoyale) {
  2194. // console.log("Check Round");
  2195. let currentRound = getRoundFromPage();
  2196. if (ROUND != currentRound) {
  2197. fire1 = true;
  2198. switchCovergeButton.init = true;
  2199. console.log("New round");
  2200. ROUND = currentRound;
  2201. // NEW_ROUND_LOADED = true;
  2202. COMPASS = null;
  2203. locHistory = [];
  2204. one_reset = false;
  2205. getMapData();
  2206. nextButtonCallback();
  2207. }
  2208. }
  2209. else {
  2210. getMapData();
  2211. }
  2212. }
  2213.  
  2214. /**
  2215. * Add listeners if buttons have been created
  2216. */
  2217.  
  2218. function finalDetail()
  2219. {
  2220. let target = document.querySelector("a[data-qa='play-same-map']");
  2221. if (target)
  2222. {
  2223. var div = document.createElement("div");
  2224. div.classList.add("buttons_buttons__0B3SB")
  2225. document.querySelector('.result-layout_content__jAHfP').appendChild(div);
  2226. for (var rd of linksList)
  2227. {
  2228. // console.log(rd)
  2229. let cl = target.cloneNode( true );
  2230. let tx = "View R" + rd[0] + " in " + rd[1];
  2231. cl.querySelector('.button_label__kpJrA').innerHTML = tx;
  2232. cl.removeAttribute('data-qa');
  2233. cl.removeAttribute('href');
  2234. cl.urlStr = rd[2];
  2235. cl.addEventListener("click", (e) => {
  2236. window.open(cl.urlStr);
  2237. })
  2238. cl.style = "top:10px;right:-10px;";
  2239. div.appendChild(cl);
  2240. }
  2241. }
  2242. else
  2243. {
  2244. setTimeout(finalDetail, 500);
  2245. }
  2246. }
  2247.  
  2248. function nextButtonCallback()
  2249. {
  2250. let nextButton = document.querySelector("button[data-qa='close-round-result']");
  2251. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2252. if (nextButton != null && fire1)
  2253. {
  2254. fire1 = false;
  2255. nextButton.addEventListener("click", (e) => {
  2256. if (mainMenuBtn != null && !cn_tips && ROUND !== 5)
  2257. {
  2258. // console.log("try to show show buttons")
  2259. mainMenuBtn.style.visibility = "";
  2260. }
  2261. if (ROUND == 5)
  2262. {
  2263. console.log("Game Finished")
  2264. if (linksList)
  2265. {
  2266. finalDetail();
  2267. }
  2268. }
  2269. })
  2270. let urlStr = ""
  2271.  
  2272. if (nextPlayer !== "Google")
  2273. {
  2274. console.log("Clone buttons");
  2275. let clone = document.querySelector("button[data-qa='close-round-result']").cloneNode( true );
  2276. let tx = "View Location in " + nextPlayer;
  2277. clone.querySelector('.button_label__kpJrA').innerHTML = tx;
  2278. clone.setAttribute('id', "LinkBtn");
  2279. clone.removeAttribute('data-qa');
  2280. if (nextPlayer == "Baidu")
  2281. {
  2282. urlStr = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  2283. }
  2284. else if (nextPlayer == "Youtube")
  2285. {
  2286. urlStr = "https://www.youtube.com/watch?v=" + yId;
  2287. }
  2288. else if (nextPlayer == "Image")
  2289. {
  2290. urlStr = iId;
  2291. }
  2292. else if (nextPlayer == "Kakao")
  2293. {
  2294. urlStr = "https://map.kakao.com/link/roadview/" + global_lat + "," + global_lng;
  2295. }
  2296. else if (nextPlayer == "Mapillary")
  2297. {
  2298. urlStr = "https://www.mapillary.com/app/?pKey=" + mmKey + "&focus=photo";
  2299. }
  2300. else if (nextPlayer == "Yandex")
  2301. {
  2302. urlStr = "https://yandex.com/maps/?&panorama%5Bdirection%5D=16%2C0&panorama%5Bpoint%5D=" + global_lng + "%2C" + global_lat;
  2303. }
  2304. else if (nextPlayer == "Bing Satellite" || nextPlayer == "Bing Streetside")
  2305. {
  2306. urlStr = "https://bing.com/maps/default.aspx?cp=" + global_lat + "~" + global_lng + "&lvl=20&style=r";
  2307. }
  2308. clone.addEventListener("click", (e) => {
  2309. window.open(urlStr);
  2310. })
  2311. if (ROUND == 5)
  2312. {
  2313. clone.style = "top:10px;";
  2314. }
  2315. else
  2316. {
  2317. clone.style = "right:-10px;";
  2318. }
  2319. linksList.push([ROUND, nextPlayer, urlStr]);
  2320. document.querySelector('.round-result_actions__5j26U').appendChild(clone);
  2321. }
  2322. }
  2323. else
  2324. {
  2325. setTimeout(nextButtonCallback, 1000);
  2326. }
  2327. }
  2328.  
  2329. function guessButtonCallback()
  2330. {
  2331. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2332. let guessButton = document.querySelector("button[data-qa='perform-guess']");
  2333. if (guessButton != null)
  2334. {
  2335.  
  2336. guessButton.addEventListener("click", (e) => {
  2337. if (mainMenuBtn != null)
  2338. {
  2339. console.log("try to hide show buttons")
  2340. mainMenuBtn.style.visibility = "hidden";
  2341. setHidden(true);
  2342. }
  2343. })
  2344. }
  2345. else
  2346. {
  2347. setTimeout(guessButtonCallback, 500);
  2348. }
  2349. }
  2350.  
  2351. /**
  2352. * Load different streetview players
  2353. */
  2354.  
  2355. function loaderChecker(data)
  2356. {
  2357.  
  2358. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2359. if (data.includes("A United World") || data.includes("A Unity World") || data.includes("Unity Test") || data.includes("Unity Special Edition"))
  2360. {
  2361. console.log("Complete Map");
  2362. data = "Yandex Bing Streetside Kakao";
  2363. }
  2364.  
  2365. if (data.includes("Yandex"))
  2366. {
  2367. console.log("Yandex Map");
  2368. if (data == "Yandex Bing Streetside Kakao")
  2369. {
  2370. yandex_map = false;
  2371. }
  2372. else
  2373. {
  2374. yandex_map = true;
  2375. }
  2376. injectYandexScript().then(() => {
  2377. console.log("Ready to inject Yandex player");
  2378. injectYandexPlayer();
  2379. }).catch((error) => {
  2380. console.log(error);
  2381. });
  2382. BR_LOAD_YANDEX = true;
  2383. }
  2384. else
  2385. {
  2386. console.log("Not Yandex map");
  2387. YANDEX_INJECTED = true;
  2388. YandexPlayer = "YD";
  2389. }
  2390.  
  2391. if (data.includes("Bing Streetside") || data.includes("Bing Satellite") || (sessionStorage.getItem('Satellite') == "T" && !rtded))
  2392. {
  2393. if (data.includes("Bing Satellite"))
  2394. {
  2395. ms_sat_map = true;
  2396. let tempRad = data.split("Bing Satellite")[1];
  2397. if (/\d/.test(tempRad))
  2398. {
  2399. ms_radius = parseInt(tempRad.replace(/\D/g,'')) * 1000;
  2400. }
  2401. if (tempRad.includes("Birdseye"))
  2402. {
  2403. ms_birdseye = true;
  2404. }
  2405. if (tempRad.includes("Random"))
  2406. {
  2407. ms_random = true;
  2408. }
  2409. }
  2410. console.log("Bing Map");
  2411. injectMSPlayer();
  2412. initBing = true;
  2413. BR_LOAD_MS = true;
  2414. }
  2415. else
  2416. {
  2417. console.log("Not Bing map");
  2418. MS_INJECTED = true;
  2419. MSStreetPlayer = "MS";
  2420. }
  2421.  
  2422. if (data.includes("Kakao"))
  2423. {
  2424. console.log("Kakao Map");
  2425. if (data == "Yandex Bing Streetside Kakao")
  2426. {
  2427. Kakao_map = false;
  2428. }
  2429. else
  2430. {
  2431. Kakao_map = true;
  2432. }
  2433. injectKakaoScript().then(() => {
  2434. console.log("Ready to inject Kakao player");
  2435. }).catch((error) => {
  2436. console.log(error);
  2437. });
  2438. BR_LOAD_KAKAO = true;
  2439. }
  2440. else{
  2441. KAKAO_INJECTED = true;
  2442. KakaoPlayer = "KK";
  2443. console.log("Not Kakao map");
  2444. }
  2445.  
  2446.  
  2447. if (!data.includes("China Tips for each province"))
  2448. {
  2449. cn_tips = false;
  2450. mainMenuBtn.style.visibility = "";
  2451. setHidden(false);
  2452. }
  2453. else
  2454. {
  2455. cn_tips = true;
  2456. guaranteeUI();
  2457. }
  2458.  
  2459. }
  2460.  
  2461. function loadPlayers() {
  2462. let mapBounds;
  2463. playerLoaded = true;
  2464. injectContainer();
  2465. getSeed().then((data) => {
  2466. console.log(data)
  2467. let map_name = "Default"
  2468. if (typeof data.isRated !== 'undefined')
  2469. {
  2470. rtded = data.isRated;
  2471. }
  2472. if (rtded)
  2473. {
  2474. map_name = "Public Game";
  2475. }
  2476. else
  2477. {
  2478. if (!isBattleRoyale)
  2479. {
  2480. mapBounds = [data.bounds.max.lat, data.bounds.max.lng, data.bounds.min.lat, data.bounds.min.lng];
  2481. map_name = data.mapName;
  2482. }
  2483. else
  2484. {
  2485. if (isBullseye)
  2486. {
  2487. mapBounds = [data.boundingBox.max.lat, data.boundingBox.max.lng, data.boundingBox.min.lat, data.boundingBox.min.lng];
  2488. map_name = data.mapName;
  2489. }
  2490. else if (isDuel)
  2491. {
  2492. mapBounds = [data.mapBounds.max.lat, data.mapBounds.max.lng, data.mapBounds.min.lat, data.mapBounds.min.lng];
  2493. map_name = data.options.map.name;
  2494. }
  2495. else if (isLiveChallenge)
  2496. {
  2497. mapBounds = [data.mapBounds.max.lat, data.mapBounds.max.lng, data.mapBounds.min.lat, data.mapBounds.min.lng];
  2498. map_name = data.mapName;
  2499. }
  2500. else
  2501. {
  2502. map_name = "Unity Test";
  2503. }
  2504. }
  2505. }
  2506. if (mapBounds)
  2507. {
  2508. ms_radius = magic_formula(mapBounds);
  2509. // console.log(ms_radius / 1000)
  2510. }
  2511. loaderChecker(map_name)
  2512.  
  2513. }).catch((error) => {
  2514. console.log(error);
  2515. });
  2516.  
  2517. }
  2518.  
  2519. function guaranteeUI()
  2520. {
  2521. // console.log("UI")
  2522. if (document.getElementById("GH-ui") !== null)
  2523. {
  2524. document.getElementById("GH-ui").style.display = "block";
  2525. }
  2526. else
  2527. {
  2528. setTimeout(guaranteeUI, 500);
  2529. }
  2530. }
  2531.  
  2532. /**
  2533. * Handles Return to start and undo
  2534. */
  2535.  
  2536. function handleReturnToStart() {
  2537. let rtsButton = document.querySelector("button[data-qa='return-to-start']");
  2538. console.log("Handle Return to start");
  2539. rtsButton.addEventListener("click", (e) => {
  2540. if (nextPlayer !== "Baidu")
  2541. {
  2542. goToLocation(true);
  2543. }
  2544. else
  2545. {
  2546. document.getElementById("i_container").src = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  2547. }
  2548. const elementClicked = e.target;
  2549. elementClicked.setAttribute('listener', 'true');
  2550. console.log("Return to start");
  2551. });
  2552. guessButtonCallback();
  2553. // setTimeout(function () {goToLocation();}, 1000);
  2554. }
  2555.  
  2556. function handleUndo() {
  2557. let undoButton = document.querySelector("button[data-qa='undo-move']");
  2558. console.log("Handle undo");
  2559. undoButton.addEventListener("click", (e) => {
  2560. if (locHistory.length > 0) {
  2561. goToUndoMove();
  2562. console.log("Undo Move");
  2563. }
  2564. })
  2565. }
  2566.  
  2567. /**
  2568. * Load game information
  2569. */
  2570.  
  2571. function satCallback()
  2572. {
  2573. // console.log("Sat callback")
  2574. if (typeof MSStreetPlayer.entities !== typeof undefined && typeof Microsoft.Maps !== typeof undefined)
  2575. {
  2576. goToLocation(false);
  2577. }
  2578. else
  2579. {
  2580. setTimeout(satCallback, 250);
  2581. }
  2582. }
  2583.  
  2584. function kakaoCallback()
  2585. {
  2586. console.log("Kakao callback")
  2587. if (typeof kakao.maps !== typeof undefined)
  2588. {
  2589. goToLocation(true);
  2590. // setTimeout(function () {goToLocation(true);}, 5000);
  2591. }
  2592. else
  2593. {
  2594. setTimeout(satCallback, 250);
  2595. }
  2596. }
  2597.  
  2598.  
  2599. function modularget(data)
  2600. {
  2601. if (data)
  2602. {
  2603. locationCheck(data);
  2604. if (nextPlayer == "Kakao")
  2605. {
  2606. kakaoCallback();
  2607. }
  2608. else
  2609. {
  2610. goToLocation(true);
  2611. }
  2612. handleMinimapCallback();
  2613. handleButtons();
  2614. }
  2615. }
  2616.  
  2617. function getMapData() {
  2618. // myHighlight("Seed data");
  2619.  
  2620. getSeed().then((data) => {
  2621. let switchCovergeButton = document.getElementById("switch");
  2622. let mainMenuBtn = document.getElementById("Show Buttons")
  2623. if (isBattleRoyale) {
  2624. if (data.status == "Finished" || typeof data.gameId == typeof undefined) {
  2625. // console.log("Battle Royale Lobby");
  2626. }
  2627. else
  2628. {
  2629. let origin = false;
  2630. if (!CURRENT_ROUND_DATA) {
  2631. CURRENT_ROUND_DATA = data
  2632. origin = true;
  2633. }
  2634.  
  2635. if (origin || !(data.currentRoundNumber === CURRENT_ROUND_DATA.currentRoundNumber)) {
  2636. // myHighlight("Battle Royale New round");
  2637. switchCovergeButton.init = true;
  2638. // NEW_ROUND_LOADED = true;
  2639. COMPASS = null;
  2640. locHistory = [];
  2641. one_reset = false;
  2642. setHidden(false);
  2643. if (!origin) {
  2644. CURRENT_ROUND_DATA = data;
  2645. }
  2646. modularget(data);
  2647. }
  2648. }
  2649. }
  2650. else {
  2651. if (!cn_tips)
  2652. {
  2653. mainMenuBtn.style.visibility = "";
  2654. }
  2655. else
  2656. {
  2657. mainMenuBtn.style.visibility = "hidden";
  2658. AdjustBtnPos("14em", "0em");
  2659. }
  2660. modularget(data);
  2661. }
  2662.  
  2663. }).catch((error) => {
  2664. console.log(error);
  2665. });
  2666. }
  2667.  
  2668. function handleMinimapCallback()
  2669. {
  2670. let trueCond = true;
  2671. let timeoutTime = 250;
  2672. if (isBattleRoyale) {
  2673. if (isDuel)
  2674. {
  2675. if (document.querySelector(".overlay_overlay__AR02x"))
  2676. {
  2677. trueCond = false;
  2678. }
  2679. else
  2680. {
  2681. trueCond = true;
  2682. }
  2683. }
  2684. else
  2685. {
  2686. if (document.querySelector(".popup__content"))
  2687. {
  2688. trueCond = false;
  2689. }
  2690. else
  2691. {
  2692. trueCond = true;
  2693. }
  2694. }
  2695. timeoutTime = 2500;
  2696. }
  2697.  
  2698. if (trueCond)
  2699. {
  2700. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2701. let cur = MinimapBtn.current;
  2702. // console.log(cur)
  2703. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  2704. if (cur == mapDiv.id)
  2705. {
  2706. setTimeout(function () {mapDiv.click();}, 500);
  2707. setTimeout(function () {mapDiv.click();}, 1000);
  2708. setTimeout(function () {mapDiv.click();}, 3000);
  2709. }
  2710. }
  2711. }
  2712. else
  2713. {
  2714. setTimeout(handleMinimapCallback, timeoutTime);
  2715. }
  2716. }
  2717.  
  2718. /**
  2719. * Hide unnecessary buttons for non-Google coverages
  2720. */
  2721.  
  2722. function handleButtons() {
  2723. let CHECKPOINT = document.querySelector("button[data-qa='set-checkpoint']");
  2724. let ZOOM_IN = document.querySelector("button[data-qa='pano-zoom-in']");
  2725. let ZOOM_OUT = document.querySelector("button[data-qa='pano-zoom-out']");
  2726. let UNDO_MOVE = document.querySelector("button[data-qa='undo-move']");
  2727. let DEFAULT_COMPASS = document.querySelector(".compass");
  2728. let NEW_COMPASS = document.querySelector(".panorama-compass_compassContainer__MEnh0");
  2729. let RETURN_TO_START = document.querySelector("button[data-qa='return-to-start']");
  2730.  
  2731. let C1 = (CHECKPOINT !== null);
  2732. let C2 = (ZOOM_IN !== null);
  2733. let C3 = (ZOOM_OUT !== null);
  2734. let C4 = (UNDO_MOVE !== null);
  2735. let C5 = (DEFAULT_COMPASS !== null);
  2736. let C6 = (NEW_COMPASS !== null);
  2737. let C7 = (RETURN_TO_START !== null);
  2738.  
  2739. let waitCond = C5 || C6;
  2740. let cpCond = true;
  2741. let comCond = true;
  2742. if (!NM)
  2743. {
  2744. cpCond = C1 && C4 && C7;
  2745. }
  2746. if (!NZ)
  2747. {
  2748. comCond = C2 && C3;
  2749. }
  2750.  
  2751. function moduleButtons(cond)
  2752. {
  2753.  
  2754. if (!NM)
  2755. {
  2756. CHECKPOINT.style.visibility = cond;
  2757. UNDO_MOVE.style.visibility = cond;
  2758. }
  2759. if (!NZ)
  2760. {
  2761. ZOOM_IN.style.visibility = cond;
  2762. ZOOM_OUT.style.visibility = cond;
  2763. }
  2764. if (C5)
  2765. {
  2766. DEFAULT_COMPASS.style.visibility = cond;
  2767. }
  2768. if (C6)
  2769. {
  2770. NEW_COMPASS.style.visibility = cond;
  2771. }
  2772. }
  2773.  
  2774. if (waitCond && cpCond && comCond)
  2775. {
  2776. console.log("Handle Buttons");
  2777. if (nextPlayer === "Google") {
  2778. moduleButtons("");
  2779. }
  2780. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Bing Satellite")
  2781. {
  2782. moduleButtons("hidden");
  2783. }
  2784. else if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Mapillary" || nextPlayer === "Bing Streetside")
  2785. {
  2786. moduleButtons("hidden");
  2787. if (nextPlayer === "Yandex" || nextPlayer === "Kakao")
  2788. {
  2789. if (C5)
  2790. {
  2791. DEFAULT_COMPASS.style.visibility = "";
  2792. }
  2793. if (C6)
  2794. {
  2795. NEW_COMPASS.style.visibility = "";
  2796. }
  2797. }
  2798. if (!NM)
  2799. {
  2800. UNDO_MOVE.style.visibility = "";
  2801. handleUndo();
  2802. }
  2803. }
  2804. if (!NM)
  2805. {
  2806. handleReturnToStart();
  2807. }
  2808. }
  2809. else
  2810. {
  2811. setTimeout(handleButtons, 250);
  2812. }
  2813. }
  2814.  
  2815. /**
  2816. * Check which player to use for the next location
  2817. */
  2818.  
  2819. function locationCheck(data) {
  2820. // console.log(data);
  2821. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2822. let round;
  2823.  
  2824.  
  2825.  
  2826. if (isBattleRoyale) {
  2827. if (isDuel || isBullseye || isLiveChallenge)
  2828. {
  2829. round = data.rounds[data.currentRoundNumber - 1].panorama;
  2830. }
  2831. else
  2832. {
  2833. round = data.rounds[data.currentRoundNumber - 1];
  2834. }
  2835. }
  2836. else {
  2837. round = data.rounds[data.round - 1];
  2838. }
  2839. global_lat = round.lat;
  2840. global_lng = round.lng;
  2841. global_panoID = round.panoId;
  2842. global_heading = round.heading;
  2843. global_pitch = round.pitch;
  2844.  
  2845. nextPlayer = "Google";
  2846.  
  2847. // if (ms_sat_map)
  2848. // {
  2849. // nextPlayer = "Bing Satellite";
  2850. // }
  2851.  
  2852. if (global_panoID) {
  2853. let locInfo;
  2854. if (isBullseye || isLiveChallenge)
  2855. {
  2856. locInfo = global_panoID;
  2857. }
  2858. else
  2859. {
  2860. locInfo = hex2a(global_panoID);
  2861. }
  2862. // console.log(locInfo)
  2863. if (locInfo.substring(0, 3) == "YTB")
  2864. {
  2865. nextPlayer = "Youtube";
  2866. let lengths = [3, 11, 4, 4];
  2867. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2868. let fullID = locInfo.substring(3).split('START');
  2869. yId = toPiece[1];
  2870. yTime = Number(toPiece[2]);
  2871. yEnd = Number(toPiece[3]);
  2872. }
  2873. else
  2874. {
  2875. let mapType = locInfo.substring(0, 5);
  2876.  
  2877. // panoId unchanged
  2878.  
  2879. if (mapType === "YDMAP" ) {
  2880. nextPlayer = "Yandex";
  2881. }
  2882. else if (mapType === "KKMAP" ) {
  2883. nextPlayer = "Kakao";
  2884. }
  2885.  
  2886. // New panoId formats
  2887.  
  2888. else if (mapType === "BAIDU" ) {
  2889. nextPlayer = "Baidu";
  2890. let lengths = [5, 7, 7, 3];
  2891. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2892. let panoId1 = base62.decode(toPiece[1]).toString().substring(1);
  2893. let panoId2 = base62.decode(toPiece[2]).toString().substring(1);
  2894. global_BDID = panoId1 + panoId2 + toPiece[3]
  2895. }
  2896. else if (mapType === "MAPIL")
  2897. {
  2898. nextPlayer = "Mapillary";
  2899. mmKey = locInfo.substring(5).replace(/\D/g,'');
  2900. }
  2901. else if (mapType === "IMAGE")
  2902. {
  2903. nextPlayer = "Image";
  2904. let lengths = [5, 4, 4, 7, 2];
  2905. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2906. iId = "https://i.ibb.co/" + toPiece[3] + "/" + toPiece[1] + "." + toPiece[2].replace(/[^0-9a-z]/gi, '')
  2907. }
  2908. else if (mapType === "BINGM" ) {
  2909. nextPlayer = "Bing Streetside";
  2910. }
  2911. else if (mapType === "SATEL" ) {
  2912. nextPlayer = "Bing Satellite";
  2913. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  2914. }
  2915.  
  2916. // legacy panoId formats support
  2917.  
  2918. else if (mapType === "BDMAP") {
  2919. nextPlayer = "Baidu";
  2920. let coord = locInfo.substring(5);
  2921.  
  2922. if(coord.includes('BDAh'))
  2923. {
  2924. global_BDID = coord.split('BDAh')[0].replace("panoId","");
  2925. let tem = coord.split('BDAh')[1];
  2926. global_BDAh = tem.split('BDBh')[0];
  2927. global_BDBh = tem.split('BDBh')[1];
  2928. }
  2929. else
  2930. {
  2931. global_BDID = coord.replace("panoId","");
  2932. }
  2933. }
  2934. else if (mapType === "MLMAP") {
  2935. nextPlayer = "Mapillary";
  2936. mmKey = locInfo.substring(5);
  2937. }
  2938. else
  2939. {
  2940. nextPlayer = "Google";
  2941. // GooglePlayer.setPano(locInfo);
  2942. }
  2943. }
  2944. }
  2945. else
  2946. {
  2947. if (Kakao_map)
  2948. {
  2949. nextPlayer = "Kakao";
  2950. }
  2951. else if (yandex_map)
  2952. {
  2953. nextPlayer = "Yandex";
  2954. }
  2955. else
  2956. {
  2957. nextPlayer = "Google";
  2958. }
  2959. }
  2960.  
  2961. // if ( krCoordinates[0] > global_lat && krCoordinates[2] < global_lat && krCoordinates[1] < global_lng && krCoordinates[3] > global_lng)
  2962. // {
  2963. // nextSecondaryPlayer = "Kakao";
  2964. // }
  2965. // else if (nextPlayer = "Mapillary")
  2966. // {
  2967. // nextSecondaryPlayer = "Google";
  2968. // }
  2969. // else
  2970. // {
  2971. // nextSecondaryPlayer = "Mapillary";
  2972. // }
  2973.  
  2974. // Disable buttons if NM, NMPZ
  2975.  
  2976. if(!isBattleRoyale)
  2977. {
  2978. NM = data.forbidMoving;
  2979. NP = data.forbidRotating;
  2980. NZ = data.forbidZooming;
  2981. }
  2982. else
  2983. {
  2984. // console.log(data)
  2985. if (isBullseye || isLiveChallenge)
  2986. {
  2987. NM = data.options.movementOptions.forbidMoving;
  2988. NP = data.options.movementOptions.forbidRotating;
  2989. NZ = data.options.movementOptions.forbidZooming;
  2990. }
  2991. else
  2992. {
  2993. NM = data.movementOptions.forbidMoving;
  2994. NP = data.movementOptions.forbidRotating;
  2995. NZ = data.movementOptions.forbidZooming;
  2996. }
  2997. }
  2998. if (NM || NP || NZ)
  2999. {
  3000.  
  3001. setDisable("NMPZ");
  3002. }
  3003. else
  3004. {
  3005. setDisable(nextPlayer);
  3006. }
  3007.  
  3008. if (nextPlayer == "Google")
  3009. {
  3010. switchCovergeButton.innerHTML = "Switch to Mapillary";
  3011. }
  3012. else
  3013. {
  3014. switchCovergeButton.innerHTML = "Switch to Google";
  3015. }
  3016. nextPlayer_save = nextPlayer;
  3017. console.log(nextPlayer_save);
  3018.  
  3019. // console.log("??")
  3020. // console.log(sessionStorage.getItem('Satellite') == "T")
  3021. if (ms_sat_map || (sessionStorage.getItem('Satellite') == "T" && nextPlayer !== "Baidu" && nextPlayer !== "Bing Streetside" && !rtded))
  3022. {
  3023. nextPlayer = "Bing Satellite";
  3024. }
  3025.  
  3026. if (nextPlayer == "Bing Satellite")
  3027. {
  3028. let di3 = formatDist();
  3029. satelliteSwitchButton.innerHTML = `Satellite (${di3})`;
  3030. }
  3031. else
  3032. {
  3033. satelliteSwitchButton.innerHTML = "Streeview mode";
  3034. }
  3035. console.log(nextPlayer);
  3036.  
  3037.  
  3038. injectCanvas(false);
  3039. }
  3040.  
  3041.  
  3042. /**
  3043. * setID for canvas
  3044. */
  3045.  
  3046. function initializeCanvas() {
  3047. let GAME_CANVAS = "";
  3048. let DUEL_CANVAS = "";
  3049. //console.log("Is duels");
  3050. //console.log(duels);
  3051.  
  3052. if (isBattleRoyale) {
  3053. if (isDuel) {
  3054. GAME_CANVAS = document.querySelector(".game-panorama_panorama__rdhFg");
  3055. DUEL_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__PNKve");
  3056. }
  3057. else if (isBullseye) {
  3058. GAME_CANVAS = document.querySelector(".game-panorama_panorama__ncMwh");
  3059. DUEL_CANVAS = "dummy";
  3060. }
  3061. else if (isLiveChallenge)
  3062. {
  3063. GAME_CANVAS = document.querySelector(".game-panorama_panorama__6RmkO");
  3064. DUEL_CANVAS = "dummy";
  3065. }
  3066. else
  3067. {
  3068. GAME_CANVAS = document.querySelector(".br-game-layout__panorama-wrapper");
  3069. DUEL_CANVAS = "dummy";
  3070. }
  3071. }
  3072. else {
  3073. GAME_CANVAS = document.querySelector(".game-layout__canvas");
  3074. DUEL_CANVAS = "dummy";
  3075. }
  3076. if (GAME_CANVAS && DUEL_CANVAS)
  3077. {
  3078. // console.log("Canvas injected");
  3079. GAME_CANVAS.id = "player";
  3080.  
  3081. if (isDuel) {
  3082. DUEL_CANVAS.id = "default_player";
  3083. }
  3084. partialCreateMapillary = (typeof mapillary !== typeof undefined)
  3085. partialCreateYandex = (typeof ymaps !== typeof undefined)
  3086. partialCreateKakao = (typeof kakao !== typeof undefined)
  3087. partialCreateMS = (typeof Microsoft !== typeof undefined);
  3088. loadPlayers();
  3089. injectMapillaryPlayer();
  3090. }
  3091. else
  3092. {
  3093. setTimeout(initializeCanvas, 250);
  3094. }
  3095.  
  3096. }
  3097.  
  3098. /**
  3099. * Hide or show players based on where the next location is
  3100. */
  3101.  
  3102. function injectCanvas(cond) {
  3103. if (isDuel)
  3104. {
  3105. canvasSwitch(cond);
  3106. }
  3107. else
  3108. {
  3109. // console.log("BING??")
  3110. // console.log(BR_LOAD_MS)
  3111.  
  3112. Google();
  3113. Baidu();
  3114. if (BR_LOAD_KAKAO)
  3115. {
  3116. Kakao();
  3117. }
  3118. if (BR_LOAD_YANDEX)
  3119. {
  3120. Yandex();
  3121. }
  3122. if (BR_LOAD_MS)
  3123. {
  3124. // console.log("Yes")
  3125. Bing(cond);
  3126. }
  3127. Mapillary();
  3128. }
  3129. ZoomControls();
  3130. }
  3131.  
  3132. // for duels (class ID change)
  3133.  
  3134. function canvasSwitch(cond)
  3135. {
  3136.  
  3137. console.log("canvas switch")
  3138. // let cond = true;
  3139. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3140. let GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panorama__rdhFg");
  3141. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  3142. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  3143. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  3144. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  3145. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  3146. // 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])
  3147.  
  3148. 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))
  3149. {
  3150. document.getElementById("default_player").style.position = "absolute";
  3151. document.getElementById("default_player").className = "inactive";
  3152. BAIDU_MAPS_CANVAS.style.position = "absolute";
  3153. BAIDU_MAPS_CANVAS.className = "inactive";
  3154. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  3155. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  3156. MAPILLARY_MAPS_CANVAS.className = "inactive";
  3157. if (BR_LOAD_KAKAO)
  3158. {
  3159. KAKAO_MAPS_CANVAS.style.position = "absolute";
  3160. KAKAO_MAPS_CANVAS.className = "inactive";
  3161. }
  3162. if (BR_LOAD_YANDEX)
  3163. {
  3164. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  3165. YANDEX_MAPS_CANVAS.style.position = "absolute";
  3166. }
  3167. if (BR_LOAD_MS)
  3168. {
  3169. BING_MAPS_CANVAS.style.position = "absolute";
  3170. BING_MAPS_CANVAS.className = "inactive";
  3171. }
  3172.  
  3173. if (!cond)
  3174. {
  3175. teleportBtn.google = false;
  3176. switchCovergeButton.useGoogle = false;
  3177. }
  3178.  
  3179. if (nextPlayer === "Google") {
  3180. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  3181. teleportBtn.google = true;
  3182. switchCovergeButton.useGoogle = true;
  3183. console.log("Google Duel Canvas loaded");
  3184. }
  3185. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image")
  3186. {
  3187. BAIDU_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3188. console.log("Container Duel Canvas loaded");
  3189. }
  3190. else if (nextPlayer === "Kakao")
  3191. {
  3192. if (BR_LOAD_KAKAO)
  3193. {
  3194. KAKAO_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3195. }
  3196. console.log("Kakao Duel Canvas loaded");
  3197. }
  3198. else if (nextPlayer === "Yandex")
  3199. {
  3200. if (BR_LOAD_YANDEX)
  3201. {
  3202. YANDEX_MAPS_CANVAS.style.visibility = "";
  3203. }
  3204. console.log("Yandex Duel Canvas loaded");
  3205. }
  3206. else if (nextPlayer === "Mapillary")
  3207. {
  3208. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  3209. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3210. // MapillaryPlayer.resize();
  3211. console.log("Mapillary Duel Canvas loaded");
  3212. }
  3213. else if (nextPlayer === "Bing Streetside" || nextPlayer === "Bing Satellite")
  3214. {
  3215. if (BR_LOAD_MS)
  3216. {
  3217. BING_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3218. }
  3219. console.log("MS Duel Canvas loaded");
  3220. }
  3221. }
  3222. else
  3223. {
  3224. setTimeout(canvasSwitch(cond), 1000);
  3225. }
  3226. }
  3227.  
  3228. // for Battle Royale and classic (change visibility)
  3229.  
  3230. function Google() {
  3231. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3232. let GOOGLE_MAPS_CANVAS = ""
  3233. if (isBattleRoyale) {
  3234. if (isBullseye)
  3235. {
  3236. GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__r_5ea");
  3237. }
  3238. if (isLiveChallenge)
  3239. {
  3240. GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__gp8og");
  3241. }
  3242. else
  3243. {
  3244. GOOGLE_MAPS_CANVAS = document.querySelector(".br-game-layout__panorama-canvas");
  3245. }
  3246. }
  3247. else {
  3248. GOOGLE_MAPS_CANVAS = document.querySelector(".game-layout__panorama-canvas");
  3249. }
  3250. if (nextPlayer === "Google") {
  3251. GOOGLE_MAPS_CANVAS.style.visibility = "";
  3252. teleportBtn.google = true;
  3253. switchCovergeButton.useGoogle = true;
  3254. console.log("Google Canvas loaded");
  3255. }
  3256. else {
  3257. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  3258. teleportBtn.google = false;
  3259. // console.log("Google Canvas hidden");
  3260. }
  3261. }
  3262.  
  3263. function Baidu() {
  3264. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  3265. // console.log("Baidu canvas");
  3266. if (BAIDU_MAPS_CANVAS !== null)
  3267. {
  3268. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3269. BAIDU_MAPS_CANVAS.style.position = "absolute";
  3270. if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  3271. BAIDU_MAPS_CANVAS.style.visibility = "";
  3272. switchCovergeButton.useGoogle = false;
  3273. console.log("Container Canvas loaded");
  3274. }
  3275. else {
  3276. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  3277. // console.log("Container Canvas hidden");
  3278. }
  3279. }
  3280. else
  3281. {
  3282. setTimeout(Baidu, 250);
  3283. }
  3284.  
  3285. }
  3286.  
  3287. function Kakao() {
  3288. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  3289. // console.log("Kakao canvas");
  3290. if (KAKAO_MAPS_CANVAS != null)
  3291. {
  3292. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3293. KAKAO_MAPS_CANVAS.style.position = "absolute";
  3294. if (nextPlayer === "Kakao") {
  3295. KAKAO_MAPS_CANVAS.style.visibility = "";
  3296. switchCovergeButton.useGoogle = false;
  3297. console.log("Kakao Canvas loaded");
  3298. }
  3299. else {
  3300. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  3301. // console.log("Kakao Canvas hidden");
  3302. }
  3303. }
  3304. else
  3305. {
  3306. setTimeout(Kakao, 250);
  3307. }
  3308.  
  3309. }
  3310.  
  3311. function Yandex() {
  3312. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  3313. if (YANDEX_MAPS_CANVAS != null)
  3314. {
  3315. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3316. if (isBullseye)
  3317. {
  3318. let div = document.getElementById("player");
  3319. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__ncMwh");
  3320. div.prepend(YANDEX_MAPS_CANVAS);
  3321. }
  3322. if (isLiveChallenge)
  3323. {
  3324. let div = document.getElementById("player");
  3325. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__6RmkO");
  3326. div.prepend(YANDEX_MAPS_CANVAS);
  3327. }
  3328. // console.log("Yandex canvas");
  3329. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  3330. // console.log("Yandex canvas");
  3331. /* console.log(YANDEX_MAPS_CANVAS); */
  3332. if (nextPlayer === "Yandex") {
  3333. YANDEX_MAPS_CANVAS.style.visibility = "";
  3334. switchCovergeButton.useGoogle = false;
  3335. console.log("Yandex Canvas loaded");
  3336. }
  3337. else {
  3338. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  3339. console.log("Yandex Canvas hidden");
  3340. }
  3341. }
  3342. else
  3343. {
  3344. setTimeout(Yandex, 250);
  3345. }
  3346.  
  3347. }
  3348.  
  3349. function Mapillary()
  3350. {
  3351. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  3352. if (MAPILLARY_MAPS_CANVAS != null)
  3353. {
  3354. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3355. // console.log("Mapillary canvas");
  3356. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  3357. if (nextPlayer === "Mapillary") {
  3358. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  3359. switchCovergeButton.useGoogle = false;
  3360. console.log("Mapillary Canvas loaded");
  3361.  
  3362. }
  3363. else {
  3364. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  3365. // console.log("Mapillary Canvas hidden");
  3366. }
  3367. }
  3368. else
  3369. {
  3370. setTimeout(Mapillary, 250);
  3371. }
  3372.  
  3373. }
  3374.  
  3375. function Bing(cond) {
  3376. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  3377. // console.log("stuck")
  3378. if (BING_MAPS_CANVAS != null)
  3379. {
  3380. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3381. // console.log("Mapillary canvas");
  3382. BING_MAPS_CANVAS.style.position = "absolute";
  3383. if (nextPlayer === "Bing Satellite" || nextPlayer === "Bing Streetside") {
  3384. BING_MAPS_CANVAS.style.visibility = "";
  3385. if (!cond)
  3386. {
  3387. switchCovergeButton.useGoogle = false;
  3388. }
  3389. console.log("Bing Canvas loaded");
  3390. }
  3391. else {
  3392. BING_MAPS_CANVAS.style.visibility = "hidden";
  3393. // console.log("Bing Canvas hidden");
  3394. }
  3395. }
  3396. else
  3397. {
  3398. setTimeout(Bing(cond), 500)
  3399. }
  3400. }
  3401.  
  3402.  
  3403. /**
  3404. * Adjust button placement
  3405. */
  3406.  
  3407. function ZoomControls() {
  3408. let style = `
  3409. .ymaps-2-1-79-panorama-gotoymaps {display: none !important;}
  3410. .ymaps-2-1-79-panorama-control__zoom {top: 2rem !important; left: 2rem !important; z-Index: 0}
  3411. .mapillary-bearing-indicator-container {top: 2rem !important; left: 2rem !important;}
  3412. .mapillary-zoom-container {top: 6rem !important; left: 2.20rem !important;}
  3413. .NavBar_MapTypeButtonContainerWrapper {visibility: hidden !important;}
  3414. .bm_LocateMeControl {visibility: hidden !important;}
  3415. .NavBar_Container {top: -6rem !important; left: 2rem !important;}
  3416. .streetsideToolPanel {top: 4rem !important; left: 2rem !important;}
  3417. .NavBarButton_Container {visibility: hidden !important;}
  3418. `;
  3419.  
  3420. // let nav = document.querySelector('.NavBar_MapTypeButtonContainerWrapper');
  3421. // let locate = document.getElementById("LocateMeButton");
  3422. // let navAll = document.getElementById("MicrosoftNav");
  3423. // if (nav)
  3424. // {
  3425. // nav.style.visibility = "hidden";
  3426. // }
  3427. // if (locate)
  3428. // {
  3429. // locate.style.visibility = "hidden";
  3430. // }
  3431. // if (navAll)
  3432. // {
  3433. // navAll.style.top = "15em"
  3434. // }
  3435.  
  3436. let style_element = document.createElement("style");
  3437. style_element.innerHTML = style;
  3438. document.body.appendChild(style_element);
  3439. // document.getElementById("mapillary-bearing-indicator-container").style.top = "20em"
  3440. }
  3441.  
  3442. /**
  3443. * Updates the compass to match Yandex Panorama facing
  3444. */
  3445. function updateCompass() {
  3446. if (!COMPASS) {
  3447. let compass = document.querySelector("img.compass__indicator");
  3448. if (compass != null) {
  3449. COMPASS = compass;
  3450. let direction = YandexPlayer.getDirection()[0] * -1;
  3451. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  3452. }
  3453. }
  3454. else {
  3455. let direction = YandexPlayer.getDirection()[0] * -1;
  3456. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  3457. }
  3458. }
  3459.  
  3460. /**
  3461. * Open next location in streetview player given next player and next coordinate
  3462. */
  3463.  
  3464.  
  3465.  
  3466. function goToLocation(cond) {
  3467. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3468. console.log("Going to location");
  3469. console.log(nextPlayer);
  3470. if (nextPlayer === "Yandex") {
  3471. let options = {};
  3472. YandexPlayer.moveTo([global_lat, global_lng], options);
  3473. YandexPlayer.setDirection([0, 16]);
  3474. YandexPlayer.setSpan([10, 67]);
  3475. }
  3476. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  3477. if (document.getElementById("i_container") !== null)
  3478. {
  3479. let iframe = document.getElementById("i_container");
  3480. if (nextPlayer === "Baidu")
  3481. {
  3482. if (!isFirefox)
  3483. {
  3484. iframe.style.top = '-60px';
  3485. iframe.style.height = (window.innerHeight + 200) + 'px';
  3486. }
  3487. else
  3488. {
  3489. iframe.style.top = '-60px';
  3490. iframe.style.height = (window.innerHeight + 219) + 'px';
  3491. }
  3492.  
  3493. if (!isFirefox)
  3494. {
  3495. iframe.style.right = '-55px';
  3496. iframe.style.width = (window.innerWidth + 55) + 'px';
  3497. }
  3498. else
  3499. {
  3500. iframe.style.right = '-15px';
  3501. iframe.style.width = (window.innerWidth + 15) + 'px';
  3502. }
  3503. let urlStr2 = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  3504. 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;
  3505. // console.log(urlStr)
  3506. if (global_BDAh != null)
  3507. {
  3508. iframe.src = urlStr;
  3509. }
  3510. else
  3511. {
  3512. iframe.src = urlStr2;
  3513. }
  3514. iframe.style.visibility = "";
  3515. }
  3516. else if (nextPlayer === "Youtube")
  3517. {
  3518. document.getElementById("Youtube Button").style.visibility = "";
  3519. document.getElementById("Youtube Button").innerHTML = "Play video";
  3520. iframe.allow = "autoplay";
  3521. iframe.style.visibility = "hidden";
  3522. iframe.style.top = '-60px';
  3523. iframe.style.height = (window.innerHeight + 235) + 'px';
  3524. mainMenuBtn.innerHTML = "<font size=2>Unity<br><font size=1>v5.2.1</font>";
  3525. mainMenuBtn.style.width = "3em"
  3526. mainMenuBtn.style.backgroundPosition = "";
  3527. mainMenuBtn.backgroundColor = ""
  3528. }
  3529. else if (nextPlayer === "Image")
  3530. {
  3531. iframe.style.top = '0px';
  3532. iframe.style.height = (window.innerHeight) + 'px';
  3533. iframe.style.visibility = "";
  3534. iframe.src = iId;
  3535. }
  3536. }
  3537. else
  3538. {
  3539. setTimeout(goToLocation(true), 250);
  3540. }
  3541. // let a = new BMap.Point(global_lng, global_lat);
  3542. // BaiduPlayer.setPov({ heading: -40, pitch: 6 });
  3543. // BaiduPlayer.setPosition(a);
  3544. }
  3545. else if (nextPlayer === "Kakao") {
  3546. var roadviewClient = new kakao.maps.RoadviewClient();
  3547. var position = new kakao.maps.LatLng(global_lat, global_lng);
  3548. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3549. KakaoPlayer.setPanoId(panoId, position);
  3550. KakaoPlayer.setViewpoint({ pan: global_heading, tilt: global_pitch, zoom: -3 })
  3551. });
  3552. }
  3553. else if (nextPlayer === "Mapillary") {
  3554. MapillaryPlayer.resize()
  3555. MapillaryPlayer.moveTo(mmKey).then(
  3556. image => { //console.log(image);
  3557. },
  3558. error => { console.log(error); });
  3559. }
  3560. else if (nextPlayer === "Google") {
  3561. handleMapillary({lat: global_lat, lng: global_lng}, {meters: 500, limit: 500});
  3562. }
  3563. else if (nextPlayer === "Bing Streetside") {
  3564. let mTId = MSStreetPlayer.getMapTypeId();
  3565. if (mTId !== Microsoft.Maps.MapTypeId.streetside && mTId !== Microsoft.Maps.MapTypeId.road)
  3566. {
  3567. console.log("Reset Bing map type to Streetside")
  3568. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  3569. }
  3570. MSStreetPlayer.setOptions({disableStreetside: false});
  3571. console.log([global_lat, global_lng])
  3572. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.streetside,
  3573. zoom: 18,
  3574. streetsideOptions: {
  3575. overviewMapMode: Microsoft.Maps.OverviewMapMode.hidden,
  3576. showCurrentAddress: false,
  3577. showProblemReporting: false,
  3578. showExitButton: false,
  3579. },
  3580. center: new Microsoft.Maps.Location(global_lat, global_lng),
  3581. heading: 90,
  3582. pitch: -30});
  3583. }
  3584. else if (nextPlayer === "Bing Satellite") {
  3585. // console.log("Bing Satellite Player")
  3586. let mTId = MSStreetPlayer.getMapTypeId();
  3587. if (mTId !== Microsoft.Maps.MapTypeId.aerial && mTId !== Microsoft.Maps.MapTypeId.road)
  3588. {
  3589. console.log("Reset Bing map type to Satellite")
  3590. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  3591. }
  3592. // MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  3593. let ctr = new Microsoft.Maps.Location(global_lat, global_lng)
  3594. let loc_centre = {lat: global_lat, lng: global_lng};
  3595. for (var i = MSStreetPlayer.entities.getLength() - 1; i >= 0; i--) {
  3596. var pushpin = MSStreetPlayer.entities.get(i);
  3597. if (pushpin instanceof Microsoft.Maps.Pushpin) {
  3598. MSStreetPlayer.entities.removeAt(i);
  3599. }
  3600. }
  3601. // console.log("Satellite radius: " + (ms_radius / 1000).toString() + "km");
  3602. let latlngBounds = getBBox2(loc_centre, ms_radius);
  3603. // console.log(latlngBounds)
  3604. let bounds = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(latlngBounds[0], latlngBounds[1]), new Microsoft.Maps.Location(latlngBounds[2], latlngBounds[3]));
  3605. // console.log(bounds)
  3606. // console.log(Microsoft.Maps.LabelOverlay.hidden)
  3607. if (ms_birdseye || ms_random)
  3608. {
  3609. let dg = 0;
  3610. if (ms_random)
  3611. {
  3612. dg = (Math.floor(Math.random() * 4)) * 90
  3613. }
  3614. Microsoft.Maps.getIsBirdseyeAvailable(ctr, dg, onResponse);
  3615. function onResponse(isAvailable) {
  3616. console.log("Birds-eye");
  3617. console.log(isAvailable);
  3618. MSStreetPlayer.setView({mapTypeId: isAvailable ? Microsoft.Maps.MapTypeId.birdseye : Microsoft.Maps.MapTypeId.aerial,
  3619. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  3620. center: ctr,
  3621. zoom: 15,
  3622. })
  3623. FixLink();
  3624. }
  3625. }
  3626. else
  3627. {
  3628. MSStreetPlayer.setOptions({disableStreetside: true});
  3629. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.aerial,
  3630. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  3631. center: ctr,
  3632. zoom: 15,
  3633. })
  3634. }
  3635. MSStreetPlayer.setOptions({maxBounds: bounds})
  3636. var pin = new Microsoft.Maps.Pushpin(ctr, {});
  3637.  
  3638. //Add the pushpin to the map
  3639. MSStreetPlayer.entities.push(pin);
  3640.  
  3641.  
  3642.  
  3643.  
  3644. FixLink();
  3645. // hideNav();
  3646. }
  3647. if (cond)
  3648. {
  3649. switchCovergeButton.lat = global_lat;
  3650. switchCovergeButton.lng = global_lng;
  3651. }
  3652. }
  3653.  
  3654. function FixLink()
  3655. {
  3656. let ele = document.querySelector('[title="Microsoft Bing"]');
  3657. // console.log("?")
  3658. if (ele)
  3659. {
  3660. // console.log("!")
  3661. ele.href = "#";
  3662. }
  3663. else
  3664. {
  3665. setTimeout(FixLink, 250);
  3666. }
  3667. }
  3668.  
  3669. /**
  3670. * Handle undo using the location history of the current round
  3671. */
  3672.  
  3673. function goToUndoMove(data) {
  3674. /* console.log(global_lat);
  3675. console.log(global_lng); */
  3676. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3677. let options = {};
  3678. let prevStep = null;
  3679. if (locHistory.length === 1) {
  3680. prevStep = locHistory[0];
  3681. }
  3682. else {
  3683. prevStep = locHistory.pop();
  3684. }
  3685. // console.log(prevStep);
  3686. // console.log(locHistory)
  3687. if (nextPlayer === "Yandex") {
  3688. defaultPanoIdChange = false;
  3689. YandexPlayer.moveTo([prevStep[0], prevStep[1]], options);
  3690. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  3691. YandexPlayer.setSpan([10, 67]);
  3692. switchCovergeButton.lat = prevStep[0];
  3693. switchCovergeButton.lng = prevStep[1];
  3694. }
  3695. else if (nextPlayer === "Kakao") {
  3696. let btn = document.querySelector("button[data-qa='undo-move']");
  3697. btn.disabled = false;
  3698. btn.classList.remove('styles_disabled__2YdHD');
  3699. defaultPanoIdChange = false;
  3700. let position = new kakao.maps.LatLng(prevStep[0], prevStep[1]);
  3701. KakaoPlayer.setPanoId(prevStep[2], position);
  3702. switchCovergeButton.lat = prevStep[0];
  3703. switchCovergeButton.lng = prevStep[1];
  3704. switchCovergeButton.useGoogle = false;
  3705. teleportBtn.google = false;
  3706. // console.log("Undo 1 step");
  3707. // console.log(locHistory);
  3708. }
  3709. else if (nextPlayer === "Mapillary" ) {
  3710. // console.log(prevStep[1]);
  3711.  
  3712. MapillaryPlayer.moveTo(prevStep[2]).then(
  3713. image => {
  3714. //console.log(image);
  3715. switchCovergeButton.lat = prevStep[1];
  3716. switchCovergeButton.lng = prevStep[0];
  3717. },
  3718. error => { console.log(error); });
  3719. }
  3720. else if (nextPlayer === "Bing Streetside") {
  3721. defaultPanoIdChange = false;
  3722. // console.log(locHistory);
  3723. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(prevStep[0], prevStep[1]),});
  3724. switchCovergeButton.lat = prevStep[0];
  3725. switchCovergeButton.lng = prevStep[1];
  3726. switchCovergeButton.heading = prevStep[2];
  3727. }
  3728.  
  3729. }
  3730.  
  3731. function handleTeleport()
  3732. {
  3733. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3734. if (teleportBtn)
  3735. {
  3736. teleportBtn.addEventListener("click", () => {
  3737. if (!teleportBtn.google)
  3738. {
  3739. // console.log("non-Google Teleport");
  3740. let prevStep = null;
  3741. if (locHistory.length === 1) {
  3742. prevStep = locHistory[0];
  3743. }
  3744. else {
  3745. prevStep = locHistory[locHistory.length - 1];
  3746. }
  3747. // console.log(locHistory);
  3748. let options = {};
  3749. let place, position, pID;
  3750. if (nextPlayer === "Yandex") {
  3751. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3752. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  3753. YandexPlayer.moveTo([place.lat, place.lng], options);
  3754. YandexPlayer.setSpan([10, 67]);
  3755. switchCovergeButton.lat = place.lat;
  3756. switchCovergeButton.lng = place.lng;
  3757. }
  3758. else if (nextPlayer === "Kakao") {
  3759. var roadviewClient = new kakao.maps.RoadviewClient();
  3760. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[3]), teleportBtn.distance * 0.001);
  3761. position = new kakao.maps.LatLng(place.lat, place.lng);
  3762. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3763. KakaoPlayer.setPanoId(panoId, position);
  3764. });
  3765. switchCovergeButton.lat = place.lat;
  3766. switchCovergeButton.lng = place.lng;
  3767. }
  3768. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  3769. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3770. handleMapillary(place, {meters: 500, limit: 500});
  3771. switchCovergeButton.lat = place.lat;
  3772. switchCovergeButton.lng = place.lng;
  3773. // locHistory.push([place.lat, place.lng, prevStep[2], prevStep[3]]);
  3774. }
  3775. else if (nextPlayer === "Bing Streetside") {
  3776. // console.log("teleport")
  3777. // console.log(prevStep);
  3778. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3779. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(place.lat, place.lng), 1, 1);
  3780. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  3781. function onSuccess(panoramaInfo) {
  3782. // console.log("Coverage")
  3783. // console.log([panoramaInfo.la, panoramaInfo.lo])
  3784. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  3785. });
  3786. }
  3787. function onMissingCoverage() {
  3788. console.log("No Coverage")
  3789. }
  3790. }
  3791.  
  3792. if (teleportBtn.distance > 150)
  3793. {
  3794. teleportBtn.distance = 100;
  3795. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  3796. }
  3797. }
  3798. });
  3799. }
  3800. }
  3801.  
  3802. function SyncListener()
  3803. {
  3804. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3805. switchCovergeButton.addEventListener("click", () => {
  3806. if (switchCovergeButton.useGoogle == false) {
  3807. // switchCovergeButton.useGoogle = true;
  3808. console.log(nextPlayer)
  3809. if (nextPlayer === "Yandex") {
  3810. let options = {};
  3811. YandexPlayer.moveTo([switchCovergeButton.lat, switchCovergeButton.lng], options);
  3812. YandexPlayer.setDirection([switchCovergeButton.heading, 0]);
  3813.  
  3814. // nextPlayer = "Yandex";
  3815. }
  3816. else if (nextPlayer === "Kakao") {
  3817. let roadviewClient = new kakao.maps.RoadviewClient();
  3818. // console.log(switchCovergeButton.lat);
  3819. let position = new kakao.maps.LatLng(switchCovergeButton.lat, switchCovergeButton.lng);
  3820. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3821. KakaoPlayer.setPanoId(panoId, position);
  3822. });
  3823. KakaoPlayer.setViewpoint({
  3824. pan: switchCovergeButton.heading,
  3825. tilt: 0,
  3826. zoom: -3
  3827. });
  3828. // nextPlayer = "Kakao";
  3829. }
  3830. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  3831. // nextPlayer = "Kakao";
  3832. handleMapillary({lat: switchCovergeButton.lat, lng: switchCovergeButton.lng}, {meters: 100, limit: 100});
  3833. }
  3834. else if (nextPlayer === "Bing Streetside") {
  3835. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(switchCovergeButton.lat, switchCovergeButton.lng), 0.01, 0.01);
  3836. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  3837. function onSuccess(panoramaInfo) {
  3838. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  3839. heading: switchCovergeButton.heading
  3840. });
  3841. }
  3842. function onMissingCoverage() {
  3843. console.log("No Coverage")
  3844. }
  3845. }
  3846. }
  3847. });
  3848.  
  3849. }
  3850.  
  3851. /**
  3852. * Gets the seed data for the current game
  3853. *
  3854. * @returns Promise with seed data as object
  3855. */
  3856. function getSeed() {
  3857. // console.log("getSeed called");
  3858. return new Promise((resolve, reject) => {
  3859. let token = getToken();
  3860. let URL;
  3861. let cred = ""
  3862.  
  3863. const PATHNAME = window.location.pathname;
  3864.  
  3865. if (PATHNAME.startsWith("/game/")) {
  3866. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  3867. }
  3868. else if (PATHNAME.startsWith("/challenge/")) {
  3869. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  3870. }
  3871. else if (PATHNAME.startsWith("/battle-royale/")) {
  3872. URL = `https://game-server.geoguessr.com/api/battle-royale/${token}`;
  3873. }
  3874. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  3875. URL = `https://game-server.geoguessr.com/api/duels/${token}`;
  3876. }
  3877. else if (PATHNAME.startsWith("/bullseye/")) {
  3878. URL = `https://game-server.geoguessr.com/api/bullseye/${token}`;
  3879. }
  3880. else if (PATHNAME.startsWith("/live-challenge/")) {
  3881. URL = `https://game-server.geoguessr.com/api/live-challenge/${token}`;
  3882. }
  3883. if (isBattleRoyale) {
  3884. fetch(URL, {
  3885. // Include credentials to GET from the endpoint
  3886. credentials: 'include'
  3887. })
  3888. .then((response) => response.json())
  3889. .then((data) => {
  3890. resolve(data);
  3891. })
  3892. .catch((error) => {
  3893. reject(error);
  3894. });
  3895. }
  3896. else {
  3897. fetch(URL)
  3898. .then((response) => response.json())
  3899. .then((data) => {
  3900. resolve(data);
  3901. })
  3902. .catch((error) => {
  3903. reject(error);
  3904. });
  3905. }
  3906. });
  3907. }
  3908.  
  3909. /**
  3910. * Gets the token from the current URL
  3911. *
  3912. * @returns token
  3913. */
  3914. function getToken() {
  3915. const PATHNAME = window.location.pathname;
  3916. if (PATHNAME.startsWith("/game/")) {
  3917. return PATHNAME.replace("/game/", "");
  3918. }
  3919. else if (PATHNAME.startsWith("/challenge/")) {
  3920. return PATHNAME.replace("/challenge/", "");
  3921. }
  3922. else if (PATHNAME.startsWith("/battle-royale/")) {
  3923. return PATHNAME.replace("/battle-royale/", "");
  3924. }
  3925. else if (PATHNAME.startsWith("/duels/")) {
  3926. return PATHNAME.replace("/duels/", "");
  3927. }
  3928. else if (PATHNAME.startsWith("/team-duels/")) {
  3929. return PATHNAME.replace("/team-duels/", "");
  3930. }
  3931. else if (PATHNAME.startsWith("/bullseye/")) {
  3932. return PATHNAME.replace("/bullseye/", "");
  3933. }
  3934. else if (PATHNAME.startsWith("/live-challenge/")) {
  3935. return PATHNAME.replace("/live-challenge/", "");
  3936. }
  3937. }
  3938.  
  3939. /**
  3940. * Gets the round number from the ongoing game from the page itself
  3941. *
  3942. * @returns Round number
  3943. */
  3944. function getRoundFromPage() {
  3945. const roundData = document.querySelector("div[data-qa='round-number']");
  3946. if (roundData) {
  3947. let roundElement = roundData.querySelector("div:last-child");
  3948. if (roundElement) {
  3949. let round = parseInt(roundElement.innerText.charAt(0));
  3950. if (!isNaN(round) && round >= 1 && round <= 5) {
  3951. return round;
  3952. }
  3953. }
  3954. }
  3955. else {
  3956. return ROUND;
  3957. }
  3958. }
  3959.  
  3960.  
  3961. /**
  3962. * Injects Yandex Script
  3963. */
  3964. function injectYandexScript() {
  3965. return new Promise((resolve, reject) => {
  3966. if (!YANDEX_INJECTED) {
  3967. if (YANDEX_API_KEY === "") {
  3968. console.log("No Yandex Key")
  3969. reject();
  3970. }
  3971. else {
  3972. if (!partialCreateYandex)
  3973. {
  3974. const SCRIPT = document.createElement("script");
  3975. SCRIPT.type = "text/javascript";
  3976. SCRIPT.async = true;
  3977. SCRIPT.src = `https://api-maps.yandex.ru/2.1/?lang=en_US&apikey=${YANDEX_API_KEY}`;
  3978. document.body.appendChild(SCRIPT);
  3979. SCRIPT.onload = () => {
  3980. ymaps.ready(() => {
  3981. YANDEX_INJECTED = true;
  3982. myHighlight("Yandex API Loaded");
  3983. resolve();
  3984. });
  3985. }
  3986. }
  3987. else
  3988. {
  3989. YANDEX_INJECTED = true;
  3990. resolve();
  3991. }
  3992. }
  3993. }
  3994. else {
  3995. resolve();
  3996. }
  3997. });
  3998. }
  3999.  
  4000. /**
  4001. * Injects Yandex Player and calls handleReturnToStart
  4002. */
  4003. function injectYandexPlayer() {
  4004. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4005. let lat = 41.321861;
  4006. let lng = 69.212920;
  4007.  
  4008. let options = {
  4009. "direction": [0, 16],
  4010. "span": [10, 67],
  4011. "controls": ["zoomControl"]
  4012. };
  4013. ymaps.panorama.createPlayer("player", [lat, lng], options)
  4014. .done((player) => {
  4015. YandexPlayer = player;
  4016. YandexPlayer.events.add("directionchange", (e) => {
  4017. updateCompass();
  4018. let pov = YandexPlayer.getDirection();
  4019. if (locHistory.length > 0 && nextPlayer == "Yandex") {
  4020. switchCovergeButton.heading = pov[0];
  4021. locHistory[locHistory.length - 1][2] = pov[0];
  4022. locHistory[locHistory.length - 1][3] = pov[1];
  4023. }
  4024. });
  4025. YandexPlayer.events.add("panoramachange", (e) => {
  4026. if (defaultPanoIdChange) {
  4027. let num = YandexPlayer.getPanorama().getPosition();
  4028. let pov = YandexPlayer.getDirection();
  4029. // console.log(num);
  4030. // console.log(pov);
  4031. if (nextPlayer == "Yandex")
  4032. {
  4033. locHistory.push([num[0], num[1], pov[0], pov[1]]);
  4034. switchCovergeButton.lat = num[0];
  4035. switchCovergeButton.lng = num[1];
  4036. }
  4037. let btn = document.querySelector("button[data-qa='undo-move']");
  4038. if (locHistory.length > 1) {
  4039. btn.disabled = false;
  4040. btn.classList.remove('styles_disabled__2YdHD');
  4041. }
  4042. // console.log(locHistory);
  4043. }
  4044. defaultPanoIdChange = true;
  4045.  
  4046. });
  4047. console.log("Yandex Player injected");
  4048. });
  4049.  
  4050. }
  4051.  
  4052.  
  4053. /**
  4054. * Injects Baidu script
  4055. */
  4056.  
  4057. function reportWindowSize() {
  4058. let iframeC = document.getElementById("i_container");
  4059. if (iframeC)
  4060. {
  4061. if (nextPlayer == "Baidu")
  4062. {
  4063. iframeC.style.top = '-60px';
  4064. iframeC.style.height = (window.innerHeight + 200) + 'px';
  4065. iframeC.style.right = '-55px';
  4066. iframeC.style.width = (window.innerWidth + 55) + 'px';
  4067. }
  4068. else if (nextPlayer == "Youtube")
  4069. {
  4070. iframeC.style.top = '-60px';
  4071. iframeC.style.height = (window.innerHeight + 235) + 'px';
  4072. }
  4073. else if (nextPlayer == "Image")
  4074. {
  4075. iframeC.style.top = '0px';
  4076. iframeC.style.height = (window.innerHeight) + 'px';
  4077. }
  4078.  
  4079. }
  4080. }
  4081.  
  4082. window.onresize = reportWindowSize;
  4083.  
  4084. function injectContainer() {
  4085. myHighlight("iframe container loaded")
  4086. const iframe = document.createElement('iframe');
  4087. iframe.frameBorder = 0;
  4088. iframe.style.position = "absolute";
  4089. iframe.id = "i_container";
  4090. if (isBattleRoyale) {
  4091. if (isDuel)
  4092. {
  4093. iframe.className = "inactive";
  4094. }
  4095. else if (isBullseye)
  4096. {
  4097. iframe.className = "game-panorama_panorama__ncMwh";
  4098. }
  4099. else if (isLiveChallenge)
  4100. {
  4101. iframe.className = "game-panorama_panorama__6RmkO";
  4102. }
  4103. else
  4104. {
  4105. iframe.className = "br-game-layout__panorama";
  4106. }
  4107. }
  4108. else {
  4109. iframe.className = "game-layout__panorama";
  4110. }
  4111. var div = document.getElementById("player");
  4112. div.style.overflow = "hidden";
  4113. if (isBullseye || isLiveChallenge)
  4114. {
  4115. div.prepend(iframe);
  4116. }
  4117. else
  4118. {
  4119. div.appendChild(iframe);
  4120. }
  4121. }
  4122.  
  4123. // function injectMedia() {
  4124. // myHighlight("Baidu API loaded")
  4125. // const iframe = document.createElement('iframe');
  4126. // iframe.allow = "autoplay"
  4127. // iframe.src = "https://www.youtube.com/embed/72kRM86V-dw?&autoplay=1&modestbranding=1&controls=0&start=10"
  4128. // iframe.frameBorder = 0;
  4129. // iframe.style.position = "absolute";
  4130. // iframe.id = "media-player";
  4131. // 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;"
  4132. // if (isBattleRoyale) {
  4133. // if (isDuel)
  4134. // {
  4135. // iframe.className = "inactive"
  4136. // }
  4137. // else
  4138. // {
  4139. // iframe.className = "br-game-layout__panorama"
  4140. // }
  4141. // }
  4142. // else {
  4143. // iframe.className = "game-layout__panorama"
  4144. // }
  4145. // var div = document.getElementById("player");
  4146. // div.style.overflow = "hidden";
  4147. // div.appendChild(iframe);
  4148. // }
  4149.  
  4150. /**
  4151. * Injects Kakao script
  4152. */
  4153.  
  4154. function injectKakaoScript() {
  4155. return new Promise((resolve, reject) => {
  4156. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4157. if (!KAKAO_INJECTED) {
  4158. if (KAKAO_API_KEY === "") {
  4159. console.log("No Kakao Key")
  4160. }
  4161. else {
  4162.  
  4163. let canvas = document.createElement("kmap");
  4164. if (isBattleRoyale) {
  4165. if (isDuel)
  4166. {
  4167. canvas.innerHTML = `
  4168. <div id="roadview" class="inactive" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4169. `;
  4170. }
  4171. else if (isBullseye)
  4172. {
  4173. canvas.innerHTML = `
  4174. <div id="roadview" class="game-panorama_panorama__ncMwh" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4175. `;
  4176. }
  4177. else if (isLiveChallenge)
  4178. {
  4179. canvas.innerHTML = `
  4180. <div id="roadview" class="game-panorama_panorama__6RmkO" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4181. `;
  4182. }
  4183. else
  4184. {
  4185. canvas.innerHTML = `
  4186. <div id="roadview" class="br-game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4187. `;
  4188. }
  4189. }
  4190. else {
  4191. canvas.innerHTML = `
  4192. <div id="roadview" class="game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4193. `;
  4194. }
  4195.  
  4196.  
  4197. var div = document.getElementById("player");
  4198. if (isBullseye || isLiveChallenge)
  4199. {
  4200. div.prepend(canvas);
  4201. }
  4202. else
  4203. {
  4204. div.appendChild(canvas);
  4205. }
  4206.  
  4207. let SCRIPT;
  4208. if (!partialCreateKakao)
  4209. {
  4210. SCRIPT = document.createElement("script");
  4211. SCRIPT.async = true;
  4212. // SCRIPT.type = "text/javascript";
  4213. SCRIPT.src = `//dapi.kakao.com/v2/maps/sdk.js?appkey=${KAKAO_API_KEY}&autoload=false`;
  4214. document.body.appendChild(SCRIPT);
  4215. }
  4216.  
  4217. function drawmapKakao()
  4218. {
  4219. kakao.maps.load(function () {
  4220. var position = new kakao.maps.LatLng(33.450701, 126.560667);
  4221. let roadviewContainer = document.getElementById('roadview');
  4222. KakaoPlayer = new kakao.maps.Roadview(roadviewContainer);
  4223. var panoId = 1023434522;
  4224. KakaoPlayer.setPanoId(panoId, position);
  4225. KAKAO_INJECTED = true;
  4226. // Remove the compass from Kakao
  4227. kakao.maps.event.addListener(KakaoPlayer, 'init', () => {
  4228. const compassContainer = roadviewContainer.querySelector('div[id*="_box_util_"]');
  4229. if (compassContainer) compassContainer.style.display = 'none';
  4230. });
  4231. kakao.maps.event.addListener(KakaoPlayer, 'panoid_changed', function() {
  4232. if (defaultPanoIdChange && KakaoPlayer) {
  4233. let latlng = KakaoPlayer.getPosition();
  4234. let lat = latlng.getLat();
  4235. let lng = latlng.getLng();
  4236. let pID = KakaoPlayer.getViewpointWithPanoId();
  4237. if (nextPlayer == "Kakao" && lat != 33.45047613915499)
  4238. {
  4239. // console.log("push");
  4240. locHistory.push([lat, lng, pID.panoId, pID.pan]);
  4241. switchCovergeButton.lat = lat;
  4242. switchCovergeButton.lng = lng;
  4243. switchCovergeButton.heading = pID.pan;
  4244. }
  4245. let btn = document.querySelector("button[data-qa='undo-move']");
  4246. if (locHistory.length > 1 && (btn != null)) {
  4247. btn.disabled = false;
  4248. btn.classList.remove('styles_disabled__2YdHD');
  4249. }
  4250. // console.log(locHistory);
  4251. }
  4252. defaultPanoIdChange = true;
  4253. });
  4254. kakao.maps.event.addListener(KakaoPlayer, 'viewpoint_changed', function() {
  4255. // console.log("pov_listener attached");
  4256. let pID = KakaoPlayer.getViewpointWithPanoId();
  4257. if (locHistory.length > 0 && nextPlayer == "Kakao") {
  4258. switchCovergeButton.heading = pID.pan;
  4259. locHistory[locHistory.length - 1][3] = pID.pan;
  4260. }
  4261. if (GooglePlayer) {
  4262. const { heading, pitch } = GooglePlayer.getPov()
  4263. if ((!almostEqual(pID.pan, heading) || !almostEqual(pID.tilt, pitch)) && nextPlayer == "Kakao") {
  4264. // Updating the google street view POV will update the compass
  4265. GooglePlayer.setPov({ heading: pID.pan, pitch: pID.tilt })
  4266. }
  4267. }
  4268. // console.log(locHistory);
  4269. })
  4270. });
  4271. }
  4272.  
  4273. if (partialCreateKakao)
  4274. {
  4275. drawmapKakao();
  4276. }
  4277. else
  4278. {
  4279. SCRIPT.onload = () => {
  4280. drawmapKakao();
  4281. myHighlight("Kakao API Loaded");
  4282. resolve();
  4283. };
  4284. }
  4285.  
  4286. }
  4287. }
  4288. else {
  4289. resolve();
  4290. }
  4291. });
  4292. }
  4293.  
  4294.  
  4295. function injectMSPlayer() {
  4296. return new Promise((resolve, reject) => {
  4297. if (!MS_INJECTED) {
  4298. if (MS_API_KEY === "") {
  4299. let canvas = document.getElementById("player");
  4300. console.log("No MS Key")
  4301. }
  4302. else {
  4303.  
  4304. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4305. let SCRIPT;
  4306. if (!partialCreateMS)
  4307. {
  4308. SCRIPT = document.createElement("script");
  4309. SCRIPT.type = "text/javascript";
  4310. SCRIPT.async = true;
  4311. SCRIPT.src = `https://www.bing.com/api/maps/mapcontrol?key=${MS_API_KEY}`;
  4312. document.body.appendChild(SCRIPT);
  4313. }
  4314. let canvas = document.createElement("msmap");
  4315. if (isBattleRoyale) {
  4316. if (isDuel)
  4317. {
  4318. canvas.innerHTML = `<div id="ms-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4319. }
  4320. else if (isBullseye)
  4321. {
  4322. 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>`;
  4323. }
  4324. else if (isLiveChallenge)
  4325. {
  4326. 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>`;
  4327. }
  4328. else
  4329. {
  4330. 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>`;
  4331. }
  4332. }
  4333. else {
  4334. canvas.innerHTML = `<div id="ms-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4335. }
  4336.  
  4337. var div = document.getElementById("player");
  4338. if (isBullseye || isLiveChallenge)
  4339. {
  4340. div.prepend(canvas);
  4341. }
  4342. else
  4343. {
  4344. div.appendChild(canvas);
  4345. }
  4346. function drawmapMS()
  4347. {
  4348. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  4349. MS_INJECTED = true;
  4350. // MSStreetPlayer.setOptions({
  4351. // minZoom: 13
  4352. // });
  4353. Microsoft.Maps.Events.addHandler(MSStreetPlayer, 'viewchangeend', function () { updateView(MSStreetPlayer); });
  4354. function updateView(map) {
  4355. let ctrm = map.getCenter();
  4356. if (nextPlayer == "Bing Streetside" && (switchCovergeButton.lat !== ctrm.latitude && switchCovergeButton.lng !== ctrm.longitude))
  4357. {
  4358. let heading2 = bearing(switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude)
  4359. // console.log("moved");
  4360. // console.log([switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude])
  4361. // console.log(heading2);
  4362. locHistory.push([ctrm.latitude, ctrm.longitude, heading2]);
  4363. switchCovergeButton.lat = ctrm.latitude;
  4364. switchCovergeButton.lng = ctrm.longitude;
  4365. switchCovergeButton.heading = heading2;
  4366. let btn = document.querySelector("button[data-qa='undo-move']");
  4367. if (locHistory.length > 1 && (btn != null)) {
  4368. btn.disabled = false;
  4369. btn.classList.remove('styles_disabled__2YdHD');
  4370. }
  4371. }
  4372. }
  4373.  
  4374.  
  4375. }
  4376.  
  4377. if (partialCreateMS)
  4378. {
  4379. drawmapMS();
  4380. }
  4381. else
  4382. {
  4383. SCRIPT.addEventListener('load', () => {
  4384. myHighlight("Bing Maps API loaded");
  4385. let timeout = 0;
  4386. let interval = setInterval(() => {
  4387. if (timeout >= 40) {
  4388. reject();
  4389. clearInterval(interval);
  4390. }
  4391. if (document.getElementById('ms-player') !== null && typeof Microsoft.Maps.Map !== typeof undefined) {
  4392. drawmapMS();
  4393. resolve();
  4394. clearInterval(interval);
  4395. }
  4396. timeout += 1;
  4397. }, 1000);
  4398. })
  4399. }
  4400. }
  4401. }
  4402. else {
  4403. resolve();
  4404. }
  4405. });
  4406. }
  4407.  
  4408.  
  4409.  
  4410. function injectMapillaryPlayer() {
  4411. return new Promise((resolve, reject) => {
  4412. if (!MAPILLARY_INJECTED) {
  4413. if (MAPILLARY_API_KEY === "") {
  4414. let canvas = document.getElementById("player");
  4415. console.log("No Mapillary Key")
  4416. }
  4417. else {
  4418. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4419.  
  4420. let SCRIPT;
  4421. if (!partialCreateMapillary)
  4422. {
  4423. SCRIPT = document.createElement("script");
  4424. SCRIPT.type = "text/javascript";
  4425. SCRIPT.async = true;
  4426. SCRIPT.src = `https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.js`;
  4427. document.body.appendChild(SCRIPT);
  4428. document.querySelector('head').innerHTML += '<link href="https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.css" rel="stylesheet"/>';
  4429. }
  4430. let canvas = document.createElement("mmap");
  4431. if (isBattleRoyale) {
  4432. if (isDuel)
  4433. {
  4434.  
  4435. canvas.innerHTML = `<div id="mapillary-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4436. }
  4437. else if (isBullseye)
  4438. {
  4439. 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>`;
  4440. }
  4441. else if (isLiveChallenge)
  4442. {
  4443. 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>`;
  4444. }
  4445. else
  4446. {
  4447. 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>`;
  4448. }
  4449. }
  4450. else {
  4451. canvas.innerHTML = `<div id="mapillary-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4452. }
  4453.  
  4454. var div = document.getElementById("player");
  4455. if (isBullseye || isLiveChallenge)
  4456. {
  4457. div.prepend(canvas);
  4458. }
  4459. else
  4460. {
  4461. div.appendChild(canvas);
  4462. }
  4463.  
  4464. function drawMapML()
  4465. {
  4466. var {Viewer} = mapillary;
  4467.  
  4468. MapillaryPlayer = new Viewer({
  4469. accessToken: MAPILLARY_API_KEY,
  4470. container: 'mapillary-player', // the ID of our container defined in the HTML body
  4471. });
  4472.  
  4473. MapillaryPlayer.on('image', async (event) => {
  4474. // cnt = cnt + 1;
  4475. // console.log(cnt);
  4476. let image = event.image;
  4477. let pos = image.originalLngLat;
  4478. let cond = true;
  4479. for (const element of locHistory) {
  4480. if (element[2] == image.id)
  4481. {
  4482. cond = false;
  4483. }
  4484. }
  4485. if (cond)
  4486. {
  4487. switchCovergeButton.lat = pos.lat;
  4488. switchCovergeButton.lng = pos.lng;
  4489. switchCovergeButton.heading = image.compassAngle;
  4490. // console.log(pos);
  4491. locHistory.push([pos.lat, pos.lng, image.id, image.compassAngle]);
  4492. }
  4493. let btn = document.querySelector("button[data-qa='undo-move']");
  4494. if (btn !== null && locHistory.length > 1)
  4495. {
  4496. btn.disabled = false;
  4497. btn.classList.remove('styles_disabled__2YdHD');
  4498. }
  4499. });
  4500.  
  4501. MAPILLARY_INJECTED = true;
  4502. }
  4503. if (partialCreateMapillary)
  4504. {
  4505. drawMapML();
  4506. }
  4507. else
  4508. {
  4509.  
  4510. SCRIPT.addEventListener('load', () => {
  4511. myHighlight("Mapillary API Loaded");
  4512. // resolve(BMap);
  4513. drawMapML();
  4514. resolve();
  4515. })
  4516. }
  4517. }
  4518. }
  4519. else {
  4520. resolve();
  4521. }
  4522. });
  4523. }
  4524.  
  4525.  
  4526. function handleMapillary(latlng, options)
  4527. {
  4528. console.log("handleMapillary")
  4529. handleMapillaryHelper(latlng, options).then((data) => {
  4530. //console.log(data.data)
  4531. let idToSet = 0;
  4532. let curDist = 100000000;
  4533. for (const element of data.data) {
  4534. // console.log(element)
  4535. if (element.hasOwnProperty("computed_geometry"))
  4536. {
  4537. try {
  4538. let rCord = element.computed_geometry["coordinates"];
  4539. let dist = distance(latlng.lat,latlng.lng,rCord[1],rCord[0])
  4540. if (dist < curDist)
  4541. {
  4542. idToSet = element.id;
  4543. curDist = dist
  4544. }
  4545. } catch (e) {
  4546. console.log("Error")
  4547. }
  4548. }
  4549. }
  4550. if (idToSet !== 0)
  4551. {
  4552. MapillaryPlayer.moveTo(idToSet).then(
  4553. image => { //console.log(image);
  4554. },
  4555. error => { console.log(error); });
  4556. }}).catch((error) => {
  4557. console.log(error);
  4558. });
  4559. }
  4560.  
  4561. function handleMapillaryHelper(latlng, options)
  4562. {
  4563. return new Promise((resolve, reject) => {
  4564. // console.log("1")
  4565. let bbox = getBBox(latlng, options.meters);
  4566. 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)
  4567. // console.log(URL)
  4568. fetch(URL)
  4569. .then((response) => {resolve(response.json())})
  4570. .catch((error) => {console.log(error);});
  4571. });
  4572. }
  4573.  
  4574.  
  4575. /**
  4576. * Minimap presets
  4577. */
  4578.  
  4579. let water_name_only =
  4580. [
  4581. {
  4582. "elementType": "geometry",
  4583. "stylers": [
  4584. {
  4585. "visibility": "off"
  4586. }
  4587. ]
  4588. },
  4589. {
  4590. "featureType": "administrative",
  4591. "stylers": [
  4592. {
  4593. "visibility": "off"
  4594. }
  4595. ]
  4596. },
  4597. {
  4598. "featureType": "landscape",
  4599. "stylers": [
  4600. {
  4601. "visibility": "off"
  4602. }
  4603. ]
  4604. },
  4605. {
  4606. "featureType": "poi",
  4607. "stylers": [
  4608. {
  4609. "visibility": "off"
  4610. }
  4611. ]
  4612. },
  4613. {
  4614. "featureType": "road",
  4615. "stylers": [
  4616. {
  4617. "visibility": "off"
  4618. }
  4619. ]
  4620. },
  4621. {
  4622. "featureType": "transit",
  4623. "stylers": [
  4624. {
  4625. "visibility": "off"
  4626. }
  4627. ]
  4628. }
  4629. ]
  4630. let country_name_only =
  4631. [
  4632. {
  4633. "elementType": "geometry",
  4634. "stylers": [
  4635. {
  4636. "visibility": "off"
  4637. }
  4638. ]
  4639. },
  4640. {
  4641. "featureType": "administrative",
  4642. "stylers": [
  4643. {
  4644. "visibility": "off"
  4645. }
  4646. ]
  4647. },
  4648. {
  4649. "featureType": "administrative.country",
  4650. "elementType": "labels",
  4651. "stylers": [
  4652. {
  4653. "visibility": "on"
  4654. }
  4655. ]
  4656. },
  4657. {
  4658. "featureType": "landscape",
  4659. "stylers": [
  4660. {
  4661. "visibility": "off"
  4662. }
  4663. ]
  4664. },
  4665. {
  4666. "featureType": "poi",
  4667. "stylers": [
  4668. {
  4669. "visibility": "off"
  4670. }
  4671. ]
  4672. },
  4673. {
  4674. "featureType": "road",
  4675. "stylers": [
  4676. {
  4677. "visibility": "off"
  4678. }
  4679. ]
  4680. },
  4681. {
  4682. "featureType": "transit",
  4683. "stylers": [
  4684. {
  4685. "visibility": "off"
  4686. }
  4687. ]
  4688. },
  4689. {
  4690. "featureType": "water",
  4691. "stylers": [
  4692. {
  4693. "visibility": "off"
  4694. }
  4695. ]
  4696. }
  4697. ]
  4698.  
  4699. let no_label_or_terrain =
  4700. [
  4701. {
  4702. "elementType": "geometry",
  4703. "stylers": [
  4704. {
  4705. "visibility": "off"
  4706. }
  4707. ]
  4708. },
  4709. {
  4710. "featureType": "administrative",
  4711. "stylers": [
  4712. {
  4713. "visibility": "off"
  4714. }
  4715. ]
  4716. },
  4717. {
  4718. "featureType": "landscape",
  4719. "stylers": [
  4720. {
  4721. "visibility": "off"
  4722. }
  4723. ]
  4724. },
  4725. {
  4726. "featureType": "poi",
  4727. "stylers": [
  4728. {
  4729. "visibility": "off"
  4730. }
  4731. ]
  4732. },
  4733. {
  4734. "featureType": "road",
  4735. "stylers": [
  4736. {
  4737. "visibility": "off"
  4738. }
  4739. ]
  4740. },
  4741. {
  4742. "featureType": "transit",
  4743. "stylers": [
  4744. {
  4745. "visibility": "off"
  4746. }
  4747. ]
  4748. },
  4749. {
  4750. "featureType": "water",
  4751. "stylers": [
  4752. {
  4753. "visibility": "on"
  4754. }
  4755. ]
  4756. },
  4757. {
  4758. "featureType": "water",
  4759. "elementType": "labels",
  4760. "stylers": [
  4761. {
  4762. "visibility": "off"
  4763. }
  4764. ]
  4765. }
  4766. ]
  4767.  
  4768. let no_label =
  4769. [
  4770. {
  4771. "elementType": "labels",
  4772. "stylers": [
  4773. {
  4774. "visibility": "off"
  4775. }
  4776. ]
  4777. },
  4778. {
  4779. "featureType": "administrative",
  4780. "stylers": [
  4781. {
  4782. "visibility": "off"
  4783. }
  4784. ]
  4785. }
  4786. ]
  4787.  
  4788. let blank =
  4789.  
  4790. [
  4791. {
  4792. "stylers": [
  4793. {
  4794. "visibility": "off"
  4795. }
  4796. ]
  4797. }
  4798. ]
  4799.  
  4800. let thick_border =
  4801.  
  4802. [
  4803. {
  4804. "featureType": "administrative.country",
  4805. "elementType": "geometry.stroke",
  4806. "stylers": [
  4807. {
  4808. "weight": 1.5
  4809. }
  4810. ]
  4811. },
  4812. {
  4813. "featureType": "administrative.province",
  4814. "elementType": "geometry.stroke",
  4815. "stylers": [
  4816. {
  4817. "weight": 3.5
  4818. }
  4819. ]
  4820. }
  4821. ]
  4822.  
  4823. let Indonesia =
  4824.  
  4825. [
  4826. {
  4827. "featureType": "administrative",
  4828. "stylers": [
  4829. {
  4830. "visibility": "off"
  4831. }
  4832. ]
  4833. },
  4834. {
  4835. "featureType": "landscape",
  4836. "elementType": "labels",
  4837. "stylers": [
  4838. {
  4839. "visibility": "off"
  4840. }
  4841. ]
  4842. },
  4843. {
  4844. "featureType": "poi.park",
  4845. "elementType": "labels",
  4846. "stylers": [
  4847. {
  4848. "visibility": "off"
  4849. }
  4850. ]
  4851. },
  4852. {
  4853. "featureType": "road",
  4854. "elementType": "labels",
  4855. "stylers": [
  4856. {
  4857. "visibility": "off"
  4858. }
  4859. ]
  4860. },
  4861. {
  4862. "featureType": "transit",
  4863. "elementType": "labels",
  4864. "stylers": [
  4865. {
  4866. "visibility": "off"
  4867. }
  4868. ]
  4869. },
  4870. {
  4871. "featureType": "water",
  4872. "elementType": "labels",
  4873. "stylers": [
  4874. {
  4875. "visibility": "off"
  4876. }
  4877. ]
  4878. }
  4879. ]
  4880.  
  4881. let dark = [
  4882. {
  4883. "elementType": "geometry",
  4884. "stylers": [
  4885. {
  4886. "color": "#212121"
  4887. }
  4888. ]
  4889. },
  4890. {
  4891. "elementType": "labels.icon",
  4892. "stylers": [
  4893. {
  4894. "visibility": "off"
  4895. }
  4896. ]
  4897. },
  4898. {
  4899. "elementType": "labels.text.fill",
  4900. "stylers": [
  4901. {
  4902. "color": "#757575"
  4903. }
  4904. ]
  4905. },
  4906. {
  4907. "elementType": "labels.text.stroke",
  4908. "stylers": [
  4909. {
  4910. "color": "#212121"
  4911. }
  4912. ]
  4913. },
  4914. {
  4915. "featureType": "administrative",
  4916. "elementType": "geometry",
  4917. "stylers": [
  4918. {
  4919. "color": "#757575"
  4920. }
  4921. ]
  4922. },
  4923. {
  4924. "featureType": "administrative.country",
  4925. "elementType": "labels.text.fill",
  4926. "stylers": [
  4927. {
  4928. "color": "#9e9e9e"
  4929. }
  4930. ]
  4931. },
  4932. {
  4933. "featureType": "administrative.land_parcel",
  4934. "stylers": [
  4935. {
  4936. "visibility": "off"
  4937. }
  4938. ]
  4939. },
  4940. {
  4941. "featureType": "administrative.locality",
  4942. "elementType": "labels.text.fill",
  4943. "stylers": [
  4944. {
  4945. "color": "#bdbdbd"
  4946. }
  4947. ]
  4948. },
  4949. {
  4950. "featureType": "poi",
  4951. "elementType": "labels.text.fill",
  4952. "stylers": [
  4953. {
  4954. "color": "#757575"
  4955. }
  4956. ]
  4957. },
  4958. {
  4959. "featureType": "poi.park",
  4960. "elementType": "geometry",
  4961. "stylers": [
  4962. {
  4963. "color": "#181818"
  4964. }
  4965. ]
  4966. },
  4967. {
  4968. "featureType": "poi.park",
  4969. "elementType": "labels.text.fill",
  4970. "stylers": [
  4971. {
  4972. "color": "#616161"
  4973. }
  4974. ]
  4975. },
  4976. {
  4977. "featureType": "poi.park",
  4978. "elementType": "labels.text.stroke",
  4979. "stylers": [
  4980. {
  4981. "color": "#1b1b1b"
  4982. }
  4983. ]
  4984. },
  4985. {
  4986. "featureType": "road",
  4987. "elementType": "geometry.fill",
  4988. "stylers": [
  4989. {
  4990. "color": "#2c2c2c"
  4991. }
  4992. ]
  4993. },
  4994. {
  4995. "featureType": "road",
  4996. "elementType": "labels.text.fill",
  4997. "stylers": [
  4998. {
  4999. "color": "#8a8a8a"
  5000. }
  5001. ]
  5002. },
  5003. {
  5004. "featureType": "road.arterial",
  5005. "elementType": "geometry",
  5006. "stylers": [
  5007. {
  5008. "color": "#373737"
  5009. }
  5010. ]
  5011. },
  5012. {
  5013. "featureType": "road.highway",
  5014. "elementType": "geometry",
  5015. "stylers": [
  5016. {
  5017. "color": "#3c3c3c"
  5018. }
  5019. ]
  5020. },
  5021. {
  5022. "featureType": "road.highway.controlled_access",
  5023. "elementType": "geometry",
  5024. "stylers": [
  5025. {
  5026. "color": "#4e4e4e"
  5027. }
  5028. ]
  5029. },
  5030. {
  5031. "featureType": "road.local",
  5032. "elementType": "labels.text.fill",
  5033. "stylers": [
  5034. {
  5035. "color": "#616161"
  5036. }
  5037. ]
  5038. },
  5039. {
  5040. "featureType": "transit",
  5041. "elementType": "labels.text.fill",
  5042. "stylers": [
  5043. {
  5044. "color": "#757575"
  5045. }
  5046. ]
  5047. },
  5048. {
  5049. "featureType": "water",
  5050. "elementType": "geometry",
  5051. "stylers": [
  5052. {
  5053. "color": "#000000"
  5054. }
  5055. ]
  5056. },
  5057. {
  5058. "featureType": "water",
  5059. "elementType": "labels.text.fill",
  5060. "stylers": [
  5061. {
  5062. "color": "#3d3d3d"
  5063. }
  5064. ]
  5065. }
  5066. ]
  5067.  
  5068. let default_preset = []
  5069.  
  5070. let presetMinimap = [[default_preset, "Default"],
  5071. [blank, "Blank"],
  5072. [water_name_only, "Oceanman"],
  5073. [country_name_only, "Impossible"],
  5074. [no_label_or_terrain, "Streaks"],
  5075. [no_label, "Easy 5K"],
  5076. [Indonesia, "POI only"],
  5077. [dark, "Dark Mode"],
  5078. [thick_border, "Borders"],
  5079. [default_preset, "Satellite"],
  5080. [default_preset, "Terrain"],
  5081. [default_preset, "Hybrid"],
  5082. [custom, "Custom", customMode]]
  5083.  
  5084. let GEOJSON_INVISIBLE =
  5085. {
  5086. strokeOpacity: 0,
  5087. fillOpacity: 0,
  5088. }
  5089.  
  5090. let presetOverlay = [["Clear",""],
  5091. ["Coverage",""],
  5092. ["Official",""],
  5093. ["Longitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/lonl.json"],
  5094. ["Latitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/latl.json"],
  5095. ["US County","https://raw.githubusercontent.com/CodeForCary/CountyDataUSA5m/master/cb_2017_us_county_5m.json"],
  5096. ["France","https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements.geojson"],
  5097. ["Time Zone", "https://raw.githubusercontent.com/treyerl/timezones/master/timezones_wVVG8.geojson"],
  5098. ["UK Parliament", "https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/electoral/gb/wpc.json"],
  5099. ["Custom", YOUR_URL]]
  5100.  
  5101. /**
  5102. * Display map per local laws and regulations
  5103. */
  5104.  
  5105. let SEOverlay, NWOverlay, SEOverlay3;
  5106. let TW = [[24.80, 119.00, 22.00, 123.20],
  5107. [24.20, 119.90, 22.90, 121.85],
  5108. [24.00, 120.90, 23.80, 121.20],
  5109. [23.93, 121.03, 23.85, 121.15],
  5110. [23.92, 121.055, 23.89, 121.10],
  5111. [23.92, 121.055, 23.89, 121.10],
  5112. [23.92, 121.055, 23.89, 121.10],
  5113. ]
  5114.  
  5115. let TS = [[30.40, 93.40, 28, 97.20],
  5116. [29.40, 94.55, 28.20, 96.45]]
  5117.  
  5118. let NW = [36.20, 77.70, 34.40, 80.70]