There is nothing wrong with using !important
in Greasemonkey scripts and Stylish styles. (It is sometimes misused in regular web pages, but userscripts are different).
!important
is the only way to override styles set in attributes. For example, if we want to change this:
<div id="annoyingBlock" style="background: red; top: 4em; display: inline block ... Bunch of other styles that we don't want to touch.">
Look at me!
</div>
to have a white background, our userscript must either overwrite that style
attribute (which can be a right pain on large complex sites and can bust the other inline styles we may still want) or, it must use the !important
flag, like so:
GM_addStyle ( " \
#annoyingBlock { \
background: white !important; \
} \
" );
This is because attributes (inline styles) have a higher precedence over anything but !important
styles.
If your style changes using .css()
are getting overwritten by the page's javascript, use a technique like in this answer to combat that.