Most of the Web page default background color is white, personal feeling more dazzling, so wrote a JS script to change the body part of the background color, the code is as follows:
//==userscript==//@name Changebackgroundcolor//@namespace Tingl//@include *//@version 1//@grant None//==/userscript==(function () { ' Use strict '; varcolor = ' #ececec '; varstyle; functionCreateStyle () {style= document.createelement (' style ')); Style.type= ' Text/css '; Style.innerhtml= ' body {background-color: ' + color + '!important;} '; } functionChangebackgroundcolor () {if(!style.parentnode) Document.head.appendChild (style); } createstyle (); Changebackgroundcolor (); Document.head.addEventListener ("Domnoderemoved", Changebackgroundcolor);}) ()
The code is simple, directly create a body CSS style rules, and then added to the head, if the page content changes or asynchronous update, etc. to make the style removed, through the event monitoring mechanism to re-add to the head.
The script is limited in scope because it simply changes the background color on the body.
Use JS to dynamically modify the body background color of the Web page