WorldGuessr Coordinate Finder

Adds a button to get latitude and longitude in WorldGuessr and copy it to clipboard, plus a minimap when coordinates are available

当前为 2025-04-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name WorldGuessr Coordinate Finder
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Adds a button to get latitude and longitude in WorldGuessr and copy it to clipboard, plus a minimap when coordinates are available
  6. // @author Projectornist
  7. // @license You can modify as long as you credit me
  8. // @match https://www.worldguessr.com/*
  9. // @grant GM_addStyle
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. GM_addStyle(`
  16. #getCoordsButton {
  17. position: fixed;
  18. top: 20px;
  19. right: 20px;
  20. padding: 10px 20px;
  21. background-color: black;
  22. color: white;
  23. border: none;
  24. border-radius: 5px;
  25. font-size: 16px;
  26. cursor: pointer;
  27. z-index: 9999;
  28. }
  29. #getCoordsButton:hover {
  30. background-color: #333;
  31. }
  32. #coordsDisplay {
  33. position: fixed;
  34. top: 70px;
  35. right: 20px;
  36. padding: 10px;
  37. background-color: rgba(0, 0, 0, 0.7);
  38. color: white;
  39. border-radius: 5px;
  40. font-size: 14px;
  41. display: none;
  42. z-index: 9999;
  43. }
  44. #googleMapContainer {
  45. position: fixed;
  46. bottom: 20px;
  47. left: 20px;
  48. width: 300px;
  49. height: 300px;
  50. background-color: rgba(0, 0, 0, 0.8);
  51. border-radius: 10px;
  52. overflow: hidden;
  53. display: none;
  54. z-index: 9999;
  55. }
  56. #googleMapContainer iframe {
  57. width: 100%;
  58. height: 100%;
  59. border: none;
  60. }
  61. #googleMapContainer .closeBtn {
  62. position: absolute;
  63. top: 10px;
  64. right: 10px;
  65. background-color: #333;
  66. color: white;
  67. padding: 5px;
  68. cursor: pointer;
  69. }
  70. `);
  71.  
  72. if (document.getElementById('getCoordsButton')) {
  73. return;
  74. }
  75.  
  76. const button = document.createElement('button');
  77. button.id = 'getCoordsButton';
  78. button.textContent = 'Get Coordinates';
  79. document.body.appendChild(button);
  80.  
  81. const coordsDisplay = document.createElement('div');
  82. coordsDisplay.id = 'coordsDisplay';
  83. document.body.appendChild(coordsDisplay);
  84.  
  85. const mapContainer = document.createElement('div');
  86. mapContainer.id = 'googleMapContainer';
  87. document.body.appendChild(mapContainer);
  88.  
  89. const closeBtn = document.createElement('button');
  90. closeBtn.textContent = 'X';
  91. closeBtn.className = 'closeBtn';
  92. mapContainer.appendChild(closeBtn);
  93.  
  94. function getCoordinates() {
  95. const urlParams = new URLSearchParams(window.location.search);
  96. const lat = urlParams.get('lat');
  97. const long = urlParams.get('long');
  98.  
  99. if (lat && long) {
  100. coordsDisplay.textContent = `Latitude: ${lat}, Longitude: ${long}`;
  101. coordsDisplay.style.display = 'block';
  102. showMinimap(lat, long);
  103. } else {
  104. coordsDisplay.textContent = 'Coordinates not found';
  105. coordsDisplay.style.display = 'block';
  106. }
  107. }
  108.  
  109. function showMinimap(lat, long) {
  110. const iframe = document.createElement('iframe');
  111. iframe.src = `https://www.google.com/maps?q=${lat},${long}&z=18&output=embed`;
  112.  
  113. mapContainer.style.display = 'block';
  114. mapContainer.appendChild(iframe);
  115.  
  116. closeBtn.onclick = () => {
  117. mapContainer.style.display = 'none';
  118. mapContainer.innerHTML = '';
  119. mapContainer.appendChild(closeBtn);
  120. };
  121. }
  122.  
  123. function checkCoordinatesAvailability() {
  124. const urlParams = new URLSearchParams(window.location.search);
  125. const lat = urlParams.get('lat');
  126. const long = urlParams.get('long');
  127.  
  128. if (lat && long) {
  129. button.style.display = 'inline-block';
  130. } else {
  131. button.style.display = 'none';
  132. }
  133. }
  134.  
  135. setInterval(checkCoordinatesAvailability, 1000);
  136.  
  137. button.addEventListener('click', function() {
  138. getCoordinates();
  139. });
  140.  
  141. document.addEventListener('keydown', function(event) {
  142. if (event.key === 'o' || event.key === 'O') {
  143. button.style.display = button.style.display === 'none' ? 'inline-block' : 'none';
  144. }
  145. });
  146. })();