ClickButton

Click on every button containing the text inserted

Verze ze dne 09. 09. 2016. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         ClickButton
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Click on every button containing the text inserted
// @author       Leonard Okaz
// @match        http://*/*
// @match        https://*/*
// @grant        none
// ==/UserScript==

(function() {
    var button = document.createElement("BUTTON");
    var text = "ClickButton script Tampermonkey";
    var buttonText = document.createTextNode(text);
    button.appendChild(buttonText);
    button.style.background = "#8A2BE2";
    button.style.color = "white";
    button.style.position = "relative";
    button.style.zIndex = "1000";
    button.onclick = function() {
        var matchingText = prompt("Please enter the text", "ClickButton script Tampermonkey");
        if(matchingText !== null) {
            var buttons = document.getElementsByTagName('button');
            for (var iteratorButton = 0; iteratorButton < buttons.length; iteratorButton++) {
                // Check if the button is not hidden and clickable, otherwise it can become a source of hack
                if (buttons[iteratorButton].style.display ===  "none") continue;
                else if (buttons[iteratorButton].innerHTML === matchingText) {
                    buttons[iteratorButton].click();
                }
            }
        }
    };
    document.body.insertBefore(button, document.body.firstChild);
})();