Search code examples
cssbuttonstylish

How can I change button value with stylish?


This is the button:

<input type="submit" name="submitbutton" value=" black "><input>

I want to change value "black" to "white" but I can't. How can I change the value with stylish?


Solution

  • Stylish is an add-on/extension that just allows you to inject CSS. The value of that button is a JavaScript / DOM property; Stylish cannot change those.

    You need to install Greasemonkey (Firefox) or Tampermonkey (Chrome).

    Then you can run this userscript to change that value:

    // ==UserScript==
    // @name     _YOUR_SCRIPT_NAME
    // @include  http://YOUR_SERVER.COM/YOUR_PATH/*
    // @grant    GM_addStyle
    // ==/UserScript==
    /*- The @grant directive is needed to work around a design change
        introduced in GM 1.0.   It restores the sandbox.
    */
    var btn = document.querySelector ("input[name='submitbutton']");
    if (btn) {
        btn.value = "White";
    }
    else {
        alert ("From GM script: Button not found");
    }