Geoguessr - Spacebar to advance to next round

This script allows you to press spacebar to advance to the next round or game in geoguessr, rather than hunting for buttons to click on.

  1. // ==UserScript==
  2. // @name Geoguessr - Spacebar to advance to next round
  3. // @version 0.0.1
  4. // @description This script allows you to press spacebar to advance to the next round or game in geoguessr, rather than hunting for buttons to click on.
  5. // @match https://www.geoguessr.com/*
  6. // @author Tyow#3742
  7. // @grant none
  8. // @license MIT
  9. // @namespace https://greasyfork.org/users/1011193
  10. // ==/UserScript==
  11.  
  12.  
  13. let SPACE_TO_ADVANCE_ENABLED = true;
  14.  
  15. function autoClick()
  16. {
  17. let a = document.querySelector('div[class*=round-result_actions_] button');
  18. let c = document.querySelector('button[data-qa*=start-game-button]');
  19. let d = document.querySelector('div[data-qa*=function-lock] button');
  20. let e = document.querySelector('button[data-qa*=close-round-result]');
  21. let f = document.querySelector('button[data-qa*="play-again-button"]');
  22. let possible_buttons = [a,c,d,e,f];
  23. for (let possible_button of possible_buttons)
  24. {
  25. if (possible_button) possible_button.click();
  26. }
  27. }
  28.  
  29. document.addEventListener('keypress', (f) => {
  30. console.log(f);
  31. switch (f.key) {
  32. case ' ': // press space to automatically press buttons that advance the game (next round, new game, etc)
  33. if (SPACE_TO_ADVANCE_ENABLED && (document.activeElement.tagName.toLowerCase() != 'input' && document.activeElement.tagName.toLowerCase() != 'textarea')) {
  34. autoClick();
  35. f.preventDefault();
  36. }
  37. break;
  38. };
  39. });