Ghost Game Fix

Disables the "play again" button after you press it on duels for 30 seconds

  1. // ==UserScript==
  2. // @name Ghost Game Fix
  3. // @version 1.0.0
  4. // @description Disables the "play again" button after you press it on duels for 30 seconds
  5. // @match https://www.geoguessr.com/*
  6. // @author Tyow#3742
  7. // @grant none
  8. // @license MIT
  9. // @namespace https://gf.qytechs.cn/en/users/1011193-tyow
  10. // ==/UserScript==
  11.  
  12. const disableButton = b => {
  13. b.disabled = true;
  14. // This only comes into play for a couple of the buttons
  15. b.style.color = "black";
  16. // Countdown div
  17. let d = document.createElement("div");
  18. d.style.fontSize = "22px";
  19. d.style.color = "white";
  20. b.appendChild(d);
  21. // Wait 30 seconds, then reenable
  22. // https://stackoverflow.com/questions/18785217/countdown-timer-in-javascript-using-settimeout
  23. const countDown = (endTime) => {
  24. if (endTime > 0) {
  25. d.innerText = endTime;
  26. setTimeout(() => countDown(endTime -1), 1000);
  27. } else {
  28. b.disabled = false;
  29. b.style.color = "white";
  30. b.removeChild(d);
  31. }
  32. }
  33. countDown(30);
  34. }
  35.  
  36. // Wait for window to load, so that the button will be there
  37. window.onload = (event) => {
  38. // Play Again button
  39. let button = document.getElementsByClassName("button_button__CnARx button_variantPrimary__xc8Hp")[0];
  40. if (location.pathname.startsWith("/duels") && location.pathname.endsWith("/summary")) {
  41. while (button == undefined) {
  42. button = document.getElementsByClassName("button_button__CnARx button_variantPrimary__xc8Hp")[0];
  43. }
  44. // If here, the buttons have loaded into the dom
  45. button.addEventListener("click", () => disableButton(button));
  46. console.log("disable button attached for: ");
  47. console.log(button);
  48. return;
  49. }
  50. // Buttons for game mode at /competitive page
  51. let compButtons = document.getElementsByClassName("play_card__svL35");
  52. if (location.pathname.startsWith("/competitive")) {
  53. while (compButtons.length == 0) {
  54. console.log(compButtons);
  55. compButtons = document.getElementsByClassName("play_card__svL35");
  56. }
  57. // If here, the buttons have loaded into the dom
  58. for (let i = 0; i < compButtons.length; i++) {
  59. compButtons[i].addEventListener("click", () => disableButton(compButtons[i]));
  60. console.log("disable button attached for: ");
  61. console.log(compButtons[i]);
  62. }
  63. return;
  64. }
  65. // Buttons at multiplayer page
  66. let multButtons = document.getElementsByClassName("game-menu-button_button__WPwVi game-menu-button_fillParent__2Dqat");
  67. if (location.pathname.startsWith("/multiplayer")) {
  68. while (multButtons.length == 0) {
  69.  
  70. console.log(multButtons);
  71. multButtons = document.getElementsByClassName("game-menu-button_button__WPwVi game-menu-button_fillParent__2Dqat");
  72. }
  73. // If here, the buttons have loaded into the dom
  74. for (let i = 0; i < multButtons.length; i++) {
  75. multButtons[i].addEventListener("click", () => disableButton(multButtons[i]));
  76. console.log("disable button attached for: ");
  77. console.log(multButtons[i]);
  78. }
  79. return;
  80. }
  81. };

QingJ © 2025

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