ClickButton

Click on every button (or disguised button) containing the text inserted

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         ClickButton
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Click on every button (or disguised button) containing the text inserted
// @author       Leonard Okaz
// @match        http://*/*
// @match        https://*/*
// @grant        none
// ==/UserScript==

(function() {
    var button = buildButton();
    button.onclick = function() {
        var matchingText = prompt("Please enter the text", null);
        if(matchingText !== null) {
            var buttons = document.querySelectorAll("button, input[type=submit], a");
            for (var iButton = 0; iButton < buttons.length; iButton++) {
                var button = buttons[iButton];
                alert(button.type);
                if (!securedButton(button)) { alert("Security"); continue; }
                else if (button.type === "button" || (button.type === "" && button.href !== "")) {
                    if (button.innerHTML === matchingText) {
                        buttons[iButton].click();
                    }
                }
                else if (button.type === "submit") { //input[type=submit]
                    if (button.value === matchingText) {
                        buttons[iButton].click();
                    }
                }
            }
        }
    };
    document.body.insertBefore(button, document.body.firstChild);
})();

function buildButton() {
    var button = document.createElement("BUTTON");
    var buttonText = document.createTextNode("ClickButton script Tampermonkey");
    button.appendChild(buttonText);
    button.style.background = "#8A2BE2";
    button.style.color = "white";
    button.style.position = "relative";
    button.style.zIndex = "1000";
    return button;
}

// Check if the button is not hidden and clickable, otherwise it can become a source of hack
function securedButton(button) {
    if (button.style.display !==  "none") {
        return true;
    }
    if (buttons[iteratorButton].style.opacity ===  "1" || (buttons[iteratorButton].style.opacity === "" && buttons[iteratorButton].style.opacity !== "0")) {
        return true;
    }
    return false;
}