Add AdGuard-trusted scriptlets to replace the old JS rules
https://github.com/AdguardTeam/AdguardFilters/blob/master/AnnoyancesFilter/sections/cookies_specific.txt#L4707
There are tons of JS rules in the Annoyances filter that deal with cookie consent screens.
We should find a way to use scriptlets for that. We may need to introduce a "trusted" type of scriptlets for that, allowed to the user filter and our filter lists only, i.e. trustLevel: full.
- [ ]
click()an element: over 180 rules using this https://github.com/AdguardTeam/Scriptlets/issues/23 - [ ]
localStorage.setItem: over 200 rules usinglocalStorage.setItem - [ ] Setting cookies: over 200 rules using
document.cookie. - [ ] setting HTML elements attributes, example: https://github.com/AdguardTeam/AdguardFilters/pull/69608
- [ ] creating bait elements
- [ ] https://github.com/AdguardTeam/Scriptlets/issues/137
- [ ] https://github.com/AdguardTeam/Scriptlets/issues/196
- [ ] https://github.com/AdguardTeam/Scriptlets/issues/202
https://github.com/AdguardTeam/AdguardFilters/blob/70ee34ef97c141408bbe45f646a7f4354cd3e8cb/AnnoyancesFilter/sections/cookies_specific.txt#L4704-L5073 - daily file have new lines above 4707
I'll keep a checklist with categorized ideas in the top comment.
But I'll need examples for every kind of it.
I suggest to mark new AdGuard-trusted scriptlets with a prefix ag- or agtrusted- so final names will be like ag-set-cookie-free or agtrusted-click-element. they also should have no aliases to emphasize that there are no analogs and as a result to prevent converting and supporting in third-party filters lists
Let's go with trusted-, it's a bit longer, but the meaning is clearer.
Regarding creating bait elements, I think that at the moment this website might be a good example - https://github.com/AdguardTeam/AdguardFilters/issues/75764
Their script is obfuscated, but if I understand correctly, they are doing something like:
if ( document.getElementsByClassName("mghead").length < 1 ) {
console.log("adblock detected");
}
so creating element with class mghead fixes anti-adblock.
Can you please add sessionStorage along with it? #118
Adblock Plus has a snippet simulate-event-poc which is related to click-an-element subtask
https://github.com/abp-filters/abp-filters-anti-cv/commit/246d6ae5358b5da6ec14c06c6169582e77ac20f6
@slavaleleka this one is interesting, but it should definitely be limited to trusted lists only.
ABP still support all snippets form only anti-cv file or from own addons settings in place "my added rules".
So no need fastly write system for privileges (can wait as mark use other snippet as safe loaded form any filter list file).
We're adding support for "trusted" scriptlets to CoreLibs: https://github.com/AdguardTeam/CoreLibs/issues/1612
Once it's added, we should start working on the new scriptlets.
I suppose all world wait for official syntax.
Regarding setting HTML elements attributes, it would be useful if we could also set attribute by getting one of the current attributes from element.
For example, here - https://hdfilmifullizle.com/13-mezar-izle
This website stores video source in data-sonrayukle attribute (and add src attribute after an ad is finished), so that would be nice, if we could also in this scriptlet get attribute from an element and add src attribute with that attribute.
Screenshot

These were implemented in 1.7.3 release:
- trusted-click-element
- trusted-replace-xhr-response
- trusted-replace-fetch-response
- trusted-set-local-storage-item
- trusted-set-cookie
The rest will be added in 1.8
issues for the rest trusted scriptlets
- https://github.com/AdguardTeam/Scriptlets/issues/137
- https://github.com/AdguardTeam/Scriptlets/issues/278
- https://github.com/AdguardTeam/Scriptlets/issues/281
Regarding
setting HTML elements attributes, it would be useful if we could also set attribute by getting one of the current attributes from element.
With this we can replace script rules for https://github.com/AdguardTeam/AdguardFilters/issues/132525, https://github.com/AdguardTeam/AdguardFilters/issues/132814, https://github.com/AdguardTeam/AdguardFilters/issues/135699 Maybe should add TODO comment.