Adblock. Add css class or remove attribute from element

Vitalii picture Vitalii · Mar 21, 2016 · Viewed 15.8k times · Source

Is it possible to add css rule to an element at some page by adblock? Something like this

#myElement {
    color: white !important;
}

I tried to find a script that updates style of this element on page load but it seems that it is not a best way.

Answer

andromeda947 picture andromeda947 · Dec 22, 2016

It's possible to do it on uBlock Origin and Adguard (as far as I know). Each has its own syntax for the styling rules, but uBlock is capable understanding both.


Here is an example of a CSS rule that changes Twitter background:

twitter.com#$#body.logged-in{ background-color: #8c8787 !important; }

The styling filters should be constructed like this:

<domain> + #$# + <selector> + { <style> }

Just avoid puting a space between the selector and the opening brace. Cause it can give you some trouble. Reference:

https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#style https://adguard.com/en/filterrules.html#cosmetic-css-rules