Geoguessr Blink Mode

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

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

  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.2.1
  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. // @icon https://www.svgrepo.com/show/40039/eye.svg
  13. // ==/UserScript==
  14.  
  15.  
  16. const guiEnabled = true
  17. // ^^^^ Set to false (all lowercase) if you want to hide the GUI and manually enable the script/set the time, otherwise true
  18.  
  19. let timeLimit = 1.5
  20. // ^^^ Modify this number above to change the time
  21.  
  22. let roundDelay = 0
  23. // ^ Modify this number above to change the length of time the round is delayed for
  24.  
  25.  
  26.  
  27. // --------- DON'T MODIFY ANYTHING BELOW THIS LINE -------- //
  28.  
  29.  
  30.  
  31. const classicGameGuiHTML = `
  32. <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>
  33. <div class="start-standard-game_settings__x94PU">
  34. <div style="display: flex; justify-content: space-around;">
  35. <div style="display: flex; align-items: center;">
  36. <span class="game-options_optionLabel__dJ_Cy" style="margin: 0; padding-right: 6px;">Enabled</span>
  37. <input type="checkbox" id="enableScript" onclick="toggleBlinkMode(this)" class="toggle_toggle__hwnyw">
  38. </div>
  39.  
  40. <div style="display: flex; align-items: center;">
  41. <span class="game-options_optionLabel__dJ_Cy" style="margin: 0; padding-right: 6px;">Time (Seconds)</span>
  42. <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;">
  43. </div>
  44. </div>
  45. <div style="margin-top: 10px">
  46. <span class="game-options_optionLabel__dJ_Cy" style="margin: 0; padding-right: 6px;">Round Delay (Seconds)</span>
  47. <input type="text" id="delayTime" onchange="changeDelayTime(this)" style="background: rgba(255,255,255,0.1); color: white; border: none; border-radius: 5px; width: 60px;">
  48. </div>
  49. </div>
  50. `
  51.  
  52. const friendLobbyGuiHTML = `
  53. <div class="section_sectionHeader__WQ7Xz section_sizeMedium__yPqLK" style="margin-top: 10px"><div class="bars_root___G89E"><span class="bars_content__UVGlL"><h2>Blink Mode Settings</h2></span><div class="bars_after__Z1Rxt bars_lengthLong__XyWLx"></div></div></div>
  54. <div class="start-standard-game_settings__x94PU" style="margin-top: 8px">
  55. <div style="display: flex; justify-content: space-around;">
  56. <div style="display: flex; align-items: center;">
  57. <span class="game-options_optionLabel__dJ_Cy" style="margin: 0; padding-right: 6px;">Enabled</span>
  58. <input type="checkbox" id="enableScript" onclick="toggleBlinkMode(this)" class="toggle_toggle__hwnyw">
  59. </div>
  60.  
  61. <div style="display: flex; align-items: center;">
  62. <span class="game-options_optionLabel__dJ_Cy" style="margin: 0; padding-right: 6px;">Time (Seconds)</span>
  63. <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;">
  64. </div>
  65.  
  66. <div style="display: flex; align-items: center;">
  67. <span class="game-options_optionLabel__dJ_Cy" style="margin: 0; padding-right: 6px;">Round Delay (Seconds)</span>
  68. <input type="text" id="delayTime" onchange="changeDelayTime(this)" style="background: rgba(255,255,255,0.1); color: white; border: none; border-radius: 5px; width: 60px;">
  69. </div>
  70. </div>
  71. </div>
  72. `
  73.  
  74. const guiHTMLHeader = `
  75. <div id="blinkHeaderToggle" class="header_item__8_Ol1">
  76. <div class="quick-search_wrapper__SP8ZI">
  77. <div class="slanted-wrapper_root__2eaEs slanted-wrapper_variantGrayTransparent__aufaF">
  78. <div class="slanted-wrapper_start__Kl7rv slanted-wrapper_right__G0JWR"></div>
  79. <div class="quick-search_searchInputWrapper__WWuRE">
  80. <div id="popup" style="background: rgba(26, 26, 46, 0.9); padding: 15px; width: 200px; border-radius: 10px;">
  81. <div style="display: flex; justify-content: space-between; align-items: center;">
  82. <span class="game-options_optionLabel__dJ_Cy">Enabled</span>
  83. <input type="checkbox" id="enableScriptHeader" onclick="toggleBlinkMode(this)">
  84. </div>
  85.  
  86. <div style="display: flex; justify-content: space-between; align-items: center; margin-top: 10px;">
  87. <span class="game-options_optionLabel__dJ_Cy">Time (Seconds)</span>
  88. <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;">
  89. </div>
  90.  
  91. <div style="display: flex; justify-content: space-between; align-items: center; margin-top: 10px;">
  92. <span class="game-options_optionLabel__dJ_Cy" style="margin: 0; padding-right: 6px;">Round Delay (Seconds)</span>
  93. <input type="text" id="delayTimeHeader" onchange="changeDelayTime(this)" style="background: rgba(255,255,255,0.1); color: white; border: none; border-radius: 5px; width: 60px;">
  94. </div>
  95. </div>
  96. <button style="width: 59.19px" id="headerGuiToggle" class="quick-search_searchInputButton__kK9Hz"><picture style="justify-content: center" class="quick-search_iconSection__3Wdfr"><img src="https://www.svgrepo.com/show/40039/eye.svg" style="width: 15px; filter: brightness(0) invert(1); opacity: 60%;"></picture></button>
  97. </div>
  98. <div class="slanted-wrapper_end__cD1Qu slanted-wrapper_right__G0JWR"></div>
  99. </div>
  100. </div>
  101. </div>
  102. `
  103.  
  104.  
  105. if (localStorage.getItem('blinkEnabled') == null) {
  106. localStorage.setItem('blinkEnabled', 'disabled');
  107. }
  108.  
  109. if (!guiEnabled) {
  110. localStorage.setItem('blinkEnabled', 'enabled');
  111. }
  112.  
  113. if (localStorage.getItem('blinkTime') == null || isNaN(localStorage.getItem('blinkTime'))) {
  114. localStorage.setItem('blinkTime', timeLimit);
  115. }
  116. if (localStorage.getItem('delayTime') == null || isNaN(localStorage.getItem('delayTime'))) {
  117. localStorage.setItem('delayTime', roundDelay);
  118. }
  119.  
  120. if (guiEnabled) {
  121. timeLimit = parseFloat(localStorage.getItem('blinkTime'));
  122. roundDelay = parseFloat(localStorage.getItem('delayTime'));
  123. }
  124.  
  125. window.toggleBlinkMode = (e) => {
  126. localStorage.setItem('blinkEnabled', e.checked ? 'enabled' : 'disabled');
  127.  
  128. if (document.querySelector('#enableScript')) {
  129. document.querySelector('#enableScript').checked = e.checked;
  130. }
  131. if (document.querySelector('#enableScriptHeader')) {
  132. document.querySelector('#enableScriptHeader').checked = e.checked;
  133. }
  134. }
  135.  
  136. window.changeBlinkTime = (e) => {
  137. if (!isNaN(e.value)) {
  138. localStorage.setItem('blinkTime', parseFloat(e.value));
  139. timeLimit = parseFloat(e.value);
  140.  
  141. if (document.querySelector('#blinkTime')) {
  142. document.querySelector('#blinkTime').value = e.value;
  143. }
  144. if (document.querySelector('#blinkTimeHeader')) {
  145. document.querySelector('#blinkTimeHeader').value = e.value;
  146. }
  147. }
  148. }
  149.  
  150. window.changeDelayTime = (e) => {
  151. if (!isNaN(e.value)) {
  152. localStorage.setItem('delayTime', parseFloat(e.value));
  153. roundDelay = parseFloat(e.value);
  154.  
  155. if (document.querySelector('#delayTime')) {
  156. document.querySelector('#delayTime').value = e.value;
  157. }
  158. if (document.querySelector('#delayTimeHeader')) {
  159. document.querySelector('#delayTimeHeader').value = e.value;
  160. }
  161. }
  162. }
  163.  
  164. const checkInsertGui = () => {
  165. // Play page for classic games
  166. if (document.querySelector('.radio-box_root__ka_9S') && document.querySelector('#enableScript') === null) {
  167. document.querySelector('.section_sectionMedium__yXgE6').insertAdjacentHTML('beforeend', classicGameGuiHTML);
  168. if (localStorage.getItem('blinkEnabled') === 'enabled') {
  169. document.querySelector('#enableScript').checked = true;
  170. }
  171. document.querySelector('#blinkTime').value = timeLimit;
  172. document.querySelector('#delayTime').value = roundDelay;
  173. }
  174.  
  175. // Lobby for friends party games
  176. if (document.querySelector('.game-options_root__ppDoQ') && document.querySelector('#enableScript') === null) {
  177. document.querySelector('.game-options_optionGroup__qNKx1').insertAdjacentHTML('beforeend', friendLobbyGuiHTML);
  178. if (localStorage.getItem('blinkEnabled') === 'enabled') {
  179. document.querySelector('#enableScript').checked = true;
  180. }
  181. document.querySelector('#blinkTime').value = timeLimit;
  182. document.querySelector('#delayTime').value = roundDelay;
  183. }
  184.  
  185. // Header
  186. if (document.querySelector('.header_header___qZAn') && document.querySelector('#blinkHeaderToggle') === null) {
  187. document.querySelector('.header_context__UqsBa').insertAdjacentHTML('afterbegin', guiHTMLHeader);
  188. const showButton = document.querySelector('#headerGuiToggle');
  189. const popup = document.querySelector('#popup');
  190. popup.style.display = 'none';
  191.  
  192. document.addEventListener('click', (e) => {
  193. const target = e.target;
  194. if (target == popup || popup.contains(target)) return;
  195. if (target.matches('#headerGuiToggle, #headerGuiToggle *')) {
  196. e.preventDefault();
  197.  
  198. popup.style.display = 'block';
  199. Popper.createPopper(showButton, popup, {
  200. placement: 'bottom',
  201. modifiers: [
  202. {
  203. name: 'offset',
  204. options: {
  205. offset: [0, 10],
  206. },
  207. },
  208. ],
  209. });
  210. } else {
  211. popup.style.display = 'none';
  212. }
  213.  
  214. if (document.querySelector('#enableScriptHeader')) {
  215. if (localStorage.getItem('blinkEnabled') === 'enabled') {
  216. document.querySelector('#enableScriptHeader').checked = true;
  217. }
  218. document.querySelector('#blinkTimeHeader').value = timeLimit;
  219. document.querySelector('#delayTimeHeader').value = roundDelay;
  220. }
  221. });
  222. }
  223. }
  224.  
  225. function hidePanorama() {
  226. document.querySelector('.mapsConsumerUiSceneInternalCoreScene__root').style.filter = 'brightness(0%)';
  227. }
  228.  
  229. function showPanorama() {
  230. document.querySelector('.mapsConsumerUiSceneInternalCoreScene__root').style.filter = 'brightness(100%)';
  231. }
  232.  
  233. function isLoading() {
  234. return document.querySelector('.fullscreen-spinner_root__IwRRr') || !document.querySelector('.widget-scene-canvas');
  235. }
  236.  
  237. let wasBackdropThereOrLoading = false;
  238. function isBackdropThereOrLoading() {
  239. return isLoading() // loading
  240. || document.querySelector('.result-layout_root__NfX12') // classic
  241. || document.querySelector('.overlay_backdrop__Rh_QC') // duels / team duels
  242. || document.querySelector('.game_backdrop__A_Ze9') || document.querySelector('.overlays_backdrop__sIb35') // live challenges
  243. || document.querySelector('.popup_backdrop__R52hP') // BR
  244. || document.querySelector('.game-starting_container__TMoWC') || document.querySelector('.round-score_container__avps2') // bullseye
  245. || document.querySelector('.overlay-modal_backlight__Ekx7t'); // city streaks
  246. }
  247.  
  248. let showTimeoutID = null
  249. let hideTimeoutID = null
  250. function triggerBlink() {
  251. hidePanorama();
  252. clearTimeout(showTimeoutID);
  253. showTimeoutID = setTimeout(showPanorama, roundDelay * 1000);
  254. clearTimeout(hideTimeoutID);
  255. hideTimeoutID = setTimeout(hidePanorama, (timeLimit + roundDelay) * 1000);
  256. }
  257.  
  258. let observer = new MutationObserver((mutations) => {
  259. if (guiEnabled) {
  260. checkInsertGui();
  261. }
  262.  
  263. if (localStorage.getItem('blinkEnabled') === 'enabled') {
  264. if (isBackdropThereOrLoading()) {
  265. wasBackdropThereOrLoading = true;
  266. if (!isLoading()) hidePanorama();
  267. } else if (wasBackdropThereOrLoading) {
  268. wasBackdropThereOrLoading = false;
  269. triggerBlink();
  270. }
  271. }
  272. });
  273.  
  274. observer.observe(document.body, {
  275. characterDataOldValue: false,
  276. subtree: true,
  277. childList: true,
  278. characterData: false
  279. });

QingJ © 2025

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