Geoguessr Blink Mode

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

目前为 2022-05-30 提交的版本。查看 最新版本

  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 0.3.0
  5. // @author macca#8949
  6. // @license MIT
  7. // @include https://www.geoguessr.com/*
  8. // @run-at document-start
  9. // @grant none
  10. // @namespace https://greasyfork.org/en/scripts/438579-geoguessr-blink-mode
  11. // ==/UserScript==
  12.  
  13. const guiEnabled = true
  14. // ^^^^ Set to false (all lowercase) if you want to hide the GUI and manually enable the script/set the time, otherwise true
  15.  
  16. let timeLimit = 1.5
  17. // ^^^ Modify this number above to change the time
  18.  
  19.  
  20.  
  21. // --------- DON'T MODIFY ANYTHING BELOW THIS LINE -------- //
  22.  
  23.  
  24.  
  25. const guiHTML = `
  26. <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>
  27. <div class="start-standard-game_settings__x94PU">
  28. <div style="display: flex; justify-content: space-around;">
  29. <div style="display: flex; align-items: center;">
  30. <span class="game-options_optionLabel__dJ_Cy" style="margin: 0; padding-right: 6px;">Enabled</span>
  31. <input type="checkbox" id="enableScript" onclick="toggleBlinkMode(this)" class="toggle_toggle__hwnyw">
  32. </div>
  33.  
  34. <div style="display: flex; align-items: center;">
  35. <span class="game-options_optionLabel__dJ_Cy" style="margin: 0; padding-right: 6px;">Time (Seconds)</span>
  36. <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;">
  37. </div>
  38. </div>
  39. <p class="body-text_sizeXSmall__rwJFf" style="margin-top: 20px;">Ensure classic compass is enabled</p>
  40. </div>
  41. `
  42.  
  43.  
  44. if (localStorage.getItem('blinkEnabled') == null) {
  45. localStorage.setItem('blinkEnabled', 'disabled');
  46. }
  47.  
  48. if (!guiEnabled) {
  49. localStorage.setItem('blinkEnabled', 'enabled');
  50. }
  51.  
  52. if (localStorage.getItem('blinkTime') == null || isNaN(localStorage.getItem('blinkTime'))) {
  53. localStorage.setItem('blinkTime', timeLimit);
  54. }
  55.  
  56. if (guiEnabled) {
  57. timeLimit = localStorage.getItem('blinkTime');
  58. }
  59.  
  60. window.toggleBlinkMode = (e) => {
  61. localStorage.setItem('blinkEnabled', e.checked ? 'enabled' : 'disabled');
  62. }
  63.  
  64. window.changeBlinkTime = (e) => {
  65. if (!isNaN(e.value)) {
  66. localStorage.setItem('blinkTime', parseFloat(e.value));
  67. timeLimit = parseFloat(e.value);
  68. }
  69. }
  70.  
  71. const checkInsertGui = () => {
  72. if (document.querySelector('.section_sectionMedium__yXgE6') && document.querySelector('#enableScript') === null) {
  73. document.querySelector('.section_sectionMedium__yXgE6').insertAdjacentHTML('beforeend', guiHTML);
  74. if (localStorage.getItem('blinkEnabled') === 'enabled') {
  75. document.querySelector('#enableScript').checked = true;
  76. }
  77.  
  78. document.querySelector('#blinkTime').value = timeLimit;
  79. }
  80. }
  81.  
  82. let previousTransform = '';
  83.  
  84. const onScreen = (element) => {
  85. let rect = element.getBoundingClientRect();
  86. let topElement = document.elementFromPoint(rect.left + (rect.width / 2), rect.top + (rect.height / 2));
  87. if (element.isSameNode(topElement) & previousTransform != topElement.style.transform) {
  88. previousTransform = topElement.style.transform;
  89. return true;
  90. }
  91. return false;
  92. }
  93.  
  94. let observer = new MutationObserver((mutations) => {
  95. if (guiEnabled) {
  96. checkInsertGui();
  97. }
  98.  
  99. if (localStorage.getItem('blinkEnabled') === 'enabled') {
  100. if (document.querySelector('.compass__indicator')) {
  101. if (onScreen(document.querySelector('.compass__indicator'))) {
  102. setTimeout(() => {
  103. document.querySelector('.widget-scene-canvas').style.display = 'none';
  104. }, timeLimit * 1000);
  105. }
  106. }
  107. }
  108. });
  109.  
  110. observer.observe(document.body, {
  111. characterDataOldValue: false,
  112. subtree: true,
  113. childList: true,
  114. characterData: false
  115. });