adblock

Adblock. Add css class or remove attribute from element


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.


Solution

  • It's possible to do it on uBlock Origin and AdGuard. Each has its own syntax for the styling rules, but each is now 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#subjectstylearg, https://adguard.com/kb/general/ad-filtering/create-own-filters/#cosmetic-css-rules