Scriptlets icon indicating copy to clipboard operation
Scriptlets copied to clipboard

Add new scriptlet — 'trusted-add-class'

Open Alex-302 opened this issue 1 year ago • 3 comments

The trusted-add-class would provide an opportunity to add any class name to an element. For example, sometimes it happens that a script checks the body class list.

example.com#%#//scriptlet('trusted-add-class', selector, classNames[, applying])

where

  • classNames can be a single class or multiple classes separated by commas, e.g. foo or foo,bar
  • applying can be asap, complete and stay like in remove-attr

Can be used on:

  • myonlineradio.hu - bypass antiadblock.

Alex-302 avatar May 30 '24 09:05 Alex-302

https://github.com/AdguardTeam/Scriptlets/issues/431

Alex-302 avatar May 30 '24 09:05 Alex-302

I think that it can be achieved by using trusted-set-attr, for example:

example.org#%#//scriptlet('trusted-set-attr', 'div', 'class', 'foo bar')

Only the applying part is not supported, so I guess it could be implemented if necessary.

AdamWr avatar Jul 12 '24 08:07 AdamWr

Does this construction assume that it will be usable when the div already has classes?

So that others will not disappear by default or pages will start checking the position in the attribute or even counting the number of white separating characters?

krystian3w avatar Jul 15 '24 08:07 krystian3w