Geoguessr Unity Script

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

Verze ze dne 08. 03. 2022. Zobrazit nejnovější verzi.

  1. // ==UserScript==
  2. // @name Geoguessr Unity Script
  3. // @description For a full list of features included in this script, see this document https://docs.google.com/document/d/18nLXSQQLOzl4WpUgZkM-mxhhQLY6P3FKonQGp-H0fqI/edit?usp=sharing
  4. // @version 5.2.7
  5. // @author Jupaoqq
  6. // @include https://www.geoguessr.com/*
  7. // @run-at document-start
  8. // @license MIT
  9. // @namespace https://greatest.deepsurf.us/users/838374
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. /**
  14. * Custom your minimap here!
  15. */
  16.  
  17. /**
  18. * 1: replace "roadmap" in the customMode field with any of the options below:
  19. * "roadmap" displays the default road map view. This is the default map type.
  20. * "satellite" displays Google Earth satellite images.
  21. * "hybrid" displays a mixture of normal and satellite views.
  22. * "terrain" displays a physical map based on terrain information.
  23. */
  24.  
  25. let customMode = "roadmap";
  26.  
  27. /**
  28. * 2: Go to https://mapstyle.withgoogle.com/ first click "No thanks, take me to the old style wizard"
  29. * then click "MORE OPTIONS" to hide or reveal certain features.
  30. * When you are done, click "FINISH", then "COPY JSON", and replace my settings in custom with your settings below.
  31. */
  32.  
  33. let custom =
  34.  
  35. [
  36. {
  37. "featureType": "administrative",
  38. "stylers": [
  39. {
  40. "visibility": "off"
  41. }
  42. ]
  43. },
  44. {
  45. "featureType": "landscape",
  46. "stylers": [
  47. {
  48. "visibility": "off"
  49. }
  50. ]
  51. },
  52. {
  53. "featureType": "poi.park",
  54. "stylers": [
  55. {
  56. "visibility": "off"
  57. }
  58. ]
  59. },
  60. {
  61. "featureType": "road",
  62. "elementType": "labels",
  63. "stylers": [
  64. {
  65. "visibility": "off"
  66. }
  67. ]
  68. },
  69. {
  70. "featureType": "transit",
  71. "stylers": [
  72. {
  73. "visibility": "off"
  74. }
  75. ]
  76. }
  77. ]
  78.  
  79. /**
  80. * End of Minimap customization instruction section
  81. */
  82.  
  83. /**
  84. * Overlay anything on the minimap here!
  85. * 1. overlay an GeoJSON object
  86. * 2. overlay a custom image
  87. */
  88.  
  89. /**
  90. * Overlay an GeoJSON object:
  91. */
  92.  
  93. // change the GeoJson display style.
  94. // strokeOpacity, strokeWeight, fillOpacity takes a value between 0 and 1.
  95. // strokeColor and fillColor supports Hexadecimal color (#00FF00 is green)
  96. // If clickable is set to true, you would not be able to make a guess within the shape
  97.  
  98. let GEOJSON_STYLE =
  99. {
  100. strokeColor: "black",
  101. strokeOpacity: 1,
  102. strokeWeight: 0.2,
  103. fillColor: "#00FF00",
  104. fillOpacity: 0,
  105. clickable: false,
  106. }
  107.  
  108. // replace the URL with your desired link
  109. // For example, search "Germany GeoJson" on Github, find this link (https://github.com/isellsoap/deutschlandGeoJSON/blob/main/4_kreise/4_niedrig.geo.json)
  110. // Then click "Download" to get the raw.githubusercontent.com link (https://raw.githubusercontent.com/isellsoap/deutschlandGeoJSON/main/4_kreise/4_niedrig.geo.json)
  111. // and replace the URL below with that URL.
  112. // State zipcode: see this site https://github.com/OpenDataDE/State-zip-code-GeoJSON
  113.  
  114. let YOUR_URL = "https://raw.githubusercontent.com/severinlandolt/map-switzerland/main/02%20GeoJSON/CH_Kantonsgrenzen_100_geo.json"
  115.  
  116. // set it to true to add your custom GeoJSON by copy it to the code below (this is for
  117.  
  118. let GeoJsonCustomUser = false
  119.  
  120. // replace with your custom GeoJson, go to https://geojson.io/ to customize it then copy the Json to here
  121.  
  122. let CUSTOM_GEOJSON =
  123.  
  124. {
  125. "type": "FeatureCollection",
  126. "features": [
  127. {
  128. "type": "Feature",
  129. "properties": {},
  130. "geometry": {
  131. "type": "LineString",
  132. "coordinates": [
  133. [
  134. 2.493896484375,
  135. 52.7163309360463
  136. ],
  137. [
  138. 2.4609375,
  139. 53.15994678846807
  140. ],
  141. [
  142. 3.2025146484375,
  143. 53.179703893605385
  144. ],
  145. [
  146. 3.2080078125,
  147. 52.96518371955126
  148. ],
  149. [
  150. 2.48291015625,
  151. 52.948637884883205
  152. ]
  153. ]
  154. }
  155. },
  156. {
  157. "type": "Feature",
  158. "properties": {},
  159. "geometry": {
  160. "type": "LineString",
  161. "coordinates": [
  162. [
  163. 3.218994140625,
  164. 52.05586831074774
  165. ],
  166. [
  167. 3.218994140625,
  168. 52.13685974852633
  169. ],
  170. [
  171. 2.515869140625,
  172. 52.1267438596429
  173. ],
  174. [
  175. 2.515869140625,
  176. 51.77803705914517
  177. ],
  178. [
  179. 3.2354736328125,
  180. 51.78993084774129
  181. ],
  182. [
  183. 3.228607177734375,
  184. 51.96119237712624
  185. ],
  186. [
  187. 2.8571319580078125,
  188. 51.95230623740452
  189. ]
  190. ]
  191. }
  192. },
  193. {
  194. "type": "Feature",
  195. "properties": {
  196. "stroke": "#555555",
  197. "stroke-width": 2,
  198. "stroke-opacity": 1
  199. },
  200. "geometry": {
  201. "type": "LineString",
  202. "coordinates": [
  203. [
  204. 2.5048828125,
  205. 52.619725272670266
  206. ],
  207. [
  208. 2.5103759765625,
  209. 52.274880130680536
  210. ],
  211. [
  212. 2.867431640625,
  213. 52.284962354465726
  214. ],
  215. [
  216. 3.2299804687499996,
  217. 52.29504228453735
  218. ],
  219. [
  220. 3.2135009765625,
  221. 52.63973017532399
  222. ],
  223. [
  224. 2.5096893310546875,
  225. 52.621392697207625
  226. ]
  227. ]
  228. }
  229. }
  230. ]
  231. }
  232.  
  233. /**
  234. * Overlay a custom image:
  235. */
  236.  
  237. // set it to true to add your image overlay
  238.  
  239. let OverlayCustom = false
  240.  
  241. // replace the URL with your desired link
  242.  
  243. let OVERLAY_URL = "https://www.battleface.com/blog/wp-content/uploads/2020/10/patreon-profile-tom-geowizard.jpg"
  244.  
  245. // set the bounds for the image - latitude (North and South), longitude (North and South)
  246.  
  247. let OVERLAY_BOUNDS =
  248. {
  249. north: 53,
  250. west: -3,
  251. south: 51,
  252. east: 1,
  253. };
  254.  
  255. // change the image overlay display style.
  256.  
  257. let OVERLAY_STYLE =
  258. {
  259. fillOpacity: 0.2,
  260. clickable: false,
  261. }
  262.  
  263. /**
  264. * End of Minimap Overlay instruction section
  265. */
  266.  
  267. // API Keys
  268.  
  269. var MS_API_KEY = "AjWqExh5E9aZfgKKBrgJMM2tbBeJ_q9ET7__194VDfcpl8lEWYTYNRWoYE1kqy95";
  270. var YANDEX_API_KEY = "b704b5a9-3d67-4d19-b702-ec7807cecfc6";
  271. var KAKAO_API_KEY = "cbacbe41e3a223d794f321de4f3e247b";
  272. const MAPS_API_URL = "https://maps.googleapis.com/maps/api/js"; // removed "?" from the link
  273. var MAPILLARY_API_KEY_LIST =
  274. ["MLY|6723031704435203|5afd537469b114cf814881137ad74b7c",
  275. "MLY|6691659414239148|b45e7e82cde126044cbc2cf5d4a7c9b1",
  276. "MLY|5074369465929308|f7ad2802cbaf26c63f88046a292df68b",
  277. "MLY|7451643761528219|6477f2db0e3928b51e45ec9311983936",
  278. "MLY|4855256237866198|6d0464771831c8a4bf2be095e1e1aabc",
  279. "MLY|4772941976102161|8458d4f08d2e1970cdfe0a4e242c04ff",
  280. "MLY|4492067214235489|94c44703942362ad6f6b70b5d32c3a45",
  281. "MLY|4618251611628426|0cef71d6ec8b997a5ec06ecdeabf11ec",
  282. "MLY|4096846270415982|fa2ce29641503e6ef665f17459633570",
  283. "MLY|4231415756962414|fe353880fd246e8a4a6ae32152f7dbb0",]
  284.  
  285. var MAPILLARY_API_KEY = MAPILLARY_API_KEY_LIST[Math.floor(Math.random() * MAPILLARY_API_KEY_LIST.length)];
  286.  
  287. console.log("Geoguessr Unity Script v5.2.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. rtded = data.options.isRated;
  2498. }
  2499. if (rtded)
  2500. {
  2501. map_name = "Public Game";
  2502. }
  2503. else
  2504. {
  2505. if (!isBattleRoyale)
  2506. {
  2507. mapBounds = [data.bounds.max.lat, data.bounds.max.lng, data.bounds.min.lat, data.bounds.min.lng];
  2508. map_name = data.mapName;
  2509. }
  2510. else
  2511. {
  2512. if (isBullseye)
  2513. {
  2514. mapBounds = [data.boundingBox.max.lat, data.boundingBox.max.lng, data.boundingBox.min.lat, data.boundingBox.min.lng];
  2515. map_name = data.mapName;
  2516. }
  2517. else if (isDuel)
  2518. {
  2519. mapBounds = [data.mapBounds.max.lat, data.mapBounds.max.lng, data.mapBounds.min.lat, data.mapBounds.min.lng];
  2520. map_name = data.options.map.name;
  2521. }
  2522. else if (isLiveChallenge)
  2523. {
  2524. mapBounds = [data.mapBounds.max.lat, data.mapBounds.max.lng, data.mapBounds.min.lat, data.mapBounds.min.lng];
  2525. map_name = data.mapName;
  2526. }
  2527. else
  2528. {
  2529. map_name = "Unity Test";
  2530. }
  2531. }
  2532. }
  2533. if (mapBounds)
  2534. {
  2535. ms_radius = magic_formula(mapBounds);
  2536. // console.log(ms_radius / 1000)
  2537. }
  2538. loaderChecker(map_name)
  2539.  
  2540. }).catch((error) => {
  2541. console.log(error);
  2542. });
  2543.  
  2544. }
  2545.  
  2546. function guaranteeUI()
  2547. {
  2548. // console.log("UI")
  2549. if (document.getElementById("GH-ui") !== null)
  2550. {
  2551. document.getElementById("GH-ui").style.display = "block";
  2552. }
  2553. else
  2554. {
  2555. setTimeout(guaranteeUI, 500);
  2556. }
  2557. }
  2558.  
  2559. /**
  2560. * Handles Return to start and undo
  2561. */
  2562.  
  2563. function handleReturnToStart() {
  2564. let rtsButton = document.querySelector("button[data-qa='return-to-start']");
  2565. console.log("Handle Return to start");
  2566. rtsButton.addEventListener("click", (e) => {
  2567. if (nextPlayer !== "Baidu")
  2568. {
  2569. goToLocation(true);
  2570. }
  2571. else
  2572. {
  2573. document.getElementById("i_container").src = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  2574. }
  2575. const elementClicked = e.target;
  2576. elementClicked.setAttribute('listener', 'true');
  2577. console.log("Return to start");
  2578. });
  2579. guessButtonCallback();
  2580. // setTimeout(function () {goToLocation();}, 1000);
  2581. }
  2582.  
  2583. function handleUndo() {
  2584. let undoButton = document.querySelector("button[data-qa='undo-move']");
  2585. console.log("Handle undo");
  2586. undoButton.addEventListener("click", (e) => {
  2587. if (locHistory.length > 0) {
  2588. goToUndoMove();
  2589. console.log("Undo Move");
  2590. }
  2591. })
  2592. }
  2593.  
  2594. /**
  2595. * Load game information
  2596. */
  2597.  
  2598. function satCallback()
  2599. {
  2600. // console.log("Sat callback")
  2601. if (typeof MSStreetPlayer.entities !== typeof undefined && typeof Microsoft.Maps !== typeof undefined)
  2602. {
  2603. goToLocation(false);
  2604. }
  2605. else
  2606. {
  2607. setTimeout(satCallback, 250);
  2608. }
  2609. }
  2610.  
  2611. function kakaoCallback()
  2612. {
  2613. console.log("Kakao callback")
  2614. if (typeof kakao.maps !== typeof undefined)
  2615. {
  2616. goToLocation(true);
  2617. setTimeout(function () {goToLocation(true);}, 3000);
  2618. }
  2619. else
  2620. {
  2621. setTimeout(satCallback, 250);
  2622. }
  2623. }
  2624.  
  2625.  
  2626. function modularget(data)
  2627. {
  2628. if (data)
  2629. {
  2630. locationCheck(data);
  2631. if (nextPlayer == "Kakao")
  2632. {
  2633. kakaoCallback();
  2634. }
  2635. else
  2636. {
  2637. goToLocation(true);
  2638. }
  2639. handleMinimapCallback();
  2640. handleButtons();
  2641. }
  2642. }
  2643.  
  2644. function getMapData() {
  2645. // myHighlight("Seed data");
  2646.  
  2647. getSeed().then((data) => {
  2648. let switchCovergeButton = document.getElementById("switch");
  2649. let mainMenuBtn = document.getElementById("Show Buttons")
  2650. if (isBattleRoyale) {
  2651. if (data.status == "Finished" || typeof data.gameId == typeof undefined) {
  2652. // console.log("Battle Royale Lobby");
  2653. }
  2654. else
  2655. {
  2656. let origin = false;
  2657. if (!CURRENT_ROUND_DATA) {
  2658. CURRENT_ROUND_DATA = data
  2659. origin = true;
  2660. }
  2661.  
  2662. if (origin || !(data.currentRoundNumber === CURRENT_ROUND_DATA.currentRoundNumber)) {
  2663. // myHighlight("Battle Royale New round");
  2664. switchCovergeButton.init = true;
  2665. // NEW_ROUND_LOADED = true;
  2666. COMPASS = null;
  2667. locHistory = [];
  2668. one_reset = false;
  2669. setHidden(false);
  2670. if (!origin) {
  2671. CURRENT_ROUND_DATA = data;
  2672. }
  2673. modularget(data);
  2674. }
  2675. }
  2676. }
  2677. else {
  2678. if (!cn_tips)
  2679. {
  2680. mainMenuBtn.style.visibility = "";
  2681. }
  2682. else
  2683. {
  2684. mainMenuBtn.style.visibility = "hidden";
  2685. AdjustBtnPos("14em", "0em");
  2686. }
  2687. modularget(data);
  2688. }
  2689.  
  2690. }).catch((error) => {
  2691. console.log(error);
  2692. });
  2693. }
  2694.  
  2695. function handleMinimapCallback()
  2696. {
  2697. let trueCond = true;
  2698. let timeoutTime = 250;
  2699. if (isBattleRoyale) {
  2700. if (isDuel)
  2701. {
  2702. if (document.querySelector(".overlay_overlay__AR02x"))
  2703. {
  2704. trueCond = false;
  2705. }
  2706. else
  2707. {
  2708. trueCond = true;
  2709. }
  2710. }
  2711. else
  2712. {
  2713. if (document.querySelector(".popup__content"))
  2714. {
  2715. trueCond = false;
  2716. }
  2717. else
  2718. {
  2719. trueCond = true;
  2720. }
  2721. }
  2722. timeoutTime = 2500;
  2723. }
  2724.  
  2725. if (trueCond)
  2726. {
  2727. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2728. let cur = MinimapBtn.current;
  2729. // console.log(cur)
  2730. for (let mapDiv of document.getElementsByClassName("preset-minimap")){
  2731. if (cur == mapDiv.id)
  2732. {
  2733. setTimeout(function () {mapDiv.click();}, 500);
  2734. setTimeout(function () {mapDiv.click();}, 1000);
  2735. setTimeout(function () {mapDiv.click();}, 3000);
  2736. }
  2737. }
  2738. }
  2739. else
  2740. {
  2741. setTimeout(handleMinimapCallback, timeoutTime);
  2742. }
  2743. }
  2744.  
  2745. /**
  2746. * Hide unnecessary buttons for non-Google coverages
  2747. */
  2748.  
  2749. function handleButtons() {
  2750. let CHECKPOINT = document.querySelector("button[data-qa='set-checkpoint']");
  2751. let ZOOM_IN = document.querySelector("button[data-qa='pano-zoom-in']");
  2752. let ZOOM_OUT = document.querySelector("button[data-qa='pano-zoom-out']");
  2753. let UNDO_MOVE = document.querySelector("button[data-qa='undo-move']");
  2754. let DEFAULT_COMPASS = document.querySelector(".compass");
  2755. let NEW_COMPASS = document.querySelector(".panorama-compass_compassContainer__MEnh0");
  2756. let RETURN_TO_START = document.querySelector("button[data-qa='return-to-start']");
  2757.  
  2758. let C1 = (CHECKPOINT !== null);
  2759. let C2 = (ZOOM_IN !== null);
  2760. let C3 = (ZOOM_OUT !== null);
  2761. let C4 = (UNDO_MOVE !== null);
  2762. let C5 = (DEFAULT_COMPASS !== null);
  2763. let C6 = (NEW_COMPASS !== null);
  2764. let C7 = (RETURN_TO_START !== null);
  2765.  
  2766. let waitCond = C5 || C6;
  2767. let cpCond = true;
  2768. let comCond = true;
  2769. if (!NM)
  2770. {
  2771. cpCond = C1 && C4 && C7;
  2772. }
  2773. if (!NZ)
  2774. {
  2775. comCond = C2 && C3;
  2776. }
  2777.  
  2778. function moduleButtons(cond)
  2779. {
  2780.  
  2781. if (!NM)
  2782. {
  2783. CHECKPOINT.style.visibility = cond;
  2784. UNDO_MOVE.style.visibility = cond;
  2785. }
  2786. if (!NZ)
  2787. {
  2788. ZOOM_IN.style.visibility = cond;
  2789. ZOOM_OUT.style.visibility = cond;
  2790. }
  2791. if (C5)
  2792. {
  2793. DEFAULT_COMPASS.style.visibility = cond;
  2794. }
  2795. if (C6)
  2796. {
  2797. NEW_COMPASS.style.visibility = cond;
  2798. }
  2799. }
  2800.  
  2801. if (waitCond && cpCond && comCond)
  2802. {
  2803. console.log("Handle Buttons");
  2804. if (nextPlayer === "Google") {
  2805. moduleButtons("");
  2806. }
  2807. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image" || nextPlayer === "Bing Satellite")
  2808. {
  2809. moduleButtons("hidden");
  2810. }
  2811. else if (nextPlayer === "Yandex" || nextPlayer === "Kakao" || nextPlayer === "Mapillary" || nextPlayer === "Bing Streetside")
  2812. {
  2813. moduleButtons("hidden");
  2814. if (nextPlayer === "Yandex" || nextPlayer === "Kakao")
  2815. {
  2816. if (C5)
  2817. {
  2818. DEFAULT_COMPASS.style.visibility = "";
  2819. }
  2820. if (C6)
  2821. {
  2822. NEW_COMPASS.style.visibility = "";
  2823. }
  2824. }
  2825. if (!NM)
  2826. {
  2827. UNDO_MOVE.style.visibility = "";
  2828. handleUndo();
  2829. }
  2830. }
  2831. if (!NM)
  2832. {
  2833. handleReturnToStart();
  2834. }
  2835. }
  2836. else
  2837. {
  2838. setTimeout(handleButtons, 250);
  2839. }
  2840. }
  2841.  
  2842. /**
  2843. * Check which player to use for the next location
  2844. */
  2845.  
  2846. function locationCheck(data) {
  2847. // console.log(data);
  2848. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  2849. let round;
  2850.  
  2851.  
  2852.  
  2853. if (isBattleRoyale) {
  2854. if (isDuel || isBullseye || isLiveChallenge)
  2855. {
  2856. round = data.rounds[data.currentRoundNumber - 1].panorama;
  2857. }
  2858. else
  2859. {
  2860. round = data.rounds[data.currentRoundNumber - 1];
  2861. }
  2862. }
  2863. else {
  2864. round = data.rounds[data.round - 1];
  2865. }
  2866. global_lat = round.lat;
  2867. global_lng = round.lng;
  2868. global_panoID = round.panoId;
  2869. global_heading = round.heading;
  2870. global_pitch = round.pitch;
  2871.  
  2872. nextPlayer = "Google";
  2873.  
  2874. // if (ms_sat_map)
  2875. // {
  2876. // nextPlayer = "Bing Satellite";
  2877. // }
  2878.  
  2879. if (global_panoID) {
  2880. let locInfo;
  2881. if (isBullseye || isLiveChallenge)
  2882. {
  2883. locInfo = global_panoID;
  2884. }
  2885. else
  2886. {
  2887. locInfo = hex2a(global_panoID);
  2888. }
  2889. // console.log(locInfo)
  2890. if (locInfo.substring(0, 3) == "YTB")
  2891. {
  2892. nextPlayer = "Youtube";
  2893. let lengths = [3, 11, 4, 4];
  2894. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2895. let fullID = locInfo.substring(3).split('START');
  2896. yId = toPiece[1];
  2897. yTime = Number(toPiece[2]);
  2898. yEnd = Number(toPiece[3]);
  2899. }
  2900. else
  2901. {
  2902. let mapType = locInfo.substring(0, 5);
  2903.  
  2904. // panoId unchanged
  2905.  
  2906. if (mapType === "YDMAP" ) {
  2907. nextPlayer = "Yandex";
  2908. }
  2909. else if (mapType === "KKMAP" ) {
  2910. nextPlayer = "Kakao";
  2911. }
  2912.  
  2913. // New panoId formats
  2914.  
  2915. else if (mapType === "BAIDU" ) {
  2916. nextPlayer = "Baidu";
  2917. let lengths = [5, 7, 7, 3];
  2918. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2919. let panoId1 = base62.decode(toPiece[1]).toString().substring(1);
  2920. let panoId2 = base62.decode(toPiece[2]).toString().substring(1);
  2921. global_BDID = panoId1 + panoId2 + toPiece[3]
  2922. }
  2923. else if (mapType === "MAPIL")
  2924. {
  2925. nextPlayer = "Mapillary";
  2926. mmKey = locInfo.substring(5).replace(/\D/g,'');
  2927. }
  2928. else if (mapType === "IMAGE")
  2929. {
  2930. nextPlayer = "Image";
  2931. let lengths = [5, 4, 4, 7, 2];
  2932. let toPiece = lengths.map((p => i => locInfo.slice(p, p += i))(0));
  2933. iId = "https://i.ibb.co/" + toPiece[3] + "/" + toPiece[1] + "." + toPiece[2].replace(/[^0-9a-z]/gi, '')
  2934. }
  2935. else if (mapType === "BINGM" ) {
  2936. nextPlayer = "Bing Streetside";
  2937. }
  2938. else if (mapType === "SATEL" ) {
  2939. nextPlayer = "Bing Satellite";
  2940. ms_radius = parseInt(locInfo.substring(5).replace(/\D/g,'')) * 1000;
  2941. }
  2942.  
  2943. // legacy panoId formats support
  2944.  
  2945. else if (mapType === "BDMAP") {
  2946. nextPlayer = "Baidu";
  2947. let coord = locInfo.substring(5);
  2948.  
  2949. if(coord.includes('BDAh'))
  2950. {
  2951. global_BDID = coord.split('BDAh')[0].replace("panoId","");
  2952. let tem = coord.split('BDAh')[1];
  2953. global_BDAh = tem.split('BDBh')[0];
  2954. global_BDBh = tem.split('BDBh')[1];
  2955. }
  2956. else
  2957. {
  2958. global_BDID = coord.replace("panoId","");
  2959. }
  2960. }
  2961. else if (mapType === "MLMAP") {
  2962. nextPlayer = "Mapillary";
  2963. mmKey = locInfo.substring(5);
  2964. }
  2965. else
  2966. {
  2967. nextPlayer = "Google";
  2968. // GooglePlayer.setPano(locInfo);
  2969. }
  2970. }
  2971. }
  2972. else
  2973. {
  2974. if (Kakao_map)
  2975. {
  2976. nextPlayer = "Kakao";
  2977. }
  2978. else if (yandex_map)
  2979. {
  2980. nextPlayer = "Yandex";
  2981. }
  2982. else
  2983. {
  2984. nextPlayer = "Google";
  2985. }
  2986. }
  2987.  
  2988. // if ( krCoordinates[0] > global_lat && krCoordinates[2] < global_lat && krCoordinates[1] < global_lng && krCoordinates[3] > global_lng)
  2989. // {
  2990. // nextSecondaryPlayer = "Kakao";
  2991. // }
  2992. // else if (nextPlayer = "Mapillary")
  2993. // {
  2994. // nextSecondaryPlayer = "Google";
  2995. // }
  2996. // else
  2997. // {
  2998. // nextSecondaryPlayer = "Mapillary";
  2999. // }
  3000.  
  3001. // Disable buttons if NM, NMPZ
  3002.  
  3003. if(!isBattleRoyale)
  3004. {
  3005. NM = data.forbidMoving;
  3006. NP = data.forbidRotating;
  3007. NZ = data.forbidZooming;
  3008. }
  3009. else
  3010. {
  3011. // console.log(data)
  3012. if (isBullseye || isLiveChallenge)
  3013. {
  3014. NM = data.options.movementOptions.forbidMoving;
  3015. NP = data.options.movementOptions.forbidRotating;
  3016. NZ = data.options.movementOptions.forbidZooming;
  3017. }
  3018. else
  3019. {
  3020. NM = data.movementOptions.forbidMoving;
  3021. NP = data.movementOptions.forbidRotating;
  3022. NZ = data.movementOptions.forbidZooming;
  3023. }
  3024. }
  3025. if (NM || NP || NZ)
  3026. {
  3027.  
  3028. setDisable("NMPZ");
  3029. }
  3030. else
  3031. {
  3032. setDisable(nextPlayer);
  3033. }
  3034.  
  3035. if (nextPlayer == "Google")
  3036. {
  3037. switchCovergeButton.innerHTML = "Switch to Mapillary";
  3038. }
  3039. else
  3040. {
  3041. switchCovergeButton.innerHTML = "Switch to Google";
  3042. }
  3043. nextPlayer_save = nextPlayer;
  3044. console.log(nextPlayer_save);
  3045.  
  3046. // console.log("??")
  3047. // console.log(sessionStorage.getItem('Satellite') == "T")
  3048. if (ms_sat_map || (sessionStorage.getItem('Satellite') == "T" && nextPlayer !== "Baidu" && nextPlayer !== "Bing Streetside" && !rtded))
  3049. {
  3050. nextPlayer = "Bing Satellite";
  3051. }
  3052.  
  3053. if (nextPlayer == "Bing Satellite")
  3054. {
  3055. let di3 = formatDist();
  3056. satelliteSwitchButton.innerHTML = `Satellite (${di3})`;
  3057. }
  3058. else
  3059. {
  3060. satelliteSwitchButton.innerHTML = "Streeview mode";
  3061. }
  3062. console.log(nextPlayer);
  3063.  
  3064.  
  3065. injectCanvas(false);
  3066. }
  3067.  
  3068.  
  3069. /**
  3070. * setID for canvas
  3071. */
  3072.  
  3073. function initializeCanvas() {
  3074. let GAME_CANVAS = "";
  3075. let DUEL_CANVAS = "";
  3076. //console.log("Is duels");
  3077. //console.log(duels);
  3078.  
  3079. if (isBattleRoyale) {
  3080. if (isDuel) {
  3081. GAME_CANVAS = document.querySelector(".game-panorama_panorama__rdhFg");
  3082. DUEL_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__PNKve");
  3083. }
  3084. else if (isBullseye) {
  3085. GAME_CANVAS = document.querySelector(".game-panorama_panorama__ncMwh");
  3086. DUEL_CANVAS = "dummy";
  3087. }
  3088. else if (isLiveChallenge)
  3089. {
  3090. GAME_CANVAS = document.querySelector(".game-panorama_panorama__6RmkO");
  3091. DUEL_CANVAS = "dummy";
  3092. }
  3093. else
  3094. {
  3095. GAME_CANVAS = document.querySelector(".br-game-layout__panorama-wrapper");
  3096. DUEL_CANVAS = "dummy";
  3097. }
  3098. }
  3099. else {
  3100. GAME_CANVAS = document.querySelector(".game-layout__canvas");
  3101. DUEL_CANVAS = "dummy";
  3102. }
  3103. if (GAME_CANVAS && DUEL_CANVAS)
  3104. {
  3105. // console.log("Canvas injected");
  3106. GAME_CANVAS.id = "player";
  3107.  
  3108. if (isDuel) {
  3109. DUEL_CANVAS.id = "default_player";
  3110. }
  3111. partialCreateMapillary = (typeof mapillary !== typeof undefined)
  3112. partialCreateYandex = (typeof ymaps !== typeof undefined)
  3113. partialCreateKakao = (typeof kakao !== typeof undefined)
  3114. partialCreateMS = (typeof Microsoft !== typeof undefined);
  3115. loadPlayers();
  3116. injectMapillaryPlayer();
  3117. }
  3118. else
  3119. {
  3120. setTimeout(initializeCanvas, 250);
  3121. }
  3122.  
  3123. }
  3124.  
  3125. /**
  3126. * Hide or show players based on where the next location is
  3127. */
  3128.  
  3129. function injectCanvas(cond) {
  3130. if (isDuel)
  3131. {
  3132. canvasSwitch(cond);
  3133. }
  3134. else
  3135. {
  3136. // console.log("BING??")
  3137. // console.log(BR_LOAD_MS)
  3138.  
  3139. Google();
  3140. Baidu();
  3141. if (BR_LOAD_KAKAO)
  3142. {
  3143. Kakao();
  3144. }
  3145. if (BR_LOAD_YANDEX)
  3146. {
  3147. Yandex();
  3148. }
  3149. if (BR_LOAD_MS)
  3150. {
  3151. // console.log("Yes")
  3152. Bing(cond);
  3153. }
  3154. Mapillary();
  3155. }
  3156. ZoomControls();
  3157. }
  3158.  
  3159. // for duels (class ID change)
  3160.  
  3161. function canvasSwitch(cond)
  3162. {
  3163.  
  3164. console.log("canvas switch")
  3165. // let cond = true;
  3166. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3167. let GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panorama__rdhFg");
  3168. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  3169. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  3170. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  3171. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  3172. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  3173. // 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])
  3174.  
  3175. 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))
  3176. {
  3177. document.getElementById("default_player").style.position = "absolute";
  3178. document.getElementById("default_player").className = "inactive";
  3179. BAIDU_MAPS_CANVAS.style.position = "absolute";
  3180. BAIDU_MAPS_CANVAS.className = "inactive";
  3181. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  3182. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  3183. MAPILLARY_MAPS_CANVAS.className = "inactive";
  3184. if (BR_LOAD_KAKAO)
  3185. {
  3186. KAKAO_MAPS_CANVAS.style.position = "absolute";
  3187. KAKAO_MAPS_CANVAS.className = "inactive";
  3188. }
  3189. if (BR_LOAD_YANDEX)
  3190. {
  3191. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  3192. YANDEX_MAPS_CANVAS.style.position = "absolute";
  3193. }
  3194. if (BR_LOAD_MS)
  3195. {
  3196. BING_MAPS_CANVAS.style.position = "absolute";
  3197. BING_MAPS_CANVAS.className = "inactive";
  3198. }
  3199.  
  3200. if (!cond)
  3201. {
  3202. teleportBtn.google = false;
  3203. switchCovergeButton.useGoogle = false;
  3204. }
  3205.  
  3206. if (nextPlayer === "Google") {
  3207. document.getElementById("default_player").className = "game-panorama_panoramaCanvas__PNKve";
  3208. teleportBtn.google = true;
  3209. switchCovergeButton.useGoogle = true;
  3210. console.log("Google Duel Canvas loaded");
  3211. }
  3212. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image")
  3213. {
  3214. BAIDU_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3215. console.log("Container Duel Canvas loaded");
  3216. }
  3217. else if (nextPlayer === "Kakao")
  3218. {
  3219. if (BR_LOAD_KAKAO)
  3220. {
  3221. KAKAO_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3222. }
  3223. console.log("Kakao Duel Canvas loaded");
  3224. }
  3225. else if (nextPlayer === "Yandex")
  3226. {
  3227. if (BR_LOAD_YANDEX)
  3228. {
  3229. YANDEX_MAPS_CANVAS.style.visibility = "";
  3230. }
  3231. console.log("Yandex Duel Canvas loaded");
  3232. }
  3233. else if (nextPlayer === "Mapillary")
  3234. {
  3235. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  3236. MAPILLARY_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3237. // MapillaryPlayer.resize();
  3238. console.log("Mapillary Duel Canvas loaded");
  3239. }
  3240. else if (nextPlayer === "Bing Streetside" || nextPlayer === "Bing Satellite")
  3241. {
  3242. if (BR_LOAD_MS)
  3243. {
  3244. BING_MAPS_CANVAS.className = "game-panorama_panorama__rdhFg";
  3245. }
  3246. console.log("MS Duel Canvas loaded");
  3247. }
  3248. }
  3249. else
  3250. {
  3251. setTimeout(canvasSwitch(cond), 1000);
  3252. }
  3253. }
  3254.  
  3255. // for Battle Royale and classic (change visibility)
  3256.  
  3257. function Google() {
  3258. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3259. let GOOGLE_MAPS_CANVAS = ""
  3260. if (isBattleRoyale) {
  3261. if (isBullseye)
  3262. {
  3263. GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__r_5ea");
  3264. }
  3265. else if (isLiveChallenge)
  3266. {
  3267. GOOGLE_MAPS_CANVAS = document.querySelector(".game-panorama_panoramaCanvas__gp8og");
  3268. }
  3269. else
  3270. {
  3271. GOOGLE_MAPS_CANVAS = document.querySelector(".br-game-layout__panorama-canvas");
  3272. }
  3273. }
  3274. else {
  3275. GOOGLE_MAPS_CANVAS = document.querySelector(".game-layout__panorama-canvas");
  3276. }
  3277. if (GOOGLE_MAPS_CANVAS !== null)
  3278. {
  3279. if (nextPlayer === "Google") {
  3280. GOOGLE_MAPS_CANVAS.style.visibility = "";
  3281. teleportBtn.google = true;
  3282. switchCovergeButton.useGoogle = true;
  3283. }
  3284. else {
  3285. GOOGLE_MAPS_CANVAS.style.visibility = "hidden";
  3286. teleportBtn.google = false;
  3287. }
  3288. }
  3289. else
  3290. {
  3291. setTimeout(Google, 250);
  3292. }
  3293. }
  3294.  
  3295. function Baidu() {
  3296. let BAIDU_MAPS_CANVAS = document.getElementById("i_container");
  3297. // console.log("Baidu canvas");
  3298. if (BAIDU_MAPS_CANVAS !== null)
  3299. {
  3300. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3301. BAIDU_MAPS_CANVAS.style.position = "absolute";
  3302. if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  3303. BAIDU_MAPS_CANVAS.style.visibility = "";
  3304. switchCovergeButton.useGoogle = false;
  3305. console.log("Container Canvas loaded");
  3306. }
  3307. else {
  3308. BAIDU_MAPS_CANVAS.style.visibility = "hidden";
  3309. // console.log("Container Canvas hidden");
  3310. }
  3311. }
  3312. else
  3313. {
  3314. setTimeout(Baidu, 250);
  3315. }
  3316.  
  3317. }
  3318.  
  3319. function Kakao() {
  3320. let KAKAO_MAPS_CANVAS = document.getElementById("roadview");
  3321. // console.log("Kakao canvas");
  3322. if (KAKAO_MAPS_CANVAS != null)
  3323. {
  3324. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3325. KAKAO_MAPS_CANVAS.style.position = "absolute";
  3326. if (nextPlayer === "Kakao") {
  3327. KAKAO_MAPS_CANVAS.style.visibility = "";
  3328. switchCovergeButton.useGoogle = false;
  3329. console.log("Kakao Canvas loaded");
  3330. }
  3331. else {
  3332. KAKAO_MAPS_CANVAS.style.visibility = "hidden";
  3333. // console.log("Kakao Canvas hidden");
  3334. }
  3335. }
  3336. else
  3337. {
  3338. setTimeout(Kakao, 250);
  3339. }
  3340.  
  3341. }
  3342.  
  3343. function Yandex() {
  3344. let YANDEX_MAPS_CANVAS = document.querySelector(".ymaps-2-1-79-panorama-screen");
  3345. if (YANDEX_MAPS_CANVAS != null)
  3346. {
  3347. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3348. if (isBullseye)
  3349. {
  3350. let div = document.getElementById("player");
  3351. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__ncMwh");
  3352. div.prepend(YANDEX_MAPS_CANVAS);
  3353. }
  3354. if (isLiveChallenge)
  3355. {
  3356. let div = document.getElementById("player");
  3357. YANDEX_MAPS_CANVAS.classList.add("game-panorama_panorama__6RmkO");
  3358. div.prepend(YANDEX_MAPS_CANVAS);
  3359. }
  3360. // console.log("Yandex canvas");
  3361. document.querySelector(".ymaps-2-1-79-panorama-screen").style.position = "absolute";
  3362. // console.log("Yandex canvas");
  3363. /* console.log(YANDEX_MAPS_CANVAS); */
  3364. if (nextPlayer === "Yandex") {
  3365. YANDEX_MAPS_CANVAS.style.visibility = "";
  3366. switchCovergeButton.useGoogle = false;
  3367. console.log("Yandex Canvas loaded");
  3368. }
  3369. else {
  3370. YANDEX_MAPS_CANVAS.style.visibility = "hidden";
  3371. console.log("Yandex Canvas hidden");
  3372. }
  3373. }
  3374. else
  3375. {
  3376. setTimeout(Yandex, 250);
  3377. }
  3378.  
  3379. }
  3380.  
  3381. function Mapillary()
  3382. {
  3383. let MAPILLARY_MAPS_CANVAS = document.getElementById("mapillary-player");
  3384. if (MAPILLARY_MAPS_CANVAS != null)
  3385. {
  3386. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3387. // console.log("Mapillary canvas");
  3388. MAPILLARY_MAPS_CANVAS.style.position = "absolute";
  3389. if (nextPlayer === "Mapillary") {
  3390. MAPILLARY_MAPS_CANVAS.style.visibility = "";
  3391. switchCovergeButton.useGoogle = false;
  3392. console.log("Mapillary Canvas loaded");
  3393.  
  3394. }
  3395. else {
  3396. MAPILLARY_MAPS_CANVAS.style.visibility = "hidden";
  3397. // console.log("Mapillary Canvas hidden");
  3398. }
  3399. }
  3400. else
  3401. {
  3402. setTimeout(Mapillary, 250);
  3403. }
  3404.  
  3405. }
  3406.  
  3407. function Bing(cond) {
  3408. let BING_MAPS_CANVAS = document.getElementById("ms-player");
  3409. // console.log("stuck")
  3410. if (BING_MAPS_CANVAS != null)
  3411. {
  3412. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3413. // console.log("Mapillary canvas");
  3414. BING_MAPS_CANVAS.style.position = "absolute";
  3415. if (nextPlayer === "Bing Satellite" || nextPlayer === "Bing Streetside") {
  3416. BING_MAPS_CANVAS.style.visibility = "";
  3417. if (!cond)
  3418. {
  3419. switchCovergeButton.useGoogle = false;
  3420. }
  3421. console.log("Bing Canvas loaded");
  3422. }
  3423. else {
  3424. BING_MAPS_CANVAS.style.visibility = "hidden";
  3425. // console.log("Bing Canvas hidden");
  3426. }
  3427. }
  3428. else
  3429. {
  3430. setTimeout(Bing(cond), 500)
  3431. }
  3432. }
  3433.  
  3434.  
  3435. /**
  3436. * Adjust button placement
  3437. */
  3438.  
  3439. function ZoomControls() {
  3440. let style = `
  3441. .ymaps-2-1-79-panorama-gotoymaps {display: none !important;}
  3442. .ymaps-2-1-79-panorama-control__zoom {top: 2rem !important; left: 2rem !important; z-Index: 0}
  3443. .mapillary-bearing-indicator-container {top: 2rem !important; left: 2rem !important;}
  3444. .mapillary-zoom-container {top: 6rem !important; left: 2.20rem !important;}
  3445. .NavBar_MapTypeButtonContainerWrapper {visibility: hidden !important;}
  3446. .bm_LocateMeControl {visibility: hidden !important;}
  3447. .NavBar_Container {top: -6rem !important; left: 2rem !important;}
  3448. .streetsideToolPanel {top: 4rem !important; left: 2rem !important;}
  3449. .NavBarButton_Container {visibility: hidden !important;}
  3450. `;
  3451.  
  3452. // let nav = document.querySelector('.NavBar_MapTypeButtonContainerWrapper');
  3453. // let locate = document.getElementById("LocateMeButton");
  3454. // let navAll = document.getElementById("MicrosoftNav");
  3455. // if (nav)
  3456. // {
  3457. // nav.style.visibility = "hidden";
  3458. // }
  3459. // if (locate)
  3460. // {
  3461. // locate.style.visibility = "hidden";
  3462. // }
  3463. // if (navAll)
  3464. // {
  3465. // navAll.style.top = "15em"
  3466. // }
  3467.  
  3468. let style_element = document.createElement("style");
  3469. style_element.innerHTML = style;
  3470. document.body.appendChild(style_element);
  3471. // document.getElementById("mapillary-bearing-indicator-container").style.top = "20em"
  3472. }
  3473.  
  3474. /**
  3475. * Updates the compass to match Yandex Panorama facing
  3476. */
  3477. function updateCompass() {
  3478. if (!COMPASS) {
  3479. let compass = document.querySelector("img.compass__indicator");
  3480. if (compass != null) {
  3481. COMPASS = compass;
  3482. let direction = YandexPlayer.getDirection()[0] * -1;
  3483. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  3484. }
  3485. }
  3486. else {
  3487. let direction = YandexPlayer.getDirection()[0] * -1;
  3488. COMPASS.setAttribute("style", `transform: rotate(${direction}deg);`);
  3489. }
  3490. }
  3491.  
  3492. /**
  3493. * Open next location in streetview player given next player and next coordinate
  3494. */
  3495.  
  3496.  
  3497.  
  3498. function goToLocation(cond) {
  3499. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3500. console.log("Going to location");
  3501. console.log(nextPlayer);
  3502. if (nextPlayer === "Yandex") {
  3503. let options = {};
  3504. YandexPlayer.moveTo([global_lat, global_lng], options);
  3505. YandexPlayer.setDirection([0, 16]);
  3506. YandexPlayer.setSpan([10, 67]);
  3507. }
  3508. else if (nextPlayer === "Baidu" || nextPlayer === "Youtube" || nextPlayer === "Image") {
  3509. if (document.getElementById("i_container") !== null)
  3510. {
  3511. let iframe = document.getElementById("i_container");
  3512. if (nextPlayer === "Baidu")
  3513. {
  3514. if (!isFirefox)
  3515. {
  3516. iframe.style.top = '-60px';
  3517. iframe.style.height = (window.innerHeight + 200) + 'px';
  3518. }
  3519. else
  3520. {
  3521. iframe.style.top = '-60px';
  3522. iframe.style.height = (window.innerHeight + 219) + 'px';
  3523. }
  3524.  
  3525. if (!isFirefox)
  3526. {
  3527. iframe.style.right = '-55px';
  3528. iframe.style.width = (window.innerWidth + 55) + 'px';
  3529. }
  3530. else
  3531. {
  3532. iframe.style.right = '-15px';
  3533. iframe.style.width = (window.innerWidth + 15) + 'px';
  3534. }
  3535. let urlStr2 = "https://map.baidu.com/?panotype=street&pid=" + global_BDID + "&panoid=" + global_BDID + "&from=api";
  3536. 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;
  3537. // console.log(urlStr)
  3538. if (global_BDAh != null)
  3539. {
  3540. iframe.src = urlStr;
  3541. }
  3542. else
  3543. {
  3544. iframe.src = urlStr2;
  3545. }
  3546. iframe.style.visibility = "";
  3547. }
  3548. else if (nextPlayer === "Youtube")
  3549. {
  3550. document.getElementById("Youtube Button").style.visibility = "";
  3551. document.getElementById("Youtube Button").innerHTML = "Play video";
  3552. iframe.allow = "autoplay";
  3553. iframe.style.visibility = "hidden";
  3554. iframe.style.top = '-60px';
  3555. iframe.style.height = (window.innerHeight + 235) + 'px';
  3556. mainMenuBtn.innerHTML = "<font size=2>Unity<br><font size=1>v5.2.7</font>";
  3557. mainMenuBtn.style.width = "3em"
  3558. mainMenuBtn.style.backgroundPosition = "";
  3559. mainMenuBtn.backgroundColor = ""
  3560. }
  3561. else if (nextPlayer === "Image")
  3562. {
  3563. iframe.style.top = '0px';
  3564. iframe.style.height = (window.innerHeight) + 'px';
  3565. iframe.style.visibility = "";
  3566. iframe.src = iId;
  3567. }
  3568. }
  3569. else
  3570. {
  3571. setTimeout(goToLocation(true), 250);
  3572. }
  3573. // let a = new BMap.Point(global_lng, global_lat);
  3574. // BaiduPlayer.setPov({ heading: -40, pitch: 6 });
  3575. // BaiduPlayer.setPosition(a);
  3576. }
  3577. else if (nextPlayer === "Kakao") {
  3578. var roadviewClient = new kakao.maps.RoadviewClient();
  3579. var position = new kakao.maps.LatLng(global_lat, global_lng);
  3580. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3581. KakaoPlayer.setPanoId(panoId, position);
  3582. KakaoPlayer.setViewpoint({ pan: global_heading, tilt: global_pitch, zoom: -3 })
  3583. });
  3584. }
  3585. else if (nextPlayer === "Mapillary") {
  3586. MapillaryPlayer.resize()
  3587. MapillaryPlayer.moveTo(mmKey).then(
  3588. image => { //console.log(image);
  3589. },
  3590. error => { console.log(error); });
  3591. }
  3592. else if (nextPlayer === "Google") {
  3593. handleMapillary({lat: global_lat, lng: global_lng}, {meters: 500, limit: 500});
  3594. }
  3595. else if (nextPlayer === "Bing Streetside") {
  3596. let mTId = MSStreetPlayer.getMapTypeId();
  3597. if (mTId !== Microsoft.Maps.MapTypeId.streetside && mTId !== Microsoft.Maps.MapTypeId.road)
  3598. {
  3599. console.log("Reset Bing map type to Streetside")
  3600. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  3601. }
  3602. MSStreetPlayer.setOptions({disableStreetside: false});
  3603. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.streetside,
  3604. zoom: 18,
  3605. streetsideOptions: {
  3606. overviewMapMode: Microsoft.Maps.OverviewMapMode.hidden,
  3607. showCurrentAddress: false,
  3608. showProblemReporting: false,
  3609. showExitButton: false,
  3610. },
  3611. center: new Microsoft.Maps.Location(global_lat, global_lng),
  3612. heading: 90,
  3613. pitch: -30});
  3614. }
  3615. else if (nextPlayer === "Bing Satellite") {
  3616. // console.log("Bing Satellite Player")
  3617. let mTId = MSStreetPlayer.getMapTypeId();
  3618. if (mTId !== Microsoft.Maps.MapTypeId.aerial && mTId !== Microsoft.Maps.MapTypeId.road)
  3619. {
  3620. console.log("Reset Bing map type to Satellite")
  3621. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  3622. }
  3623. // MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  3624. let ctr = new Microsoft.Maps.Location(global_lat, global_lng)
  3625. let loc_centre = {lat: global_lat, lng: global_lng};
  3626. for (var i = MSStreetPlayer.entities.getLength() - 1; i >= 0; i--) {
  3627. var pushpin = MSStreetPlayer.entities.get(i);
  3628. if (pushpin instanceof Microsoft.Maps.Pushpin) {
  3629. MSStreetPlayer.entities.removeAt(i);
  3630. }
  3631. }
  3632. // console.log("Satellite radius: " + (ms_radius / 1000).toString() + "km");
  3633. let latlngBounds = getBBox2(loc_centre, ms_radius);
  3634. // console.log(latlngBounds)
  3635. let bounds = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(latlngBounds[0], latlngBounds[1]), new Microsoft.Maps.Location(latlngBounds[2], latlngBounds[3]));
  3636. MSStreetPlayer.setOptions({maxBounds: bounds})
  3637. // console.log(bounds)
  3638. // console.log(Microsoft.Maps.LabelOverlay.hidden)
  3639. if (ms_birdseye || ms_random)
  3640. {
  3641. let dg = 0;
  3642. if (ms_random)
  3643. {
  3644. dg = (Math.floor(Math.random() * 4)) * 90
  3645. }
  3646. Microsoft.Maps.getIsBirdseyeAvailable(ctr, dg, onResponse);
  3647. function onResponse(isAvailable) {
  3648. console.log("Birds-eye");
  3649. console.log(isAvailable);
  3650. MSStreetPlayer.setView({mapTypeId: isAvailable ? Microsoft.Maps.MapTypeId.birdseye : Microsoft.Maps.MapTypeId.aerial,
  3651. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  3652. center: ctr,
  3653. zoom: 15,
  3654. })
  3655. FixLink();
  3656. }
  3657. }
  3658. else
  3659. {
  3660. MSStreetPlayer.setOptions({disableStreetside: true});
  3661. MSStreetPlayer.setView({mapTypeId: Microsoft.Maps.MapTypeId.aerial,
  3662. labelOverlay: Microsoft.Maps.LabelOverlay.hidden,
  3663. center: ctr,
  3664. zoom: 15,
  3665. })
  3666. }
  3667.  
  3668. var pin = new Microsoft.Maps.Pushpin(ctr, {});
  3669.  
  3670. //Add the pushpin to the map
  3671. MSStreetPlayer.entities.push(pin);
  3672.  
  3673.  
  3674.  
  3675.  
  3676. FixLink();
  3677. // hideNav();
  3678. }
  3679. if (cond)
  3680. {
  3681. switchCovergeButton.lat = global_lat;
  3682. switchCovergeButton.lng = global_lng;
  3683. }
  3684. }
  3685.  
  3686. function FixLink()
  3687. {
  3688. let ele = document.querySelector('[title="Microsoft Bing"]');
  3689. // console.log("?")
  3690. if (ele)
  3691. {
  3692. // console.log("!")
  3693. ele.href = "#";
  3694. }
  3695. else
  3696. {
  3697. setTimeout(FixLink, 250);
  3698. }
  3699. }
  3700.  
  3701. /**
  3702. * Handle undo using the location history of the current round
  3703. */
  3704.  
  3705. function goToUndoMove(data) {
  3706. /* console.log(global_lat);
  3707. console.log(global_lng); */
  3708. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3709. let options = {};
  3710. let prevStep = null;
  3711. if (locHistory.length === 1) {
  3712. prevStep = locHistory[0];
  3713. }
  3714. else {
  3715. prevStep = locHistory.pop();
  3716. }
  3717. // console.log(prevStep);
  3718. // console.log(locHistory)
  3719. if (nextPlayer === "Yandex") {
  3720. defaultPanoIdChange = false;
  3721. YandexPlayer.moveTo([prevStep[0], prevStep[1]], options);
  3722. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  3723. YandexPlayer.setSpan([10, 67]);
  3724. switchCovergeButton.lat = prevStep[0];
  3725. switchCovergeButton.lng = prevStep[1];
  3726. }
  3727. else if (nextPlayer === "Kakao") {
  3728. let btn = document.querySelector("button[data-qa='undo-move']");
  3729. btn.disabled = false;
  3730. btn.classList.remove('styles_disabled__2YdHD');
  3731. defaultPanoIdChange = false;
  3732. let position = new kakao.maps.LatLng(prevStep[0], prevStep[1]);
  3733. KakaoPlayer.setPanoId(prevStep[2], position);
  3734. switchCovergeButton.lat = prevStep[0];
  3735. switchCovergeButton.lng = prevStep[1];
  3736. switchCovergeButton.useGoogle = false;
  3737. teleportBtn.google = false;
  3738. // console.log("Undo 1 step");
  3739. // console.log(locHistory);
  3740. }
  3741. else if (nextPlayer === "Mapillary" ) {
  3742. // console.log(prevStep[1]);
  3743.  
  3744. MapillaryPlayer.moveTo(prevStep[2]).then(
  3745. image => {
  3746. //console.log(image);
  3747. switchCovergeButton.lat = prevStep[1];
  3748. switchCovergeButton.lng = prevStep[0];
  3749. },
  3750. error => { console.log(error); });
  3751. }
  3752. else if (nextPlayer === "Bing Streetside") {
  3753. defaultPanoIdChange = false;
  3754. // console.log(locHistory);
  3755. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(prevStep[0], prevStep[1]),});
  3756. switchCovergeButton.lat = prevStep[0];
  3757. switchCovergeButton.lng = prevStep[1];
  3758. switchCovergeButton.heading = prevStep[2];
  3759. }
  3760.  
  3761. }
  3762.  
  3763. function handleTeleport()
  3764. {
  3765. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3766. if (teleportBtn)
  3767. {
  3768. teleportBtn.addEventListener("click", () => {
  3769. if (!teleportBtn.google)
  3770. {
  3771. // console.log("non-Google Teleport");
  3772. let prevStep = null;
  3773. if (locHistory.length === 1) {
  3774. prevStep = locHistory[0];
  3775. }
  3776. else {
  3777. prevStep = locHistory[locHistory.length - 1];
  3778. }
  3779. // console.log(locHistory);
  3780. let options = {};
  3781. let place, position, pID;
  3782. if (nextPlayer === "Yandex") {
  3783. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3784. YandexPlayer.setDirection([prevStep[2], prevStep[3]]);
  3785. YandexPlayer.moveTo([place.lat, place.lng], options);
  3786. YandexPlayer.setSpan([10, 67]);
  3787. switchCovergeButton.lat = place.lat;
  3788. switchCovergeButton.lng = place.lng;
  3789. }
  3790. else if (nextPlayer === "Kakao") {
  3791. var roadviewClient = new kakao.maps.RoadviewClient();
  3792. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[3]), teleportBtn.distance * 0.001);
  3793. position = new kakao.maps.LatLng(place.lat, place.lng);
  3794. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3795. KakaoPlayer.setPanoId(panoId, position);
  3796. });
  3797. switchCovergeButton.lat = place.lat;
  3798. switchCovergeButton.lng = place.lng;
  3799. }
  3800. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  3801. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3802. handleMapillary(place, {meters: 500, limit: 500});
  3803. switchCovergeButton.lat = place.lat;
  3804. switchCovergeButton.lng = place.lng;
  3805. // locHistory.push([place.lat, place.lng, prevStep[2], prevStep[3]]);
  3806. }
  3807. else if (nextPlayer === "Bing Streetside") {
  3808. // console.log("teleport")
  3809. // console.log(prevStep);
  3810. place = FindPointAtDistanceFrom(prevStep[0], prevStep[1], DegreesToRadians(prevStep[2]), teleportBtn.distance * 0.001);
  3811. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(place.lat, place.lng), 1, 1);
  3812. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  3813. function onSuccess(panoramaInfo) {
  3814. // console.log("Coverage")
  3815. // console.log([panoramaInfo.la, panoramaInfo.lo])
  3816. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  3817. });
  3818. }
  3819. function onMissingCoverage() {
  3820. console.log("No Coverage")
  3821. }
  3822. }
  3823.  
  3824. if (teleportBtn.distance > 150)
  3825. {
  3826. teleportBtn.distance = 100;
  3827. teleportBtn.innerHTML = "Teleport " + teleportBtn.distance + " m";
  3828. }
  3829. }
  3830. });
  3831. }
  3832. }
  3833.  
  3834. function SyncListener()
  3835. {
  3836. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  3837. switchCovergeButton.addEventListener("click", () => {
  3838. if (switchCovergeButton.useGoogle == false) {
  3839. // switchCovergeButton.useGoogle = true;
  3840. console.log(nextPlayer)
  3841. if (nextPlayer === "Yandex") {
  3842. let options = {};
  3843. YandexPlayer.moveTo([switchCovergeButton.lat, switchCovergeButton.lng], options);
  3844. YandexPlayer.setDirection([switchCovergeButton.heading, 0]);
  3845.  
  3846. // nextPlayer = "Yandex";
  3847. }
  3848. else if (nextPlayer === "Kakao") {
  3849. let roadviewClient = new kakao.maps.RoadviewClient();
  3850. // console.log(switchCovergeButton.lat);
  3851. let position = new kakao.maps.LatLng(switchCovergeButton.lat, switchCovergeButton.lng);
  3852. roadviewClient.getNearestPanoId(position, 500, function (panoId) {
  3853. KakaoPlayer.setPanoId(panoId, position);
  3854. });
  3855. KakaoPlayer.setViewpoint({
  3856. pan: switchCovergeButton.heading,
  3857. tilt: 0,
  3858. zoom: -3
  3859. });
  3860. // nextPlayer = "Kakao";
  3861. }
  3862. else if (nextPlayer === "Mapillary" || nextPlayer === "Google") {
  3863. // nextPlayer = "Kakao";
  3864. handleMapillary({lat: switchCovergeButton.lat, lng: switchCovergeButton.lng}, {meters: 100, limit: 100});
  3865. }
  3866. else if (nextPlayer === "Bing Streetside") {
  3867. let bounds = new Microsoft.Maps.LocationRect(new Microsoft.Maps.Location(switchCovergeButton.lat, switchCovergeButton.lng), 0.01, 0.01);
  3868. Microsoft.Maps.Map.getClosestPanorama(bounds, onSuccess, onMissingCoverage);
  3869. function onSuccess(panoramaInfo) {
  3870. MSStreetPlayer.setView({center: new Microsoft.Maps.Location(panoramaInfo.la, panoramaInfo.lo),
  3871. heading: switchCovergeButton.heading
  3872. });
  3873. }
  3874. function onMissingCoverage() {
  3875. console.log("No Coverage")
  3876. }
  3877. }
  3878. }
  3879. });
  3880.  
  3881. }
  3882.  
  3883. /**
  3884. * Gets the seed data for the current game
  3885. *
  3886. * @returns Promise with seed data as object
  3887. */
  3888. function getSeed() {
  3889. // console.log("getSeed called");
  3890. return new Promise((resolve, reject) => {
  3891. let token = getToken();
  3892. let URL;
  3893. let cred = ""
  3894.  
  3895. const PATHNAME = window.location.pathname;
  3896.  
  3897. if (PATHNAME.startsWith("/game/")) {
  3898. URL = `https://www.geoguessr.com/api/v3/games/${token}`;
  3899. }
  3900. else if (PATHNAME.startsWith("/challenge/")) {
  3901. URL = `https://www.geoguessr.com/api/v3/challenges/${token}/game`;
  3902. }
  3903. else if (PATHNAME.startsWith("/battle-royale/")) {
  3904. URL = `https://game-server.geoguessr.com/api/battle-royale/${token}`;
  3905. }
  3906. else if (PATHNAME.startsWith("/duels/") || PATHNAME.startsWith("/team-duels/")) {
  3907. URL = `https://game-server.geoguessr.com/api/duels/${token}`;
  3908. }
  3909. else if (PATHNAME.startsWith("/bullseye/")) {
  3910. URL = `https://game-server.geoguessr.com/api/bullseye/${token}`;
  3911. }
  3912. else if (PATHNAME.startsWith("/live-challenge/")) {
  3913. URL = `https://game-server.geoguessr.com/api/live-challenge/${token}`;
  3914. }
  3915. if (isBattleRoyale) {
  3916. fetch(URL, {
  3917. // Include credentials to GET from the endpoint
  3918. credentials: 'include'
  3919. })
  3920. .then((response) => response.json())
  3921. .then((data) => {
  3922. resolve(data);
  3923. })
  3924. .catch((error) => {
  3925. reject(error);
  3926. });
  3927. }
  3928. else {
  3929. fetch(URL)
  3930. .then((response) => response.json())
  3931. .then((data) => {
  3932. resolve(data);
  3933. })
  3934. .catch((error) => {
  3935. reject(error);
  3936. });
  3937. }
  3938. });
  3939. }
  3940.  
  3941. /**
  3942. * Gets the token from the current URL
  3943. *
  3944. * @returns token
  3945. */
  3946. function getToken() {
  3947. const PATHNAME = window.location.pathname;
  3948. if (PATHNAME.startsWith("/game/")) {
  3949. return PATHNAME.replace("/game/", "");
  3950. }
  3951. else if (PATHNAME.startsWith("/challenge/")) {
  3952. return PATHNAME.replace("/challenge/", "");
  3953. }
  3954. else if (PATHNAME.startsWith("/battle-royale/")) {
  3955. return PATHNAME.replace("/battle-royale/", "");
  3956. }
  3957. else if (PATHNAME.startsWith("/duels/")) {
  3958. return PATHNAME.replace("/duels/", "");
  3959. }
  3960. else if (PATHNAME.startsWith("/team-duels/")) {
  3961. return PATHNAME.replace("/team-duels/", "");
  3962. }
  3963. else if (PATHNAME.startsWith("/bullseye/")) {
  3964. return PATHNAME.replace("/bullseye/", "");
  3965. }
  3966. else if (PATHNAME.startsWith("/live-challenge/")) {
  3967. return PATHNAME.replace("/live-challenge/", "");
  3968. }
  3969. }
  3970.  
  3971. /**
  3972. * Gets the round number from the ongoing game from the page itself
  3973. *
  3974. * @returns Round number
  3975. */
  3976. function getRoundFromPage() {
  3977. const roundData = document.querySelector("div[data-qa='round-number']");
  3978. if (roundData) {
  3979. let roundElement = roundData.querySelector("div:last-child");
  3980. if (roundElement) {
  3981. let round = parseInt(roundElement.innerText.charAt(0));
  3982. if (!isNaN(round) && round >= 1 && round <= 5) {
  3983. return round;
  3984. }
  3985. }
  3986. }
  3987. else {
  3988. return ROUND;
  3989. }
  3990. }
  3991.  
  3992.  
  3993. /**
  3994. * Injects Yandex Script
  3995. */
  3996. function injectYandexScript() {
  3997. return new Promise((resolve, reject) => {
  3998. if (!YANDEX_INJECTED) {
  3999. if (YANDEX_API_KEY === "") {
  4000. console.log("No Yandex Key")
  4001. reject();
  4002. }
  4003. else {
  4004. if (!partialCreateYandex)
  4005. {
  4006. const SCRIPT = document.createElement("script");
  4007. SCRIPT.type = "text/javascript";
  4008. SCRIPT.async = true;
  4009. SCRIPT.src = `https://api-maps.yandex.ru/2.1/?lang=en_US&apikey=${YANDEX_API_KEY}`;
  4010. document.body.appendChild(SCRIPT);
  4011. SCRIPT.onload = () => {
  4012. ymaps.ready(() => {
  4013. YANDEX_INJECTED = true;
  4014. myHighlight("Yandex API Loaded");
  4015. resolve();
  4016. });
  4017. }
  4018. }
  4019. else
  4020. {
  4021. YANDEX_INJECTED = true;
  4022. resolve();
  4023. }
  4024. }
  4025. }
  4026. else {
  4027. resolve();
  4028. }
  4029. });
  4030. }
  4031.  
  4032. /**
  4033. * Injects Yandex Player and calls handleReturnToStart
  4034. */
  4035. function injectYandexPlayer() {
  4036. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4037. let lat = 41.321861;
  4038. let lng = 69.212920;
  4039.  
  4040. let options = {
  4041. "direction": [0, 16],
  4042. "span": [10, 67],
  4043. "controls": ["zoomControl"]
  4044. };
  4045. ymaps.panorama.createPlayer("player", [lat, lng], options)
  4046. .done((player) => {
  4047. YandexPlayer = player;
  4048. YandexPlayer.events.add("directionchange", (e) => {
  4049. updateCompass();
  4050. let pov = YandexPlayer.getDirection();
  4051. if (locHistory.length > 0 && nextPlayer == "Yandex") {
  4052. switchCovergeButton.heading = pov[0];
  4053. locHistory[locHistory.length - 1][2] = pov[0];
  4054. locHistory[locHistory.length - 1][3] = pov[1];
  4055. }
  4056. });
  4057. YandexPlayer.events.add("panoramachange", (e) => {
  4058. if (defaultPanoIdChange) {
  4059. let num = YandexPlayer.getPanorama().getPosition();
  4060. let pov = YandexPlayer.getDirection();
  4061. // console.log(num);
  4062. // console.log(pov);
  4063. if (nextPlayer == "Yandex")
  4064. {
  4065. locHistory.push([num[0], num[1], pov[0], pov[1]]);
  4066. switchCovergeButton.lat = num[0];
  4067. switchCovergeButton.lng = num[1];
  4068. }
  4069. let btn = document.querySelector("button[data-qa='undo-move']");
  4070. if (locHistory.length > 1) {
  4071. btn.disabled = false;
  4072. btn.classList.remove('styles_disabled__2YdHD');
  4073. }
  4074. // console.log(locHistory);
  4075. }
  4076. defaultPanoIdChange = true;
  4077.  
  4078. });
  4079. console.log("Yandex Player injected");
  4080. });
  4081.  
  4082. }
  4083.  
  4084.  
  4085. /**
  4086. * Injects Baidu script
  4087. */
  4088.  
  4089. function reportWindowSize() {
  4090. let iframeC = document.getElementById("i_container");
  4091. if (iframeC)
  4092. {
  4093. if (nextPlayer == "Baidu")
  4094. {
  4095. iframeC.style.top = '-60px';
  4096. iframeC.style.height = (window.innerHeight + 200) + 'px';
  4097. iframeC.style.right = '-55px';
  4098. iframeC.style.width = (window.innerWidth + 55) + 'px';
  4099. }
  4100. else if (nextPlayer == "Youtube")
  4101. {
  4102. iframeC.style.top = '-60px';
  4103. iframeC.style.height = (window.innerHeight + 235) + 'px';
  4104. }
  4105. else if (nextPlayer == "Image")
  4106. {
  4107. iframeC.style.top = '0px';
  4108. iframeC.style.height = (window.innerHeight) + 'px';
  4109. }
  4110.  
  4111. }
  4112. }
  4113.  
  4114. window.onresize = reportWindowSize;
  4115.  
  4116. function injectContainer() {
  4117. myHighlight("iframe container loaded")
  4118. const iframe = document.createElement('iframe');
  4119. iframe.frameBorder = 0;
  4120. iframe.style.position = "absolute";
  4121. iframe.id = "i_container";
  4122. if (isBattleRoyale) {
  4123. if (isDuel)
  4124. {
  4125. iframe.className = "inactive";
  4126. }
  4127. else if (isBullseye)
  4128. {
  4129. iframe.className = "game-panorama_panorama__ncMwh";
  4130. }
  4131. else if (isLiveChallenge)
  4132. {
  4133. iframe.className = "game-panorama_panorama__6RmkO";
  4134. }
  4135. else
  4136. {
  4137. iframe.className = "br-game-layout__panorama";
  4138. }
  4139. }
  4140. else {
  4141. iframe.className = "game-layout__panorama";
  4142. }
  4143. var div = document.getElementById("player");
  4144. div.style.overflow = "hidden";
  4145. if (isBullseye || isLiveChallenge)
  4146. {
  4147. div.prepend(iframe);
  4148. }
  4149. else
  4150. {
  4151. div.appendChild(iframe);
  4152. }
  4153. }
  4154.  
  4155. // function injectMedia() {
  4156. // myHighlight("Baidu API loaded")
  4157. // const iframe = document.createElement('iframe');
  4158. // iframe.allow = "autoplay"
  4159. // iframe.src = "https://www.youtube.com/embed/72kRM86V-dw?&autoplay=1&modestbranding=1&controls=0&start=10"
  4160. // iframe.frameBorder = 0;
  4161. // iframe.style.position = "absolute";
  4162. // iframe.id = "media-player";
  4163. // 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;"
  4164. // if (isBattleRoyale) {
  4165. // if (isDuel)
  4166. // {
  4167. // iframe.className = "inactive"
  4168. // }
  4169. // else
  4170. // {
  4171. // iframe.className = "br-game-layout__panorama"
  4172. // }
  4173. // }
  4174. // else {
  4175. // iframe.className = "game-layout__panorama"
  4176. // }
  4177. // var div = document.getElementById("player");
  4178. // div.style.overflow = "hidden";
  4179. // div.appendChild(iframe);
  4180. // }
  4181.  
  4182. /**
  4183. * Injects Kakao script
  4184. */
  4185.  
  4186. function injectKakaoScript() {
  4187. return new Promise((resolve, reject) => {
  4188. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4189. if (!KAKAO_INJECTED) {
  4190. if (KAKAO_API_KEY === "") {
  4191. console.log("No Kakao Key")
  4192. }
  4193. else {
  4194.  
  4195. let canvas = document.createElement("kmap");
  4196. if (isBattleRoyale) {
  4197. if (isDuel)
  4198. {
  4199. canvas.innerHTML = `
  4200. <div id="roadview" class="inactive" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4201. `;
  4202. }
  4203. else if (isBullseye)
  4204. {
  4205. canvas.innerHTML = `
  4206. <div id="roadview" class="game-panorama_panorama__ncMwh" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4207. `;
  4208. }
  4209. else if (isLiveChallenge)
  4210. {
  4211. canvas.innerHTML = `
  4212. <div id="roadview" class="game-panorama_panorama__6RmkO" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4213. `;
  4214. }
  4215. else
  4216. {
  4217. canvas.innerHTML = `
  4218. <div id="roadview" class="br-game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4219. `;
  4220. }
  4221. }
  4222. else {
  4223. canvas.innerHTML = `
  4224. <div id="roadview" class="game-layout__panorama" style="zIndex: 99999,position: "absolute", top: 0, left: 0, width: '100%', height: '100%',"> </div>
  4225. `;
  4226. }
  4227.  
  4228.  
  4229. var div = document.getElementById("player");
  4230. if (isBullseye || isLiveChallenge)
  4231. {
  4232. div.prepend(canvas);
  4233. }
  4234. else
  4235. {
  4236. div.appendChild(canvas);
  4237. }
  4238.  
  4239. let SCRIPT;
  4240. if (!partialCreateKakao)
  4241. {
  4242. SCRIPT = document.createElement("script");
  4243. SCRIPT.async = true;
  4244. // SCRIPT.type = "text/javascript";
  4245. SCRIPT.src = `//dapi.kakao.com/v2/maps/sdk.js?appkey=${KAKAO_API_KEY}&autoload=false`;
  4246. document.body.appendChild(SCRIPT);
  4247. }
  4248.  
  4249. function drawmapKakao()
  4250. {
  4251. kakao.maps.load(function () {
  4252. var position = new kakao.maps.LatLng(33.450701, 126.560667);
  4253. let roadviewContainer = document.getElementById('roadview');
  4254. KakaoPlayer = new kakao.maps.Roadview(roadviewContainer);
  4255. var panoId = 1023434522;
  4256. KakaoPlayer.setPanoId(panoId, position);
  4257. KAKAO_INJECTED = true;
  4258. // Remove the compass from Kakao
  4259. kakao.maps.event.addListener(KakaoPlayer, 'init', () => {
  4260. const compassContainer = roadviewContainer.querySelector('div[id*="_box_util_"]');
  4261. if (compassContainer) compassContainer.style.display = 'none';
  4262. });
  4263. kakao.maps.event.addListener(KakaoPlayer, 'panoid_changed', function() {
  4264. if (defaultPanoIdChange && KakaoPlayer) {
  4265. let latlng = KakaoPlayer.getPosition();
  4266. let lat = latlng.getLat();
  4267. let lng = latlng.getLng();
  4268. let pID = KakaoPlayer.getViewpointWithPanoId();
  4269. if (nextPlayer == "Kakao" && lat != 33.45047613915499)
  4270. {
  4271. // console.log("push");
  4272. locHistory.push([lat, lng, pID.panoId, pID.pan]);
  4273. switchCovergeButton.lat = lat;
  4274. switchCovergeButton.lng = lng;
  4275. switchCovergeButton.heading = pID.pan;
  4276. }
  4277. let btn = document.querySelector("button[data-qa='undo-move']");
  4278. if (locHistory.length > 1 && (btn != null)) {
  4279. btn.disabled = false;
  4280. btn.classList.remove('styles_disabled__2YdHD');
  4281. }
  4282. // console.log(locHistory);
  4283. }
  4284. defaultPanoIdChange = true;
  4285. });
  4286. kakao.maps.event.addListener(KakaoPlayer, 'viewpoint_changed', function() {
  4287. // console.log("pov_listener attached");
  4288. let pID = KakaoPlayer.getViewpointWithPanoId();
  4289. if (locHistory.length > 0 && nextPlayer == "Kakao") {
  4290. switchCovergeButton.heading = pID.pan;
  4291. locHistory[locHistory.length - 1][3] = pID.pan;
  4292. }
  4293. if (GooglePlayer) {
  4294. const { heading, pitch } = GooglePlayer.getPov()
  4295. if ((!almostEqual(pID.pan, heading) || !almostEqual(pID.tilt, pitch)) && nextPlayer == "Kakao") {
  4296. // Updating the google street view POV will update the compass
  4297. GooglePlayer.setPov({ heading: pID.pan, pitch: pID.tilt })
  4298. }
  4299. }
  4300. // console.log(locHistory);
  4301. })
  4302. });
  4303. }
  4304.  
  4305. if (partialCreateKakao)
  4306. {
  4307. drawmapKakao();
  4308. }
  4309. else
  4310. {
  4311. SCRIPT.onload = () => {
  4312. drawmapKakao();
  4313. myHighlight("Kakao API Loaded");
  4314. resolve();
  4315. };
  4316. }
  4317.  
  4318. }
  4319. }
  4320. else {
  4321. resolve();
  4322. }
  4323. });
  4324. }
  4325.  
  4326.  
  4327. function injectMSPlayer() {
  4328. return new Promise((resolve, reject) => {
  4329. if (!MS_INJECTED) {
  4330. if (MS_API_KEY === "") {
  4331. let canvas = document.getElementById("player");
  4332. console.log("No MS Key")
  4333. }
  4334. else {
  4335.  
  4336. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4337. let SCRIPT;
  4338. if (!partialCreateMS)
  4339. {
  4340. SCRIPT = document.createElement("script");
  4341. SCRIPT.type = "text/javascript";
  4342. SCRIPT.async = true;
  4343. SCRIPT.src = `https://www.bing.com/api/maps/mapcontrol?key=${MS_API_KEY}`;
  4344. document.body.appendChild(SCRIPT);
  4345. }
  4346. let canvas = document.createElement("msmap");
  4347. if (isBattleRoyale) {
  4348. if (isDuel)
  4349. {
  4350. canvas.innerHTML = `<div id="ms-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4351. }
  4352. else if (isBullseye)
  4353. {
  4354. 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>`;
  4355. }
  4356. else if (isLiveChallenge)
  4357. {
  4358. 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>`;
  4359. }
  4360. else
  4361. {
  4362. 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>`;
  4363. }
  4364. }
  4365. else {
  4366. canvas.innerHTML = `<div id="ms-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4367. }
  4368.  
  4369. var div = document.getElementById("player");
  4370. if (isBullseye || isLiveChallenge)
  4371. {
  4372. div.prepend(canvas);
  4373. }
  4374. else
  4375. {
  4376. div.appendChild(canvas);
  4377. }
  4378. function drawmapMS()
  4379. {
  4380. MSStreetPlayer = new Microsoft.Maps.Map(document.getElementById('ms-player'),{disableStreetsideAutoCoverage: true, allowHidingLabelsOfRoad: true});
  4381. MS_INJECTED = true;
  4382. // MSStreetPlayer.setOptions({
  4383. // minZoom: 13
  4384. // });
  4385. Microsoft.Maps.Events.addHandler(MSStreetPlayer, 'viewchangeend', function () { updateView(MSStreetPlayer); });
  4386. function updateView(map) {
  4387. let ctrm = map.getCenter();
  4388. if (nextPlayer == "Bing Streetside" && (switchCovergeButton.lat !== ctrm.latitude && switchCovergeButton.lng !== ctrm.longitude))
  4389. {
  4390. let heading2 = bearing(switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude)
  4391. // console.log("moved");
  4392. // console.log([switchCovergeButton.lat, switchCovergeButton.lng, ctrm.latitude, ctrm.longitude])
  4393. // console.log(heading2);
  4394. locHistory.push([ctrm.latitude, ctrm.longitude, heading2]);
  4395. switchCovergeButton.lat = ctrm.latitude;
  4396. switchCovergeButton.lng = ctrm.longitude;
  4397. switchCovergeButton.heading = heading2;
  4398. let btn = document.querySelector("button[data-qa='undo-move']");
  4399. if (locHistory.length > 1 && (btn != null)) {
  4400. btn.disabled = false;
  4401. btn.classList.remove('styles_disabled__2YdHD');
  4402. }
  4403. }
  4404. }
  4405.  
  4406.  
  4407. }
  4408.  
  4409. if (partialCreateMS)
  4410. {
  4411. drawmapMS();
  4412. }
  4413. else
  4414. {
  4415. SCRIPT.addEventListener('load', () => {
  4416. myHighlight("Bing Maps API loaded");
  4417. let timeout = 0;
  4418. let interval = setInterval(() => {
  4419. if (timeout >= 40) {
  4420. reject();
  4421. clearInterval(interval);
  4422. }
  4423. if (document.getElementById('ms-player') !== null && typeof Microsoft.Maps.Map !== typeof undefined) {
  4424. drawmapMS();
  4425. resolve();
  4426. clearInterval(interval);
  4427. }
  4428. timeout += 1;
  4429. }, 1000);
  4430. })
  4431. }
  4432. }
  4433. }
  4434. else {
  4435. resolve();
  4436. }
  4437. });
  4438. }
  4439.  
  4440.  
  4441.  
  4442. function injectMapillaryPlayer() {
  4443. return new Promise((resolve, reject) => {
  4444. if (!MAPILLARY_INJECTED) {
  4445. if (MAPILLARY_API_KEY === "") {
  4446. let canvas = document.getElementById("player");
  4447. console.log("No Mapillary Key")
  4448. }
  4449. else {
  4450. let [teleportBtn, teleportMoreBtn, teleportLessBtn, teleportDistResetBtn, switchCovergeButton, mainMenuBtn, timeMachineBtn, timeMachineOlderBtn, timeMachineNewerBtn, MinimapBtn, OverlayBtn, HelpBtn, TeleportArisBtn, satelliteSwitchButton] = setButtons();
  4451.  
  4452. let SCRIPT;
  4453. if (!partialCreateMapillary)
  4454. {
  4455. SCRIPT = document.createElement("script");
  4456. SCRIPT.type = "text/javascript";
  4457. SCRIPT.async = true;
  4458. SCRIPT.src = `https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.js`;
  4459. document.body.appendChild(SCRIPT);
  4460. document.querySelector('head').innerHTML += '<link href="https://unpkg.com/mapillary-js@4.0.0/dist/mapillary.css" rel="stylesheet"/>';
  4461. }
  4462. let canvas = document.createElement("mmap");
  4463. if (isBattleRoyale) {
  4464. if (isDuel)
  4465. {
  4466.  
  4467. canvas.innerHTML = `<div id="mapillary-player" class="inactive" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4468. }
  4469. else if (isBullseye)
  4470. {
  4471. 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>`;
  4472. }
  4473. else if (isLiveChallenge)
  4474. {
  4475. 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>`;
  4476. }
  4477. else
  4478. {
  4479. 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>`;
  4480. }
  4481. }
  4482. else {
  4483. canvas.innerHTML = `<div id="mapillary-player" class="game-layout__panorama" style="zIndex: 99999, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%'"></div>`;
  4484. }
  4485.  
  4486. var div = document.getElementById("player");
  4487. if (isBullseye || isLiveChallenge)
  4488. {
  4489. div.prepend(canvas);
  4490. }
  4491. else
  4492. {
  4493. div.appendChild(canvas);
  4494. }
  4495.  
  4496. function drawMapML()
  4497. {
  4498. var {Viewer} = mapillary;
  4499.  
  4500. MapillaryPlayer = new Viewer({
  4501. accessToken: MAPILLARY_API_KEY,
  4502. container: 'mapillary-player', // the ID of our container defined in the HTML body
  4503. });
  4504.  
  4505. MapillaryPlayer.on('image', async (event) => {
  4506. // cnt = cnt + 1;
  4507. // console.log(cnt);
  4508. let image = event.image;
  4509. let pos = image.originalLngLat;
  4510. let cond = true;
  4511. for (const element of locHistory) {
  4512. if (element[2] == image.id)
  4513. {
  4514. cond = false;
  4515. }
  4516. }
  4517. if (cond)
  4518. {
  4519. switchCovergeButton.lat = pos.lat;
  4520. switchCovergeButton.lng = pos.lng;
  4521. switchCovergeButton.heading = image.compassAngle;
  4522. // console.log(pos);
  4523. locHistory.push([pos.lat, pos.lng, image.id, image.compassAngle]);
  4524. }
  4525. let btn = document.querySelector("button[data-qa='undo-move']");
  4526. if (btn !== null && locHistory.length > 1)
  4527. {
  4528. btn.disabled = false;
  4529. btn.classList.remove('styles_disabled__2YdHD');
  4530. }
  4531. });
  4532.  
  4533. MAPILLARY_INJECTED = true;
  4534. }
  4535. if (partialCreateMapillary)
  4536. {
  4537. drawMapML();
  4538. }
  4539. else
  4540. {
  4541.  
  4542. SCRIPT.addEventListener('load', () => {
  4543. myHighlight("Mapillary API Loaded");
  4544. // resolve(BMap);
  4545. drawMapML();
  4546. resolve();
  4547. })
  4548. }
  4549. }
  4550. }
  4551. else {
  4552. resolve();
  4553. }
  4554. });
  4555. }
  4556.  
  4557.  
  4558. function handleMapillary(latlng, options)
  4559. {
  4560. console.log("handleMapillary")
  4561. handleMapillaryHelper(latlng, options).then((data) => {
  4562. //console.log(data.data)
  4563. let idToSet = 0;
  4564. let curDist = 100000000;
  4565. for (const element of data.data) {
  4566. // console.log(element)
  4567. if (element.hasOwnProperty("computed_geometry"))
  4568. {
  4569. try {
  4570. let rCord = element.computed_geometry["coordinates"];
  4571. let dist = distance(latlng.lat,latlng.lng,rCord[1],rCord[0])
  4572. if (dist < curDist)
  4573. {
  4574. idToSet = element.id;
  4575. curDist = dist
  4576. }
  4577. } catch (e) {
  4578. console.log("Error")
  4579. }
  4580. }
  4581. }
  4582. if (idToSet !== 0)
  4583. {
  4584. MapillaryPlayer.moveTo(idToSet).then(
  4585. image => { //console.log(image);
  4586. },
  4587. error => { console.log(error); });
  4588. }}).catch((error) => {
  4589. console.log(error);
  4590. });
  4591. }
  4592.  
  4593. function handleMapillaryHelper(latlng, options)
  4594. {
  4595. return new Promise((resolve, reject) => {
  4596. // console.log("1")
  4597. let bbox = getBBox(latlng, options.meters);
  4598. 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)
  4599. // console.log(URL)
  4600. fetch(URL)
  4601. .then((response) => {resolve(response.json())})
  4602. .catch((error) => {console.log(error);});
  4603. });
  4604. }
  4605.  
  4606.  
  4607. /**
  4608. * Minimap presets
  4609. */
  4610.  
  4611. let water_name_only =
  4612. [
  4613. {
  4614. "elementType": "geometry",
  4615. "stylers": [
  4616. {
  4617. "visibility": "off"
  4618. }
  4619. ]
  4620. },
  4621. {
  4622. "featureType": "administrative",
  4623. "stylers": [
  4624. {
  4625. "visibility": "off"
  4626. }
  4627. ]
  4628. },
  4629. {
  4630. "featureType": "landscape",
  4631. "stylers": [
  4632. {
  4633. "visibility": "off"
  4634. }
  4635. ]
  4636. },
  4637. {
  4638. "featureType": "poi",
  4639. "stylers": [
  4640. {
  4641. "visibility": "off"
  4642. }
  4643. ]
  4644. },
  4645. {
  4646. "featureType": "road",
  4647. "stylers": [
  4648. {
  4649. "visibility": "off"
  4650. }
  4651. ]
  4652. },
  4653. {
  4654. "featureType": "transit",
  4655. "stylers": [
  4656. {
  4657. "visibility": "off"
  4658. }
  4659. ]
  4660. }
  4661. ]
  4662. let country_name_only =
  4663. [
  4664. {
  4665. "elementType": "geometry",
  4666. "stylers": [
  4667. {
  4668. "visibility": "off"
  4669. }
  4670. ]
  4671. },
  4672. {
  4673. "featureType": "administrative",
  4674. "stylers": [
  4675. {
  4676. "visibility": "off"
  4677. }
  4678. ]
  4679. },
  4680. {
  4681. "featureType": "administrative.country",
  4682. "elementType": "labels",
  4683. "stylers": [
  4684. {
  4685. "visibility": "on"
  4686. }
  4687. ]
  4688. },
  4689. {
  4690. "featureType": "landscape",
  4691. "stylers": [
  4692. {
  4693. "visibility": "off"
  4694. }
  4695. ]
  4696. },
  4697. {
  4698. "featureType": "poi",
  4699. "stylers": [
  4700. {
  4701. "visibility": "off"
  4702. }
  4703. ]
  4704. },
  4705. {
  4706. "featureType": "road",
  4707. "stylers": [
  4708. {
  4709. "visibility": "off"
  4710. }
  4711. ]
  4712. },
  4713. {
  4714. "featureType": "transit",
  4715. "stylers": [
  4716. {
  4717. "visibility": "off"
  4718. }
  4719. ]
  4720. },
  4721. {
  4722. "featureType": "water",
  4723. "stylers": [
  4724. {
  4725. "visibility": "off"
  4726. }
  4727. ]
  4728. }
  4729. ]
  4730.  
  4731. let no_label_or_terrain =
  4732. [
  4733. {
  4734. "elementType": "geometry",
  4735. "stylers": [
  4736. {
  4737. "visibility": "off"
  4738. }
  4739. ]
  4740. },
  4741. {
  4742. "featureType": "administrative",
  4743. "stylers": [
  4744. {
  4745. "visibility": "off"
  4746. }
  4747. ]
  4748. },
  4749. {
  4750. "featureType": "landscape",
  4751. "stylers": [
  4752. {
  4753. "visibility": "off"
  4754. }
  4755. ]
  4756. },
  4757. {
  4758. "featureType": "poi",
  4759. "stylers": [
  4760. {
  4761. "visibility": "off"
  4762. }
  4763. ]
  4764. },
  4765. {
  4766. "featureType": "road",
  4767. "stylers": [
  4768. {
  4769. "visibility": "off"
  4770. }
  4771. ]
  4772. },
  4773. {
  4774. "featureType": "transit",
  4775. "stylers": [
  4776. {
  4777. "visibility": "off"
  4778. }
  4779. ]
  4780. },
  4781. {
  4782. "featureType": "water",
  4783. "stylers": [
  4784. {
  4785. "visibility": "on"
  4786. }
  4787. ]
  4788. },
  4789. {
  4790. "featureType": "water",
  4791. "elementType": "labels",
  4792. "stylers": [
  4793. {
  4794. "visibility": "off"
  4795. }
  4796. ]
  4797. }
  4798. ]
  4799.  
  4800. let no_label =
  4801. [
  4802. {
  4803. "elementType": "labels",
  4804. "stylers": [
  4805. {
  4806. "visibility": "off"
  4807. }
  4808. ]
  4809. },
  4810. {
  4811. "featureType": "administrative",
  4812. "stylers": [
  4813. {
  4814. "visibility": "off"
  4815. }
  4816. ]
  4817. }
  4818. ]
  4819.  
  4820. let blank =
  4821.  
  4822. [
  4823. {
  4824. "stylers": [
  4825. {
  4826. "visibility": "off"
  4827. }
  4828. ]
  4829. }
  4830. ]
  4831.  
  4832. let thick_border =
  4833.  
  4834. [
  4835. {
  4836. "featureType": "administrative.country",
  4837. "elementType": "geometry.stroke",
  4838. "stylers": [
  4839. {
  4840. "weight": 1.5
  4841. }
  4842. ]
  4843. },
  4844. {
  4845. "featureType": "administrative.province",
  4846. "elementType": "geometry.stroke",
  4847. "stylers": [
  4848. {
  4849. "weight": 3.5
  4850. }
  4851. ]
  4852. }
  4853. ]
  4854.  
  4855. let Indonesia =
  4856.  
  4857. [
  4858. {
  4859. "featureType": "administrative",
  4860. "stylers": [
  4861. {
  4862. "visibility": "off"
  4863. }
  4864. ]
  4865. },
  4866. {
  4867. "featureType": "landscape",
  4868. "elementType": "labels",
  4869. "stylers": [
  4870. {
  4871. "visibility": "off"
  4872. }
  4873. ]
  4874. },
  4875. {
  4876. "featureType": "poi.park",
  4877. "elementType": "labels",
  4878. "stylers": [
  4879. {
  4880. "visibility": "off"
  4881. }
  4882. ]
  4883. },
  4884. {
  4885. "featureType": "road",
  4886. "elementType": "labels",
  4887. "stylers": [
  4888. {
  4889. "visibility": "off"
  4890. }
  4891. ]
  4892. },
  4893. {
  4894. "featureType": "transit",
  4895. "elementType": "labels",
  4896. "stylers": [
  4897. {
  4898. "visibility": "off"
  4899. }
  4900. ]
  4901. },
  4902. {
  4903. "featureType": "water",
  4904. "elementType": "labels",
  4905. "stylers": [
  4906. {
  4907. "visibility": "off"
  4908. }
  4909. ]
  4910. }
  4911. ]
  4912.  
  4913. let dark = [
  4914. {
  4915. "elementType": "geometry",
  4916. "stylers": [
  4917. {
  4918. "color": "#212121"
  4919. }
  4920. ]
  4921. },
  4922. {
  4923. "elementType": "labels.icon",
  4924. "stylers": [
  4925. {
  4926. "visibility": "off"
  4927. }
  4928. ]
  4929. },
  4930. {
  4931. "elementType": "labels.text.fill",
  4932. "stylers": [
  4933. {
  4934. "color": "#757575"
  4935. }
  4936. ]
  4937. },
  4938. {
  4939. "elementType": "labels.text.stroke",
  4940. "stylers": [
  4941. {
  4942. "color": "#212121"
  4943. }
  4944. ]
  4945. },
  4946. {
  4947. "featureType": "administrative",
  4948. "elementType": "geometry",
  4949. "stylers": [
  4950. {
  4951. "color": "#757575"
  4952. }
  4953. ]
  4954. },
  4955. {
  4956. "featureType": "administrative.country",
  4957. "elementType": "labels.text.fill",
  4958. "stylers": [
  4959. {
  4960. "color": "#9e9e9e"
  4961. }
  4962. ]
  4963. },
  4964. {
  4965. "featureType": "administrative.land_parcel",
  4966. "stylers": [
  4967. {
  4968. "visibility": "off"
  4969. }
  4970. ]
  4971. },
  4972. {
  4973. "featureType": "administrative.locality",
  4974. "elementType": "labels.text.fill",
  4975. "stylers": [
  4976. {
  4977. "color": "#bdbdbd"
  4978. }
  4979. ]
  4980. },
  4981. {
  4982. "featureType": "poi",
  4983. "elementType": "labels.text.fill",
  4984. "stylers": [
  4985. {
  4986. "color": "#757575"
  4987. }
  4988. ]
  4989. },
  4990. {
  4991. "featureType": "poi.park",
  4992. "elementType": "geometry",
  4993. "stylers": [
  4994. {
  4995. "color": "#181818"
  4996. }
  4997. ]
  4998. },
  4999. {
  5000. "featureType": "poi.park",
  5001. "elementType": "labels.text.fill",
  5002. "stylers": [
  5003. {
  5004. "color": "#616161"
  5005. }
  5006. ]
  5007. },
  5008. {
  5009. "featureType": "poi.park",
  5010. "elementType": "labels.text.stroke",
  5011. "stylers": [
  5012. {
  5013. "color": "#1b1b1b"
  5014. }
  5015. ]
  5016. },
  5017. {
  5018. "featureType": "road",
  5019. "elementType": "geometry.fill",
  5020. "stylers": [
  5021. {
  5022. "color": "#2c2c2c"
  5023. }
  5024. ]
  5025. },
  5026. {
  5027. "featureType": "road",
  5028. "elementType": "labels.text.fill",
  5029. "stylers": [
  5030. {
  5031. "color": "#8a8a8a"
  5032. }
  5033. ]
  5034. },
  5035. {
  5036. "featureType": "road.arterial",
  5037. "elementType": "geometry",
  5038. "stylers": [
  5039. {
  5040. "color": "#373737"
  5041. }
  5042. ]
  5043. },
  5044. {
  5045. "featureType": "road.highway",
  5046. "elementType": "geometry",
  5047. "stylers": [
  5048. {
  5049. "color": "#3c3c3c"
  5050. }
  5051. ]
  5052. },
  5053. {
  5054. "featureType": "road.highway.controlled_access",
  5055. "elementType": "geometry",
  5056. "stylers": [
  5057. {
  5058. "color": "#4e4e4e"
  5059. }
  5060. ]
  5061. },
  5062. {
  5063. "featureType": "road.local",
  5064. "elementType": "labels.text.fill",
  5065. "stylers": [
  5066. {
  5067. "color": "#616161"
  5068. }
  5069. ]
  5070. },
  5071. {
  5072. "featureType": "transit",
  5073. "elementType": "labels.text.fill",
  5074. "stylers": [
  5075. {
  5076. "color": "#757575"
  5077. }
  5078. ]
  5079. },
  5080. {
  5081. "featureType": "water",
  5082. "elementType": "geometry",
  5083. "stylers": [
  5084. {
  5085. "color": "#000000"
  5086. }
  5087. ]
  5088. },
  5089. {
  5090. "featureType": "water",
  5091. "elementType": "labels.text.fill",
  5092. "stylers": [
  5093. {
  5094. "color": "#3d3d3d"
  5095. }
  5096. ]
  5097. }
  5098. ]
  5099.  
  5100. let default_preset = []
  5101.  
  5102. let presetMinimap = [[default_preset, "Default"],
  5103. [blank, "Blank"],
  5104. [water_name_only, "Oceanman"],
  5105. [country_name_only, "Impossible"],
  5106. [no_label_or_terrain, "Streaks"],
  5107. [no_label, "Easy 5K"],
  5108. [Indonesia, "POI only"],
  5109. [dark, "Dark Mode"],
  5110. [thick_border, "Borders"],
  5111. [default_preset, "Satellite"],
  5112. [default_preset, "Terrain"],
  5113. [default_preset, "Hybrid"],
  5114. [custom, "Custom", customMode]]
  5115.  
  5116. let GEOJSON_INVISIBLE =
  5117. {
  5118. strokeOpacity: 0,
  5119. fillOpacity: 0,
  5120. }
  5121.  
  5122. let presetOverlay = [["Clear",""],
  5123. ["Coverage",""],
  5124. ["Official",""],
  5125. ["Longitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/lonl.json"],
  5126. ["Latitude", "https://raw.githubusercontent.com/Jupaoqq/Jupaoqq.github.io/main/latl.json"],
  5127. ["US County","https://raw.githubusercontent.com/CodeForCary/CountyDataUSA5m/master/cb_2017_us_county_5m.json"],
  5128. ["France","https://raw.githubusercontent.com/gregoiredavid/france-geojson/master/departements.geojson"],
  5129. ["Time Zone", "https://raw.githubusercontent.com/treyerl/timezones/master/timezones_wVVG8.geojson"],
  5130. ["UK Parliament", "https://raw.githubusercontent.com/martinjc/UK-GeoJSON/master/json/electoral/gb/wpc.json"],
  5131. ["Custom", YOUR_URL]]
  5132.  
  5133. /**
  5134. * Display map per local laws and regulations
  5135. */
  5136.  
  5137. let SEOverlay, NWOverlay, SEOverlay3;
  5138. let TW = [[24.80, 119.00, 22.00, 123.20],
  5139. [24.20, 119.90, 22.90, 121.85],
  5140. [24.00, 120.90, 23.80, 121.20],
  5141. [23.93, 121.03, 23.85, 121.15],
  5142. [23.92, 121.055, 23.89, 121.10],
  5143. [23.92, 121.055, 23.89, 121.10],
  5144. [23.92, 121.055, 23.89, 121.10],
  5145. ]
  5146.  
  5147. let TS = [[30.40, 93.40, 28, 97.20],
  5148. [29.40, 94.55, 28.20, 96.45]]
  5149.  
  5150. let NW = [36.20, 77.70, 34.40, 80.70]