GC Dice-A-Roo Keyboard Controls

Adds keyboard controls for Dice-A-Roo on GC.

  1. // ==UserScript==
  2. // @name GC Dice-A-Roo Keyboard Controls
  3. // @namespace https://greasyfork.org/en/users/1175371/
  4. // @version 0.3
  5. // @description Adds keyboard controls for Dice-A-Roo on GC.
  6. // @author sanjix
  7. // @match https://www.grundos.cafe/games/play_dicearoo/
  8. // @match https://www.grundos.cafe/games/dicearoo/
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
  10. // @license MIT
  11. // ==/UserScript==
  12. var restart = document.querySelector("input[value='Press Me']")
  13. var play = document.querySelector("input[value='Lets Play!']")
  14. var roll = document.querySelector("input[value='Roll Again']");
  15.  
  16.  
  17. function diceARoo(element, event) {
  18. if (event.keyCode == 13) {
  19. element.click()
  20. }
  21. }
  22.  
  23. document.addEventListener("keydown", (event) => {
  24. if (event.keyCode == 13) {
  25. if (play != null) {
  26. play.click();
  27. } else if (roll != null) {
  28. roll.click();
  29. } else if (restart != null) {
  30. restart.click();
  31. }
  32. }
  33. });