Greasemonkey Wiki
Brought to you by:
mmartz
This API method adds a string of CSS to the document.
It creates a new <style> element, adds the given CSS to it, and inserts it into the <head>.
⬆ ⬇ | Examples | See Also | Notes
GM_addStyle( css )
Value: Function
Returns: undefined
Compatibility: Greasemonkey 0.6.1 - 3.12.0
Access: @grant
Parameters
| Properties |
|---|
| css |
Value: String
Usage: css = "body { color: red }";
⬆ ⬇ | Spanning with Line Continuation | Spanning with ES6+ Template Strings | Spanning with E4X
GM_addStyle("body { color: white; background-color: black } img { border: 0 }");
GM_addStyle("body { color: white; background-color: black }\
img { border: 0 }\
.footer { width: 875px; }");
GM_addStyle(`
body { color: white; background-color: black }
img { border: 0 }
.footer { width: 875px; }
`);
GM_addStyle(<><![CDATA[
body { color: white; background-color: black }
img { border: 0 }
.footer { width: 875px; }
]]></>.toString()
);
!important at the end of the code to override an existing value.