OpenGuessr Location Hack/Cheat

Opens with '1', has close button. Automatically updates on location change.

  1. // ==UserScript==
  2. // @name OpenGuessr Location Hack/Cheat
  3. // @namespace https://openguessr.com/
  4. // @version 3.3
  5. // @description Opens with '1', has close button. Automatically updates on location change.
  6. // @author Kakoncheater
  7. // @license MIT
  8. // @match https://openguessr.com/*
  9. // @grant GM_addStyle
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. // Add CSS for the floating iframe
  16. GM_addStyle(`
  17. #locationFrameContainer {
  18. position: fixed;
  19. bottom: 10px;
  20. left: 10px; /* Displayed in bottom left */
  21. width: 600px;
  22. height: 400px;
  23. background-color: white;
  24. border: 1px solid #ccc;
  25. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  26. z-index: 1000; /* Ensure it's on top */
  27. overflow: hidden; /* Hide scrollbars */
  28. }
  29.  
  30. #locationFrame {
  31. width: 100%;
  32. height: 100%;
  33. border: none;
  34. }
  35.  
  36. #locationFrameHeader {
  37. background-color: #f0f0f0;
  38. padding: 5px;
  39. cursor: move; /* Indicate draggable */
  40. text-align: center;
  41. font-weight: bold;
  42. display: flex; /* Use flexbox for alignment */
  43. justify-content: space-between; /* Push items to the edges */
  44. align-items: center; /* Vertically align items */
  45. }
  46.  
  47. #closeButton {
  48. background-color: #f44336;
  49. color: white;
  50. border: none;
  51. padding: 5px 10px;
  52. text-align: center;
  53. text-decoration: none;
  54. display: inline-block;
  55. font-size: 12px;
  56. cursor: pointer;
  57. border-radius: 3px;
  58. }
  59. `);
  60.  
  61. let locationFrameContainer = null; // Store the iframe container element
  62. let currentLocation = null; // Store the last known location
  63. let isDragging = false;
  64. let dragOffsetX = 0;
  65. let dragOffsetY = 0;
  66. const zoomLevel = 3; // Adjusted Zoom Level
  67.  
  68. // Function to create and display the iframe
  69. function createLocationFrame(location) {
  70. if (!location) return; // Prevent creating with null location
  71.  
  72. if (locationFrameContainer) {
  73. // Iframe already exists, just update the URL
  74. const locationFrame = locationFrameContainer.querySelector('#locationFrame');
  75. locationFrame.src = `https://www.google.com/maps?q=${location}&output=embed&z=${zoomLevel}`;
  76. currentLocation = location; //Update known location
  77. return;
  78. }
  79.  
  80. // Create the container
  81. locationFrameContainer = document.createElement('div');
  82. locationFrameContainer.id = 'locationFrameContainer';
  83.  
  84. // Create the header (for dragging)
  85. const locationFrameHeader = document.createElement('div');
  86. locationFrameHeader.id = 'locationFrameHeader';
  87. locationFrameHeader.textContent = 'Google Maps Location (Drag to Move)';
  88.  
  89. // Create the close button
  90. const closeButton = document.createElement('button');
  91. closeButton.id = 'closeButton';
  92. closeButton.textContent = 'Close';
  93. closeButton.addEventListener('click', closeLocationFrame); // Add event listener
  94.  
  95. // Add elements to the header
  96. locationFrameHeader.appendChild(document.createTextNode('Google Maps Location (Drag to Move)')); // Text node
  97. locationFrameHeader.appendChild(closeButton);
  98.  
  99. locationFrameContainer.appendChild(locationFrameHeader);
  100.  
  101. // Create the iframe
  102. const locationFrame = document.createElement('iframe');
  103. locationFrame.id = 'locationFrame';
  104. locationFrame.src = `https://www.google.com/maps?q=${location}&output=embed&z=${zoomLevel}`; // Embedded version of Maps, zoomed out to level 3
  105. locationFrameContainer.appendChild(locationFrame);
  106.  
  107. // Add to the document
  108. document.body.appendChild(locationFrameContainer);
  109.  
  110. // Make it draggable
  111. locationFrameHeader.addEventListener('mousedown', dragStart);
  112. document.addEventListener('mouseup', dragEnd);
  113. document.addEventListener('mousemove', drag);
  114.  
  115. currentLocation = location; // Store initial location.
  116. }
  117.  
  118. function dragStart(e) {
  119. isDragging = true;
  120. dragOffsetX = e.clientX - locationFrameContainer.offsetLeft;
  121. dragOffsetY = e.clientY - locationFrameContainer.offsetTop;
  122. }
  123.  
  124. function dragEnd() {
  125. isDragging = false;
  126. }
  127.  
  128. function drag(e) {
  129. if (!isDragging) return;
  130. locationFrameContainer.style.left = (e.clientX - dragOffsetX) + 'px';
  131. locationFrameContainer.style.top = (e.clientY - dragOffsetY) + 'px';
  132. locationFrameContainer.style.right = 'auto'; // prevent weirdness
  133. locationFrameContainer.style.bottom = 'auto'; // prevent weirdness
  134. }
  135.  
  136. function closeLocationFrame() {
  137. if (locationFrameContainer) {
  138. locationFrameContainer.remove();
  139. locationFrameContainer = null; // Clear the reference
  140. currentLocation = null; // Clear the stored location
  141. }
  142. }
  143.  
  144. // Function to extract location from iframe
  145. function extractLocation() {
  146. try {
  147. const iframe = document.querySelector('#PanoramaIframe');
  148. const src = iframe.getAttribute('src');
  149. const url = new URL(src);
  150. return url.searchParams.get('location');
  151. } catch (e) {
  152. return null;
  153. }
  154. }
  155.  
  156. // Key press listener, toggles the map
  157. document.addEventListener('keydown', function(event) {
  158. if (event.key === '1') {
  159. const location = extractLocation();
  160. if (location) {
  161. if (locationFrameContainer) {
  162. // Iframe exists, update the location if needed or close if current location matches
  163. const locationFrame = locationFrameContainer.querySelector('#locationFrame');
  164. if (locationFrame.src !== `https://www.google.com/maps?q=${location}&output=embed&z=${zoomLevel}`){
  165. locationFrame.src = `https://www.google.com/maps?q=${location}&output=embed&z=${zoomLevel}`;
  166. } else {
  167. closeLocationFrame();
  168. }
  169. } else {
  170. createLocationFrame(location);
  171. }
  172. currentLocation = location;
  173. } else {
  174. if(locationFrameContainer){
  175. closeLocationFrame(); //Close if location cannot be extracted
  176. }
  177. }
  178. }
  179. });
  180.  
  181. //Try extracting location every second and update if it changes
  182. setInterval(() => {
  183. const location = extractLocation();
  184. if (location) {
  185. if (location !== currentLocation) {
  186. // Location has changed!
  187. if (locationFrameContainer) {
  188. const locationFrame = locationFrameContainer.querySelector('#locationFrame');
  189. locationFrame.src = `https://www.google.com/maps?q=${location}&output=embed&z=${zoomLevel}`;
  190. } else {
  191. createLocationFrame(location);
  192. }
  193. currentLocation = location; // Update the stored location
  194. }
  195. } else if (locationFrameContainer) {
  196. closeLocationFrame(); // Close the frame if no location can be found.
  197. }
  198. }, 1000);
  199.  
  200. })();