From 1d1860b19b482a382c12d1fb81b75ae7418123f9 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 13 Aug 2026 11:45:55 +0000 Subject: [PATCH 1/3] Handle Shopify Polaris consent banner Co-authored-by: Dax --- lib/eval-snippets.ts | 22 +++++++++--- rules/autoconsent/shopify.json | 61 +++++++++++++++++++++++++++++++--- tests/shopify.spec.ts | 1 + 3 files changed, 75 insertions(+), 9 deletions(-) diff --git a/lib/eval-snippets.ts b/lib/eval-snippets.ts index 9f4099bf2c..96ae0ca782 100644 --- a/lib/eval-snippets.ts +++ b/lib/eval-snippets.ts @@ -175,9 +175,21 @@ export const snippets = { EVAL_PUBTECH_0: () => document.cookie.includes('euconsent-v2') && (document.cookie.match(/.YAAAAAAAAAAA/) || document.cookie.match(/.aAAAAAAAAAAA/) || document.cookie.match(/.YAAACFgAAAAA/)), - EVAL_SHOPIFY_TEST: () => - document.cookie.includes('gdpr_cookie_consent=0') || - (document.cookie.includes('_tracking_consent=') && + EVAL_SHOPIFY_TEST: () => { + if (document.cookie.includes('gdpr_cookie_consent=0')) return true; + if (document.cookie.includes('polaris_consent_settings=')) { + const settings = JSON.parse( + decodeURIComponent( + document.cookie + .split(';') + .find((s) => s.trim().startsWith('polaris_consent_settings')) + .split('=')[1], + ), + ); + if (settings.adsPermitted === false) return true; + } + return ( + document.cookie.includes('_tracking_consent=') && JSON.parse( decodeURIComponent( document.cookie @@ -185,7 +197,9 @@ export const snippets = { .find((s) => s.trim().startsWith('_tracking_consent')) .split('=')[1], ), - ).purposes.a === false), + ).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) => { diff --git a/rules/autoconsent/shopify.json b/rules/autoconsent/shopify.json index a939f56227..fdc2af54cc 100644 --- a/rules/autoconsent/shopify.json +++ b/rules/autoconsent/shopify.json @@ -2,25 +2,76 @@ "name": "shopify", "vendorUrl": "https://shopify.dev/docs/api/customer-privacy", "cosmetic": false, - "prehideSelectors": ["#shopify-pc__banner"], + "prehideSelectors": ["#shopify-pc__banner", "#polaris-css-lockdown-container"], "detectCmp": [ { - "exists": "#shopify-pc__banner" + "any": [ + { + "exists": "#shopify-pc__banner" + }, + { + "exists": ["#polaris-css-lockdown-container", "#polaris-consent-widgets"] + } + ] } ], "detectPopup": [ { - "visible": "#shopify-pc__banner" + "any": [ + { + "visible": "#shopify-pc__banner" + }, + { + "visible": ["#polaris-css-lockdown-container", "[role=\"region\"][aria-label=\"Cookie consent\"]"] + } + ] } ], "optIn": [ { - "waitForThenClick": "#shopify-pc__banner__btn-accept" + "if": { + "exists": [ + "#polaris-css-lockdown-container", + "[role=\"region\"][aria-label=\"Cookie consent\"] .polaris-consent-widget__actions button:last-child" + ] + }, + "then": [ + { + "waitForThenClick": [ + "#polaris-css-lockdown-container", + "[role=\"region\"][aria-label=\"Cookie consent\"] .polaris-consent-widget__actions button:last-child" + ], + "timeout": 5000 + } + ], + "else": [ + { + "waitForThenClick": "#shopify-pc__banner__btn-accept" + } + ] } ], "optOut": [ { - "waitForThenClick": "#shopify-pc__banner__btn-decline" + "if": { + "exists": ["#polaris-css-lockdown-container", "[data-polaris-one-click-opt-out=\"true\"]"] + }, + "then": [ + { + "waitForThenClick": ["#polaris-css-lockdown-container", "[data-polaris-one-click-opt-out=\"true\"]"], + "timeout": 5000 + }, + { + "waitForThenClick": ["#polaris-css-lockdown-container", "[data-testid=\"oneClickOptOutClose\"]"], + "timeout": 5000, + "optional": true + } + ], + "else": [ + { + "waitForThenClick": "#shopify-pc__banner__btn-decline" + } + ] } ], "test": [ diff --git a/tests/shopify.spec.ts b/tests/shopify.spec.ts index 1ed571349f..8168681429 100644 --- a/tests/shopify.spec.ts +++ b/tests/shopify.spec.ts @@ -4,4 +4,5 @@ generateCMPTests('shopify', [ 'https://store.leviton.com/collections/smart-load-center', 'https://snaprevise.co.uk/', 'https://www.blacklimba.com/', + 'https://www.mcgeeandco.com/products/calvert-brass-tissue-box-cover', ]); From 18a958629c3a8836215b6dbe02df4da3bc21ccc1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 14 Aug 2026 09:00:00 +0000 Subject: [PATCH 2/3] Split Shopify Polaris consent rule Co-authored-by: Dax --- rules/autoconsent/shopify-polaris.json | 67 ++++++++++++++++++++++++++ rules/autoconsent/shopify.json | 61 ++--------------------- tests/shopify-polaris.spec.ts | 4 ++ tests/shopify.spec.ts | 1 - 4 files changed, 76 insertions(+), 57 deletions(-) create mode 100644 rules/autoconsent/shopify-polaris.json create mode 100644 tests/shopify-polaris.spec.ts diff --git a/rules/autoconsent/shopify-polaris.json b/rules/autoconsent/shopify-polaris.json new file mode 100644 index 0000000000..7aa5c5dd95 --- /dev/null +++ b/rules/autoconsent/shopify-polaris.json @@ -0,0 +1,67 @@ +{ + "name": "shopify-polaris", + "vendorUrl": "https://shopify.dev/docs/api/customer-privacy", + "cosmetic": false, + "prehideSelectors": ["#polaris-css-lockdown-container"], + "detectCmp": [ + { + "exists": ["#polaris-css-lockdown-container", ".polaris-consent-widget"] + } + ], + "detectPopup": [ + { + "visible": ["#polaris-css-lockdown-container", ".polaris-consent-widget"] + } + ], + "optIn": [ + { + "waitForThenClick": [ + "#polaris-css-lockdown-container", + "[role=\"region\"][aria-label=\"Cookie consent\"] .polaris-consent-widget__actions button:last-child" + ], + "timeout": 5000 + } + ], + "optOut": [ + { + "if": { + "exists": ["#polaris-css-lockdown-container", "xpath//button[normalize-space()='Decline']"] + }, + "then": [ + { + "waitForThenClick": ["#polaris-css-lockdown-container", "xpath//button[normalize-space()='Decline']"], + "timeout": 5000 + } + ], + "else": [ + { + "if": { + "exists": ["#polaris-css-lockdown-container", "[data-polaris-one-click-opt-out=\"true\"]"] + }, + "then": [ + { + "waitForThenClick": ["#polaris-css-lockdown-container", "[data-polaris-one-click-opt-out=\"true\"]"], + "timeout": 5000 + } + ], + "else": [ + { + "waitForThenClick": ["#polaris-css-lockdown-container", "[data-testid=\"oneClickOptOutLink\"]"], + "timeout": 5000 + } + ] + } + ] + }, + { + "waitForThenClick": ["#polaris-css-lockdown-container", "[data-testid=\"oneClickOptOutClose\"]"], + "timeout": 5000, + "optional": true + } + ], + "test": [ + { + "eval": "EVAL_SHOPIFY_TEST" + } + ] +} diff --git a/rules/autoconsent/shopify.json b/rules/autoconsent/shopify.json index fdc2af54cc..a939f56227 100644 --- a/rules/autoconsent/shopify.json +++ b/rules/autoconsent/shopify.json @@ -2,76 +2,25 @@ "name": "shopify", "vendorUrl": "https://shopify.dev/docs/api/customer-privacy", "cosmetic": false, - "prehideSelectors": ["#shopify-pc__banner", "#polaris-css-lockdown-container"], + "prehideSelectors": ["#shopify-pc__banner"], "detectCmp": [ { - "any": [ - { - "exists": "#shopify-pc__banner" - }, - { - "exists": ["#polaris-css-lockdown-container", "#polaris-consent-widgets"] - } - ] + "exists": "#shopify-pc__banner" } ], "detectPopup": [ { - "any": [ - { - "visible": "#shopify-pc__banner" - }, - { - "visible": ["#polaris-css-lockdown-container", "[role=\"region\"][aria-label=\"Cookie consent\"]"] - } - ] + "visible": "#shopify-pc__banner" } ], "optIn": [ { - "if": { - "exists": [ - "#polaris-css-lockdown-container", - "[role=\"region\"][aria-label=\"Cookie consent\"] .polaris-consent-widget__actions button:last-child" - ] - }, - "then": [ - { - "waitForThenClick": [ - "#polaris-css-lockdown-container", - "[role=\"region\"][aria-label=\"Cookie consent\"] .polaris-consent-widget__actions button:last-child" - ], - "timeout": 5000 - } - ], - "else": [ - { - "waitForThenClick": "#shopify-pc__banner__btn-accept" - } - ] + "waitForThenClick": "#shopify-pc__banner__btn-accept" } ], "optOut": [ { - "if": { - "exists": ["#polaris-css-lockdown-container", "[data-polaris-one-click-opt-out=\"true\"]"] - }, - "then": [ - { - "waitForThenClick": ["#polaris-css-lockdown-container", "[data-polaris-one-click-opt-out=\"true\"]"], - "timeout": 5000 - }, - { - "waitForThenClick": ["#polaris-css-lockdown-container", "[data-testid=\"oneClickOptOutClose\"]"], - "timeout": 5000, - "optional": true - } - ], - "else": [ - { - "waitForThenClick": "#shopify-pc__banner__btn-decline" - } - ] + "waitForThenClick": "#shopify-pc__banner__btn-decline" } ], "test": [ diff --git a/tests/shopify-polaris.spec.ts b/tests/shopify-polaris.spec.ts new file mode 100644 index 0000000000..cbe9700a05 --- /dev/null +++ b/tests/shopify-polaris.spec.ts @@ -0,0 +1,4 @@ +import generateCMPTests from '../playwright/runner'; + +generateCMPTests('shopify-polaris', ['https://www.mcgeeandco.com/products/calvert-brass-tissue-box-cover']); +generateCMPTests('shopify-polaris', ['https://mightyvault.com/'], { testOptOut: false, testSelfTest: false }); diff --git a/tests/shopify.spec.ts b/tests/shopify.spec.ts index 8168681429..1ed571349f 100644 --- a/tests/shopify.spec.ts +++ b/tests/shopify.spec.ts @@ -4,5 +4,4 @@ generateCMPTests('shopify', [ 'https://store.leviton.com/collections/smart-load-center', 'https://snaprevise.co.uk/', 'https://www.blacklimba.com/', - 'https://www.mcgeeandco.com/products/calvert-brass-tissue-box-cover', ]); From c9db1854a2f1f67291cd421db8411ab802d31428 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 17 Aug 2026 10:20:05 +0000 Subject: [PATCH 3/3] Address Shopify Polaris review comments Co-authored-by: Dax --- lib/eval-snippets.ts | 40 +++++++++++++++----------- rules/autoconsent/shopify-polaris.json | 34 ++++------------------ tests/shopify-polaris.spec.ts | 2 +- 3 files changed, 29 insertions(+), 47 deletions(-) diff --git a/lib/eval-snippets.ts b/lib/eval-snippets.ts index 96ae0ca782..778a22d8eb 100644 --- a/lib/eval-snippets.ts +++ b/lib/eval-snippets.ts @@ -175,21 +175,9 @@ export const snippets = { EVAL_PUBTECH_0: () => document.cookie.includes('euconsent-v2') && (document.cookie.match(/.YAAAAAAAAAAA/) || document.cookie.match(/.aAAAAAAAAAAA/) || document.cookie.match(/.YAAACFgAAAAA/)), - EVAL_SHOPIFY_TEST: () => { - if (document.cookie.includes('gdpr_cookie_consent=0')) return true; - if (document.cookie.includes('polaris_consent_settings=')) { - const settings = JSON.parse( - decodeURIComponent( - document.cookie - .split(';') - .find((s) => s.trim().startsWith('polaris_consent_settings')) - .split('=')[1], - ), - ); - if (settings.adsPermitted === false) return true; - } - return ( - document.cookie.includes('_tracking_consent=') && + EVAL_SHOPIFY_TEST: () => + document.cookie.includes('gdpr_cookie_consent=0') || + (document.cookie.includes('_tracking_consent=') && JSON.parse( decodeURIComponent( document.cookie @@ -197,8 +185,26 @@ export const snippets = { .find((s) => s.trim().startsWith('_tracking_consent')) .split('=')[1], ), - ).purposes.a === false - ); + ).purposes.a === false), + EVAL_SHOPIFY_POLARIS_OPT_OUT: () => { + const root = document.querySelector('#polaris-css-lockdown-container')?.shadowRoot; + if (!root) return false; + const declineButton = Array.from(root.querySelectorAll('button')).find((button) => button.textContent?.trim() === 'Decline'); + const acknowledgeButton = Array.from(root.querySelectorAll('button')).find((button) => button.textContent?.trim() === 'Okay'); + const oneClickOptOut = root.querySelector('[data-polaris-one-click-opt-out="true"], [data-testid="oneClickOptOutLink"]'); + const optOut = declineButton || oneClickOptOut || acknowledgeButton; + if (!optOut) return false; + optOut.click(); + return true; + }, + EVAL_SHOPIFY_POLARIS_TEST: () => { + const settingsCookie = document.cookie + .split(';') + .find((s) => s.trim().startsWith('polaris_consent_settings')) + ?.split('=')[1]; + if (!settingsCookie) return false; + const settings = JSON.parse(decodeURIComponent(settingsCookie)); + return settings.adsPermitted === false && settings.notOptedOut === false; }, EVAL_SKYSCANNER_TEST: () => document.cookie.match(/gdpr=[^;]*adverts:::false/) && !document.cookie.match(/gdpr=[^;]*init:::true/), EVAL_SIRDATA_UNBLOCK_SCROLL: () => { diff --git a/rules/autoconsent/shopify-polaris.json b/rules/autoconsent/shopify-polaris.json index 7aa5c5dd95..2081d2e2de 100644 --- a/rules/autoconsent/shopify-polaris.json +++ b/rules/autoconsent/shopify-polaris.json @@ -24,34 +24,10 @@ ], "optOut": [ { - "if": { - "exists": ["#polaris-css-lockdown-container", "xpath//button[normalize-space()='Decline']"] - }, - "then": [ - { - "waitForThenClick": ["#polaris-css-lockdown-container", "xpath//button[normalize-space()='Decline']"], - "timeout": 5000 - } - ], - "else": [ - { - "if": { - "exists": ["#polaris-css-lockdown-container", "[data-polaris-one-click-opt-out=\"true\"]"] - }, - "then": [ - { - "waitForThenClick": ["#polaris-css-lockdown-container", "[data-polaris-one-click-opt-out=\"true\"]"], - "timeout": 5000 - } - ], - "else": [ - { - "waitForThenClick": ["#polaris-css-lockdown-container", "[data-testid=\"oneClickOptOutLink\"]"], - "timeout": 5000 - } - ] - } - ] + "wait": 1000 + }, + { + "eval": "EVAL_SHOPIFY_POLARIS_OPT_OUT" }, { "waitForThenClick": ["#polaris-css-lockdown-container", "[data-testid=\"oneClickOptOutClose\"]"], @@ -61,7 +37,7 @@ ], "test": [ { - "eval": "EVAL_SHOPIFY_TEST" + "eval": "EVAL_SHOPIFY_POLARIS_TEST" } ] } diff --git a/tests/shopify-polaris.spec.ts b/tests/shopify-polaris.spec.ts index cbe9700a05..26b4291faf 100644 --- a/tests/shopify-polaris.spec.ts +++ b/tests/shopify-polaris.spec.ts @@ -1,4 +1,4 @@ import generateCMPTests from '../playwright/runner'; generateCMPTests('shopify-polaris', ['https://www.mcgeeandco.com/products/calvert-brass-tissue-box-cover']); -generateCMPTests('shopify-polaris', ['https://mightyvault.com/'], { testOptOut: false, testSelfTest: false }); +generateCMPTests('shopify-polaris', ['https://mightyvault.com/'], { testSelfTest: false });