Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adblock. Add css class or remove attribute from element

Tags:

adblock

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.

like image 620
Vitalii Avatar asked Mar 21 '16 13:03

Vitalii


2 Answers

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

like image 180
andromeda947 Avatar answered Oct 27 '22 10:10

andromeda947


The other answers weren't working for me but there is a way to change an element's style:

example.com##h1:style(background-color: blue !important)

Make sure not to use curly brackets.

There is also some documentation on GitHub.

EDIT: As BeeLabeille mentioned this advice seems specific to uBlock.

like image 14
flntzr Avatar answered Oct 27 '22 08:10

flntzr