Skip to content

Commit

Permalink
Add rule for Shopify Customer Privacy CMP (#616)
Browse files Browse the repository at this point in the history
* Add rule for Shopify Customer Privacy CMP

* EVAL_SHOPIFY -> EVAL_SHOPIFY_TEST

* Fix tests
  • Loading branch information
noisysocks authored Jan 31, 2025
1 parent 7ef3890 commit e078a75
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/eval-snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ export const snippets = {
(document.cookie.match(/.YAAAAAAAAAAA/) || document.cookie.match(/.aAAAAAAAAAAA/) || document.cookie.match(/.YAAACFgAAAAA/)),
EVAL_REDDIT_0: () => document.cookie.includes('eu_cookie={%22opted%22:true%2C%22nonessential%22:false}'),
EVAL_ROBLOX_TEST: () => document.cookie.includes('RBXcb'),
EVAL_SHOPIFY_TEST: () =>
document.cookie.includes('gdpr_cookie_consent=0') ||
(document.cookie.includes('_tracking_consent=') &&
JSON.parse(
decodeURIComponent(
document.cookie
.split(';')
.find((s) => s.trim().startsWith('_tracking_consent'))
.split('=')[1],
),
).purposes.a === false),
EVAL_SKYSCANNER_TEST: () => document.cookie.match(/gdpr=[^;]*adverts:::false/) && !document.cookie.match(/gdpr=[^;]*init:::true/),
EVAL_SIRDATA_UNBLOCK_SCROLL: () => {
document.documentElement.classList.forEach((cls) => {
Expand Down
31 changes: 31 additions & 0 deletions rules/autoconsent/shopify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "shopify",
"vendorUrl": "https://shopify.dev/docs/api/customer-privacy",
"cosmetic": false,
"prehideSelectors": ["#shopify-pc__banner"],
"detectCmp": [
{
"exists": "#shopify-pc__banner"
}
],
"detectPopup": [
{
"visible": "#shopify-pc__banner"
}
],
"optIn": [
{
"waitForThenClick": "#shopify-pc__banner__btn-accept"
}
],
"optOut": [
{
"waitForThenClick": "#shopify-pc__banner__btn-decline"
}
],
"test": [
{
"eval": "EVAL_SHOPIFY_TEST"
}
]
}
7 changes: 7 additions & 0 deletions tests/shopify.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import generateCMPTests from '../playwright/runner';

generateCMPTests('shopify', [
'https://store.leviton.com/collections/smart-load-center',
'https://snaprevise.co.uk/',
'https://www.blacklimba.com/',
]);

0 comments on commit e078a75

Please sign in to comment.