Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Proposal: Adblocker filter like syntax for AutoCMP #331

Open
seia-soto opened this issue Jan 4, 2024 · 0 comments
Open

Feature Proposal: Adblocker filter like syntax for AutoCMP #331

seia-soto opened this issue Jan 4, 2024 · 0 comments

Comments

@seia-soto
Copy link
Contributor

Summary

Having adblocker-like syntax let you:

  • have better rule quality by filling missing fields in JSON definition in the rule creation step
  • create and manage the rules faster by having single file containing simple rules
  • publish rules easily to online

This system is opt-in and doesn't disturb current workflow in autoconsent. A dedicated project can be created to manage new syntax and transform the syntax into the current structure of autoconsent.

Please visit the following link for the quick view of suggested syntax.

The Syntax

domain.tld##selector[$option1][,option2=value][, ...]
-selector:action(args)
[-selector:action(args):chainedAction(args)]
[-...]
+selector:action(args)
[+selector:action(args):chainedAction(args)]
[+...]

Examples

The examples below are not fully implemented yet. They're likely to be changed in future.

Basic opt-in and opt-out

domain.tld##detectionSelector$cosmetic
-div#optout:wait(_: 500):click()
+div#optin:waitForVisible():click()

This is equivalent to the following JSON rule:

{
  "name": "domain.tld",
  "cosmetic": true,
  "runContext": {"urlPattern": "^https://(www\\.)?domain\\.tld/"},
  "detectCmp": [{ "exists": "detectionSelector" }],
  "detectPopup": [{ "visible": "detectionSelector" }],
  "optOut": [{ "wait": 500 }, { "click": "div#optout" }],
  "optIn": [{ "waitForVisible": "div#optin" }, { "click": "div#optin" }]
}

Chain multiple opt-in and opt-out actions

domain.tld###popup$cosmetic,name=sample
-div#showAllOptions:waitForVisible(timeout: 1000, check: all)
-div#optout:wait(_: 500):click()
+div#optin:click()

This is equivalent to the following JSON rule:

{
  "name": "sample",
  "cosmetic": true,
  "runContext": {"urlPattern": "^https://(www\\.)?domain\\.tld/"},
  "detectCmp": [{ "exists": "detectionSelector" }],
  "detectPopup": [{ "visible": "detectionSelector" }],
  "optOut": [{ "waitForVisible": "div#showAllOptions", "timeout": 1000, "check": "all" }, { "wait": 500 }, { "click": "div#optout" }],
  "optIn": [{ "click": "div#optin" }]
}

Conditionals

domain.tld###popup$cosmetic
-div#version1:if():exists()
-div#version1.optout:then():click()
-div#version2.optout:else():click()
+div#optin:click()

This is equivalent to the following JSON rule:

{
  "name": "domain.tld",
  "cosmetic": true,
  "runContext": {"urlPattern": "^https://(www\\.)?domain\\.tld/"},
  "detectCmp": [{ "exists": "detectionSelector" }],
  "detectPopup": [{ "visible": "detectionSelector" }],
  "optOut": [{ "if": { "exists": "div#version1" }, "then": [{ "click": "div#version1.optout" }], "else": [{ "click": "div#version2.optout" }] }],
  "optIn": [{ "click": "div#optin" }]
}

Drawbacks

  • Having multiple files is a better way to provide intuitive transparency.
  • Conditional syntaxes are not intuitive to write in current format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant