Space bar shortcut

try to take over the world!

  1. // ==UserScript==
  2. // @name Space bar shortcut
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://www.geoguessr.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=geoguessr.com
  9. // @grant none
  10. // @license MIT
  11. // @require https://code.jquery.com/jquery-3.6.0.min.js
  12. // ==/UserScript==
  13.  
  14. // prevent space from scrolling down
  15. window.addEventListener('keydown', function(e) {
  16. if(e.keyCode == 32 && e.target == document.body) {
  17. e.preventDefault();
  18. }
  19. });
  20.  
  21. document.body.onkeyup = function(e) {
  22. // if space is pressed and text input isn't focused
  23. var el = document.activeElement;
  24. var input_selected = (el && (el.tagName.toLowerCase() == 'input' && el.type == 'text' ||
  25. el.tagName.toLowerCase() == 'textarea'))
  26. var text_elem = $("span").filter( function() { return ($(this).text() ==='Guess')} );
  27.  
  28. if ((e.key == " " ||
  29. e.code == "Space" ||
  30. e.keyCode == 32)
  31. && !input_selected
  32. && text_elem.length == 0
  33. ) {
  34. // go to "view summary" rather than "next map"
  35. var vew_summarys = $("[data-qa*='close-round-result']");
  36. if (vew_summarys.length){
  37. // click the first one
  38. vew_summarys[0].click();
  39. return
  40. }
  41. // get all elements with the prefix for the primary button class
  42. var primary_buttons = $("[class*='button_variantPrimary_']");
  43. if (primary_buttons.length){
  44. // click the first one
  45. primary_buttons[0].click();
  46. }
  47.  
  48. }
  49. }

QingJ © 2025

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