Writing a userscript that replaces a background image

后端 未结 2 1437
耶瑟儿~
耶瑟儿~ 2021-01-27 07:38

This is the code

// ==UserScript==
// @name           Wood Background
// @namespace      http://www.nationstates.net/nation=ellorn
// @description    Changes bac         


        
2条回答
  •  忘了有多久
    2021-01-27 08:23

    For just style changes, use the Stylish add-on (some variant of this is available on almost every browser).

    Stylish is faster, lighter, and easier than Greasemonkey or userscripts. There are plenty of pre-made styles available at userstyles.org.

    Barring that, use built-in functions, like GM_addStyle().

    The following script works on Firefox and Chrome, and probably a few other browsers. (There was a syntax error in the CSS string) :

    // ==UserScript==
    // @name        Wood Background
    // @namespace   http://www.nationstates.net/nation=ellorn
    // @description Changes background to wood finish
    // @include     http:*//w11.zetaboards.com/Allied_Republics/*
    // ==/UserScript==
    
    GM_addStyle (
        "* { background: #00ff00 "
        + "url('http://awesomewallpapers.files.wordpress.com/2010/01/wooden_top.jpg')"
        + " no-repeat fixed center; }"
    );
    

    Note that it would be best to replace the * with body.

提交回复
热议问题