Adblock. Add css class or remove attribute from element

与世无争的帅哥 提交于 2021-02-17 14:56:42

问题


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.


回答1:


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




回答2:


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.




回答3:


I don't think it's possible for AdBlock to change CSS properties, you can use an extension like Stylish (available for Firefox and Chrome) to do just that though.




回答4:


For AdBlock Plus, you can try this:

##.ytp-pause-overlay, .ytp-scroll-min
##.html5-endscreen, .ytp-player-content, .videowall-endscreen, .ytp-endscreen-paginate, .ytp-show-tiles
##.ytp-endscreen-content

This should disable the display of ads during the pause, and recommended videos, at the end of the video.

PS: Ah.. this is not the subject of the question.. this removes the class from the div element. Well, maybe someone will come in handy, to delete unnecessary blocks in the Youtube player.



来源:https://stackoverflow.com/questions/36131929/adblock-add-css-class-or-remove-attribute-from-element

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!