Geoguessr Unity Script

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

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

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