Geoguessr Blink Mode

Shows the round briefly, then screen goes black and you have unlimited time to make your guess.

当前为 2022-06-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Geoguessr Blink Mode
  3. // @description Shows the round briefly, then screen goes black and you have unlimited time to make your guess.
  4. // @version 1.0.0
  5. // @author macca#8949
  6. // @license MIT
  7. // @match https://www.geoguessr.com/*
  8. // @require https://unpkg.com/@popperjs/core@2.11.5/dist/umd/popper.min.js
  9. // @run-at document-start
  10. // @grant none
  11. // @namespace https://gf.qytechs.cn/en/scripts/438579-geoguessr-blink-mode
  12. // ==/UserScript==
  13.  
  14. const guiEnabled = true
  15. // ^^^^ Set to false (all lowercase) if you want to hide the GUI and manually enable the script/set the time, otherwise true
  16.  
  17. let timeLimit = 1.5
  18. // ^^^ Modify this number above to change the time
  19.  
  20.  
  21.  
  22. // --------- DON'T MODIFY ANYTHING BELOW THIS LINE -------- //
  23.  
  24.  
  25.  
  26. const guiHTML = `
  27. <div class="section_sectionHeader__WQ7Xz section_sizeMedium__yPqLK"><div class="bars_root___G89E bars_center__vAqnw"><div class="bars_before__xAA7R bars_lengthLong__XyWLx"></div><span class="bars_content__UVGlL"><h3>Blink Mode settings</h3></span><div class="bars_after__Z1Rxt bars_lengthLong__XyWLx"></div></div></div>
  28. <div class="start-standard-game_settings__x94PU">
  29. <div style="display: flex; justify-content: space-around;">
  30. <div style="display: flex; align-items: center;">
  31. <span class="game-options_optionLabel__dJ_Cy" style="margin: 0; padding-right: 6px;">Enabled</span>
  32. <input type="checkbox" id="enableScript" onclick="toggleBlinkMode(this)" class="toggle_toggle__hwnyw">
  33. </div>
  34.  
  35. <div style="display: flex; align-items: center;">
  36. <span class="game-options_optionLabel__dJ_Cy" style="margin: 0; padding-right: 6px;">Time (Seconds)</span>
  37. <input type="text" id="blinkTime" onchange="changeBlinkTime(this)" style="background: rgba(255,255,255,0.1); color: white; border: none; border-radius: 5px; width: 60px;">
  38. </div>
  39. </div>
  40. <p class="body-text_sizeXSmall__rwJFf" style="margin-top: 20px;">Ensure classic compass is enabled</p>
  41. </div>
  42. `
  43.  
  44. const guiHTMLHeader = `
  45. <div id="blinkHeaderToggle" class="header_item__PyYsU">
  46. <div style="--icon-width:1rem;--addon-side-width:1.5625rem;--input-width:20rem;--section-height:3.125rem;--smooth-animation:0.4scubic-bezier(0.03,0.76,0.35,0.98);--border-style:0.0625remsolidvar(--ds-color-white-20);--total-width:calc(var(--icon-width)+var(--addon-side-width)+var(--input-width));--background-color:rgba(26,26,46,.95);align-items:center;display:flex;height:var(--section-height);position:relative;z-index:2;">
  47. <div id="popup" style="background: rgba(26, 26, 46, 0.9); padding: 15px; width: 200px; border-radius: 10px;">
  48. <div style="display: flex; justify-content: space-between; align-items: center;">
  49. <span class="game-options_optionLabel__dJ_Cy">Enabled</span>
  50. <input type="checkbox" id="enableScriptHeader" onclick="toggleBlinkMode(this)">
  51. </div>
  52.  
  53. <div style="display: flex; justify-content: space-between; align-items: center; margin-top: 10px;">
  54. <span class="game-options_optionLabel__dJ_Cy">Time (Seconds)</span>
  55. <input type="text" id="blinkTimeHeader" onchange="changeBlinkTime(this)" style="background: rgba(255,255,255,0.1); color: white; border: none; border-radius: 5px; width: 60px;">
  56. </div>
  57. </div>
  58. <picture class="quick-search_iconSection__aaqD2"><img id="headerGuiToggle" src="https://www.svgrepo.com/show/40039/eye.svg" style="filter: brightness(0) invert(1); opacity: 40%;"></picture>
  59. </div>
  60. </div>
  61. `
  62.  
  63.  
  64. if (localStorage.getItem('blinkEnabled') == null) {
  65. localStorage.setItem('blinkEnabled', 'disabled');
  66. }
  67.  
  68. if (!guiEnabled) {
  69. localStorage.setItem('blinkEnabled', 'enabled');
  70. }
  71.  
  72. if (localStorage.getItem('blinkTime') == null || isNaN(localStorage.getItem('blinkTime'))) {
  73. localStorage.setItem('blinkTime', timeLimit);
  74. }
  75.  
  76. if (guiEnabled) {
  77. timeLimit = localStorage.getItem('blinkTime');
  78. }
  79.  
  80. window.toggleBlinkMode = (e) => {
  81. localStorage.setItem('blinkEnabled', e.checked ? 'enabled' : 'disabled');
  82.  
  83. if (document.querySelector('#enableScript')) {
  84. document.querySelector('#enableScript').checked = e.checked;
  85. }
  86. if (document.querySelector('#enableScriptHeader')) {
  87. document.querySelector('#enableScriptHeader').checked = e.checked;
  88. }
  89. }
  90.  
  91. window.changeBlinkTime = (e) => {
  92. if (!isNaN(e.value)) {
  93. localStorage.setItem('blinkTime', parseFloat(e.value));
  94. timeLimit = parseFloat(e.value);
  95.  
  96. if (document.querySelector('#blinkTime')) {
  97. document.querySelector('#blinkTime').value = e.value;
  98. }
  99. if (document.querySelector('#blinkTimeHeader')) {
  100. document.querySelector('#blinkTimeHeader').value = e.value;
  101. }
  102. }
  103. }
  104.  
  105. const checkInsertGui = () => {
  106. // Play page
  107. if (document.querySelector('.radio-box_root__ka_9S') && document.querySelector('#enableScript') === null) {
  108. document.querySelector('.section_sectionMedium__yXgE6').insertAdjacentHTML('beforeend', guiHTML);
  109. if (localStorage.getItem('blinkEnabled') === 'enabled') {
  110. document.querySelector('#enableScript').checked = true;
  111. }
  112. document.querySelector('#blinkTime').value = timeLimit;
  113. }
  114.  
  115. // Header
  116. if (document.querySelector('.header_header__BxMhs') && document.querySelector('#blinkHeaderToggle') === null) {
  117. document.querySelector('.header_context__hzGGK').insertAdjacentHTML('afterbegin', guiHTMLHeader);
  118. const showButton = document.querySelector('#headerGuiToggle');
  119. const popup = document.querySelector('#popup');
  120. popup.style.display = 'none';
  121.  
  122. document.addEventListener('click', (e) => {
  123. const target = e.target;
  124. if (target == popup || popup.contains(target)) return;
  125. if (target == showButton) {
  126. e.preventDefault();
  127.  
  128. popup.style.display = 'block';
  129. Popper.createPopper(showButton, popup, {
  130. placement: 'bottom',
  131. modifiers: [
  132. {
  133. name: 'offset',
  134. options: {
  135. offset: [0, 10],
  136. },
  137. },
  138. ],
  139. });
  140. } else {
  141. popup.style.display = 'none';
  142. }
  143.  
  144. if (localStorage.getItem('blinkEnabled') === 'enabled') {
  145. document.querySelector('#enableScriptHeader').checked = true;
  146. }
  147. document.querySelector('#blinkTimeHeader').value = timeLimit;
  148. });
  149. }
  150. }
  151.  
  152. let previousTransform = '';
  153.  
  154. const onScreen = (element) => {
  155. let rect = element.getBoundingClientRect();
  156. let topElement = document.elementFromPoint(rect.left + (rect.width / 2), rect.top + (rect.height / 2));
  157. if (element.isSameNode(topElement) & previousTransform != topElement.style.transform) {
  158. previousTransform = topElement.style.transform;
  159. return true;
  160. }
  161. return false;
  162. }
  163.  
  164. let overlayAlreadyPresent = false;
  165. function showWhenOverlayGone() {
  166. if (document.querySelector('.overlay_backdrop__Rh_QC')) {
  167. overlayAlreadyPresent = true;
  168. document.querySelector('.widget-scene-canvas').style.display = 'none';
  169. setTimeout(showWhenOverlayGone, 100);
  170. } else {
  171. overlayAlreadyPresent = false;
  172. document.querySelector('.widget-scene-canvas').style.display = 'block';
  173. setTimeout(() => {
  174. document.querySelector('.widget-scene-canvas').style.display = 'none';
  175. }, timeLimit * 1000);
  176. }
  177. }
  178.  
  179. let observer = new MutationObserver((mutations) => {
  180. if (guiEnabled) {
  181. checkInsertGui();
  182. }
  183.  
  184. if (localStorage.getItem('blinkEnabled') === 'enabled') {
  185.  
  186. if (document.querySelector('.overlay_backdrop__Rh_QC') && !overlayAlreadyPresent) {
  187. showWhenOverlayGone()
  188. }
  189.  
  190. if (document.querySelector('.compass__indicator')) {
  191. if (onScreen(document.querySelector('.compass__indicator'))) {
  192. setTimeout(() => {
  193. document.querySelector('.widget-scene-canvas').style.display = 'none';
  194. }, timeLimit * 1000);
  195. }
  196. }
  197. }
  198. });
  199.  
  200. observer.observe(document.body, {
  201. characterDataOldValue: false,
  202. subtree: true,
  203. childList: true,
  204. characterData: false
  205. });

QingJ © 2025

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