Geoguessr Unity Script

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

目前为 2022-03-08 提交的版本。查看 最新版本

  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.7
  5. // @author Jupaoqq
  6. // @include https://www.geoguessr.com/*
  7. // @run-at document-start
  8. // @license MIT
  9. // @namespace https://greasyfork.org/users/838374
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. /**
  14. * Custom your minimap here!
  15. */
  16.  
  17. /**
  18. * 1: replace "roadmap" in the customMode field with any of the options below:
  19. * "roadmap" displays the default road map view. This is the default map type.
  20. * "satellite" displays Google Earth satellite images.
  21. * "hybrid" displays a mixture of normal and satellite views.
  22. * "terrain" displays a physical map based on terrain information.
  23. */
  24.  
  25. let customMode = "roadmap";
  26.  
  27. /**
  28. * 2: Go to https://mapstyle.withgoogle.com/ first click "No thanks, take me to the old style wizard"
  29. * then click "MORE OPTIONS" to hide or reveal certain features.
  30. * When you are done, click "FINISH", then "COPY JSON", and replace my settings in custom with your settings below.
  31. */
  32.  
  33. let custom =
  34.  
  35. [
  36. {
  37. "featureType": "administrative",
  38. "stylers": [
  39. {
  40. "visibility": "off"
  41. }
  42. ]
  43. },
  44. {
  45. "featureType": "landscape",
  46. "stylers": [
  47. {
  48. "visibility": "off"
  49. }
  50. ]
  51. },
  52. {
  53. "featureType": "poi.park",
  54. "stylers": [
  55. {
  56. "visibility": "off"
  57. }
  58. ]
  59. },
  60. {
  61. "featureType": "road",
  62. "elementType": "labels",
  63. "stylers": [
  64. {
  65. "visibility": "off"
  66. }
  67. ]
  68. },
  69. {
  70. "featureType": "transit",
  71. "stylers": [
  72. {
  73. "visibility": "off"
  74. }
  75. ]
  76. }
  77. ]
  78.  
  79. /**
  80. * End of Minimap customization instruction section
  81. */
  82.  
  83. /**
  84. * Overlay anything on the minimap here!
  85. * 1. overlay an GeoJSON object
  86. * 2. overlay a custom image
  87. */
  88.  
  89. /**
  90. * Overlay an GeoJSON object:
  91. */
  92.  
  93. // change the GeoJson display style.
  94. // strokeOpacity, strokeWeight, fillOpacity takes a value between 0 and 1.
  95. // strokeColor and fillColor supports Hexadecimal color (#00FF00 is green)
  96. // If clickable is set to true, you would not be able to make a guess within the shape
  97.  
  98. let GEOJSON_STYLE =
  99. {
  100. strokeColor: "black",
  101. strokeOpacity: 1,
  102. strokeWeight: 0.2,
  103. fillColor: "#00FF00",
  104. fillOpacity: 0,
  105. clickable: false,
  106. }
  107.  
  108. // replace the URL with your desired link
  109. // For example, search "Germany GeoJson" on Github, find this link (https://github.com/isellsoap/deutschlandGeoJSON/blob/main/4_kreise/4_niedrig.geo.json)
  110. // Then click "Download" to get the raw.githubusercontent.com link (https://raw.githubusercontent.com/isellsoap/deutschlandGeoJSON/main/4_kreise/4_niedrig.geo.json)
  111. // and replace the URL below with that URL.
  112. // State zipcode: see this site https://github.com/OpenDataDE/State-zip-code-GeoJSON
  113.  
  114. let YOUR_URL = "https://raw.githubusercontent.com/severinlandolt/map-switzerland/main/02%20GeoJSON/CH_Kantonsgrenzen_100_geo.json"
  115.  
  116. // set it to true to add your custom GeoJSON by copy it to the code below (this is for
  117.  
  118. let GeoJsonCustomUser = false
  119.  
  120. // replace with your custom GeoJson, go to https://geojson.io/ to customize it then copy the Json to here
  121.  
  122. let CUSTOM_GEOJSON =
  123.  
  124. {
  125. "type": "FeatureCollection",
  126. "features": [
  127. {
  128. "type": "Feature",
  129. "properties": {},
  130. "geometry": {
  131. "type": "LineString",
  132. "coordinates": [
  133. [
  134. 2.493896484375,
  135. 52.7163309360463
  136. ],
  137. [
  138. 2.4609375,
  139. 53.15994678846807
  140. ],
  141. [
  142. 3.2025146484375,
  143. 53.179703893605385
  144. ],
  145. [
  146. 3.2080078125,
  147. 52.96518371955126
  148. ],
  149. [
  150. 2.48291015625,
  151. 52.948637884883205
  152. ]
  153. ]
  154. }
  155. },
  156. {
  157. "type": "Feature",
  158. "properties": {},
  159. "geometry": {
  160. "type": "LineString",
  161. "coordinates": [
  162. [
  163. 3.218994140625,
  164. 52.05586831074774
  165. ],
  166. [
  167. 3.218994140625,
  168. 52.13685974852633
  169. ],
  170. [
  171. 2.515869140625,
  172. 52.1267438596429
  173. ],
  174. [
  175. 2.515869140625,
  176. 51.77803705914517
  177. ],
  178. [
  179. 3.2354736328125,
  180. 51.78993084774129
  181. ],
  182. [
  183. 3.228607177734375,
  184. 51.96119237712624
  185. ],
  186. [
  187. 2.8571319580078125,
  188. 51.95230623740452
  189. ]
  190. ]
  191. }
  192. },
  193. {
  194. "type": "Feature",
  195. "properties": {
  196. "stroke": "#555555",
  197. "stroke-width": 2,
  198. "stroke-opacity": 1
  199. },
  200. "geometry": {
  201. "type": "LineString",
  202. "coordinates": [
  203. [
  204. 2.5048828125,
  205. 52.619725272670266
  206. ],
  207. [
  208. 2.5103759765625,
  209. 52.274880130680536
  210. ],
  211. [
  212. 2.867431640625,
  213. 52.284962354465726
  214. ],
  215. [
  216. 3.2299804687499996,
  217. 52.29504228453735
  218. ],
  219. [
  220. 3.2135009765625,
  221. 52.63973017532399
  222. ],
  223. [
  224. 2.5096893310546875,
  225. 52.621392697207625
  226. ]
  227. ]
  228. }
  229. }
  230. ]
  231. }
  232.  
  233. /**
  234. * Overlay a custom image:
  235. */
  236.  
  237. // set it to true to add your image overlay
  238.  
  239. let OverlayCustom = false
  240.  
  241. // replace the URL with your desired link
  242.  
  243. let OVERLAY_URL = "https://www.battleface.com/blog/wp-content/uploads/2020/10/patreon-profile-tom-geowizard.jpg"
  244.  
  245. // set the bounds for the image - latitude (North and South), longitude (North and South)
  246.  
  247. let OVERLAY_BOUNDS =
  248. {
  249. north: 53,
  250. west: -3,
  251. south: 51,
  252. east: 1,
  253. };
  254.  
  255. // change the image overlay display style.
  256.  
  257. let OVERLAY_STYLE =
  258. {
  259. fillOpacity: 0.2,
  260. clickable: false,
  261. }
  262.  
  263. /**
  264. * End of Minimap Overlay instruction section
  265. */
  266.  
  267. // API Keys
  268.  
  269. var MS_API_KEY = "AjWqExh5E9aZfgKKBrgJMM2tbBeJ_q9ET7__194VDfcpl8lEWYTYNRWoYE1kqy95";
  270. var YANDEX_API_KEY = "b704b5a9-3d67-4d19-b702-ec7807cecfc6";
  271. var KAKAO_API_KEY = "cbacbe41e3a223d794f321de4f3e247b";
  272. const MAPS_API_URL = "https://maps.googleapis.com/maps/api/js"; // removed "?" from the link
  273. var MAPILLARY_API_KEY_LIST =
  274. ["MLY|6723031704435203|5afd537469b114cf814881137ad74b7c",
  275. "MLY|6691659414239148|b45e7e82cde126044cbc2cf5d4a7c9b1",
  276. "MLY|5074369465929308|f7ad2802cbaf26c63f88046a292df68b",
  277. "MLY|7451643761528219|6477f2db0e3928b51e45ec9311983936",
  278. "MLY|4855256237866198|6d0464771831c8a4bf2be095e1e1aabc",
  279. "MLY|4772941976102161|8458d4f08d2e1970cdfe0a4e242c04ff",
  280. "MLY|4492067214235489|94c44703942362ad6f6b70b5d32c3a45",
  281. "MLY|4618251611628426|0cef71d6ec8b997a5ec06ecdeabf11ec",
  282. "MLY|4096846270415982|fa2ce29641503e6ef665f17459633570",
  283. "MLY|4231415756962414|fe353880fd246e8a4a6ae32152f7dbb0",]
  284.  
  285. var MAPILLARY_API_KEY = MAPILLARY_API_KEY_LIST[Math.floor(Math.random() * MAPILLARY_API_KEY_LIST.length)];
  286.  
  287. console.log("Geoguessr Unity Script v5.2.7 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.7</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.7</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.7</font>";
  1065. mainMenuBtn.style.width = "3em"
  1066. mainMenuBtn.style.backgroundPosition = "";
  1067. mainMenuBtn.backgroundColor = ""
  1068. }
  1069. for (let element of document.getElementsByClassName("unity-btn")){
  1070. if (element.id !== "Show Buttons")
  1071. {
  1072. element.style.visibility = "hidden";
  1073. }
  1074. }
  1075. mainMenuBtn.hide = true;
  1076. }
  1077. });
  1078.  
  1079. var teleportBtn = document.createElement("Button");
  1080. teleportBtn.classList.add("unity-btn");
  1081. teleportBtn.teleType = "default";
  1082. teleportBtn.id = "Teleport Button";
  1083. teleportBtn.distance = 100;
  1084. teleportBtn.google = true;
  1085. teleportBtn.innerHTML = "Teleport 100m";
  1086. teleportBtn.style = "visibility:hidden;width:10em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1087. document.body.appendChild(teleportBtn);
  1088.  
  1089. teleportBtn.addEventListener("click", () => {
  1090. // console.log("Google Teleport");
  1091. if (switchCovergeButton.init)
  1092. {
  1093. // console.log("run");
  1094. switchCovergeButton.init = false;
  1095. if (teleportBtn.google)
  1096. {
  1097. switchCovergeButton.useGoogle = true;
  1098. teleportBtn.google = true;
  1099. }
  1100. else
  1101. {
  1102. switchCovergeButton.useGoogle = false;
  1103. teleportBtn.google = false;
  1104. }
  1105. }
  1106. else
  1107. {
  1108. // console.log(teleportBtn.google)
  1109. if (teleportBtn.google && GooglePlayer != null)
  1110. {
  1111. let heading = GooglePlayer.getPov().heading;
  1112. let place = FindPointAtDistanceFrom(curPosition.lat, curPosition.lng , DegreesToRadians(heading), teleportBtn.distance * 0.001)
  1113. svService.getPanorama({ location: place, radius: 1000, source: teleportBtn.teleType}, svCheck);
  1114. }
  1115. }
  1116. });
  1117.  
  1118. var teleportMoreBtn = document.createElement("Button");
  1119. teleportMoreBtn.classList.add("unity-btn");
  1120. teleportMoreBtn.id = "plus"
  1121. teleportMoreBtn.innerHTML = "+";
  1122. teleportMoreBtn.style =
  1123. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1124. document.body.appendChild(teleportMoreBtn);
  1125. teleportMoreBtn.addEventListener("click", () => {
  1126. if (teleportBtn.distance > 21 && teleportBtn.distance < 149) {
  1127. teleportBtn.distance = teleportBtn.distance + 25;
  1128. }
  1129. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  1130. });
  1131.  
  1132. var teleportLessBtn = document.createElement("Button");
  1133. teleportLessBtn.classList.add("unity-btn");
  1134. teleportLessBtn.id = "minus"
  1135. teleportLessBtn.innerHTML = "-";
  1136. teleportLessBtn.style =
  1137. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1138. document.body.appendChild(teleportLessBtn);
  1139. teleportLessBtn.addEventListener("click", () => {
  1140. if (teleportBtn.distance > 26) {
  1141. teleportBtn.distance = teleportBtn.distance - 25;
  1142. }
  1143. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  1144. });
  1145.  
  1146. var teleportDistResetBtn = document.createElement("Button");
  1147. teleportDistResetBtn.classList.add("unity-btn");
  1148. teleportDistResetBtn.id = "reset"
  1149. teleportDistResetBtn.innerHTML = "Reset Distance";
  1150. teleportDistResetBtn.style =
  1151. "visibility:hidden;width:9em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1152. document.body.appendChild(teleportDistResetBtn);
  1153. teleportDistResetBtn.addEventListener("click", () => {
  1154. teleportBtn.distance = 100;
  1155. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  1156. });
  1157.  
  1158. var satelliteSwitchButton = document.createElement("Button");
  1159. satelliteSwitchButton.classList.add("unity-btn");
  1160. satelliteSwitchButton.id = "Satellite Switch";
  1161. satelliteSwitchButton.state = false;
  1162. satelliteSwitchButton.innerHTML = "Streetview mode";
  1163. satelliteSwitchButton.style =
  1164. "visibility:hidden;width:8.5em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;line-height: 14px;";
  1165. document.body.appendChild(satelliteSwitchButton);
  1166. satelliteSwitchButton.addEventListener("click", () => {
  1167. if (!initBing)
  1168. {
  1169. let di = formatDist();
  1170. satelliteSwitchButton.innerHTML = `Satellite (${di})`;
  1171.  
  1172. initBing = true;
  1173. MS_INJECTED = false;
  1174. BR_LOAD_MS = true;
  1175.  
  1176. injectMSPlayer();
  1177. nextPlayer = "Bing Satellite";
  1178. injectCanvas(true);
  1179. satCallback();
  1180.  
  1181. sessionStorage.setItem('Satellite', "T");
  1182. console.log("Load Bing Maps API")
  1183. //
  1184. }
  1185. else
  1186. {
  1187. if (!satelliteSwitchButton.innerHTML.includes("Satellite"))
  1188. {
  1189. // console.log("true!!")
  1190. let di2 = formatDist();
  1191. satelliteSwitchButton.innerHTML = `Satellite (${di2})`;
  1192.  
  1193. nextPlayer = "Bing Satellite";
  1194. injectCanvas(true);
  1195. satCallback();
  1196. nextPlayer = nextPlayer_save;
  1197.  
  1198. sessionStorage.setItem('Satellite', "T");
  1199. // console.log("hello")
  1200. }
  1201. else
  1202. {
  1203. satelliteSwitchButton.innerHTML = "Streetview mode";
  1204. if (nextPlayer_save == "Bing Satellite")
  1205. {
  1206. nextPlayer = "Google";
  1207. }
  1208. else
  1209. {
  1210. nextPlayer = nextPlayer_save;
  1211. }
  1212.  
  1213. injectCanvas(true);
  1214. if (sessionStorage.getItem('Satellite') == "T")
  1215. {
  1216. if (nextPlayer !== "Google")
  1217. {
  1218. goToLocation(true);
  1219. }
  1220. handleButtons();
  1221. }
  1222. sessionStorage.setItem('Satellite', "F");
  1223. }
  1224. if (satelliteSwitchButton.innerHTML !== "Streetview mode" || nextPlayer == "Baidu")
  1225. {
  1226. switchCovergeButton.disabled = true;
  1227. switchCovergeButton.style.background = "red";
  1228. }
  1229. else
  1230. {
  1231. switchCovergeButton.disabled = false;
  1232. switchCovergeButton.style.background = "#BF40BF";
  1233. }
  1234. }
  1235. });
  1236.  
  1237. var switchCovergeButton = document.createElement("Button");
  1238. switchCovergeButton.classList.add("unity-btn");
  1239. switchCovergeButton.sat = false;
  1240. switchCovergeButton.id = "switch";
  1241. switchCovergeButton.init = false;
  1242. switchCovergeButton.useGoogle = false;
  1243. switchCovergeButton.lng = 0
  1244. switchCovergeButton.lat = 0
  1245. switchCovergeButton.heading = 0
  1246. switchCovergeButton.innerHTML = "Switch to Google";
  1247. switchCovergeButton.style =
  1248. "visibility:hidden;width:15em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1249. document.body.appendChild(switchCovergeButton);
  1250. switchCovergeButton.addEventListener("click", () => {
  1251. nextPlayer = nextPlayer_save;
  1252. let GOOGLE_MAPS_CANVAS1 = document.querySelector(".game-layout__panorama-canvas");
  1253. let GOOGLE_MAPS_CANVAS2 = document.querySelector(".br-game-layout__panorama-canvas");
  1254. let GOOGLE_MAPS_CANVAS3 = document.querySelector(".inactive");
  1255. let GOOGLE_MAPS_CANVAS4 = document.querySelector(".game-panorama_panoramaCanvas__r_5ea");
  1256. let duel = false;
  1257.  
  1258. let GOOGLE_MAPS_CANVAS = null;
  1259. if (GOOGLE_MAPS_CANVAS1 !== null)
  1260. {
  1261. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS1;
  1262. }
  1263. else if (GOOGLE_MAPS_CANVAS2 !== null)
  1264. {
  1265. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS2;
  1266. }
  1267. else if (GOOGLE_MAPS_CANVAS4 !== null)
  1268. {
  1269. GOOGLE_MAPS_CANVAS = GOOGLE_MAPS_CANVAS4;
  1270. }
  1271. if (GOOGLE_MAPS_CANVAS3 !== null)
  1272. {
  1273. duel = true;
  1274. }
  1275.  
  1276. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  1277. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  1278. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player")
  1279. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  1280. let MS_MAPS_CANVAS = document.getElementById("ms-player");
  1281. // if (nextPlayer !== "Baidu") {
  1282. if (switchCovergeButton.useGoogle == false) {
  1283. if (duel)
  1284. {
  1285. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  1286. if (nextPlayer == "Kakao")
  1287. {
  1288. KAKAO_MAPS_CANVAS.className = "inactive";
  1289. }
  1290. else if (nextPlayer == "Bing Satellite" || nextPlayer == "Bing Streetside")
  1291. {
  1292. MS_MAPS_CANVAS.className = "inactive";
  1293. }
  1294. else
  1295. {
  1296. MAPILLARY_MAPS_CANVAS.className = "inactive";
  1297. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  1298. }
  1299. }
  1300. else
  1301. {
  1302. GOOGLE_MAPS_CANVAS.style.visibility = "";
  1303. if (nextPlayer == "Kakao")
  1304. {
  1305. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  1306. }
  1307. else if (nextPlayer == "Yandex")
  1308. {
  1309. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  1310. }
  1311. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image")
  1312. {
  1313. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  1314. }
  1315. else if (nextPlayer == "Mapillary" || nextPlayer == "Google")
  1316. {
  1317. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  1318. }
  1319. else if (nextPlayer == "Bing Satellite" || nextPlayer == "Bing Streetside")
  1320. {
  1321. MS_MAPS_CANVAS.style.visibility = "hidden";
  1322. }
  1323.  
  1324. }
  1325. const lat = GooglePlayer.getPosition().lat();
  1326. const lng = GooglePlayer.getPosition().lng();
  1327. switch_call = true;
  1328. if (!almostEqual2(lat, switchCovergeButton.lat) || !almostEqual2(lat, switchCovergeButton.lng)) {
  1329. svService.getPanorama({ location: { lat: switchCovergeButton.lat, lng: switchCovergeButton.lng }, radius: 1000 }, svCheck);
  1330. }
  1331. switchCovergeButton.useGoogle = true;
  1332. teleportBtn.google = true;
  1333. switchCovergeButton.init = false;
  1334.  
  1335. console.log("use Google");
  1336. }
  1337. else {
  1338. if (MS_MAPS_CANVAS)
  1339. {
  1340. MS_MAPS_CANVAS.style.visibility = "hidden";
  1341. }
  1342.  
  1343. if (duel)
  1344. {
  1345. document.getElementById("default_player").className = "inactive";
  1346. if (nextPlayer == "Kakao")
  1347. {
  1348. KAKAO_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  1349. }
  1350. else if (nextPlayer == "Bing Satellite" || nextPlayer == "Bing Streetside")
  1351. {
  1352. MS_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  1353. }
  1354. else
  1355. {
  1356. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panoramaCanvas__PNKve";
  1357. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  1358. MapillaryPlayer.resize();
  1359. //window.dispatchEvent(new Event('resize'));
  1360. // document.querySelector(".mapillary-canvas").style.;
  1361. // mapillary-canvas
  1362. }
  1363.  
  1364. }
  1365. else
  1366. {
  1367. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  1368. if (nextPlayer == "Kakao")
  1369. {
  1370. KAKAO_MAPS_CANVAS.style.visibility = "";
  1371. }
  1372. else if (nextPlayer == "Yandex")
  1373. {
  1374. YANDEX_MAPS_CANVAS.style.visibility = "";
  1375. }
  1376. else if (nextPlayer == "Baidu" || nextPlayer == "Youtube" || nextPlayer == "Image")
  1377. {
  1378. BAIDU_MAPS_CANVAS.style.visibility = "";
  1379. }
  1380. else if (nextPlayer == "Mapillary" || nextPlayer == "Google" )
  1381. {
  1382. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  1383. }
  1384. else if (nextPlayer == "Bing Satellite" || nextPlayer == "Bing Streetside")
  1385. {
  1386. MS_MAPS_CANVAS.style.visibility = "";
  1387. }
  1388. }
  1389. switchCovergeButton.useGoogle = false;
  1390. teleportBtn.google = false;
  1391. switchCovergeButton.init = true;
  1392. console.log("use Others");
  1393. }
  1394. if (switchCovergeButton.useGoogle)
  1395. {
  1396. if (nextPlayer == "Google")
  1397. {
  1398. switchCovergeButton.innerHTML = "Switch to Mapillary";
  1399. satelliteSwitchButton.disabled = false;
  1400. satelliteSwitchButton.style.background = "#BF40BF";
  1401. }
  1402. else
  1403. {
  1404. switchCovergeButton.innerHTML = "Switch to " + nextPlayer;
  1405. satelliteSwitchButton.disabled = true;
  1406. satelliteSwitchButton.style.background = "red";
  1407. }
  1408. }
  1409. else
  1410. {
  1411. if (nextPlayer == "Google" || nextPlayer == "Baidu")
  1412. {
  1413. switchCovergeButton.innerHTML = "Switch to Google";
  1414. satelliteSwitchButton.disabled = true;
  1415. satelliteSwitchButton.style.background = "red";
  1416. }
  1417. else
  1418. {
  1419. switchCovergeButton.innerHTML = "Switch to Google";
  1420. satelliteSwitchButton.disabled = false;
  1421. satelliteSwitchButton.style.background = "#BF40BF";
  1422. }
  1423. }
  1424. // if (switchCovergeButton.sat)
  1425. // {
  1426. // satelliteSwitchButton.disabled = true;
  1427. // satelliteSwitchButton.style.background = "red";
  1428. // }
  1429. // else
  1430. // {
  1431. // satelliteSwitchButton.disabled = false;
  1432. // satelliteSwitchButton.style.background = "#BF40BF";
  1433. // }
  1434. // }
  1435. // else {
  1436. // switchCovergeButton.useGoogle = false;
  1437. // teleportBtn.google = false;
  1438. // console.log("use Others");
  1439. // }
  1440. // if (!(typeof Microsoft == typeof undefined) && (satelliteSwitchButton.innerHTML == "Satellite mode"))
  1441. // {
  1442. // console.log("called")
  1443.  
  1444. // satelliteSwitchButton.innerHTML = "Streetview mode";
  1445. // // nextPlayer = satelliteSwitchButton.old_viewer;
  1446. // if (!switchCovergeButton.useGoogle)
  1447. // {
  1448. // nextPlayer = satelliteSwitchButton.old_viewer;
  1449. // }
  1450. // else
  1451. // {
  1452. // nextPlayer = "Google";
  1453. // }
  1454. // injectCanvas(false);
  1455. // nextPlayer = nextPlayer_save;
  1456.  
  1457. // }
  1458. });
  1459.  
  1460. var timeMachineNewerBtn = document.createElement("Button");
  1461. timeMachineNewerBtn.classList.add("unity-btn");
  1462. timeMachineNewerBtn.id = "plus year"
  1463. timeMachineNewerBtn.innerHTML = "+";
  1464. timeMachineNewerBtn.style =
  1465. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1466. document.body.appendChild(timeMachineNewerBtn);
  1467. timeMachineNewerBtn.addEventListener("click", () => {
  1468. if (timeMachineBtn.index < timeMachineBtn.list.length - 1 && !timeMachineBtn.plusminusLock) {
  1469. timeMachineBtn.index = timeMachineBtn.index + 1;
  1470. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  1471. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1472. // console.log(timeMachineBtn.index)
  1473. }
  1474. GenBtnColor();
  1475.  
  1476. });
  1477.  
  1478. var timeMachineOlderBtn = document.createElement("Button");
  1479. timeMachineOlderBtn.classList.add("unity-btn");
  1480. timeMachineOlderBtn.id = "minus year"
  1481. timeMachineOlderBtn.innerHTML = "-";
  1482. timeMachineOlderBtn.style =
  1483. "visibility:hidden;width:2em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1484. document.body.appendChild(timeMachineOlderBtn);
  1485. timeMachineOlderBtn.addEventListener("click", () => {
  1486. if (timeMachineBtn.index > 0 && !timeMachineBtn.plusminusLock) {
  1487. timeMachineBtn.index = timeMachineBtn.index - 1;
  1488. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  1489. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1490. // console.log(timeMachineBtn.index)
  1491. }
  1492. GenBtnColor();
  1493. });
  1494.  
  1495. function svCheck2(data, status) {
  1496. let l = []
  1497. if (status === 'OK') {
  1498. // console.log("OK for " + data.location.latLng + " at ID " + data.location.pano);
  1499. // console.log(data.time)
  1500. for (const alt of data.time) {
  1501. let date = Object.values(alt).find((value) => value instanceof Date)
  1502.  
  1503. l.push([alt.pano, date.toDateString()]);
  1504. }
  1505. // console.log(l);
  1506. timeMachineBtn.list = l
  1507. timeMachineBtn.index = l.length - 1;
  1508. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1509. GenBtnColor();
  1510. timeMachineBtn.plusminusLock = false;
  1511. // timeMachineOlderBtn.click()
  1512. // timeMachineBtn.innerHTML = "Default Date";
  1513. }
  1514. }
  1515.  
  1516. var timeMachineBtn = document.createElement("Button");
  1517. timeMachineBtn.classList.add("unity-btn");
  1518. timeMachineBtn.id = "Date Button";
  1519. timeMachineBtn.plusminusLock = true;
  1520. timeMachineBtn.panoId = 0;
  1521. timeMachineBtn.index = -1;
  1522. timeMachineBtn.list = [];
  1523. timeMachineBtn.innerHTML = "Time Machine";
  1524. timeMachineBtn.style =
  1525. "visibility:hidden;width:10em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1526. document.body.appendChild(timeMachineBtn);
  1527. timeMachineBtn.addEventListener("click", () => {
  1528. // console.log(timeMachineBtn.index)
  1529. if (timeMachineBtn.panoId != 0)
  1530. {
  1531. if(timeMachineBtn.index == -1)
  1532. {
  1533. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  1534. }
  1535. else
  1536. {
  1537. timeMachineBtn.index = timeMachineBtn.list.length - 1;
  1538. GooglePlayer.setPano(timeMachineBtn.list[timeMachineBtn.index][0]);
  1539. timeMachineBtn.innerHTML = "<font size=2>[" + (timeMachineBtn.index + 1) + "] " + timeMachineBtn.list[timeMachineBtn.index][1] + "</font>";
  1540. GenBtnColor();
  1541. }
  1542. }
  1543. else
  1544. {
  1545. timeMachineBtn.panoId = GooglePlayer.pano;
  1546. svService.getPanorama({pano: timeMachineBtn.panoId}, svCheck2);
  1547. }
  1548. });
  1549.  
  1550. // Battle Royale UI optimization
  1551.  
  1552. // let hide = true;
  1553.  
  1554. var MinimapBtn = document.createElement("Button");
  1555. MinimapBtn.classList.add("unity-btn");
  1556. MinimapBtn.id = "Minimap Button";
  1557. MinimapBtn.innerHTML = "Minimap Style";
  1558. MinimapBtn.current = "Default";
  1559. MinimapBtn.childVisible = false;
  1560. MinimapBtn.style =
  1561. "visibility:hidden;width:7.25em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1562. document.body.appendChild(MinimapBtn);
  1563. MinimapBtn.addEventListener("click", () => {
  1564. if (MinimapBtn.childVisible)
  1565. {
  1566. for (let element of document.getElementsByClassName("preset-minimap")){
  1567. element.style.visibility="hidden";
  1568. }
  1569. MinimapBtn.childVisible = false;
  1570. }
  1571. else
  1572. {
  1573. for (let element of document.getElementsByClassName("preset-minimap")){
  1574. element.style.visibility="";
  1575. }
  1576. MinimapBtn.childVisible = true;
  1577. }
  1578.  
  1579. });
  1580.  
  1581.  
  1582. let HeightCount = 0
  1583. for (let a of presetMinimap)
  1584. {
  1585. let aButton = document.createElement("Button");
  1586. aButton.id = a[1];
  1587. aButton.classList.add("preset-minimap");
  1588. aButton.classList.add("unity-btn");
  1589. aButton.innerHTML = a[1];
  1590. aButton.style =
  1591. "visibility:hidden;width:7.25em;height:1.5em;position:absolute;z-index:99999;background-color: #ff69b4;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1592. document.body.appendChild(aButton);
  1593. HeightCount++;
  1594. }
  1595.  
  1596. var OverlayBtn = document.createElement("Button");
  1597. OverlayBtn.classList.add("unity-btn");
  1598. OverlayBtn.id = "Overlay Button";
  1599. OverlayBtn.innerHTML = "Overlay";
  1600. OverlayBtn.current = "Clear";
  1601. OverlayBtn.childVisible = false;
  1602. OverlayBtn.style =
  1603. "visibility:hidden;width:7.25em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1604. document.body.appendChild(OverlayBtn);
  1605.  
  1606. OverlayBtn.addEventListener("click", () => {
  1607. if (OverlayBtn.childVisible)
  1608. {
  1609. for (let element of document.getElementsByClassName("overlay-minimap")){
  1610. element.style.visibility = "hidden";
  1611. }
  1612. OverlayBtn.childVisible = false;
  1613. }
  1614. else
  1615. {
  1616. for (let element of document.getElementsByClassName("overlay-minimap")){
  1617. element.style.visibility = "";
  1618. }
  1619. OverlayBtn.childVisible = true;
  1620. }
  1621.  
  1622. });
  1623.  
  1624. let HeightCount2 = 0
  1625. for (let b of presetOverlay)
  1626. {
  1627. let bButton = document.createElement("Button");
  1628. bButton.id = b[0];
  1629. bButton.url = b[1];
  1630. bButton.loaded = false;
  1631. bButton.classList.add("overlay-minimap");
  1632. bButton.classList.add("unity-btn");
  1633. bButton.innerHTML = b[0];
  1634. bButton.style =
  1635. "visibility:hidden;width:7.25em;height:1.5em;position:absolute;z-index:99999;background-color: #ff69b4;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1636. if (bButton.id == "Clear")
  1637. {
  1638. bButton.loaded = true;
  1639. bButton.style.background = "#ff1493";
  1640. }
  1641. document.body.appendChild(bButton);
  1642. HeightCount2++;
  1643. }
  1644.  
  1645. var HelpBtn = document.createElement("Button");
  1646. HelpBtn.classList.add("unity-btn");
  1647. HelpBtn.id = "Help Button";
  1648. HelpBtn.innerHTML = "Script Help";
  1649. HelpBtn.style =
  1650. "visibility:hidden;width:6em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1651. document.body.appendChild(HelpBtn);
  1652. HelpBtn.addEventListener("click", () => {
  1653. window.open('https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing');
  1654. });
  1655.  
  1656. var TeleportArisBtn = document.createElement("Button");
  1657. TeleportArisBtn.classList.add("unity-btn");
  1658. TeleportArisBtn.id = "Teleport Options Button";
  1659. TeleportArisBtn.innerHTML = "Default";
  1660. TeleportArisBtn.style =
  1661. "visibility:hidden;width:5.5em;height:2em;position:absolute;z-index:99999;background-color: #BF40BF;background-repeat:no-repeat;background-image:linear-gradient(180deg, #0066cc 50%, #ffcc00 50%);border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;";
  1662. document.body.appendChild(TeleportArisBtn);
  1663. TeleportArisBtn.addEventListener("click", () => {
  1664. if (teleportBtn.teleType == "default")
  1665. {
  1666. teleportBtn.teleType = "outdoor"
  1667. TeleportArisBtn.innerHTML = "Official";
  1668. }
  1669. else
  1670. {
  1671. teleportBtn.teleType = "default"
  1672. TeleportArisBtn.innerHTML = "Default";
  1673. }
  1674. });
  1675.  
  1676. var playYoutubeBtn = document.createElement("Button");
  1677. playYoutubeBtn.classList.add("unity-btn");
  1678. playYoutubeBtn.id = "Youtube Button";
  1679. playYoutubeBtn.innerHTML = "Play video";
  1680. playYoutubeBtn.style =
  1681. "visibility:hidden;width:5.5em;height:2.5em;position:absolute;z-index:999999;background-color: #BF40BF;border: none;color: white;padding: none;text-align: center;vertical-align: text-top;text-decoration: none;display: inline-block;font-size: 16px;line-height: 14px;";
  1682. document.body.appendChild(playYoutubeBtn);
  1683. playYoutubeBtn.addEventListener("click", () => {
  1684. let iframe = document.getElementById("i_container");
  1685. iframe.style.position = "absolute";
  1686. iframe.allow = "autoplay";
  1687. let srcString = "https://www.youtube.com/embed/" + yId + "?&playlist=" + yId + "&autoplay=1&modestbranding=1&controls=0&start=";
  1688. if (yTime == "0" && yEnd == "0")
  1689. {
  1690. }
  1691. else
  1692. {
  1693. srcString += yTime + "&end=" + yEnd;
  1694. }
  1695. iframe.src = srcString;
  1696. iframe.style.visibility = "";
  1697. playYoutubeBtn.innerHTML = "Play video from start";
  1698. });
  1699.  
  1700.  
  1701. console.log("Script buttons Loaded");
  1702. }
  1703.  
  1704. function GenBtnColor()
  1705. {
  1706. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  1707. if (timeMachineBtn.index == timeMachineBtn.list.length - 1)
  1708. {
  1709. timeMachineNewerBtn.style.backgroundColor = "red";
  1710. timeMachineNewerBtn.disabled = true;
  1711. }
  1712. else
  1713. {
  1714. timeMachineNewerBtn.style.backgroundColor = "#BF40BF";
  1715. timeMachineNewerBtn.disabled = false;
  1716. }
  1717. if (timeMachineBtn.index == 0)
  1718. {
  1719. timeMachineOlderBtn.style.backgroundColor = "red";
  1720. timeMachineOlderBtn.disabled = true;
  1721. }
  1722. else
  1723. {
  1724. timeMachineOlderBtn.style.backgroundColor = "#BF40BF";
  1725. timeMachineOlderBtn.disabled = false;
  1726. }
  1727. }
  1728.  
  1729. /**
  1730. * Handle Keyboard inputs
  1731. */
  1732.  
  1733. function kBoard()
  1734. {
  1735. document.addEventListener('keydown', logKey);
  1736. }
  1737.  
  1738. function logKey(e) {
  1739. // console.log(e.code);
  1740. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  1741. if (e.code == "Space")
  1742. {
  1743. setHidden(true);
  1744. }
  1745. if (e.code == "Digit3")
  1746. {
  1747. teleportBtn.click();
  1748. }
  1749. else if (e.code == "Digit4")
  1750. {
  1751. timeMachineOlderBtn.click();
  1752. }
  1753. else if (e.code == "Digit5")
  1754. {
  1755. timeMachineBtn.click();
  1756. }
  1757. else if (e.code == "Digit6")
  1758. {
  1759. timeMachineNewerBtn.click();
  1760. }
  1761. else if (e.code == "Digit7")
  1762. {
  1763. if (mainMenuBtn.style.visibility == "hidden")
  1764. {
  1765. mainMenuBtn.style.visibility = "";
  1766. }
  1767. else
  1768. {
  1769. mainMenuBtn.style.visibility = "hidden";
  1770. }
  1771. }
  1772. }
  1773.  
  1774.  
  1775. /**
  1776. * Hide or reveal the buttons, and disable buttons if such feature is not available
  1777. */
  1778.  
  1779. function setHidden(cond)
  1780. {
  1781. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  1782. if (mainMenuBtn != null)
  1783. {
  1784. mainMenuBtn.style.visibility = "";
  1785. mainMenuBtn.innerHTML = "<font size=2>Unity<br><font size=1>v5.2.7</font>";
  1786. mainMenuBtn.style.width = "3em"
  1787. mainMenuBtn.style.backgroundPosition = "";
  1788. mainMenuBtn.backgroundColor = ""
  1789. mainMenuBtn.hide = true;
  1790. if (cond)
  1791. {
  1792.  
  1793. if (teleportBtn != null)
  1794. {
  1795. for (let element of document.getElementsByClassName("unity-btn")){
  1796. element.style.visibility = "hidden";
  1797. }
  1798. }
  1799. let iframe = document.getElementById("i_container");
  1800. if (iframe != null)
  1801. {
  1802. if (!isBattleRoyale)
  1803. {
  1804. iframe.src = ""
  1805. }
  1806. else
  1807. {
  1808. // TODO
  1809. }
  1810. }
  1811.  
  1812. }
  1813. else
  1814. {
  1815. for (let element of document.getElementsByClassName("unity-btn")){
  1816. if (element.id !== "Show Buttons")
  1817. {
  1818. element.style.visibility = "hidden";
  1819. }
  1820. }
  1821. }
  1822. }
  1823. }
  1824.  
  1825. function setDisable(cond) {
  1826. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  1827. function setAll(cond1, cond2)
  1828. {
  1829. teleportMoreBtn.style.backgroundColor = cond1;
  1830. teleportMoreBtn.disabled = cond2;
  1831. teleportLessBtn.style.backgroundColor = cond1;
  1832. teleportLessBtn.disabled = cond2;
  1833. teleportDistResetBtn.style.backgroundColor = cond1;
  1834. teleportDistResetBtn.disabled = cond2;
  1835. switchCovergeButton.style.backgroundColor = cond1;
  1836. switchCovergeButton.disabled = cond2;
  1837. teleportBtn.style.backgroundColor = cond1;
  1838. teleportBtn.disabled = cond2;
  1839. TeleportArisBtn.style.backgroundColor = cond1;
  1840. TeleportArisBtn.disabled = cond2;
  1841. timeMachineBtn.style.backgroundColor = cond1;
  1842. timeMachineBtn.disabled = cond2;
  1843. satelliteSwitchButton.style.backgroundColor = cond1;
  1844. satelliteSwitchButton.disabled = cond2;
  1845. }
  1846.  
  1847. function setMapstyle(cond1, cond2)
  1848. {
  1849. for (let mapDiv of document.getElementsByClassName("preset-minimap"))
  1850. {
  1851. if (mapDiv.id == "Borders" || mapDiv.id == "Satellite" || mapDiv.id == "Terrain" || mapDiv.id == "Hybrid" || mapDiv.id == "Custom")
  1852. {
  1853. mapDiv.style.backgroundColor = cond1;
  1854. mapDiv.disabled = cond2;
  1855. }
  1856. }
  1857. for (let mapDiv2 of document.getElementsByClassName("overlay-minimap"))
  1858. {
  1859. if (mapDiv2.id == "Coverage" || mapDiv2.id == "Official")
  1860. {
  1861. mapDiv2.style.backgroundColor = cond1;
  1862. mapDiv2.disabled = cond2;
  1863. }
  1864. }
  1865. }
  1866. // console.log(cond)
  1867.  
  1868. if (teleportBtn != null) {
  1869. if (rtded) {
  1870. setAll("red", true);
  1871. setMapstyle("red", true)
  1872. }
  1873. else
  1874. {
  1875. setMapstyle("#ff69b4", false)
  1876. if (cond == ms_sat_map)
  1877. {
  1878. setAll("red", true);
  1879. }
  1880. else if (cond == "NMPZ") {
  1881. setAll("red", true);
  1882. if (cond !== "Baidu")
  1883. {
  1884. satelliteSwitchButton.style.backgroundColor = "#BF40BF";
  1885. satelliteSwitchButton.disabled = false;
  1886. }
  1887. if (NZ)
  1888. {
  1889. if (ms_radius > 5000)
  1890. {
  1891. ms_radius = 5000;
  1892. }
  1893. }
  1894. if (NM)
  1895. {
  1896. if (ms_radius > 2000)
  1897. {
  1898. ms_radius = 2000;
  1899. }
  1900. }
  1901. if (NM && NZ)
  1902. {
  1903. if (ms_radius > 1000)
  1904. {
  1905. ms_radius = 1000;
  1906. }
  1907. }
  1908. if (NM && NP && NZ)
  1909. {
  1910. if (ms_radius > 500)
  1911. {
  1912. ms_radius = 500;
  1913. }
  1914. }
  1915. }
  1916. else if (cond == "Google") {
  1917. setAll("#BF40BF", false);
  1918. }
  1919. else if (cond === "Baidu" || cond === "Youtube" || cond === "Image" || cond == "Bing Satellite") {
  1920. setAll("red", true);
  1921. switchCovergeButton.style.backgroundColor = "#BF40BF";
  1922. switchCovergeButton.disabled = false;
  1923. if (cond !== "Baidu")
  1924. {
  1925. satelliteSwitchButton.style.backgroundColor = "#BF40BF";
  1926. satelliteSwitchButton.disabled = false;
  1927. }
  1928. }
  1929. else if (cond == "Kakao" || cond == "Yandex" || cond == "Mapillary" || cond == "Bing Streetside") {
  1930. setAll("#BF40BF", false);
  1931. timeMachineBtn.style.backgroundColor = "red";
  1932. timeMachineBtn.disabled = true;
  1933. }
  1934. // else if (cond == "Bing Satellite") {
  1935. // setAll("red", true);
  1936. // switchCovergeButton.style.backgroundColor = "#BF40BF";
  1937. // switchCovergeButton.disabled = false;
  1938. // satelliteSwitchButton.style.backgroundColor = "#BF40BF";
  1939. // satelliteSwitchButton.disabled = false;
  1940. // }
  1941. }
  1942. timeMachineNewerBtn.style.backgroundColor = "red";
  1943. timeMachineNewerBtn.disabled = true;
  1944. timeMachineOlderBtn.style.backgroundColor = "red";
  1945. timeMachineOlderBtn.disabled = true;
  1946. }
  1947. }
  1948.  
  1949.  
  1950. /**
  1951. * This observer stays alive while the script is running
  1952. */
  1953.  
  1954. function launchObserver() {
  1955. UnityInitiate();
  1956. handleTeleport();
  1957. SyncListener();
  1958. kBoard();
  1959. console.log("Main Observer");
  1960. const OBSERVER = new MutationObserver((mutations, observer) => {
  1961. detectGamePage();
  1962. });
  1963. observerCallback(OBSERVER)
  1964. }
  1965. function observerCallback(obs)
  1966. {
  1967. if (obs)
  1968. {
  1969. obs.observe(document.head, { attributes: true, childList: true, subtree: true });
  1970. }
  1971. else
  1972. {
  1973. setTimeout(observerCallback, 250);
  1974. }
  1975. }
  1976.  
  1977. /**
  1978. * Once the Google Maps API was loaded we can do more stuff
  1979. */
  1980.  
  1981. window.addEventListener('DOMContentLoaded', (event) => {
  1982. injecter(() => {
  1983. launchObserver();
  1984. })
  1985. });
  1986.  
  1987. const base62 = {
  1988. charset: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  1989. .split(''),
  1990. encode: integer => {
  1991. if (integer === 0) {
  1992. return 0;
  1993. }
  1994. let s = [];
  1995. while (integer > 0) {
  1996. s = [base62.charset[integer % 62], ...s];
  1997. integer = Math.floor(integer / 62);
  1998. }
  1999. return s.join('');
  2000. },
  2001. decode: chars => chars.split('').reverse().reduce((prev, curr, i) =>
  2002. prev + (base62.charset.indexOf(curr) * (62 ** i)), 0)
  2003. };
  2004.  
  2005.  
  2006. /**
  2007. * Check whether the current page is a game, if so which game mode
  2008. */
  2009.  
  2010. function detectGamePage() {
  2011. if (document.querySelector(".game-layout__panorama-message") !== null && !one_reset)
  2012. {
  2013. one_reset = true;
  2014. console.log("Hide fail to load panorama canvas");
  2015. document.querySelector(".game-layout__panorama-message").style.visibility = "hidden";
  2016. }
  2017. function loadModule()
  2018. {
  2019. if (toLoad) {
  2020. initializeCanvas();
  2021. }
  2022. waitLoad();
  2023. }
  2024. let toLoad = !playerLoaded && !YandexPlayer && !KakaoPlayer && !MapillaryPlayer && !MSStreetPlayer && !YANDEX_INJECTED && !KAKAO_INJECTED && !MAPILLARY_INJECTED && !MS_INJECTED
  2025. const PATHNAME = window.location.pathname;
  2026. if (PATHNAME.startsWith("/game/") || PATHNAME.startsWith("/challenge/")) {
  2027. // console.log("Game page");
  2028. isBattleRoyale = false;
  2029. isDuel = false;
  2030. loadModule();
  2031. }
  2032. else if (PATHNAME.startsWith("/battle-royale/")) {
  2033. if (document.querySelector(".br-game-layout") == null) {
  2034. // console.log("Battle Royale Lobby");
  2035. rstValues();
  2036. }
  2037. else {
  2038. // console.log("Battle Royale");
  2039. isBattleRoyale = true;
  2040. isDuel = false;
  2041. loadModule();
  2042. }
  2043. }
  2044. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  2045. if (document.querySelector(".game_layout__TO_jf") == null) {
  2046. // console.log("Battle Royale Lobby");
  2047. rstValues();
  2048. }
  2049. else {
  2050. // console.log("Duels");
  2051. isBattleRoyale = true;
  2052. isDuel = true;
  2053. loadModule();
  2054. }
  2055. }
  2056. else if (PATHNAME.startsWith("/bullseye/")) {
  2057. if (document.querySelector(".game_layout__0vAWj") == null) {
  2058. // console.log("Battle Royale Lobby");
  2059. rstValues();
  2060. }
  2061. else {
  2062. // console.log("bullseye");
  2063. isBattleRoyale = true;
  2064. isBullseye = true;
  2065. loadModule();
  2066. }
  2067. }
  2068. else if (PATHNAME.startsWith("/live-challenge/")) {
  2069. if (document.querySelector(".game_layout__p7CLf") == null) {
  2070. // console.log("Battle Royale Lobby");
  2071. rstValues();
  2072. }
  2073. else {
  2074. // console.log("bullseye");
  2075. isLiveChallenge = true;
  2076. isBattleRoyale = true;
  2077. loadModule();
  2078. }
  2079. }
  2080. else {
  2081. rstValues();
  2082. // console.log("Not a Game page");
  2083. }
  2084. }
  2085.  
  2086. function rstValues()
  2087. {
  2088. ROUND = 0;
  2089. YandexPlayer = null;
  2090. KakaoPlayer = null;
  2091. MapillaryPlayer = null;
  2092. MSStreetPlayer = null;
  2093.  
  2094. BAIDU_INJECTED = false;
  2095. YANDEX_INJECTED = false;
  2096. KAKAO_INJECTED = false;
  2097. MAPILLARY_INJECTED = false;
  2098. MS_INJECTED = false;
  2099.  
  2100. nextPlayer = "Google";
  2101. nextPlayer_save = "Google";
  2102. global_lat = 0;
  2103. global_lng = 0;
  2104. global_panoID = null;
  2105. global_BDAh = null;
  2106. global_BDBh = null;
  2107. global_BDID = null;
  2108. yId = null;
  2109. yTime = null;
  2110. yEnd = null;
  2111. iId = null;
  2112.  
  2113. COMPASS = null;
  2114. eventListenerAttached = false;
  2115. povListenerAttached = false;
  2116. playerLoaded = false;
  2117. locHistory = [];
  2118. one_reset = false;
  2119. setHidden(true);
  2120. yandex_map = false;
  2121. Kakao_map = false;
  2122. mmKey = 0;
  2123. CURRENT_ROUND_DATA = null;
  2124. ms_radius = 15000;
  2125. ms_random = false;
  2126. ms_birdseye = false;
  2127.  
  2128. isDuel = false;
  2129. isBattleRoyale = false;
  2130. isBullseye = false;
  2131. isLiveChallenge = false;
  2132.  
  2133. BR_LOAD_KAKAO = false;
  2134. BR_LOAD_YANDEX = false;
  2135. BR_LOAD_MS = false;
  2136.  
  2137. ms_sat_map = false;
  2138. rtded = false;
  2139.  
  2140. linksList = [];
  2141.  
  2142. NM = false;
  2143. NP = false;
  2144. NZ = false;
  2145. initBing = false;
  2146. }
  2147.  
  2148. /**
  2149. * Wait for various players to load
  2150. */
  2151.  
  2152. function waitLoad() {
  2153. if (!YandexPlayer || !KakaoPlayer || !MapillaryPlayer || !MSStreetPlayer || !YANDEX_INJECTED || !KAKAO_INJECTED || !MAPILLARY_INJECTED || !MS_INJECTED) {
  2154. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2155.  
  2156. if (document.querySelector(".ticket-bar_root__H8RcX") != null)
  2157. {
  2158. if (document.querySelector(".br-game-layout__panorama-canvas") != null)
  2159. {
  2160. AdjustBtnPos("-2em + 2px", "300px");
  2161. }
  2162. else if (document.querySelector(".game-panorama_panorama__rdhFg") != null)
  2163. {
  2164. AdjustBtnPos("6em", "0em");
  2165. }
  2166. else if (document.querySelector(".game-panorama_panorama__ncMwh") != null)
  2167. {
  2168. AdjustBtnPos("5em", "18.5em");
  2169. }
  2170. else if (document.querySelector(".game-panorama_panorama__6RmkO") != null)
  2171. {
  2172. AdjustBtnPos("4em", "15.5em");
  2173. }
  2174. else
  2175. {
  2176. AdjustBtnPos("4em", "0em");
  2177. }
  2178. }
  2179. else
  2180. {
  2181. if (document.querySelector(".br-game-layout__panorama-canvas") != null)
  2182. {
  2183. AdjustBtnPos("-6em + 2px", "300px");
  2184. }
  2185. else if (document.querySelector(".game-panorama_panorama__rdhFg") != null)
  2186. {
  2187. AdjustBtnPos("2em", "0em");
  2188. }
  2189. else if (document.querySelector(".game-panorama_panorama__ncMwh") != null)
  2190. {
  2191. AdjustBtnPos("1em", "18.5em");
  2192. }
  2193. else if (document.querySelector(".game-panorama_panorama__6RmkO") != null)
  2194. {
  2195. AdjustBtnPos("0em", "15.5em");
  2196. }
  2197. else
  2198. {
  2199. AdjustBtnPos("0em", "0em");
  2200. }
  2201. }
  2202. setTimeout(waitLoad, 250);
  2203. } else {
  2204. checkRound();
  2205. }
  2206. }
  2207.  
  2208. /**
  2209. * Checks for round changes
  2210. */
  2211.  
  2212. function checkRound() {
  2213. // console.log("Check Round");
  2214. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2215.  
  2216. if (!isBattleRoyale) {
  2217. // console.log("Check Round");
  2218. let currentRound = getRoundFromPage();
  2219. if (ROUND != currentRound) {
  2220. fire1 = true;
  2221. switchCovergeButton.init = true;
  2222. console.log("New round");
  2223. ROUND = currentRound;
  2224. // NEW_ROUND_LOADED = true;
  2225. COMPASS = null;
  2226. locHistory = [];
  2227. one_reset = false;
  2228. getMapData();
  2229. nextButtonCallback();
  2230. }
  2231. }
  2232. else {
  2233. getMapData();
  2234. }
  2235. }
  2236.  
  2237. /**
  2238. * Add listeners if buttons have been created
  2239. */
  2240.  
  2241. function finalDetail()
  2242. {
  2243. let target = document.querySelector("a[data-qa='play-same-map']");
  2244. if (target)
  2245. {
  2246. var div = document.createElement("div");
  2247. div.classList.add("buttons_buttons__0B3SB")
  2248. document.querySelector('.result-layout_content__jAHfP').appendChild(div);
  2249. for (var rd of linksList)
  2250. {
  2251. // console.log(rd)
  2252. let cl = target.cloneNode( true );
  2253. let tx = "View R" + rd[0] + " in " + rd[1];
  2254. cl.querySelector('.button_label__kpJrA').innerHTML = tx;
  2255. cl.removeAttribute('data-qa');
  2256. cl.removeAttribute('href');
  2257. cl.urlStr = rd[2];
  2258. cl.addEventListener("click", (e) => {
  2259. window.open(cl.urlStr);
  2260. })
  2261. cl.style = "top:10px;right:-10px;";
  2262. div.appendChild(cl);
  2263. }
  2264. }
  2265. else
  2266. {
  2267. setTimeout(finalDetail, 500);
  2268. }
  2269. }
  2270.  
  2271. function nextButtonCallback()
  2272. {
  2273. let nextButton = document.querySelector("button[data-qa='close-round-result']");
  2274. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2275. if (nextButton != null && fire1)
  2276. {
  2277. fire1 = false;
  2278. nextButton.addEventListener("click", (e) => {
  2279. if (mainMenuBtn != null && !cn_tips && ROUND !== 5)
  2280. {
  2281. // console.log("try to show show buttons")
  2282. mainMenuBtn.style.visibility = "";
  2283. }
  2284. if (ROUND == 5)
  2285. {
  2286. console.log("Game Finished")
  2287. if (linksList)
  2288. {
  2289. finalDetail();
  2290. }
  2291. }
  2292. })
  2293. let urlStr = ""
  2294.  
  2295. if (nextPlayer !== "Google")
  2296. {
  2297. console.log("Clone buttons");
  2298. let clone = document.querySelector("button[data-qa='close-round-result']").cloneNode( true );
  2299. let tx = "View Location in " + nextPlayer;
  2300. clone.querySelector('.button_label__kpJrA').innerHTML = tx;
  2301. clone.setAttribute('id', "LinkBtn");
  2302. clone.removeAttribute('data-qa');
  2303. if (nextPlayer == "Baidu")
  2304. {
  2305. urlStr = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  2306. }
  2307. else if (nextPlayer == "Youtube")
  2308. {
  2309. urlStr = "https://www.youtube.com/watch?v=" + yId;
  2310. }
  2311. else if (nextPlayer == "Image")
  2312. {
  2313. urlStr = iId;
  2314. }
  2315. else if (nextPlayer == "Kakao")
  2316. {
  2317. urlStr = "https://map.kakao.com/link/roadview/" + global_lat + "," + global_lng;
  2318. }
  2319. else if (nextPlayer == "Mapillary")
  2320. {
  2321. urlStr = "https://www.mapillary.com/app/?pKey=" + mmKey + "&focus=photo";
  2322. }
  2323. else if (nextPlayer == "Yandex")
  2324. {
  2325. urlStr = "https://yandex.com/maps/?&panorama%5Bdirection%5D=16%2C0&panorama%5Bpoint%5D=" + global_lng + "%2C" + global_lat;
  2326. }
  2327. else if (nextPlayer == "Bing Satellite" || nextPlayer == "Bing Streetside")
  2328. {
  2329. urlStr = "https://bing.com/maps/default.aspx?cp=" + global_lat + "~" + global_lng + "&lvl=20&style=r";
  2330. }
  2331. clone.addEventListener("click", (e) => {
  2332. window.open(urlStr);
  2333. })
  2334. if (ROUND == 5)
  2335. {
  2336. clone.style = "top:10px;";
  2337. }
  2338. else
  2339. {
  2340. clone.style = "right:-10px;";
  2341. }
  2342. linksList.push([ROUND, nextPlayer, urlStr]);
  2343. document.querySelector('.round-result_actions__5j26U').appendChild(clone);
  2344. }
  2345. }
  2346. else
  2347. {
  2348. setTimeout(nextButtonCallback, 1000);
  2349. }
  2350. }
  2351.  
  2352. function guessButtonCallback()
  2353. {
  2354. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2355. let guessButton = document.querySelector("button[data-qa='perform-guess']");
  2356. if (guessButton != null)
  2357. {
  2358.  
  2359. guessButton.addEventListener("click", (e) => {
  2360. if (mainMenuBtn != null)
  2361. {
  2362. console.log("try to hide show buttons")
  2363. mainMenuBtn.style.visibility = "hidden";
  2364. setHidden(true);
  2365. }
  2366. })
  2367. }
  2368. else
  2369. {
  2370. setTimeout(guessButtonCallback, 500);
  2371. }
  2372. }
  2373.  
  2374. /**
  2375. * Load different streetview players
  2376. */
  2377.  
  2378. function loaderChecker(data)
  2379. {
  2380.  
  2381. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2382. if (data.includes("A United World") || data.includes("A Unity World") || data.includes("Unity Test") || data.includes("Unity Special Edition"))
  2383. {
  2384. console.log("Complete Map");
  2385. data = "Yandex Bing Streetside Kakao";
  2386. }
  2387.  
  2388. if (data.includes("Yandex"))
  2389. {
  2390. console.log("Yandex Map");
  2391. if (data == "Yandex Bing Streetside Kakao")
  2392. {
  2393. yandex_map = false;
  2394. }
  2395. else
  2396. {
  2397. yandex_map = true;
  2398. }
  2399. injectYandexScript().then(() => {
  2400. console.log("Ready to inject Yandex player");
  2401. injectYandexPlayer();
  2402. }).catch((error) => {
  2403. console.log(error);
  2404. });
  2405. BR_LOAD_YANDEX = true;
  2406. }
  2407. else
  2408. {
  2409. console.log("Not Yandex map");
  2410. YANDEX_INJECTED = true;
  2411. YandexPlayer = "YD";
  2412. }
  2413.  
  2414. if (data.includes("Bing Streetside") || data.includes("Bing Satellite") || (sessionStorage.getItem('Satellite') == "T" && !rtded))
  2415. {
  2416. if (data.includes("Bing Satellite"))
  2417. {
  2418. ms_sat_map = true;
  2419. let tempRad = data.split("Bing Satellite")[1];
  2420. if (/\d/.test(tempRad))
  2421. {
  2422. ms_radius = parseInt(tempRad.replace(/\D/g,'')) * 1000;
  2423. }
  2424. if (tempRad.includes("Birdseye"))
  2425. {
  2426. ms_birdseye = true;
  2427. }
  2428. if (tempRad.includes("Random"))
  2429. {
  2430. ms_random = true;
  2431. }
  2432. }
  2433. console.log("Bing Map");
  2434. injectMSPlayer();
  2435. initBing = true;
  2436. BR_LOAD_MS = true;
  2437. }
  2438. else
  2439. {
  2440. console.log("Not Bing map");
  2441. MS_INJECTED = true;
  2442. MSStreetPlayer = "MS";
  2443. }
  2444.  
  2445. if (data.includes("Kakao"))
  2446. {
  2447. console.log("Kakao Map");
  2448. if (data == "Yandex Bing Streetside Kakao")
  2449. {
  2450. Kakao_map = false;
  2451. }
  2452. else
  2453. {
  2454. Kakao_map = true;
  2455. }
  2456. injectKakaoScript().then(() => {
  2457. console.log("Ready to inject Kakao player");
  2458. }).catch((error) => {
  2459. console.log(error);
  2460. });
  2461. BR_LOAD_KAKAO = true;
  2462. }
  2463. else{
  2464. KAKAO_INJECTED = true;
  2465. KakaoPlayer = "KK";
  2466. console.log("Not Kakao map");
  2467. }
  2468.  
  2469.  
  2470. if (!data.includes("China Tips for each province"))
  2471. {
  2472. cn_tips = false;
  2473. mainMenuBtn.style.visibility = "";
  2474. setHidden(false);
  2475. }
  2476. else
  2477. {
  2478. cn_tips = true;
  2479. guaranteeUI();
  2480. }
  2481.  
  2482. }
  2483.  
  2484. function loadPlayers() {
  2485. let mapBounds;
  2486. playerLoaded = true;
  2487. injectContainer();
  2488. getSeed().then((data) => {
  2489. // console.log(data)
  2490. let map_name = "Default"
  2491. if (typeof data.isRated !== 'undefined')
  2492. {
  2493. rtded = data.isRated;
  2494. }
  2495. if (typeof data.options !== 'undefined')
  2496. {
  2497. if (typeof data.options.isRated !== 'undefined')
  2498. {
  2499. rtded = data.options.isRated;
  2500. }
  2501. }
  2502. if (rtded)
  2503. {
  2504. map_name = "Public Game";
  2505. }
  2506. else
  2507. {
  2508. if (!isBattleRoyale)
  2509. {
  2510. mapBounds = [data.bounds.max.lat, data.bounds.max.lng, data.bounds.min.lat, data.bounds.min.lng];
  2511. map_name = data.mapName;
  2512. }
  2513. else
  2514. {
  2515. if (isBullseye)
  2516. {
  2517. mapBounds = [data.boundingBox.max.lat, data.boundingBox.max.lng, data.boundingBox.min.lat, data.boundingBox.min.lng];
  2518. map_name = data.mapName;
  2519. }
  2520. else if (isDuel)
  2521. {
  2522. mapBounds = [data.mapBounds.max.lat, data.mapBounds.max.lng, data.mapBounds.min.lat, data.mapBounds.min.lng];
  2523. map_name = data.options.map.name;
  2524. }
  2525. else if (isLiveChallenge)
  2526. {
  2527. mapBounds = [data.mapBounds.max.lat, data.mapBounds.max.lng, data.mapBounds.min.lat, data.mapBounds.min.lng];
  2528. map_name = data.mapName;
  2529. }
  2530. else
  2531. {
  2532. map_name = "Unity Test";
  2533. }
  2534. }
  2535. }
  2536. if (mapBounds)
  2537. {
  2538. ms_radius = magic_formula(mapBounds);
  2539. // console.log(ms_radius / 1000)
  2540. }
  2541. loaderChecker(map_name)
  2542.  
  2543. }).catch((error) => {
  2544. console.log(error);
  2545. });
  2546.  
  2547. }
  2548.  
  2549. function guaranteeUI()
  2550. {
  2551. // console.log("UI")
  2552. if (document.getElementById("GH-ui") !== null)
  2553. {
  2554. document.getElementById("GH-ui").style.display = "block";
  2555. }
  2556. else
  2557. {
  2558. setTimeout(guaranteeUI, 500);
  2559. }
  2560. }
  2561.  
  2562. /**
  2563. * Handles Return to start and undo
  2564. */
  2565.  
  2566. function handleReturnToStart() {
  2567. let rtsButton = document.querySelector("button[data-qa='return-to-start']");
  2568. console.log("Handle Return to start");
  2569. rtsButton.addEventListener("click", (e) => {
  2570. if (nextPlayer !== "Baidu")
  2571. {
  2572. goToLocation(true);
  2573. }
  2574. else
  2575. {
  2576. document.getElementById("i_container").src = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  2577. }
  2578. const elementClicked = e.target;
  2579. elementClicked.setAttribute('listener', 'true');
  2580. console.log("Return to start");
  2581. });
  2582. guessButtonCallback();
  2583. // setTimeout(function () {goToLocation();}, 1000);
  2584. }
  2585.  
  2586. function handleUndo() {
  2587. let undoButton = document.querySelector("button[data-qa='undo-move']");
  2588. console.log("Handle undo");
  2589. undoButton.addEventListener("click", (e) => {
  2590. if (locHistory.length > 0) {
  2591. goToUndoMove();
  2592. console.log("Undo Move");
  2593. }
  2594. })
  2595. }
  2596.  
  2597. /**
  2598. * Load game information
  2599. */
  2600.  
  2601. function satCallback()
  2602. {
  2603. // console.log("Sat callback")
  2604. if (typeof MSStreetPlayer.entities !== typeof undefined && typeof Microsoft.Maps !== typeof undefined)
  2605. {
  2606. goToLocation(false);
  2607. }
  2608. else
  2609. {
  2610. setTimeout(satCallback, 250);
  2611. }
  2612. }
  2613.  
  2614. function kakaoCallback()
  2615. {
  2616. console.log("Kakao callback")
  2617. if (typeof kakao.maps !== typeof undefined)
  2618. {
  2619. goToLocation(true);
  2620. setTimeout(function () {goToLocation(true);}, 3000);
  2621. }
  2622. else
  2623. {
  2624. setTimeout(satCallback, 250);
  2625. }
  2626. }
  2627.  
  2628.  
  2629. function modularget(data)
  2630. {
  2631. if (data)
  2632. {
  2633. locationCheck(data);
  2634. if (nextPlayer == "Kakao")
  2635. {
  2636. kakaoCallback();
  2637. }
  2638. else
  2639. {
  2640. goToLocation(true);
  2641. }
  2642. handleMinimapCallback();
  2643. handleButtons();
  2644. }
  2645. }
  2646.  
  2647. function getMapData() {
  2648. // myHighlight("Seed data");
  2649.  
  2650. getSeed().then((data) => {
  2651. let switchCovergeButton = document.getElementById("switch");
  2652. let mainMenuBtn = document.getElementById("Show Buttons")
  2653. if (isBattleRoyale) {
  2654. if (data.status == "Finished" || typeof data.gameId == typeof undefined) {
  2655. // console.log("Battle Royale Lobby");
  2656. }
  2657. else
  2658. {
  2659. let origin = false;
  2660. if (!CURRENT_ROUND_DATA) {
  2661. CURRENT_ROUND_DATA = data
  2662. origin = true;
  2663. }
  2664.  
  2665. if (origin || !(data.currentRoundNumber === CURRENT_ROUND_DATA.currentRoundNumber)) {
  2666. // myHighlight("Battle Royale New round");
  2667. switchCovergeButton.init = true;
  2668. // NEW_ROUND_LOADED = true;
  2669. COMPASS = null;
  2670. locHistory = [];
  2671. one_reset = false;
  2672. setHidden(false);
  2673. if (!origin) {
  2674. CURRENT_ROUND_DATA = data;
  2675. }
  2676. modularget(data);
  2677. }
  2678. }
  2679. }
  2680. else {
  2681. if (!cn_tips)
  2682. {
  2683. mainMenuBtn.style.visibility = "";
  2684. }
  2685. else
  2686. {
  2687. mainMenuBtn.style.visibility = "hidden";
  2688. AdjustBtnPos("14em", "0em");
  2689. }
  2690. modularget(data);
  2691. }
  2692.  
  2693. }).catch((error) => {
  2694. console.log(error);
  2695. });
  2696. }
  2697.  
  2698. function handleMinimapCallback()
  2699. {
  2700. let trueCond = true;
  2701. let timeoutTime = 250;
  2702. if (isBattleRoyale) {
  2703. if (isDuel)
  2704. {
  2705. if (document.querySelector(".overlay_overlay__AR02x"))
  2706. {
  2707. trueCond = false;
  2708. }
  2709. else
  2710. {
  2711. trueCond = true;
  2712. }
  2713. }
  2714. else
  2715. {
  2716. if (document.querySelector(".popup__content"))
  2717. {
  2718. trueCond = false;
  2719. }
  2720. else
  2721. {
  2722. trueCond = true;
  2723. }
  2724. }
  2725. timeoutTime = 2500;
  2726. }
  2727.  
  2728. if (trueCond)
  2729. {
  2730. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2731. let cur = MinimapBtn.current;
  2732. // console.log(cur)
  2733. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  2734. if (cur == mapDiv.id)
  2735. {
  2736. setTimeout(function () {mapDiv.click();}, 500);
  2737. setTimeout(function () {mapDiv.click();}, 1000);
  2738. setTimeout(function () {mapDiv.click();}, 3000);
  2739. }
  2740. }
  2741. }
  2742. else
  2743. {
  2744. setTimeout(handleMinimapCallback, timeoutTime);
  2745. }
  2746. }
  2747.  
  2748. /**
  2749. * Hide unnecessary buttons for non-Google coverages
  2750. */
  2751.  
  2752. function handleButtons() {
  2753. let CHECKPOINT = document.querySelector("button[data-qa='set-checkpoint']");
  2754. let ZOOM_IN = document.querySelector("button[data-qa='pano-zoom-in']");
  2755. let ZOOM_OUT = document.querySelector("button[data-qa='pano-zoom-out']");
  2756. let UNDO_MOVE = document.querySelector("button[data-qa='undo-move']");
  2757. let DEFAULT_COMPASS = document.querySelector(".compass");
  2758. let NEW_COMPASS = document.querySelector(".panorama-compass_compassContainer__MEnh0");
  2759. let RETURN_TO_START = document.querySelector("button[data-qa='return-to-start']");
  2760.  
  2761. let C1 = (CHECKPOINT !== null);
  2762. let C2 = (ZOOM_IN !== null);
  2763. let C3 = (ZOOM_OUT !== null);
  2764. let C4 = (UNDO_MOVE !== null);
  2765. let C5 = (DEFAULT_COMPASS !== null);
  2766. let C6 = (NEW_COMPASS !== null);
  2767. let C7 = (RETURN_TO_START !== null);
  2768.  
  2769. let waitCond = C5 || C6;
  2770. let cpCond = true;
  2771. let comCond = true;
  2772. if (!NM)
  2773. {
  2774. cpCond = C1 && C4 && C7;
  2775. }
  2776. if (!NZ)
  2777. {
  2778. comCond = C2 && C3;
  2779. }
  2780.  
  2781. function moduleButtons(cond)
  2782. {
  2783.  
  2784. if (!NM)
  2785. {
  2786. CHECKPOINT.style.visibility = cond;
  2787. UNDO_MOVE.style.visibility = cond;
  2788. }
  2789. if (!NZ)
  2790. {
  2791. ZOOM_IN.style.visibility = cond;
  2792. ZOOM_OUT.style.visibility = cond;
  2793. }
  2794. if (C5)
  2795. {
  2796. DEFAULT_COMPASS.style.visibility = cond;
  2797. }
  2798. if (C6)
  2799. {
  2800. NEW_COMPASS.style.visibility = cond;
  2801. }
  2802. }
  2803.  
  2804. if (waitCond && cpCond && comCond)
  2805. {
  2806. console.log("Handle Buttons");
  2807. if (nextPlayer === "Google") {
  2808. moduleButtons("");
  2809. }
  2810. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Bing Satellite")
  2811. {
  2812. moduleButtons("hidden");
  2813. }
  2814. else if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Mapillary" || nextPlayer === "Bing Streetside")
  2815. {
  2816. moduleButtons("hidden");
  2817. if (nextPlayer === "Yandex" || nextPlayer === "Kakao")
  2818. {
  2819. if (C5)
  2820. {
  2821. DEFAULT_COMPASS.style.visibility = "";
  2822. }
  2823. if (C6)
  2824. {
  2825. NEW_COMPASS.style.visibility = "";
  2826. }
  2827. }
  2828. if (!NM)
  2829. {
  2830. UNDO_MOVE.style.visibility = "";
  2831. handleUndo();
  2832. }
  2833. }
  2834. if (!NM)
  2835. {
  2836. handleReturnToStart();
  2837. }
  2838. }
  2839. else
  2840. {
  2841. setTimeout(handleButtons, 250);
  2842. }
  2843. }
  2844.  
  2845. /**
  2846. * Check which player to use for the next location
  2847. */
  2848.  
  2849. function locationCheck(data) {
  2850. // console.log(data);
  2851. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2852. let round;
  2853.  
  2854.  
  2855.  
  2856. if (isBattleRoyale) {
  2857. if (isDuel || isBullseye || isLiveChallenge)
  2858. {
  2859. round = data.rounds[data.currentRoundNumber - 1].panorama;
  2860. }
  2861. else
  2862. {
  2863. round = data.rounds[data.currentRoundNumber - 1];
  2864. }
  2865. }
  2866. else {
  2867. round = data.rounds[data.round - 1];
  2868. }
  2869. global_lat = round.lat;
  2870. global_lng = round.lng;
  2871. global_panoID = round.panoId;
  2872. global_heading = round.heading;
  2873. global_pitch = round.pitch;
  2874.  
  2875. nextPlayer = "Google";
  2876.  
  2877. // if (ms_sat_map)
  2878. // {
  2879. // nextPlayer = "Bing Satellite";
  2880. // }
  2881.  
  2882. if (global_panoID) {
  2883. let locInfo;
  2884. if (isBullseye || isLiveChallenge)
  2885. {
  2886. locInfo = global_panoID;
  2887. }
  2888. else
  2889. {
  2890. locInfo = hex2a(global_panoID);
  2891. }
  2892. // console.log(locInfo)
  2893. if (locInfo.substring(0, 3) == "YTB")
  2894. {
  2895. nextPlayer = "Youtube";
  2896. let lengths = [3, 11, 4, 4];
  2897. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2898. let fullID = locInfo.substring(3).split('START');
  2899. yId = toPiece[1];
  2900. yTime = Number(toPiece[2]);
  2901. yEnd = Number(toPiece[3]);
  2902. }
  2903. else
  2904. {
  2905. let mapType = locInfo.substring(0, 5);
  2906.  
  2907. // panoId unchanged
  2908.  
  2909. if (mapType === "YDMAP" ) {
  2910. nextPlayer = "Yandex";
  2911. }
  2912. else if (mapType === "KKMAP" ) {
  2913. nextPlayer = "Kakao";
  2914. }
  2915.  
  2916. // New panoId formats
  2917.  
  2918. else if (mapType === "BAIDU" ) {
  2919. nextPlayer = "Baidu";
  2920. let lengths = [5, 7, 7, 3];
  2921. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2922. let panoId1 = base62.decode(toPiece[1]).toString().substring(1);
  2923. let panoId2 = base62.decode(toPiece[2]).toString().substring(1);
  2924. global_BDID = panoId1 + panoId2 + toPiece[3]
  2925. }
  2926. else if (mapType === "MAPIL")
  2927. {
  2928. nextPlayer = "Mapillary";
  2929. mmKey = locInfo.substring(5).replace(/\D/g,'');
  2930. }
  2931. else if (mapType === "IMAGE")
  2932. {
  2933. nextPlayer = "Image";
  2934. let lengths = [5, 4, 4, 7, 2];
  2935. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2936. iId = "https://i.ibb.co/" + toPiece[3] + "/" + toPiece[1] + "." + toPiece[2].replace(/[^0-9a-z]/gi, '')
  2937. }
  2938. else if (mapType === "BINGM" ) {
  2939. nextPlayer = "Bing Streetside";
  2940. }
  2941. else if (mapType === "SATEL" ) {
  2942. nextPlayer = "Bing Satellite";
  2943. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  2944. }
  2945.  
  2946. // legacy panoId formats support
  2947.  
  2948. else if (mapType === "BDMAP") {
  2949. nextPlayer = "Baidu";
  2950. let coord = locInfo.substring(5);
  2951.  
  2952. if(coord.includes('BDAh'))
  2953. {
  2954. global_BDID = coord.split('BDAh')[0].replace("panoId","");
  2955. let tem = coord.split('BDAh')[1];
  2956. global_BDAh = tem.split('BDBh')[0];
  2957. global_BDBh = tem.split('BDBh')[1];
  2958. }
  2959. else
  2960. {
  2961. global_BDID = coord.replace("panoId","");
  2962. }
  2963. }
  2964. else if (mapType === "MLMAP") {
  2965. nextPlayer = "Mapillary";
  2966. mmKey = locInfo.substring(5);
  2967. }
  2968. else
  2969. {
  2970. nextPlayer = "Google";
  2971. // GooglePlayer.setPano(locInfo);
  2972. }
  2973. }
  2974. }
  2975. else
  2976. {
  2977. if (Kakao_map)
  2978. {
  2979. nextPlayer = "Kakao";
  2980. }
  2981. else if (yandex_map)
  2982. {
  2983. nextPlayer = "Yandex";
  2984. }
  2985. else
  2986. {
  2987. nextPlayer = "Google";
  2988. }
  2989. }
  2990.  
  2991. // if ( krCoordinates[0] > global_lat && krCoordinates[2] < global_lat && krCoordinates[1] < global_lng && krCoordinates[3] > global_lng)
  2992. // {
  2993. // nextSecondaryPlayer = "Kakao";
  2994. // }
  2995. // else if (nextPlayer = "Mapillary")
  2996. // {
  2997. // nextSecondaryPlayer = "Google";
  2998. // }
  2999. // else
  3000. // {
  3001. // nextSecondaryPlayer = "Mapillary";
  3002. // }
  3003.  
  3004. // Disable buttons if NM, NMPZ
  3005.  
  3006. if(!isBattleRoyale)
  3007. {
  3008. NM = data.forbidMoving;
  3009. NP = data.forbidRotating;
  3010. NZ = data.forbidZooming;
  3011. }
  3012. else
  3013. {
  3014. // console.log(data)
  3015. if (isBullseye || isLiveChallenge)
  3016. {
  3017. NM = data.options.movementOptions.forbidMoving;
  3018. NP = data.options.movementOptions.forbidRotating;
  3019. NZ = data.options.movementOptions.forbidZooming;
  3020. }
  3021. else
  3022. {
  3023. NM = data.movementOptions.forbidMoving;
  3024. NP = data.movementOptions.forbidRotating;
  3025. NZ = data.movementOptions.forbidZooming;
  3026. }
  3027. }
  3028. if (NM || NP || NZ)
  3029. {
  3030.  
  3031. setDisable("NMPZ");
  3032. }
  3033. else
  3034. {
  3035. setDisable(nextPlayer);
  3036. }
  3037.  
  3038. if (nextPlayer == "Google")
  3039. {
  3040. switchCovergeButton.innerHTML = "Switch to Mapillary";
  3041. }
  3042. else
  3043. {
  3044. switchCovergeButton.innerHTML = "Switch to Google";
  3045. }
  3046. nextPlayer_save = nextPlayer;
  3047. console.log(nextPlayer_save);
  3048.  
  3049. // console.log("??")
  3050. // console.log(sessionStorage.getItem('Satellite') == "T")
  3051. if (ms_sat_map || (sessionStorage.getItem('Satellite') == "T" && nextPlayer !== "Baidu" && nextPlayer !== "Bing Streetside" && !rtded))
  3052. {
  3053. nextPlayer = "Bing Satellite";
  3054. }
  3055.  
  3056. if (nextPlayer == "Bing Satellite")
  3057. {
  3058. let di3 = formatDist();
  3059. satelliteSwitchButton.innerHTML = `Satellite (${di3})`;
  3060. }
  3061. else
  3062. {
  3063. satelliteSwitchButton.innerHTML = "Streeview mode";
  3064. }
  3065. console.log(nextPlayer);
  3066.  
  3067.  
  3068. injectCanvas(false);
  3069. }
  3070.  
  3071.  
  3072. /**
  3073. * setID for canvas
  3074. */
  3075.  
  3076. function initializeCanvas() {
  3077. let GAME_CANVAS = "";
  3078. let DUEL_CANVAS = "";
  3079. //console.log("Is duels");
  3080. //console.log(duels);
  3081.  
  3082. if (isBattleRoyale) {
  3083. if (isDuel) {
  3084. GAME_CANVAS = document.querySelector(".game-panorama_panorama__rdhFg");
  3085. DUEL_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__PNKve");
  3086. }
  3087. else if (isBullseye) {
  3088. GAME_CANVAS = document.querySelector(".game-panorama_panorama__ncMwh");
  3089. DUEL_CANVAS = "dummy";
  3090. }
  3091. else if (isLiveChallenge)
  3092. {
  3093. GAME_CANVAS = document.querySelector(".game-panorama_panorama__6RmkO");
  3094. DUEL_CANVAS = "dummy";
  3095. }
  3096. else
  3097. {
  3098. GAME_CANVAS = document.querySelector(".br-game-layout__panorama-wrapper");
  3099. DUEL_CANVAS = "dummy";
  3100. }
  3101. }
  3102. else {
  3103. GAME_CANVAS = document.querySelector(".game-layout__canvas");
  3104. DUEL_CANVAS = "dummy";
  3105. }
  3106. if (GAME_CANVAS && DUEL_CANVAS)
  3107. {
  3108. // console.log("Canvas injected");
  3109. GAME_CANVAS.id = "player";
  3110.  
  3111. if (isDuel) {
  3112. DUEL_CANVAS.id = "default_player";
  3113. }
  3114. partialCreateMapillary = (typeof mapillary !== typeof undefined)
  3115. partialCreateYandex = (typeof ymaps !== typeof undefined)
  3116. partialCreateKakao = (typeof kakao !== typeof undefined)
  3117. partialCreateMS = (typeof Microsoft !== typeof undefined);
  3118. loadPlayers();
  3119. injectMapillaryPlayer();
  3120. }
  3121. else
  3122. {
  3123. setTimeout(initializeCanvas, 250);
  3124. }
  3125.  
  3126. }
  3127.  
  3128. /**
  3129. * Hide or show players based on where the next location is
  3130. */
  3131.  
  3132. function injectCanvas(cond) {
  3133. if (isDuel)
  3134. {
  3135. canvasSwitch(cond);
  3136. }
  3137. else
  3138. {
  3139. // console.log("BING??")
  3140. // console.log(BR_LOAD_MS)
  3141.  
  3142. Google();
  3143. Baidu();
  3144. if (BR_LOAD_KAKAO)
  3145. {
  3146. Kakao();
  3147. }
  3148. if (BR_LOAD_YANDEX)
  3149. {
  3150. Yandex();
  3151. }
  3152. if (BR_LOAD_MS)
  3153. {
  3154. // console.log("Yes")
  3155. Bing(cond);
  3156. }
  3157. Mapillary();
  3158. }
  3159. ZoomControls();
  3160. }
  3161.  
  3162. // for duels (class ID change)
  3163.  
  3164. function canvasSwitch(cond)
  3165. {
  3166.  
  3167. console.log("canvas switch")
  3168. // let cond = true;
  3169. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3170. let GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panorama__rdhFg");
  3171. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  3172. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  3173. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  3174. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  3175. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  3176. // 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])
  3177.  
  3178. 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))
  3179. {
  3180. document.getElementById("default_player").style.position = "absolute";
  3181. document.getElementById("default_player").className = "inactive";
  3182. BAIDU_MAPS_CANVAS.style.position = "absolute";
  3183. BAIDU_MAPS_CANVAS.className = "inactive";
  3184. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  3185. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  3186. MAPILLARY_MAPS_CANVAS.className = "inactive";
  3187. if (BR_LOAD_KAKAO)
  3188. {
  3189. KAKAO_MAPS_CANVAS.style.position = "absolute";
  3190. KAKAO_MAPS_CANVAS.className = "inactive";
  3191. }
  3192. if (BR_LOAD_YANDEX)
  3193. {
  3194. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  3195. YANDEX_MAPS_CANVAS.style.position = "absolute";
  3196. }
  3197. if (BR_LOAD_MS)
  3198. {
  3199. BING_MAPS_CANVAS.style.position = "absolute";
  3200. BING_MAPS_CANVAS.className = "inactive";
  3201. }
  3202.  
  3203. if (!cond)
  3204. {
  3205. teleportBtn.google = false;
  3206. switchCovergeButton.useGoogle = false;
  3207. }
  3208.  
  3209. if (nextPlayer === "Google") {
  3210. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  3211. teleportBtn.google = true;
  3212. switchCovergeButton.useGoogle = true;
  3213. console.log("Google Duel Canvas loaded");
  3214. }
  3215. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image")
  3216. {
  3217. BAIDU_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3218. console.log("Container Duel Canvas loaded");
  3219. }
  3220. else if (nextPlayer === "Kakao")
  3221. {
  3222. if (BR_LOAD_KAKAO)
  3223. {
  3224. KAKAO_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3225. }
  3226. console.log("Kakao Duel Canvas loaded");
  3227. }
  3228. else if (nextPlayer === "Yandex")
  3229. {
  3230. if (BR_LOAD_YANDEX)
  3231. {
  3232. YANDEX_MAPS_CANVAS.style.visibility = "";
  3233. }
  3234. console.log("Yandex Duel Canvas loaded");
  3235. }
  3236. else if (nextPlayer === "Mapillary")
  3237. {
  3238. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  3239. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3240. // MapillaryPlayer.resize();
  3241. console.log("Mapillary Duel Canvas loaded");
  3242. }
  3243. else if (nextPlayer === "Bing Streetside" || nextPlayer === "Bing Satellite")
  3244. {
  3245. if (BR_LOAD_MS)
  3246. {
  3247. BING_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3248. }
  3249. console.log("MS Duel Canvas loaded");
  3250. }
  3251. }
  3252. else
  3253. {
  3254. setTimeout(canvasSwitch(cond), 1000);
  3255. }
  3256. }
  3257.  
  3258. // for Battle Royale and classic (change visibility)
  3259.  
  3260. function Google() {
  3261. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3262. let GOOGLE_MAPS_CANVAS = ""
  3263. if (isBattleRoyale) {
  3264. if (isBullseye)
  3265. {
  3266. GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__r_5ea");
  3267. }
  3268. else if (isLiveChallenge)
  3269. {
  3270. GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__gp8og");
  3271. }
  3272. else
  3273. {
  3274. GOOGLE_MAPS_CANVAS = document.querySelector(".br-game-layout__panorama-canvas");
  3275. }
  3276. }
  3277. else {
  3278. GOOGLE_MAPS_CANVAS = document.querySelector(".game-layout__panorama-canvas");
  3279. }
  3280. if (GOOGLE_MAPS_CANVAS !== null)
  3281. {
  3282. if (nextPlayer === "Google") {
  3283. GOOGLE_MAPS_CANVAS.style.visibility = "";
  3284. teleportBtn.google = true;
  3285. switchCovergeButton.useGoogle = true;
  3286. }
  3287. else {
  3288. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  3289. teleportBtn.google = false;
  3290. }
  3291. }
  3292. else
  3293. {
  3294. setTimeout(Google, 250);
  3295. }
  3296. }
  3297.  
  3298. function Baidu() {
  3299. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  3300. // console.log("Baidu canvas");
  3301. if (BAIDU_MAPS_CANVAS !== null)
  3302. {
  3303. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3304. BAIDU_MAPS_CANVAS.style.position = "absolute";
  3305. if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  3306. BAIDU_MAPS_CANVAS.style.visibility = "";
  3307. switchCovergeButton.useGoogle = false;
  3308. console.log("Container Canvas loaded");
  3309. }
  3310. else {
  3311. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  3312. // console.log("Container Canvas hidden");
  3313. }
  3314. }
  3315. else
  3316. {
  3317. setTimeout(Baidu, 250);
  3318. }
  3319.  
  3320. }
  3321.  
  3322. function Kakao() {
  3323. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  3324. // console.log("Kakao canvas");
  3325. if (KAKAO_MAPS_CANVAS != null)
  3326. {
  3327. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3328. KAKAO_MAPS_CANVAS.style.position = "absolute";
  3329. if (nextPlayer === "Kakao") {
  3330. KAKAO_MAPS_CANVAS.style.visibility = "";
  3331. switchCovergeButton.useGoogle = false;
  3332. console.log("Kakao Canvas loaded");
  3333. }
  3334. else {
  3335. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  3336. // console.log("Kakao Canvas hidden");
  3337. }
  3338. }
  3339. else
  3340. {
  3341. setTimeout(Kakao, 250);
  3342. }
  3343.  
  3344. }
  3345.  
  3346. function Yandex() {
  3347. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  3348. if (YANDEX_MAPS_CANVAS != null)
  3349. {
  3350. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3351. if (isBullseye)
  3352. {
  3353. let div = document.getElementById("player");
  3354. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__ncMwh");
  3355. div.prepend(YANDEX_MAPS_CANVAS);
  3356. }
  3357. if (isLiveChallenge)
  3358. {
  3359. let div = document.getElementById("player");
  3360. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__6RmkO");
  3361. div.prepend(YANDEX_MAPS_CANVAS);
  3362. }
  3363. // console.log("Yandex canvas");
  3364. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  3365. // console.log("Yandex canvas");
  3366. /* console.log(YANDEX_MAPS_CANVAS); */
  3367. if (nextPlayer === "Yandex") {
  3368. YANDEX_MAPS_CANVAS.style.visibility = "";
  3369. switchCovergeButton.useGoogle = false;
  3370. console.log("Yandex Canvas loaded");
  3371. }
  3372. else {
  3373. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  3374. console.log("Yandex Canvas hidden");
  3375. }
  3376. }
  3377. else
  3378. {
  3379. setTimeout(Yandex, 250);
  3380. }
  3381.  
  3382. }
  3383.  
  3384. function Mapillary()
  3385. {
  3386. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  3387. if (MAPILLARY_MAPS_CANVAS != null)
  3388. {
  3389. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3390. // console.log("Mapillary canvas");
  3391. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  3392. if (nextPlayer === "Mapillary") {
  3393. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  3394. switchCovergeButton.useGoogle = false;
  3395. console.log("Mapillary Canvas loaded");
  3396.  
  3397. }
  3398. else {
  3399. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  3400. // console.log("Mapillary Canvas hidden");
  3401. }
  3402. }
  3403. else
  3404. {
  3405. setTimeout(Mapillary, 250);
  3406. }
  3407.  
  3408. }
  3409.  
  3410. function Bing(cond) {
  3411. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  3412. // console.log("stuck")
  3413. if (BING_MAPS_CANVAS != null)
  3414. {
  3415. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3416. // console.log("Mapillary canvas");
  3417. BING_MAPS_CANVAS.style.position = "absolute";
  3418. if (nextPlayer === "Bing Satellite" || nextPlayer === "Bing Streetside") {
  3419. BING_MAPS_CANVAS.style.visibility = "";
  3420. if (!cond)
  3421. {
  3422. switchCovergeButton.useGoogle = false;
  3423. }
  3424. console.log("Bing Canvas loaded");
  3425. }
  3426. else {
  3427. BING_MAPS_CANVAS.style.visibility = "hidden";
  3428. // console.log("Bing Canvas hidden");
  3429. }
  3430. }
  3431. else
  3432. {
  3433. setTimeout(Bing(cond), 500)
  3434. }
  3435. }
  3436.  
  3437.  
  3438. /**
  3439. * Adjust button placement
  3440. */
  3441.  
  3442. function ZoomControls() {
  3443. let style = `
  3444. .ymaps-2-1-79-panorama-gotoymaps {display: none !important;}
  3445. .ymaps-2-1-79-panorama-control__zoom {top: 2rem !important; left: 2rem !important; z-Index: 0}
  3446. .mapillary-bearing-indicator-container {top: 2rem !important; left: 2rem !important;}
  3447. .mapillary-zoom-container {top: 6rem !important; left: 2.20rem !important;}
  3448. .NavBar_MapTypeButtonContainerWrapper {visibility: hidden !important;}
  3449. .bm_LocateMeControl {visibility: hidden !important;}
  3450. .NavBar_Container {top: -6rem !important; left: 2rem !important;}
  3451. .streetsideToolPanel {top: 4rem !important; left: 2rem !important;}
  3452. .NavBarButton_Container {visibility: hidden !important;}
  3453. `;
  3454.  
  3455. // let nav = document.querySelector('.NavBar_MapTypeButtonContainerWrapper');
  3456. // let locate = document.getElementById("LocateMeButton");
  3457. // let navAll = document.getElementById("MicrosoftNav");
  3458. // if (nav)
  3459. // {
  3460. // nav.style.visibility = "hidden";
  3461. // }
  3462. // if (locate)
  3463. // {
  3464. // locate.style.visibility = "hidden";
  3465. // }
  3466. // if (navAll)
  3467. // {
  3468. // navAll.style.top = "15em"
  3469. // }
  3470.  
  3471. let style_element = document.createElement("style");
  3472. style_element.innerHTML = style;
  3473. document.body.appendChild(style_element);
  3474. // document.getElementById("mapillary-bearing-indicator-container").style.top = "20em"
  3475. }
  3476.  
  3477. /**
  3478. * Updates the compass to match Yandex Panorama facing
  3479. */
  3480. function updateCompass() {
  3481. if (!COMPASS) {
  3482. let compass = document.querySelector("img.compass__indicator");
  3483. if (compass != null) {
  3484. COMPASS = compass;
  3485. let direction = YandexPlayer.getDirection()[0] * -1;
  3486. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  3487. }
  3488. }
  3489. else {
  3490. let direction = YandexPlayer.getDirection()[0] * -1;
  3491. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  3492. }
  3493. }
  3494.  
  3495. /**
  3496. * Open next location in streetview player given next player and next coordinate
  3497. */
  3498.  
  3499.  
  3500.  
  3501. function goToLocation(cond) {
  3502. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3503. console.log("Going to location");
  3504. console.log(nextPlayer);
  3505. if (nextPlayer === "Yandex") {
  3506. let options = {};
  3507. YandexPlayer.moveTo([global_lat, global_lng], options);
  3508. YandexPlayer.setDirection([0, 16]);
  3509. YandexPlayer.setSpan([10, 67]);
  3510. }
  3511. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  3512. if (document.getElementById("i_container") !== null)
  3513. {
  3514. let iframe = document.getElementById("i_container");
  3515. if (nextPlayer === "Baidu")
  3516. {
  3517. if (!isFirefox)
  3518. {
  3519. iframe.style.top = '-60px';
  3520. iframe.style.height = (window.innerHeight + 200) + 'px';
  3521. }
  3522. else
  3523. {
  3524. iframe.style.top = '-60px';
  3525. iframe.style.height = (window.innerHeight + 219) + 'px';
  3526. }
  3527.  
  3528. if (!isFirefox)
  3529. {
  3530. iframe.style.right = '-55px';
  3531. iframe.style.width = (window.innerWidth + 55) + 'px';
  3532. }
  3533. else
  3534. {
  3535. iframe.style.right = '-15px';
  3536. iframe.style.width = (window.innerWidth + 15) + 'px';
  3537. }
  3538. let urlStr2 = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  3539. 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;
  3540. // console.log(urlStr)
  3541. if (global_BDAh != null)
  3542. {
  3543. iframe.src = urlStr;
  3544. }
  3545. else
  3546. {
  3547. iframe.src = urlStr2;
  3548. }
  3549. iframe.style.visibility = "";
  3550. }
  3551. else if (nextPlayer === "Youtube")
  3552. {
  3553. document.getElementById("Youtube Button").style.visibility = "";
  3554. document.getElementById("Youtube Button").innerHTML = "Play video";
  3555. iframe.allow = "autoplay";
  3556. iframe.style.visibility = "hidden";
  3557. iframe.style.top = '-60px';
  3558. iframe.style.height = (window.innerHeight + 235) + 'px';
  3559. mainMenuBtn.innerHTML = "<font size=2>Unity<br><font size=1>v5.2.7</font>";
  3560. mainMenuBtn.style.width = "3em"
  3561. mainMenuBtn.style.backgroundPosition = "";
  3562. mainMenuBtn.backgroundColor = ""
  3563. }
  3564. else if (nextPlayer === "Image")
  3565. {
  3566. iframe.style.top = '0px';
  3567. iframe.style.height = (window.innerHeight) + 'px';
  3568. iframe.style.visibility = "";
  3569. iframe.src = iId;
  3570. }
  3571. }
  3572. else
  3573. {
  3574. setTimeout(goToLocation(true), 250);
  3575. }
  3576. // let a = new BMap.Point(global_lng, global_lat);
  3577. // BaiduPlayer.setPov({ heading: -40, pitch: 6 });
  3578. // BaiduPlayer.setPosition(a);
  3579. }
  3580. else if (nextPlayer === "Kakao") {
  3581. var roadviewClient = new kakao.maps.RoadviewClient();
  3582. var position = new kakao.maps.LatLng(global_lat, global_lng);
  3583. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3584. KakaoPlayer.setPanoId(panoId, position);
  3585. KakaoPlayer.setViewpoint({ pan: global_heading, tilt: global_pitch, zoom: -3 })
  3586. });
  3587. }
  3588. else if (nextPlayer === "Mapillary") {
  3589. MapillaryPlayer.resize()
  3590. MapillaryPlayer.moveTo(mmKey).then(
  3591. image => { //console.log(image);
  3592. },
  3593. error => { console.log(error); });
  3594. }
  3595. else if (nextPlayer === "Google") {
  3596. handleMapillary({lat: global_lat, lng: global_lng}, {meters: 500, limit: 500});
  3597. }
  3598. else if (nextPlayer === "Bing Streetside") {
  3599. let mTId = MSStreetPlayer.getMapTypeId();
  3600. if (mTId !== Microsoft.Maps.MapTypeId.streetside && mTId !== Microsoft.Maps.MapTypeId.road)
  3601. {
  3602. console.log("Reset Bing map type to Streetside")
  3603. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  3604. }
  3605. MSStreetPlayer.setOptions({disableStreetside: false});
  3606. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.streetside,
  3607. zoom: 18,
  3608. streetsideOptions: {
  3609. overviewMapMode: Microsoft.Maps.OverviewMapMode.hidden,
  3610. showCurrentAddress: false,
  3611. showProblemReporting: false,
  3612. showExitButton: false,
  3613. },
  3614. center: new Microsoft.Maps.Location(global_lat, global_lng),
  3615. heading: 90,
  3616. pitch: -30});
  3617. }
  3618. else if (nextPlayer === "Bing Satellite") {
  3619. // console.log("Bing Satellite Player")
  3620. let mTId = MSStreetPlayer.getMapTypeId();
  3621. if (mTId !== Microsoft.Maps.MapTypeId.aerial && mTId !== Microsoft.Maps.MapTypeId.road)
  3622. {
  3623. console.log("Reset Bing map type to Satellite")
  3624. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  3625. }
  3626. // MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  3627. let ctr = new Microsoft.Maps.Location(global_lat, global_lng)
  3628. let loc_centre = {lat: global_lat, lng: global_lng};
  3629. for (var i = MSStreetPlayer.entities.getLength() - 1; i >= 0; i--) {
  3630. var pushpin = MSStreetPlayer.entities.get(i);
  3631. if (pushpin instanceof Microsoft.Maps.Pushpin) {
  3632. MSStreetPlayer.entities.removeAt(i);
  3633. }
  3634. }
  3635. // console.log("Satellite radius: " + (ms_radius / 1000).toString() + "km");
  3636. let latlngBounds = getBBox2(loc_centre, ms_radius);
  3637. // console.log(latlngBounds)
  3638. let bounds = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(latlngBounds[0], latlngBounds[1]), new Microsoft.Maps.Location(latlngBounds[2], latlngBounds[3]));
  3639. MSStreetPlayer.setOptions({maxBounds: bounds})
  3640. // console.log(bounds)
  3641. // console.log(Microsoft.Maps.LabelOverlay.hidden)
  3642. if (ms_birdseye || ms_random)
  3643. {
  3644. let dg = 0;
  3645. if (ms_random)
  3646. {
  3647. dg = (Math.floor(Math.random() * 4)) * 90
  3648. }
  3649. Microsoft.Maps.getIsBirdseyeAvailable(ctr, dg, onResponse);
  3650. function onResponse(isAvailable) {
  3651. console.log("Birds-eye");
  3652. console.log(isAvailable);
  3653. MSStreetPlayer.setView({mapTypeId: isAvailable ? Microsoft.Maps.MapTypeId.birdseye : Microsoft.Maps.MapTypeId.aerial,
  3654. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  3655. center: ctr,
  3656. zoom: 15,
  3657. })
  3658. FixLink();
  3659. }
  3660. }
  3661. else
  3662. {
  3663. MSStreetPlayer.setOptions({disableStreetside: true});
  3664. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.aerial,
  3665. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  3666. center: ctr,
  3667. zoom: 15,
  3668. })
  3669. }
  3670.  
  3671. var pin = new Microsoft.Maps.Pushpin(ctr, {});
  3672.  
  3673. //Add the pushpin to the map
  3674. MSStreetPlayer.entities.push(pin);
  3675.  
  3676.  
  3677.  
  3678.  
  3679. FixLink();
  3680. // hideNav();
  3681. }
  3682. if (cond)
  3683. {
  3684. switchCovergeButton.lat = global_lat;
  3685. switchCovergeButton.lng = global_lng;
  3686. }
  3687. }
  3688.  
  3689. function FixLink()
  3690. {
  3691. let ele = document.querySelector('[title="Microsoft Bing"]');
  3692. // console.log("?")
  3693. if (ele)
  3694. {
  3695. // console.log("!")
  3696. ele.href = "#";
  3697. }
  3698. else
  3699. {
  3700. setTimeout(FixLink, 250);
  3701. }
  3702. }
  3703.  
  3704. /**
  3705. * Handle undo using the location history of the current round
  3706. */
  3707.  
  3708. function goToUndoMove(data) {
  3709. /* console.log(global_lat);
  3710. console.log(global_lng); */
  3711. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3712. let options = {};
  3713. let prevStep = null;
  3714. if (locHistory.length === 1) {
  3715. prevStep = locHistory[0];
  3716. }
  3717. else {
  3718. prevStep = locHistory.pop();
  3719. }
  3720. // console.log(prevStep);
  3721. // console.log(locHistory)
  3722. if (nextPlayer === "Yandex") {
  3723. defaultPanoIdChange = false;
  3724. YandexPlayer.moveTo([prevStep[0], prevStep[1]], options);
  3725. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  3726. YandexPlayer.setSpan([10, 67]);
  3727. switchCovergeButton.lat = prevStep[0];
  3728. switchCovergeButton.lng = prevStep[1];
  3729. }
  3730. else if (nextPlayer === "Kakao") {
  3731. let btn = document.querySelector("button[data-qa='undo-move']");
  3732. btn.disabled = false;
  3733. btn.classList.remove('styles_disabled__2YdHD');
  3734. defaultPanoIdChange = false;
  3735. let position = new kakao.maps.LatLng(prevStep[0], prevStep[1]);
  3736. KakaoPlayer.setPanoId(prevStep[2], position);
  3737. switchCovergeButton.lat = prevStep[0];
  3738. switchCovergeButton.lng = prevStep[1];
  3739. switchCovergeButton.useGoogle = false;
  3740. teleportBtn.google = false;
  3741. // console.log("Undo 1 step");
  3742. // console.log(locHistory);
  3743. }
  3744. else if (nextPlayer === "Mapillary" ) {
  3745. // console.log(prevStep[1]);
  3746.  
  3747. MapillaryPlayer.moveTo(prevStep[2]).then(
  3748. image => {
  3749. //console.log(image);
  3750. switchCovergeButton.lat = prevStep[1];
  3751. switchCovergeButton.lng = prevStep[0];
  3752. },
  3753. error => { console.log(error); });
  3754. }
  3755. else if (nextPlayer === "Bing Streetside") {
  3756. defaultPanoIdChange = false;
  3757. // console.log(locHistory);
  3758. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(prevStep[0], prevStep[1]),});
  3759. switchCovergeButton.lat = prevStep[0];
  3760. switchCovergeButton.lng = prevStep[1];
  3761. switchCovergeButton.heading = prevStep[2];
  3762. }
  3763.  
  3764. }
  3765.  
  3766. function handleTeleport()
  3767. {
  3768. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3769. if (teleportBtn)
  3770. {
  3771. teleportBtn.addEventListener("click", () => {
  3772. if (!teleportBtn.google)
  3773. {
  3774. // console.log("non-Google Teleport");
  3775. let prevStep = null;
  3776. if (locHistory.length === 1) {
  3777. prevStep = locHistory[0];
  3778. }
  3779. else {
  3780. prevStep = locHistory[locHistory.length - 1];
  3781. }
  3782. // console.log(locHistory);
  3783. let options = {};
  3784. let place, position, pID;
  3785. if (nextPlayer === "Yandex") {
  3786. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3787. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  3788. YandexPlayer.moveTo([place.lat, place.lng], options);
  3789. YandexPlayer.setSpan([10, 67]);
  3790. switchCovergeButton.lat = place.lat;
  3791. switchCovergeButton.lng = place.lng;
  3792. }
  3793. else if (nextPlayer === "Kakao") {
  3794. var roadviewClient = new kakao.maps.RoadviewClient();
  3795. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[3]), teleportBtn.distance * 0.001);
  3796. position = new kakao.maps.LatLng(place.lat, place.lng);
  3797. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3798. KakaoPlayer.setPanoId(panoId, position);
  3799. });
  3800. switchCovergeButton.lat = place.lat;
  3801. switchCovergeButton.lng = place.lng;
  3802. }
  3803. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  3804. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3805. handleMapillary(place, {meters: 500, limit: 500});
  3806. switchCovergeButton.lat = place.lat;
  3807. switchCovergeButton.lng = place.lng;
  3808. // locHistory.push([place.lat, place.lng, prevStep[2], prevStep[3]]);
  3809. }
  3810. else if (nextPlayer === "Bing Streetside") {
  3811. // console.log("teleport")
  3812. // console.log(prevStep);
  3813. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3814. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(place.lat, place.lng), 1, 1);
  3815. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  3816. function onSuccess(panoramaInfo) {
  3817. // console.log("Coverage")
  3818. // console.log([panoramaInfo.la, panoramaInfo.lo])
  3819. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  3820. });
  3821. }
  3822. function onMissingCoverage() {
  3823. console.log("No Coverage")
  3824. }
  3825. }
  3826.  
  3827. if (teleportBtn.distance > 150)
  3828. {
  3829. teleportBtn.distance = 100;
  3830. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  3831. }
  3832. }
  3833. });
  3834. }
  3835. }
  3836.  
  3837. function SyncListener()
  3838. {
  3839. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3840. switchCovergeButton.addEventListener("click", () => {
  3841. if (switchCovergeButton.useGoogle == false) {
  3842. // switchCovergeButton.useGoogle = true;
  3843. console.log(nextPlayer)
  3844. if (nextPlayer === "Yandex") {
  3845. let options = {};
  3846. YandexPlayer.moveTo([switchCovergeButton.lat, switchCovergeButton.lng], options);
  3847. YandexPlayer.setDirection([switchCovergeButton.heading, 0]);
  3848.  
  3849. // nextPlayer = "Yandex";
  3850. }
  3851. else if (nextPlayer === "Kakao") {
  3852. let roadviewClient = new kakao.maps.RoadviewClient();
  3853. // console.log(switchCovergeButton.lat);
  3854. let position = new kakao.maps.LatLng(switchCovergeButton.lat, switchCovergeButton.lng);
  3855. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3856. KakaoPlayer.setPanoId(panoId, position);
  3857. });
  3858. KakaoPlayer.setViewpoint({
  3859. pan: switchCovergeButton.heading,
  3860. tilt: 0,
  3861. zoom: -3
  3862. });
  3863. // nextPlayer = "Kakao";
  3864. }
  3865. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  3866. // nextPlayer = "Kakao";
  3867. handleMapillary({lat: switchCovergeButton.lat, lng: switchCovergeButton.lng}, {meters: 100, limit: 100});
  3868. }
  3869. else if (nextPlayer === "Bing Streetside") {
  3870. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(switchCovergeButton.lat, switchCovergeButton.lng), 0.01, 0.01);
  3871. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  3872. function onSuccess(panoramaInfo) {
  3873. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  3874. heading: switchCovergeButton.heading
  3875. });
  3876. }
  3877. function onMissingCoverage() {
  3878. console.log("No Coverage")
  3879. }
  3880. }
  3881. }
  3882. });
  3883.  
  3884. }
  3885.  
  3886. /**
  3887. * Gets the seed data for the current game
  3888. *
  3889. * @returns Promise with seed data as object
  3890. */
  3891. function getSeed() {
  3892. // console.log("getSeed called");
  3893. return new Promise((resolve, reject) => {
  3894. let token = getToken();
  3895. let URL;
  3896. let cred = ""
  3897.  
  3898. const PATHNAME = window.location.pathname;
  3899.  
  3900. if (PATHNAME.startsWith("/game/")) {
  3901. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  3902. }
  3903. else if (PATHNAME.startsWith("/challenge/")) {
  3904. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  3905. }
  3906. else if (PATHNAME.startsWith("/battle-royale/")) {
  3907. URL = `https://game-server.geoguessr.com/api/battle-royale/${token}`;
  3908. }
  3909. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  3910. URL = `https://game-server.geoguessr.com/api/duels/${token}`;
  3911. }
  3912. else if (PATHNAME.startsWith("/bullseye/")) {
  3913. URL = `https://game-server.geoguessr.com/api/bullseye/${token}`;
  3914. }
  3915. else if (PATHNAME.startsWith("/live-challenge/")) {
  3916. URL = `https://game-server.geoguessr.com/api/live-challenge/${token}`;
  3917. }
  3918. if (isBattleRoyale) {
  3919. fetch(URL, {
  3920. // Include credentials to GET from the endpoint
  3921. credentials: 'include'
  3922. })
  3923. .then((response) => response.json())
  3924. .then((data) => {
  3925. resolve(data);
  3926. })
  3927. .catch((error) => {
  3928. reject(error);
  3929. });
  3930. }
  3931. else {
  3932. fetch(URL)
  3933. .then((response) => response.json())
  3934. .then((data) => {
  3935. resolve(data);
  3936. })
  3937. .catch((error) => {
  3938. reject(error);
  3939. });
  3940. }
  3941. });
  3942. }
  3943.  
  3944. /**
  3945. * Gets the token from the current URL
  3946. *
  3947. * @returns token
  3948. */
  3949. function getToken() {
  3950. const PATHNAME = window.location.pathname;
  3951. if (PATHNAME.startsWith("/game/")) {
  3952. return PATHNAME.replace("/game/", "");
  3953. }
  3954. else if (PATHNAME.startsWith("/challenge/")) {
  3955. return PATHNAME.replace("/challenge/", "");
  3956. }
  3957. else if (PATHNAME.startsWith("/battle-royale/")) {
  3958. return PATHNAME.replace("/battle-royale/", "");
  3959. }
  3960. else if (PATHNAME.startsWith("/duels/")) {
  3961. return PATHNAME.replace("/duels/", "");
  3962. }
  3963. else if (PATHNAME.startsWith("/team-duels/")) {
  3964. return PATHNAME.replace("/team-duels/", "");
  3965. }
  3966. else if (PATHNAME.startsWith("/bullseye/")) {
  3967. return PATHNAME.replace("/bullseye/", "");
  3968. }
  3969. else if (PATHNAME.startsWith("/live-challenge/")) {
  3970. return PATHNAME.replace("/live-challenge/", "");
  3971. }
  3972. }
  3973.  
  3974. /**
  3975. * Gets the round number from the ongoing game from the page itself
  3976. *
  3977. * @returns Round number
  3978. */
  3979. function getRoundFromPage() {
  3980. const roundData = document.querySelector("div[data-qa='round-number']");
  3981. if (roundData) {
  3982. let roundElement = roundData.querySelector("div:last-child");
  3983. if (roundElement) {
  3984. let round = parseInt(roundElement.innerText.charAt(0));
  3985. if (!isNaN(round) && round >= 1 && round <= 5) {
  3986. return round;
  3987. }
  3988. }
  3989. }
  3990. else {
  3991. return ROUND;
  3992. }
  3993. }
  3994.  
  3995.  
  3996. /**
  3997. * Injects Yandex Script
  3998. */
  3999. function injectYandexScript() {
  4000. return new Promise((resolve, reject) => {
  4001. if (!YANDEX_INJECTED) {
  4002. if (YANDEX_API_KEY === "") {
  4003. console.log("No Yandex Key")
  4004. reject();
  4005. }
  4006. else {
  4007. if (!partialCreateYandex)
  4008. {
  4009. const SCRIPT = document.createElement("script");
  4010. SCRIPT.type = "text/javascript";
  4011. SCRIPT.async = true;
  4012. SCRIPT.src = `https://api-maps.yandex.ru/2.1/?lang=en_US&apikey=${YANDEX_API_KEY}`;
  4013. document.body.appendChild(SCRIPT);
  4014. SCRIPT.onload = () => {
  4015. ymaps.ready(() => {
  4016. YANDEX_INJECTED = true;
  4017. myHighlight("Yandex API Loaded");
  4018. resolve();
  4019. });
  4020. }
  4021. }
  4022. else
  4023. {
  4024. YANDEX_INJECTED = true;
  4025. resolve();
  4026. }
  4027. }
  4028. }
  4029. else {
  4030. resolve();
  4031. }
  4032. });
  4033. }
  4034.  
  4035. /**
  4036. * Injects Yandex Player and calls handleReturnToStart
  4037. */
  4038. function injectYandexPlayer() {
  4039. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4040. let lat = 41.321861;
  4041. let lng = 69.212920;
  4042.  
  4043. let options = {
  4044. "direction": [0, 16],
  4045. "span": [10, 67],
  4046. "controls": ["zoomControl"]
  4047. };
  4048. ymaps.panorama.createPlayer("player", [lat, lng], options)
  4049. .done((player) => {
  4050. YandexPlayer = player;
  4051. YandexPlayer.events.add("directionchange", (e) => {
  4052. updateCompass();
  4053. let pov = YandexPlayer.getDirection();
  4054. if (locHistory.length > 0 && nextPlayer == "Yandex") {
  4055. switchCovergeButton.heading = pov[0];
  4056. locHistory[locHistory.length - 1][2] = pov[0];
  4057. locHistory[locHistory.length - 1][3] = pov[1];
  4058. }
  4059. });
  4060. YandexPlayer.events.add("panoramachange", (e) => {
  4061. if (defaultPanoIdChange) {
  4062. let num = YandexPlayer.getPanorama().getPosition();
  4063. let pov = YandexPlayer.getDirection();
  4064. // console.log(num);
  4065. // console.log(pov);
  4066. if (nextPlayer == "Yandex")
  4067. {
  4068. locHistory.push([num[0], num[1], pov[0], pov[1]]);
  4069. switchCovergeButton.lat = num[0];
  4070. switchCovergeButton.lng = num[1];
  4071. }
  4072. let btn = document.querySelector("button[data-qa='undo-move']");
  4073. if (locHistory.length > 1) {
  4074. btn.disabled = false;
  4075. btn.classList.remove('styles_disabled__2YdHD');
  4076. }
  4077. // console.log(locHistory);
  4078. }
  4079. defaultPanoIdChange = true;
  4080.  
  4081. });
  4082. console.log("Yandex Player injected");
  4083. });
  4084.  
  4085. }
  4086.  
  4087.  
  4088. /**
  4089. * Injects Baidu script
  4090. */
  4091.  
  4092. function reportWindowSize() {
  4093. let iframeC = document.getElementById("i_container");
  4094. if (iframeC)
  4095. {
  4096. if (nextPlayer == "Baidu")
  4097. {
  4098. iframeC.style.top = '-60px';
  4099. iframeC.style.height = (window.innerHeight + 200) + 'px';
  4100. iframeC.style.right = '-55px';
  4101. iframeC.style.width = (window.innerWidth + 55) + 'px';
  4102. }
  4103. else if (nextPlayer == "Youtube")
  4104. {
  4105. iframeC.style.top = '-60px';
  4106. iframeC.style.height = (window.innerHeight + 235) + 'px';
  4107. }
  4108. else if (nextPlayer == "Image")
  4109. {
  4110. iframeC.style.top = '0px';
  4111. iframeC.style.height = (window.innerHeight) + 'px';
  4112. }
  4113.  
  4114. }
  4115. }
  4116.  
  4117. window.onresize = reportWindowSize;
  4118.  
  4119. function injectContainer() {
  4120. myHighlight("iframe container loaded")
  4121. const iframe = document.createElement('iframe');
  4122. iframe.frameBorder = 0;
  4123. iframe.style.position = "absolute";
  4124. iframe.id = "i_container";
  4125. if (isBattleRoyale) {
  4126. if (isDuel)
  4127. {
  4128. iframe.className = "inactive";
  4129. }
  4130. else if (isBullseye)
  4131. {
  4132. iframe.className = "game-panorama_panorama__ncMwh";
  4133. }
  4134. else if (isLiveChallenge)
  4135. {
  4136. iframe.className = "game-panorama_panorama__6RmkO";
  4137. }
  4138. else
  4139. {
  4140. iframe.className = "br-game-layout__panorama";
  4141. }
  4142. }
  4143. else {
  4144. iframe.className = "game-layout__panorama";
  4145. }
  4146. var div = document.getElementById("player");
  4147. div.style.overflow = "hidden";
  4148. if (isBullseye || isLiveChallenge)
  4149. {
  4150. div.prepend(iframe);
  4151. }
  4152. else
  4153. {
  4154. div.appendChild(iframe);
  4155. }
  4156. }
  4157.  
  4158. // function injectMedia() {
  4159. // myHighlight("Baidu API loaded")
  4160. // const iframe = document.createElement('iframe');
  4161. // iframe.allow = "autoplay"
  4162. // iframe.src = "https://www.youtube.com/embed/72kRM86V-dw?&autoplay=1&modestbranding=1&controls=0&start=10"
  4163. // iframe.frameBorder = 0;
  4164. // iframe.style.position = "absolute";
  4165. // iframe.id = "media-player";
  4166. // 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;"
  4167. // if (isBattleRoyale) {
  4168. // if (isDuel)
  4169. // {
  4170. // iframe.className = "inactive"
  4171. // }
  4172. // else
  4173. // {
  4174. // iframe.className = "br-game-layout__panorama"
  4175. // }
  4176. // }
  4177. // else {
  4178. // iframe.className = "game-layout__panorama"
  4179. // }
  4180. // var div = document.getElementById("player");
  4181. // div.style.overflow = "hidden";
  4182. // div.appendChild(iframe);
  4183. // }
  4184.  
  4185. /**
  4186. * Injects Kakao script
  4187. */
  4188.  
  4189. function injectKakaoScript() {
  4190. return new Promise((resolve, reject) => {
  4191. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4192. if (!KAKAO_INJECTED) {
  4193. if (KAKAO_API_KEY === "") {
  4194. console.log("No Kakao Key")
  4195. }
  4196. else {
  4197.  
  4198. let canvas = document.createElement("kmap");
  4199. if (isBattleRoyale) {
  4200. if (isDuel)
  4201. {
  4202. canvas.innerHTML = `
  4203. <div id="roadview" class="inactive" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4204. `;
  4205. }
  4206. else if (isBullseye)
  4207. {
  4208. canvas.innerHTML = `
  4209. <div id="roadview" class="game-panorama_panorama__ncMwh" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4210. `;
  4211. }
  4212. else if (isLiveChallenge)
  4213. {
  4214. canvas.innerHTML = `
  4215. <div id="roadview" class="game-panorama_panorama__6RmkO" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4216. `;
  4217. }
  4218. else
  4219. {
  4220. canvas.innerHTML = `
  4221. <div id="roadview" class="br-game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4222. `;
  4223. }
  4224. }
  4225. else {
  4226. canvas.innerHTML = `
  4227. <div id="roadview" class="game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4228. `;
  4229. }
  4230.  
  4231.  
  4232. var div = document.getElementById("player");
  4233. if (isBullseye || isLiveChallenge)
  4234. {
  4235. div.prepend(canvas);
  4236. }
  4237. else
  4238. {
  4239. div.appendChild(canvas);
  4240. }
  4241.  
  4242. let SCRIPT;
  4243. if (!partialCreateKakao)
  4244. {
  4245. SCRIPT = document.createElement("script");
  4246. SCRIPT.async = true;
  4247. // SCRIPT.type = "text/javascript";
  4248. SCRIPT.src = `//dapi.kakao.com/v2/maps/sdk.js?appkey=${KAKAO_API_KEY}&autoload=false`;
  4249. document.body.appendChild(SCRIPT);
  4250. }
  4251.  
  4252. function drawmapKakao()
  4253. {
  4254. kakao.maps.load(function () {
  4255. var position = new kakao.maps.LatLng(33.450701, 126.560667);
  4256. let roadviewContainer = document.getElementById('roadview');
  4257. KakaoPlayer = new kakao.maps.Roadview(roadviewContainer);
  4258. var panoId = 1023434522;
  4259. KakaoPlayer.setPanoId(panoId, position);
  4260. KAKAO_INJECTED = true;
  4261. // Remove the compass from Kakao
  4262. kakao.maps.event.addListener(KakaoPlayer, 'init', () => {
  4263. const compassContainer = roadviewContainer.querySelector('div[id*="_box_util_"]');
  4264. if (compassContainer) compassContainer.style.display = 'none';
  4265. });
  4266. kakao.maps.event.addListener(KakaoPlayer, 'panoid_changed', function() {
  4267. if (defaultPanoIdChange && KakaoPlayer) {
  4268. let latlng = KakaoPlayer.getPosition();
  4269. let lat = latlng.getLat();
  4270. let lng = latlng.getLng();
  4271. let pID = KakaoPlayer.getViewpointWithPanoId();
  4272. if (nextPlayer == "Kakao" && lat != 33.45047613915499)
  4273. {
  4274. // console.log("push");
  4275. locHistory.push([lat, lng, pID.panoId, pID.pan]);
  4276. switchCovergeButton.lat = lat;
  4277. switchCovergeButton.lng = lng;
  4278. switchCovergeButton.heading = pID.pan;
  4279. }
  4280. let btn = document.querySelector("button[data-qa='undo-move']");
  4281. if (locHistory.length > 1 && (btn != null)) {
  4282. btn.disabled = false;
  4283. btn.classList.remove('styles_disabled__2YdHD');
  4284. }
  4285. // console.log(locHistory);
  4286. }
  4287. defaultPanoIdChange = true;
  4288. });
  4289. kakao.maps.event.addListener(KakaoPlayer, 'viewpoint_changed', function() {
  4290. // console.log("pov_listener attached");
  4291. let pID = KakaoPlayer.getViewpointWithPanoId();
  4292. if (locHistory.length > 0 && nextPlayer == "Kakao") {
  4293. switchCovergeButton.heading = pID.pan;
  4294. locHistory[locHistory.length - 1][3] = pID.pan;
  4295. }
  4296. if (GooglePlayer) {
  4297. const { heading, pitch } = GooglePlayer.getPov()
  4298. if ((!almostEqual(pID.pan, heading) || !almostEqual(pID.tilt, pitch)) && nextPlayer == "Kakao") {
  4299. // Updating the google street view POV will update the compass
  4300. GooglePlayer.setPov({ heading: pID.pan, pitch: pID.tilt })
  4301. }
  4302. }
  4303. // console.log(locHistory);
  4304. })
  4305. });
  4306. }
  4307.  
  4308. if (partialCreateKakao)
  4309. {
  4310. drawmapKakao();
  4311. }
  4312. else
  4313. {
  4314. SCRIPT.onload = () => {
  4315. drawmapKakao();
  4316. myHighlight("Kakao API Loaded");
  4317. resolve();
  4318. };
  4319. }
  4320.  
  4321. }
  4322. }
  4323. else {
  4324. resolve();
  4325. }
  4326. });
  4327. }
  4328.  
  4329.  
  4330. function injectMSPlayer() {
  4331. return new Promise((resolve, reject) => {
  4332. if (!MS_INJECTED) {
  4333. if (MS_API_KEY === "") {
  4334. let canvas = document.getElementById("player");
  4335. console.log("No MS Key")
  4336. }
  4337. else {
  4338.  
  4339. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4340. let SCRIPT;
  4341. if (!partialCreateMS)
  4342. {
  4343. SCRIPT = document.createElement("script");
  4344. SCRIPT.type = "text/javascript";
  4345. SCRIPT.async = true;
  4346. SCRIPT.src = `https://www.bing.com/api/maps/mapcontrol?key=${MS_API_KEY}`;
  4347. document.body.appendChild(SCRIPT);
  4348. }
  4349. let canvas = document.createElement("msmap");
  4350. if (isBattleRoyale) {
  4351. if (isDuel)
  4352. {
  4353. canvas.innerHTML = `<div id="ms-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4354. }
  4355. else if (isBullseye)
  4356. {
  4357. 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>`;
  4358. }
  4359. else if (isLiveChallenge)
  4360. {
  4361. 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>`;
  4362. }
  4363. else
  4364. {
  4365. 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>`;
  4366. }
  4367. }
  4368. else {
  4369. canvas.innerHTML = `<div id="ms-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4370. }
  4371.  
  4372. var div = document.getElementById("player");
  4373. if (isBullseye || isLiveChallenge)
  4374. {
  4375. div.prepend(canvas);
  4376. }
  4377. else
  4378. {
  4379. div.appendChild(canvas);
  4380. }
  4381. function drawmapMS()
  4382. {
  4383. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  4384. MS_INJECTED = true;
  4385. // MSStreetPlayer.setOptions({
  4386. // minZoom: 13
  4387. // });
  4388. Microsoft.Maps.Events.addHandler(MSStreetPlayer, 'viewchangeend', function () { updateView(MSStreetPlayer); });
  4389. function updateView(map) {
  4390. let ctrm = map.getCenter();
  4391. if (nextPlayer == "Bing Streetside" && (switchCovergeButton.lat !== ctrm.latitude && switchCovergeButton.lng !== ctrm.longitude))
  4392. {
  4393. let heading2 = bearing(switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude)
  4394. // console.log("moved");
  4395. // console.log([switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude])
  4396. // console.log(heading2);
  4397. locHistory.push([ctrm.latitude, ctrm.longitude, heading2]);
  4398. switchCovergeButton.lat = ctrm.latitude;
  4399. switchCovergeButton.lng = ctrm.longitude;
  4400. switchCovergeButton.heading = heading2;
  4401. let btn = document.querySelector("button[data-qa='undo-move']");
  4402. if (locHistory.length > 1 && (btn != null)) {
  4403. btn.disabled = false;
  4404. btn.classList.remove('styles_disabled__2YdHD');
  4405. }
  4406. }
  4407. }
  4408.  
  4409.  
  4410. }
  4411.  
  4412. if (partialCreateMS)
  4413. {
  4414. drawmapMS();
  4415. }
  4416. else
  4417. {
  4418. SCRIPT.addEventListener('load', () => {
  4419. myHighlight("Bing Maps API loaded");
  4420. let timeout = 0;
  4421. let interval = setInterval(() => {
  4422. if (timeout >= 40) {
  4423. reject();
  4424. clearInterval(interval);
  4425. }
  4426. if (document.getElementById('ms-player') !== null && typeof Microsoft.Maps.Map !== typeof undefined) {
  4427. drawmapMS();
  4428. resolve();
  4429. clearInterval(interval);
  4430. }
  4431. timeout += 1;
  4432. }, 1000);
  4433. })
  4434. }
  4435. }
  4436. }
  4437. else {
  4438. resolve();
  4439. }
  4440. });
  4441. }
  4442.  
  4443.  
  4444.  
  4445. function injectMapillaryPlayer() {
  4446. return new Promise((resolve, reject) => {
  4447. if (!MAPILLARY_INJECTED) {
  4448. if (MAPILLARY_API_KEY === "") {
  4449. let canvas = document.getElementById("player");
  4450. console.log("No Mapillary Key")
  4451. }
  4452. else {
  4453. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4454.  
  4455. let SCRIPT;
  4456. if (!partialCreateMapillary)
  4457. {
  4458. SCRIPT = document.createElement("script");
  4459. SCRIPT.type = "text/javascript";
  4460. SCRIPT.async = true;
  4461. SCRIPT.src = `https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.js`;
  4462. document.body.appendChild(SCRIPT);
  4463. document.querySelector('head').innerHTML += '<link href="https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.css" rel="stylesheet"/>';
  4464. }
  4465. let canvas = document.createElement("mmap");
  4466. if (isBattleRoyale) {
  4467. if (isDuel)
  4468. {
  4469.  
  4470. canvas.innerHTML = `<div id="mapillary-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4471. }
  4472. else if (isBullseye)
  4473. {
  4474. 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>`;
  4475. }
  4476. else if (isLiveChallenge)
  4477. {
  4478. 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>`;
  4479. }
  4480. else
  4481. {
  4482. 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>`;
  4483. }
  4484. }
  4485. else {
  4486. canvas.innerHTML = `<div id="mapillary-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4487. }
  4488.  
  4489. var div = document.getElementById("player");
  4490. if (isBullseye || isLiveChallenge)
  4491. {
  4492. div.prepend(canvas);
  4493. }
  4494. else
  4495. {
  4496. div.appendChild(canvas);
  4497. }
  4498.  
  4499. function drawMapML()
  4500. {
  4501. var {Viewer} = mapillary;
  4502.  
  4503. MapillaryPlayer = new Viewer({
  4504. accessToken: MAPILLARY_API_KEY,
  4505. container: 'mapillary-player', // the ID of our container defined in the HTML body
  4506. });
  4507.  
  4508. MapillaryPlayer.on('image', async (event) => {
  4509. // cnt = cnt + 1;
  4510. // console.log(cnt);
  4511. let image = event.image;
  4512. let pos = image.originalLngLat;
  4513. let cond = true;
  4514. for (const element of locHistory) {
  4515. if (element[2] == image.id)
  4516. {
  4517. cond = false;
  4518. }
  4519. }
  4520. if (cond)
  4521. {
  4522. switchCovergeButton.lat = pos.lat;
  4523. switchCovergeButton.lng = pos.lng;
  4524. switchCovergeButton.heading = image.compassAngle;
  4525. // console.log(pos);
  4526. locHistory.push([pos.lat, pos.lng, image.id, image.compassAngle]);
  4527. }
  4528. let btn = document.querySelector("button[data-qa='undo-move']");
  4529. if (btn !== null && locHistory.length > 1)
  4530. {
  4531. btn.disabled = false;
  4532. btn.classList.remove('styles_disabled__2YdHD');
  4533. }
  4534. });
  4535.  
  4536. MAPILLARY_INJECTED = true;
  4537. }
  4538. if (partialCreateMapillary)
  4539. {
  4540. drawMapML();
  4541. }
  4542. else
  4543. {
  4544.  
  4545. SCRIPT.addEventListener('load', () => {
  4546. myHighlight("Mapillary API Loaded");
  4547. // resolve(BMap);
  4548. drawMapML();
  4549. resolve();
  4550. })
  4551. }
  4552. }
  4553. }
  4554. else {
  4555. resolve();
  4556. }
  4557. });
  4558. }
  4559.  
  4560.  
  4561. function handleMapillary(latlng, options)
  4562. {
  4563. console.log("handleMapillary")
  4564. handleMapillaryHelper(latlng, options).then((data) => {
  4565. //console.log(data.data)
  4566. let idToSet = 0;
  4567. let curDist = 100000000;
  4568. for (const element of data.data) {
  4569. // console.log(element)
  4570. if (element.hasOwnProperty("computed_geometry"))
  4571. {
  4572. try {
  4573. let rCord = element.computed_geometry["coordinates"];
  4574. let dist = distance(latlng.lat,latlng.lng,rCord[1],rCord[0])
  4575. if (dist < curDist)
  4576. {
  4577. idToSet = element.id;
  4578. curDist = dist
  4579. }
  4580. } catch (e) {
  4581. console.log("Error")
  4582. }
  4583. }
  4584. }
  4585. if (idToSet !== 0)
  4586. {
  4587. MapillaryPlayer.moveTo(idToSet).then(
  4588. image => { //console.log(image);
  4589. },
  4590. error => { console.log(error); });
  4591. }}).catch((error) => {
  4592. console.log(error);
  4593. });
  4594. }
  4595.  
  4596. function handleMapillaryHelper(latlng, options)
  4597. {
  4598. return new Promise((resolve, reject) => {
  4599. // console.log("1")
  4600. let bbox = getBBox(latlng, options.meters);
  4601. 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)
  4602. // console.log(URL)
  4603. fetch(URL)
  4604. .then((response) => {resolve(response.json())})
  4605. .catch((error) => {console.log(error);});
  4606. });
  4607. }
  4608.  
  4609.  
  4610. /**
  4611. * Minimap presets
  4612. */
  4613.  
  4614. let water_name_only =
  4615. [
  4616. {
  4617. "elementType": "geometry",
  4618. "stylers": [
  4619. {
  4620. "visibility": "off"
  4621. }
  4622. ]
  4623. },
  4624. {
  4625. "featureType": "administrative",
  4626. "stylers": [
  4627. {
  4628. "visibility": "off"
  4629. }
  4630. ]
  4631. },
  4632. {
  4633. "featureType": "landscape",
  4634. "stylers": [
  4635. {
  4636. "visibility": "off"
  4637. }
  4638. ]
  4639. },
  4640. {
  4641. "featureType": "poi",
  4642. "stylers": [
  4643. {
  4644. "visibility": "off"
  4645. }
  4646. ]
  4647. },
  4648. {
  4649. "featureType": "road",
  4650. "stylers": [
  4651. {
  4652. "visibility": "off"
  4653. }
  4654. ]
  4655. },
  4656. {
  4657. "featureType": "transit",
  4658. "stylers": [
  4659. {
  4660. "visibility": "off"
  4661. }
  4662. ]
  4663. }
  4664. ]
  4665. let country_name_only =
  4666. [
  4667. {
  4668. "elementType": "geometry",
  4669. "stylers": [
  4670. {
  4671. "visibility": "off"
  4672. }
  4673. ]
  4674. },
  4675. {
  4676. "featureType": "administrative",
  4677. "stylers": [
  4678. {
  4679. "visibility": "off"
  4680. }
  4681. ]
  4682. },
  4683. {
  4684. "featureType": "administrative.country",
  4685. "elementType": "labels",
  4686. "stylers": [
  4687. {
  4688. "visibility": "on"
  4689. }
  4690. ]
  4691. },
  4692. {
  4693. "featureType": "landscape",
  4694. "stylers": [
  4695. {
  4696. "visibility": "off"
  4697. }
  4698. ]
  4699. },
  4700. {
  4701. "featureType": "poi",
  4702. "stylers": [
  4703. {
  4704. "visibility": "off"
  4705. }
  4706. ]
  4707. },
  4708. {
  4709. "featureType": "road",
  4710. "stylers": [
  4711. {
  4712. "visibility": "off"
  4713. }
  4714. ]
  4715. },
  4716. {
  4717. "featureType": "transit",
  4718. "stylers": [
  4719. {
  4720. "visibility": "off"
  4721. }
  4722. ]
  4723. },
  4724. {
  4725. "featureType": "water",
  4726. "stylers": [
  4727. {
  4728. "visibility": "off"
  4729. }
  4730. ]
  4731. }
  4732. ]
  4733.  
  4734. let no_label_or_terrain =
  4735. [
  4736. {
  4737. "elementType": "geometry",
  4738. "stylers": [
  4739. {
  4740. "visibility": "off"
  4741. }
  4742. ]
  4743. },
  4744. {
  4745. "featureType": "administrative",
  4746. "stylers": [
  4747. {
  4748. "visibility": "off"
  4749. }
  4750. ]
  4751. },
  4752. {
  4753. "featureType": "landscape",
  4754. "stylers": [
  4755. {
  4756. "visibility": "off"
  4757. }
  4758. ]
  4759. },
  4760. {
  4761. "featureType": "poi",
  4762. "stylers": [
  4763. {
  4764. "visibility": "off"
  4765. }
  4766. ]
  4767. },
  4768. {
  4769. "featureType": "road",
  4770. "stylers": [
  4771. {
  4772. "visibility": "off"
  4773. }
  4774. ]
  4775. },
  4776. {
  4777. "featureType": "transit",
  4778. "stylers": [
  4779. {
  4780. "visibility": "off"
  4781. }
  4782. ]
  4783. },
  4784. {
  4785. "featureType": "water",
  4786. "stylers": [
  4787. {
  4788. "visibility": "on"
  4789. }
  4790. ]
  4791. },
  4792. {
  4793. "featureType": "water",
  4794. "elementType": "labels",
  4795. "stylers": [
  4796. {
  4797. "visibility": "off"
  4798. }
  4799. ]
  4800. }
  4801. ]
  4802.  
  4803. let no_label =
  4804. [
  4805. {
  4806. "elementType": "labels",
  4807. "stylers": [
  4808. {
  4809. "visibility": "off"
  4810. }
  4811. ]
  4812. },
  4813. {
  4814. "featureType": "administrative",
  4815. "stylers": [
  4816. {
  4817. "visibility": "off"
  4818. }
  4819. ]
  4820. }
  4821. ]
  4822.  
  4823. let blank =
  4824.  
  4825. [
  4826. {
  4827. "stylers": [
  4828. {
  4829. "visibility": "off"
  4830. }
  4831. ]
  4832. }
  4833. ]
  4834.  
  4835. let thick_border =
  4836.  
  4837. [
  4838. {
  4839. "featureType": "administrative.country",
  4840. "elementType": "geometry.stroke",
  4841. "stylers": [
  4842. {
  4843. "weight": 1.5
  4844. }
  4845. ]
  4846. },
  4847. {
  4848. "featureType": "administrative.province",
  4849. "elementType": "geometry.stroke",
  4850. "stylers": [
  4851. {
  4852. "weight": 3.5
  4853. }
  4854. ]
  4855. }
  4856. ]
  4857.  
  4858. let Indonesia =
  4859.  
  4860. [
  4861. {
  4862. "featureType": "administrative",
  4863. "stylers": [
  4864. {
  4865. "visibility": "off"
  4866. }
  4867. ]
  4868. },
  4869. {
  4870. "featureType": "landscape",
  4871. "elementType": "labels",
  4872. "stylers": [
  4873. {
  4874. "visibility": "off"
  4875. }
  4876. ]
  4877. },
  4878. {
  4879. "featureType": "poi.park",
  4880. "elementType": "labels",
  4881. "stylers": [
  4882. {
  4883. "visibility": "off"
  4884. }
  4885. ]
  4886. },
  4887. {
  4888. "featureType": "road",
  4889. "elementType": "labels",
  4890. "stylers": [
  4891. {
  4892. "visibility": "off"
  4893. }
  4894. ]
  4895. },
  4896. {
  4897. "featureType": "transit",
  4898. "elementType": "labels",
  4899. "stylers": [
  4900. {
  4901. "visibility": "off"
  4902. }
  4903. ]
  4904. },
  4905. {
  4906. "featureType": "water",
  4907. "elementType": "labels",
  4908. "stylers": [
  4909. {
  4910. "visibility": "off"
  4911. }
  4912. ]
  4913. }
  4914. ]
  4915.  
  4916. let dark = [
  4917. {
  4918. "elementType": "geometry",
  4919. "stylers": [
  4920. {
  4921. "color": "#212121"
  4922. }
  4923. ]
  4924. },
  4925. {
  4926. "elementType": "labels.icon",
  4927. "stylers": [
  4928. {
  4929. "visibility": "off"
  4930. }
  4931. ]
  4932. },
  4933. {
  4934. "elementType": "labels.text.fill",
  4935. "stylers": [
  4936. {
  4937. "color": "#757575"
  4938. }
  4939. ]
  4940. },
  4941. {
  4942. "elementType": "labels.text.stroke",
  4943. "stylers": [
  4944. {
  4945. "color": "#212121"
  4946. }
  4947. ]
  4948. },
  4949. {
  4950. "featureType": "administrative",
  4951. "elementType": "geometry",
  4952. "stylers": [
  4953. {
  4954. "color": "#757575"
  4955. }
  4956. ]
  4957. },
  4958. {
  4959. "featureType": "administrative.country",
  4960. "elementType": "labels.text.fill",
  4961. "stylers": [
  4962. {
  4963. "color": "#9e9e9e"
  4964. }
  4965. ]
  4966. },
  4967. {
  4968. "featureType": "administrative.land_parcel",
  4969. "stylers": [
  4970. {
  4971. "visibility": "off"
  4972. }
  4973. ]
  4974. },
  4975. {
  4976. "featureType": "administrative.locality",
  4977. "elementType": "labels.text.fill",
  4978. "stylers": [
  4979. {
  4980. "color": "#bdbdbd"
  4981. }
  4982. ]
  4983. },
  4984. {
  4985. "featureType": "poi",
  4986. "elementType": "labels.text.fill",
  4987. "stylers": [
  4988. {
  4989. "color": "#757575"
  4990. }
  4991. ]
  4992. },
  4993. {
  4994. "featureType": "poi.park",
  4995. "elementType": "geometry",
  4996. "stylers": [
  4997. {
  4998. "color": "#181818"
  4999. }
  5000. ]
  5001. },
  5002. {
  5003. "featureType": "poi.park",
  5004. "elementType": "labels.text.fill",
  5005. "stylers": [
  5006. {
  5007. "color": "#616161"
  5008. }
  5009. ]
  5010. },
  5011. {
  5012. "featureType": "poi.park",
  5013. "elementType": "labels.text.stroke",
  5014. "stylers": [
  5015. {
  5016. "color": "#1b1b1b"
  5017. }
  5018. ]
  5019. },
  5020. {
  5021. "featureType": "road",
  5022. "elementType": "geometry.fill",
  5023. "stylers": [
  5024. {
  5025. "color": "#2c2c2c"
  5026. }
  5027. ]
  5028. },
  5029. {
  5030. "featureType": "road",
  5031. "elementType": "labels.text.fill",
  5032. "stylers": [
  5033. {
  5034. "color": "#8a8a8a"
  5035. }
  5036. ]
  5037. },
  5038. {
  5039. "featureType": "road.arterial",
  5040. "elementType": "geometry",
  5041. "stylers": [
  5042. {
  5043. "color": "#373737"
  5044. }
  5045. ]
  5046. },
  5047. {
  5048. "featureType": "road.highway",
  5049. "elementType": "geometry",
  5050. "stylers": [
  5051. {
  5052. "color": "#3c3c3c"
  5053. }
  5054. ]
  5055. },
  5056. {
  5057. "featureType": "road.highway.controlled_access",
  5058. "elementType": "geometry",
  5059. "stylers": [
  5060. {
  5061. "color": "#4e4e4e"
  5062. }
  5063. ]
  5064. },
  5065. {
  5066. "featureType": "road.local",
  5067. "elementType": "labels.text.fill",
  5068. "stylers": [
  5069. {
  5070. "color": "#616161"
  5071. }
  5072. ]
  5073. },
  5074. {
  5075. "featureType": "transit",
  5076. "elementType": "labels.text.fill",
  5077. "stylers": [
  5078. {
  5079. "color": "#757575"
  5080. }
  5081. ]
  5082. },
  5083. {
  5084. "featureType": "water",
  5085. "elementType": "geometry",
  5086. "stylers": [
  5087. {
  5088. "color": "#000000"
  5089. }
  5090. ]
  5091. },
  5092. {
  5093. "featureType": "water",
  5094. "elementType": "labels.text.fill",
  5095. "stylers": [
  5096. {
  5097. "color": "#3d3d3d"
  5098. }
  5099. ]
  5100. }
  5101. ]
  5102.  
  5103. let default_preset = []
  5104.  
  5105. let presetMinimap = [[default_preset, "Default"],
  5106. [blank, "Blank"],
  5107. [water_name_only, "Oceanman"],
  5108. [country_name_only, "Impossible"],
  5109. [no_label_or_terrain, "Streaks"],
  5110. [no_label, "Easy 5K"],
  5111. [Indonesia, "POI only"],
  5112. [dark, "Dark Mode"],
  5113. [thick_border, "Borders"],
  5114. [default_preset, "Satellite"],
  5115. [default_preset, "Terrain"],
  5116. [default_preset, "Hybrid"],
  5117. [custom, "Custom", customMode]]
  5118.  
  5119. let GEOJSON_INVISIBLE =
  5120. {
  5121. strokeOpacity: 0,
  5122. fillOpacity: 0,
  5123. }
  5124.  
  5125. let presetOverlay = [["Clear",""],
  5126. ["Coverage",""],
  5127. ["Official",""],
  5128. ["Longitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/lonl.json"],
  5129. ["Latitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/latl.json"],
  5130. ["US County","https://raw.githubusercontent.com/CodeForCary/CountyDataUSA5m/master/cb_2017_us_county_5m.json"],
  5131. ["France","https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements.geojson"],
  5132. ["Time Zone", "https://raw.githubusercontent.com/treyerl/timezones/master/timezones_wVVG8.geojson"],
  5133. ["UK Parliament", "https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/electoral/gb/wpc.json"],
  5134. ["Custom", YOUR_URL]]
  5135.  
  5136. /**
  5137. * Display map per local laws and regulations
  5138. */
  5139.  
  5140. let SEOverlay, NWOverlay, SEOverlay3;
  5141. let TW = [[24.80, 119.00, 22.00, 123.20],
  5142. [24.20, 119.90, 22.90, 121.85],
  5143. [24.00, 120.90, 23.80, 121.20],
  5144. [23.93, 121.03, 23.85, 121.15],
  5145. [23.92, 121.055, 23.89, 121.10],
  5146. [23.92, 121.055, 23.89, 121.10],
  5147. [23.92, 121.055, 23.89, 121.10],
  5148. ]
  5149.  
  5150. let TS = [[30.40, 93.40, 28, 97.20],
  5151. [29.40, 94.55, 28.20, 96.45]]
  5152.  
  5153. let NW = [36.20, 77.70, 34.40, 80.70]