Ghost Game Fix

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

Από την 13/01/2023. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Ghost Game Fix
// @version      1.0.0
// @description  Disables the "play again" button after you press it on duels for 30 seconds
// @match        https://www.geoguessr.com/*
// @author       Tyow#3742
// @grant        none
// @license      MIT
// @namespace    https://greasyfork.org/en/users/1011193-tyow
// ==/UserScript==

const disableButton = b => {
    b.disabled = true;
    // This only comes into play for a couple of the buttons
    b.style.color = "black";
    // Countdown div
    let d = document.createElement("div");
    d.style.fontSize = "22px";
    d.style.color = "white";
    b.appendChild(d);
    // Wait 30 seconds, then reenable
    // https://stackoverflow.com/questions/18785217/countdown-timer-in-javascript-using-settimeout
    const countDown = (endTime) => {
        if (endTime > 0) {
            d.innerText = endTime;
            setTimeout(() => countDown(endTime -1), 1000);
        } else {
            b.disabled = false;
            b.style.color = "white";
            b.removeChild(d);
        }
    }
    countDown(30);
}

// Wait for window to load, so that the button will be there
window.onload = (event) => {
    // Play Again button
    let button = document.getElementsByClassName("button_button__CnARx button_variantPrimary__xc8Hp")[0];
    if (location.pathname.startsWith("/duels") && location.pathname.endsWith("/summary")) {
        while (button == undefined) {
            button = document.getElementsByClassName("button_button__CnARx button_variantPrimary__xc8Hp")[0];
        }
        // If here, the buttons have loaded into the dom
        button.addEventListener("click", () => disableButton(button));
        console.log("disable button attached for: ");
        console.log(button);
        return;
    }
    // Buttons for game mode at /competitive page
    let compButtons = document.getElementsByClassName("play_card__svL35");
    if (location.pathname.startsWith("/competitive")) {
        while (compButtons.length == 0) {
            console.log(compButtons);
            compButtons = document.getElementsByClassName("play_card__svL35");
        }
        // If here, the buttons have loaded into the dom
        for (let i = 0; i < compButtons.length; i++) {
            compButtons[i].addEventListener("click", () => disableButton(compButtons[i]));
            console.log("disable button attached for: ");
            console.log(compButtons[i]);
        }
        return;
    }
    // Buttons at multiplayer page
    let multButtons = document.getElementsByClassName("game-menu-button_button__WPwVi game-menu-button_fillParent__2Dqat");
    if (location.pathname.startsWith("/multiplayer")) {
        while (multButtons.length == 0) {

            console.log(multButtons);
            multButtons = document.getElementsByClassName("game-menu-button_button__WPwVi game-menu-button_fillParent__2Dqat");
        }
        // If here, the buttons have loaded into the dom
        for (let i = 0; i < multButtons.length; i++) {
            multButtons[i].addEventListener("click", () => disableButton(multButtons[i]));
            console.log("disable button attached for: ");
            console.log(multButtons[i]);
        }
        return;
    }
};