Skip to content

Commit

Permalink
Several site-specific rules (#673)
Browse files Browse the repository at this point in the history
* add rule for rt.com

* add rule for kids.britannica.com

* Add rule for truthsocial

* Add rule for ground news
  • Loading branch information
muodov authored Mar 7, 2025
1 parent cba9742 commit 136a9b3
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/dom-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export class DomActions implements DomActionsProvider {
if (matches.length === 0) {
return [];
}
// TODO: try all matches recursively?
parent = matches[0];
}
return matches;
Expand Down
29 changes: 29 additions & 0 deletions rules/autoconsent/britannica-kids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "britannica-kids",
"vendorUrl": "https://kids.britannica.com/",
"cosmetic": true,
"runContext": {
"urlPattern": "^https://(www\\.)?kids\\.britannica\\.com/"
},
"prehideSelectors": [".bk-cookie-alert-snackbar"],
"detectCmp": [
{
"exists": ".bk-cookie-alert-snackbar"
}
],
"detectPopup": [
{
"visible": ".bk-cookie-alert-snackbar"
}
],
"optIn": [
{
"waitForThenClick": ".bk-snackbar-dismiss"
}
],
"optOut": [
{
"hide": ".bk-cookie-alert-snackbar"
}
]
}
40 changes: 40 additions & 0 deletions rules/autoconsent/groundnews.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "groundnews",
"vendorUrl": "https://ground.news/",
"cosmetic": false,
"runContext": {
"urlPattern": "^https://(www\\.)?ground\\.news/"
},
"prehideSelectors": [],
"detectCmp": [
{
"exists": ".fixed [data-testid=closeCookieBanner]"
}
],
"detectPopup": [
{
"visible": ".fixed [data-testid=closeCookieBanner]"
}
],
"optIn": [
{
"waitForThenClick": ".fixed [data-testid=acceptCookies]"
}
],
"optOut": [
{
"waitForThenClick": [".fixed:has([data-testid=closeCookieBanner])", "xpath///button[contains(., 'Manage cookies')]"]
},
{
"waitFor": ["[data-testid=modal]", "xpath///span[contains(., 'Essential cookies')]"]
},
{
"click": ["[data-testid=modal]", "xpath///button[contains(., 'On')]"],
"all": true,
"optional": true
},
{
"waitForThenClick": ["[data-testid=modal]", "xpath///button[contains(., 'Save & reload')]"]
}
]
}
29 changes: 29 additions & 0 deletions rules/autoconsent/rt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "rt",
"vendorUrl": "https://www.rt.com/",
"cosmetic": true,
"runContext": {
"urlPattern": "^https://(www\\.)?rt\\.com/"
},
"prehideSelectors": [".cookies-banner-shown"],
"detectCmp": [
{
"exists": ".cookies-banner-shown"
}
],
"detectPopup": [
{
"visible": ".cookies-banner-shown"
}
],
"optIn": [
{
"waitForThenClick": ".cookies-banner-shown .js-cookies-button"
}
],
"optOut": [
{
"hide": ".cookies-banner-shown"
}
]
}
29 changes: 29 additions & 0 deletions rules/autoconsent/truthsocial.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "truthsocial",
"vendorUrl": "https://truthsocial.com/",
"cosmetic": true,
"runContext": {
"urlPattern": "^https://(www\\.)?truthsocial\\.com/"
},
"prehideSelectors": ["[data-testid=banner]:has(a[href='https://help.truthsocial.com/legal/privacy-policy/'])"],
"detectCmp": [
{
"exists": "[data-testid=banner] a[href='https://help.truthsocial.com/legal/privacy-policy/']"
}
],
"detectPopup": [
{
"visible": "[data-testid=banner] a[href='https://help.truthsocial.com/legal/privacy-policy/']"
}
],
"optIn": [
{
"waitForThenClick": ["[data-testid=banner]", "xpath///button[contains(., 'Accept')]"]
}
],
"optOut": [
{
"hide": "[data-testid=banner]:has(a[href='https://help.truthsocial.com/legal/privacy-policy/'])"
}
]
}
3 changes: 3 additions & 0 deletions tests/britannica-kids.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import generateCMPTests from '../playwright/runner';

generateCMPTests('britannica-kids', ['https://kids.britannica.com/']);
3 changes: 3 additions & 0 deletions tests/groundnews.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import generateCMPTests from '../playwright/runner';

generateCMPTests('groundnews', ['https://ground.news/']);
3 changes: 3 additions & 0 deletions tests/rt.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import generateCMPTests from '../playwright/runner';

generateCMPTests('rt', ['https://www.rt.com/']);
3 changes: 3 additions & 0 deletions tests/truthsocial.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import generateCMPTests from '../playwright/runner';

generateCMPTests('truthsocial', ['https://truthsocial.com/']);

0 comments on commit 136a9b3

Please sign in to comment.