SafariConverterLib
SafariConverterLib copied to clipboard
Add limited support for `$cookie` rules
Safari content blocking API provides rules with action block-cookies:
Strips cookies from the header before sending it to the server. This only blocks cookies otherwise acceptable to Safari's privacy policy. Combining with ignore-previous-rules doesn't override the browser’s privacy settings.
This is nothing compared to what $cookie rules are capable of in other AdGuard versions. However, we can improve the situation a little bit if we accompany block-cookie content blocking rules with "advanced rules". The purpose of the "advanced rules" will be to use Javascript and remove cookies via document.cookie.
Briefly, here's what I suggest.
A rule like that: $cookie=test,domain=google.com
Should be converted to two rules.
- One is a safari content blocking API rule:
{ trigger: { "if-domain": "google.com*" }, "action": { type: "block-cookies" } }. - The other one is an advanced rule that will run a script removing the cookie using
document.cookie
This is certainly far from the $cookie rules capabilities, but it's better than nothing anyways.
One of the apps I tested to “block” cookies had an issue that severely degraded performance because it kept polling and removing the cookies always. Personally speaking, I’d rather have something that set the cookies to expire at the end of the day or the session, if the other solutions have performance tradeoffs.
In the case of AdGuard we rely on filters that tell AdGuard what to do, it's not a generic solution for clearing all cookies or something like that, it's just a way to implement at least partly a type of rules that are supported by other AdGuard versions.
Consider my comment an anecdote sharing the fact that a solution that constantly polls and removes cookies for a particular domain may severely degrade battery and performance.On 13 Aug 2023, at 17:26, Andrey Meshkov @.***> wrote: In the case of AdGuard we rely on filters that tell AdGuard what to do, it's not a generic solution for clearing all cookies or something like that, it's just a way to implement at least partly a type of rules that are supported by other AdGuard versions.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>