GeoGuessr Co-op

Lets you choose if you want to drive or map when playing coop.

  1. // ==UserScript==
  2. // @name GeoGuessr Co-op
  3. // @namespace http://tampermonkey.net/
  4. // @version 3
  5. // @description Lets you choose if you want to drive or map when playing coop.
  6. // @author Rotski
  7. // @match https://www.geoguessr.com/*
  8. // @license MIT
  9. // @icon https://www.svgrepo.com/show/421676/gps-location-maps.svg
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. // Load the last mode from local storage or default to driving mode
  17. let mapOnlyMode = localStorage.getItem('mapOnlyMode') === 'true';
  18.  
  19. let intervalId;
  20. let hoverIntervalId;
  21.  
  22. function applyStyles(mapContainer) {
  23. mapContainer.style.position = 'fixed';
  24. mapContainer.style.top = '0';
  25. mapContainer.style.left = '0';
  26. mapContainer.style.width = '100%';
  27. mapContainer.style.height = '100%';
  28. mapContainer.style.zIndex = '10000';
  29. mapContainer.style.backgroundColor = '#000';
  30. mapContainer.style.opacity = '1';
  31. mapContainer.style.transition = 'none';
  32. mapContainer.style.pointerEvents = 'auto';
  33. mapContainer.style.setProperty('opacity', '1', 'important');
  34. }
  35.  
  36. function fixTransparency(mapContainer) {
  37. const hoverEvent = new MouseEvent('mouseover', { bubbles: true, cancelable: true });
  38. mapContainer.dispatchEvent(hoverEvent);
  39. }
  40.  
  41. function simulateHover(mapContainer) {
  42. hoverIntervalId = setInterval(() => {
  43. if (mapOnlyMode) {
  44. fixTransparency(mapContainer);
  45. }
  46. }, 500);
  47. }
  48.  
  49. function stopSimulatingHover() {
  50. clearInterval(hoverIntervalId);
  51. }
  52.  
  53. function toggleMode(isMap) {
  54. mapOnlyMode = isMap;
  55. localStorage.setItem('mapOnlyMode', mapOnlyMode); // Save the mode to local storage
  56. adjustMapVisibility();
  57. }
  58.  
  59. function adjustMapVisibility() {
  60. const mapContainer = document.querySelector('.guess-map_canvasContainer__s7oJp');
  61. const streetView = document.querySelector('.game_panorama__1moRf');
  62. const body = document.body;
  63. const guessButton = document.querySelector('.button_button__aR6_e.button_variantBlack__UsxpK.button_disabled__rTguF');
  64.  
  65. if (mapOnlyMode) {
  66. if (streetView) streetView.style.display = 'none';
  67. if (mapContainer) {
  68. applyStyles(mapContainer);
  69. fixTransparency(mapContainer);
  70. simulateHover(mapContainer);
  71. }
  72. body.style.overflow = 'hidden';
  73. if (guessButton) {
  74. guessButton.style.position = 'fixed';
  75. guessButton.style.bottom = '20px';
  76. guessButton.style.left = '50%';
  77. guessButton.style.transform = 'translateX(-50%)'; // Center the button horizontally
  78. guessButton.style.zIndex = '10001'; // Make sure it's visible above the map
  79. }
  80. } else {
  81. if (streetView) streetView.style.display = 'block';
  82. if (mapContainer) {
  83. mapContainer.removeAttribute('style');
  84. }
  85. body.style.overflow = '';
  86. if (guessButton) {
  87. guessButton.removeAttribute('style'); // Reset styles to default
  88. }
  89. stopSimulatingHover();
  90. }
  91. }
  92.  
  93. function updateButtonStyles(mapButton, driveButton) {
  94. if (mapOnlyMode) {
  95. mapButton.style.backgroundColor = 'green';
  96. mapButton.style.opacity = '1';
  97. driveButton.style.backgroundColor = 'red';
  98. driveButton.style.opacity = '0.5';
  99. } else {
  100. mapButton.style.backgroundColor = 'red';
  101. mapButton.style.opacity = '0.5';
  102. driveButton.style.backgroundColor = 'green';
  103. driveButton.style.opacity = '1';
  104. }
  105. }
  106.  
  107. function addButtons() {
  108. const mapButton = document.createElement('button');
  109. const driveButton = document.createElement('button');
  110.  
  111. mapButton.innerText = "Map";
  112. driveButton.innerText = "Drive";
  113.  
  114. [mapButton, driveButton].forEach(button => {
  115. button.style.position = "absolute";
  116. button.style.top = "160px"; // Set vertical offset
  117. button.style.zIndex = "99999";
  118. button.style.padding = "10px";
  119. button.style.color = "white";
  120. button.style.border = "none";
  121. button.style.borderRadius = "5px";
  122. button.style.cursor = "pointer";
  123. });
  124.  
  125. mapButton.style.right = "50px";
  126. driveButton.style.right = "50px";
  127. driveButton.style.top = "220px"; // Additional offset for the second button
  128.  
  129. mapButton.onclick = () => {
  130. toggleMode(true);
  131. updateButtonStyles(mapButton, driveButton);
  132. };
  133. driveButton.onclick = () => {
  134. toggleMode(false);
  135. updateButtonStyles(mapButton, driveButton);
  136. };
  137.  
  138. document.body.appendChild(mapButton);
  139. document.body.appendChild(driveButton);
  140.  
  141. updateButtonStyles(mapButton, driveButton); // Set initial button styles
  142. }
  143.  
  144. function init() {
  145. addButtons();
  146. adjustMapVisibility(); // Apply initial map visibility based on mode
  147. }
  148.  
  149. window.addEventListener('load', init);
  150.  
  151. // Observers to handle dynamic content
  152. const observer = new MutationObserver(() => {
  153. if (mapOnlyMode) {
  154. adjustMapVisibility();
  155. }
  156. });
  157.  
  158. observer.observe(document.body, {
  159. childList: true,
  160. subtree: true
  161. });
  162. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址