Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove class from <body> dynamically using uBlock Origin

During browsing when I click an element

<body> 

changes to

<body class="xyz">

Is it possible to remove this class dynamically using uBlock Origin? Expected behavior: when I click this element, <body> does not change. remove-attr.js (suggested by this answer) does not work because class "xyz" is not present at the time when the page is loaded.

like image 905
YuseqYaseq Avatar asked Mar 22 '26 07:03

YuseqYaseq


1 Answers

For those looking to remove the class on pageload, you can now use the :remove-class(class) action operator in uBlock. There is also :remove-attr(attr) as well.

www.example.com##body:remove-class(xyz)

Wiki article: https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#subjectremove-attrarg-subjectremove-classarg


If the class only appears later (e.g. dynamically on click), try prepending with the watch-attr(arg) filter:

www.example.com##body:watch-attr(class):remove-class(xyz)

Wiki article: https://github.com/gorhill/uBlock/wiki/Procedural-cosmetic-filters#subjectwatch-attrarg

like image 132
dragonfire Avatar answered Mar 24 '26 22:03

dragonfire