GM addStyle: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
(simplify)
No edit summary
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:GM_addStyle}}
As of Greasemonkey 4.0, this method has been removed.


== Description ==
<!-- TODO: When it exists, link to the compatibility polyfill docs. -->
 
This method adds a string of CSS to the document.
It creates a new <code><style></code> element, adds the given CSS to it, and inserts it into the <code><head></code>.
 
Compatibility: [[Version_history#0.6.1|Greasemonkey 0.6.1+]]
 
== Syntax ==
 
{{Function|GM_addStyle|css}}
 
=== Arguments ===
 
; <code>css</code>
: <code>String</code> A string of CSS.
 
== Examples ==
 
<pre class='sample'>
GM_addStyle("body { color: white; background-color: black; } img { border: 0; }");
</pre>
 
== Notes ==
 
* Add <code>!important</code> at the end of a CSS declaration to override an existing value (i.e. values the page specifies).
* Using [[Multi Line Strings]] may be helpful.
 
[[Category:API_Reference|A]]

Revision as of 15:00, 3 November 2017

As of Greasemonkey 4.0, this method has been removed.