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-20 提交的版本,查看 最新版本

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