Skip to content

Commit

Permalink
Move remaining eval rules to snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
muodov committed Aug 17, 2023
1 parent d8b391b commit dd65be1
Show file tree
Hide file tree
Showing 55 changed files with 1,867 additions and 918 deletions.
85 changes: 83 additions & 2 deletions lib/eval-snippets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck

export const snippets = {
// code-based rules
EVAL_0: () => console.log(1),
EVAL_CONSENTMANAGER_1: () => window.__cmp && typeof __cmp("getCMPData") === "object",
EVAL_CONSENTMANAGER_2: () => !__cmp('consentStatus').userChoiceExists,
Expand All @@ -14,10 +16,89 @@ export const snippets = {
EVAL_KLARO_1: () => klaro.getManager().config.services.every(c => c.required || !klaro.getManager().consents[c.name]),
EVAL_ONETRUST_1: () => window.OnetrustActiveGroups.split(',').filter(s => s.length > 0).length <= 1,
EVAL_TRUSTARC_TOP: () => window && window.truste && window.truste.eu.bindMap.prefCookie === '0',


// declarative rules
MEDIAVINE_0: () => document.querySelectorAll("[data-name=\"mediavine-gdpr-cmp\"] input[type=checkbox]").forEach(x => x.checked && x.click()) || true,
BORLABS_0: () => !JSON.parse(decodeURIComponent(document.cookie.split(';').find(c => c.indexOf('borlabs-cookie') !== -1).split('=', 2)[1])).consents.statistics,
COOKIEALERT_0: () => document.querySelector('body').removeAttribute('style') || true,
COOKIEALERT_1: () => document.querySelector('body').removeAttribute('style') || true,
COOKIEALERT_2: () => window.CookieConsent.declined === true,
SNIGEL_0: () => !!document.cookie.match('snconsent'),
DSGVO_0: () => !document.cookie.includes('sp_dsgvo_cookie_settings'),
ADROLL_0: () => !document.cookie.includes('__adroll_fpc'),
EU_COOKIE_LAW_0: () => !document.cookie.includes('euCookie'),
PRIMEBOX_0: () => !document.cookie.includes('cb-enabled=accepted'),
CLINCH_0: () => document.cookie.includes('ctc_rejected=1'),
THEFREEDICTIONARY_0: () => cmpUi.showPurposes() || cmpUi.rejectAll() || true,
THEFREEDICTIONARY_1: () => cmpUi.allowAll() || true,
SIBBO_0: () => !!window.localStorage.getItem('euconsent-v2'),
BING_0: () => document.cookie.includes('AL=0') && document.cookie.includes('AD=0') && document.cookie.includes('SM=0'),
PAYPAL_0: () => document.cookie.includes('cookie_prefs') === true,
DUNELM_0: () => document.cookie.includes('cc_functional=0') && document.cookie.includes('cc_targeting=0'),
AXEPTIO_0: () => document.cookie.includes('axeptio_authorized_vendors=%2C%2C'),
UBUNTU_COM_0: () => document.cookie === '_cookies_accepted=essential',
IUBENDA_0: () => document.querySelectorAll('.purposes-item input[type=checkbox]:not([disabled])').forEach(x => {if(x.checked) x.click()}) || true,
IUBENDA_1: () => !!document.cookie.match(/_iub_cs-\d+=/),
CLICKIO_0: () => document.cookie.includes('__lxG__consent__v2_daisybit='),
YOUTUBE_MOBILE_0: () => !!document.cookie.match(/SOCS=CAE/),
STEAMPOWERED_0: () => JSON.parse(decodeURIComponent(document.cookie.split(';').find(s => s.trim().startsWith('cookieSettings')).split('=')[1])).preference_state === 2,
TARTEAUCITRON_0: () => tarteaucitron.userInterface.respondAll(false) || true,
TARTEAUCITRON_1: () => tarteaucitron.userInterface.respondAll(true) || true,
TARTEAUCITRON_2: () => document.cookie.match(/tarteaucitron=[^;]*/)[0].includes('false'),
COOKIE_LAW_INFO_0: () => CLI.disableAllCookies() || CLI.reject_close() || true,
COOKIE_LAW_INFO_1: () => document.cookie.indexOf('cookielawinfo-checkbox-non-necessary=yes') === -1,
DAILYMOTION_0: () => !!document.cookie.match('dm-euconsent-v2'),
COOKIEFIRST_1: () => document.querySelectorAll('button[data-cookiefirst-accent-color=true][role=checkbox]:not([disabled])').forEach(i => (i.getAttribute('aria-checked') == 'true' && i.click())) || true,
COOKIEFIRST_0: () => ((o)=>o.performance === false && o.functional === false && o.advertising === false) (JSON.parse(decodeURIComponent(document.cookie.split(';').find(c => c.indexOf('cookiefirst') !== -1).trim()).split('=')[1])),
ETSY_0: () => document.querySelectorAll(".gdpr-overlay-body input").forEach(toggle => { toggle.checked = false; }) || true,
ETSY_1: () => document.querySelector('.gdpr-overlay-view button[data-wt-overlay-close]').click() || true,
EZOIC_0: () => ezCMP.handleAcceptAllClick(),
EZOIC_1: () => !!document.cookie.match(/ezCMPCookieConsent=[^;]+\|2=0\|3=0\|4=0/),
COOKIE_MANAGER_POPUP_0: () => JSON.parse(document.cookie.split(';').find(c => c.trim().startsWith('CookieLevel')).split('=')[1]).social === false,
AFFINITY_SERIF_COM_0: () => document.cookie.includes('serif_manage_cookies_viewed') && !document.cookie.includes('serif_allow_analytics'),
COMPLIANZ_CATEGORIES_0: () => !!document.cookie.match(/cmplz_[^=]+=deny/),
BUNDESREGIERUNG_DE_0: () => document.cookie.match('cookie-allow-tracking=0'),
USERCENTRICS_BUTTON_0: () => JSON.parse(localStorage.getItem('usercentrics')).consents.every(c => c.isEssential || !c.consentStatus),
WAITROSE_0: () => Array.from(document.querySelectorAll('label[id$=cookies-deny-label]')).forEach(e => e.click()) || true,
WAITROSE_1: () => document.cookie.includes('wtr_cookies_advertising=0') && document.cookie.includes('wtr_cookies_analytics=0'),
COINBASE_0: () => JSON.parse(decodeURIComponent(document.cookie.match(/cm_(eu|default)_preferences=([0-9a-zA-Z\\{\\}\\[\\]%:]*);?/)[2])).consent.length <= 1,
COMPLIANZ_BANNER_0: () => document.cookie.includes('cmplz_banner-status=dismissed'),
JQUERY_COOKIEBAR_0: () => !document.cookie.includes('cookies-state=accepted'),
SIRDATA_0: () => document.cookie.includes('euconsent-v2'),
TESTCMP_COSMETIC_0: () => window.results.results[0] === 'banner_hidden',
WP_COOKIE_NOTICE_0: () => document.cookie.includes('wpl_viewed_cookie=no'),
THEVERGE_0: () => document.cookie.includes('_duet_gdpr_acknowledged=1'),
192_0: () => document.cookie.includes('CC_ADVERTISING=NO') && document.cookie.includes('CC_ANALYTICS=NO'),
USERCENTRICS_API_0: () => typeof UC_UI === 'object',
USERCENTRICS_API_1: () => !!UC_UI.closeCMP(),
USERCENTRICS_API_2: () => !!UC_UI.denyAllConsents(),
USERCENTRICS_API_3: () => !!UC_UI.acceptAllConsents(),
USERCENTRICS_API_4: () => !!UC_UI.closeCMP(),
USERCENTRICS_API_5: () => UC_UI.areAllConsentsAccepted() === true,
USERCENTRICS_API_6: () => UC_UI.areAllConsentsAccepted() === false,
MICROSOFT_0: () => Array.from(document.querySelectorAll('div > button')).filter(el => el.innerText.match('Reject|Ablehnen'))[0].click() || true,
MICROSOFT_1: () => Array.from(document.querySelectorAll('div > button')).filter(el => el.innerText.match('Accept|Annehmen'))[0].click() || true,
MICROSOFT_2: () => !!document.cookie.match('MSCC'),
COOKIEINFORMATION_0: () => CookieInformation.declineAllCategories() || true,
COOKIEINFORMATION_1: () => CookieInformation.submitAllCategories() || true,
COOKIEINFORMATION_2: () => document.cookie.includes('CookieInformationConsent='),
YOUTUBE_DESKTOP_0: () => !!document.cookie.match(/SOCS=CAE/),
UK_COOKIE_CONSENT_0: () => !document.cookie.includes('catAccCookies'),
EU_COOKIE_COMPLIANCE_0: () => document.cookie.indexOf('cookie-agreed=2') === -1,
REDDIT_0: () => document.cookie.includes('eu_cookie={%22opted%22:true%2C%22nonessential%22:false}'),
GOOGLE_0: () => !!document.cookie.match(/SOCS=CAE/),
PUBTECH_0: () => document.cookie.includes('euconsent-v2') && (document.cookie.match(/.YAAAAAAAAAAA/) || document.cookie.match(/.aAAAAAAAAAAA/) || document.cookie.match(/.YAAACFgAAAAA/)) ,
TEALIUM_0: () => typeof window.utag !== 'undefined' && typeof utag.gdpr === 'object',
TEALIUM_1: () => utag.gdpr.setConsentValue(false) || true,
TEALIUM_2: () => utag.gdpr.setConsentValue(true) || true,
TEALIUM_3: () => utag.gdpr.getConsentState() !== 1,
TESTCMP_0: () => window.results.results[0] === 'button_clicked',
CANVA_0: () => !document.cookie.includes('gtm_fpc_engagement_event'),
COMPLIANZ_OPTIN_0: () => !!document.cookie.match(/cookieconsent_preferences_disabled=[^;]+/),
XING_0: () => document.cookie.includes('userConsent=%7B%22marketing%22%3Afalse'),
}

export function getFunctionBody(snippetFunc: () => any) {
const snippetStr = snippetFunc.toString();
return snippetStr.substring(snippetStr.indexOf("()=>") + 4);
return snippetStr.substring(snippetStr.indexOf("=>") + 2);
}
46 changes: 30 additions & 16 deletions rules/autoconsent/192.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
{
"name": "192.com",
"detectCmp": [{ "exists": ".ont-cookies"}],
"detectPopup": [{ "visible": ".ont-cookies" }],
"optIn": [{ "click": ".ont-btn-main.ont-cookies-btn.js-ont-btn-ok2" }],
"optOut": [
{
"click": ".ont-cookes-btn-manage"
},
{
"click": ".ont-btn-main.ont-cookies-btn.js-ont-btn-choose"
}
],
"test": [
{"eval": "document.cookie.includes('CC_ADVERTISING=NO') && document.cookie.includes('CC_ANALYTICS=NO')"}
]
}
"name": "192.com",
"detectCmp": [
{
"exists": ".ont-cookies"
}
],
"detectPopup": [
{
"visible": ".ont-cookies"
}
],
"optIn": [
{
"click": ".ont-btn-main.ont-cookies-btn.js-ont-btn-ok2"
}
],
"optOut": [
{
"click": ".ont-cookes-btn-manage"
},
{
"click": ".ont-btn-main.ont-cookies-btn.js-ont-btn-choose"
}
],
"test": [
{
"eval": "192_0"
}
]
}
38 changes: 29 additions & 9 deletions rules/autoconsent/adroll.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
{
"name": "Adroll",
"prehideSelectors": ["#adroll_consent_container"],
"detectCmp": [{ "exists": "#adroll_consent_container" }],
"detectPopup": [{ "visible": "#adroll_consent_container" }],
"optIn": [ { "waitForThenClick": "#adroll_consent_accept" } ],
"optOut": [ { "waitForThenClick": "#adroll_consent_reject" } ],
"test": [
{ "eval": "!document.cookie.includes('__adroll_fpc')" }
]
"name": "Adroll",
"prehideSelectors": [
"#adroll_consent_container"
],
"detectCmp": [
{
"exists": "#adroll_consent_container"
}
],
"detectPopup": [
{
"visible": "#adroll_consent_container"
}
],
"optIn": [
{
"waitForThenClick": "#adroll_consent_accept"
}
],
"optOut": [
{
"waitForThenClick": "#adroll_consent_reject"
}
],
"test": [
{
"eval": "ADROLL_0"
}
]
}
76 changes: 40 additions & 36 deletions rules/autoconsent/affinity-serif-com.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
{
"name": "affinity.serif.com",
"detectCmp": [
{
"exists": ".c-cookie-banner button[data-qa='allow-all-cookies']"
}
],
"detectPopup": [
{ "visible": ".c-cookie-banner" }
],
"optIn": [
{ "click": "button[data-qa=\"allow-all-cookies\"]" }
],
"optOut": [
{
"click": "button[data-qa=\"manage-cookies\"]"
},
{
"waitFor": ".c-cookie-banner ~ [role=\"dialog\"]"
},
{
"waitForThenClick": ".c-cookie-banner ~ [role=\"dialog\"] input[type=\"checkbox\"][value=\"true\"]",
"all": true
},
{
"click": ".c-cookie-banner ~ [role=\"dialog\"] .c-modal__action button"
}
],
"test": [
{
"wait": 500
},
{
"eval": "document.cookie.includes('serif_manage_cookies_viewed') && !document.cookie.includes('serif_allow_analytics')"
}
]
}
"name": "affinity.serif.com",
"detectCmp": [
{
"exists": ".c-cookie-banner button[data-qa='allow-all-cookies']"
}
],
"detectPopup": [
{
"visible": ".c-cookie-banner"
}
],
"optIn": [
{
"click": "button[data-qa=\"allow-all-cookies\"]"
}
],
"optOut": [
{
"click": "button[data-qa=\"manage-cookies\"]"
},
{
"waitFor": ".c-cookie-banner ~ [role=\"dialog\"]"
},
{
"waitForThenClick": ".c-cookie-banner ~ [role=\"dialog\"] input[type=\"checkbox\"][value=\"true\"]",
"all": true
},
{
"click": ".c-cookie-banner ~ [role=\"dialog\"] .c-modal__action button"
}
],
"test": [
{
"wait": 500
},
{
"eval": "AFFINITY_SERIF_COM_0"
}
]
}
36 changes: 16 additions & 20 deletions rules/autoconsent/axeptio.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
{
"name": "axeptio",
"prehideSelectors": [".axeptio_widget"],
"detectCmp":
[
{
"exists": ".axeptio_widget"
"prehideSelectors": [
".axeptio_widget"
],
"detectCmp": [
{
"exists": ".axeptio_widget"
}
],
"detectPopup":
[
{
"visible": ".axeptio_widget"
"detectPopup": [
{
"visible": ".axeptio_widget"
}
],
"optIn":
[
"optIn": [
{
"waitFor": ".axeptio-widget--open"
"waitFor": ".axeptio-widget--open"
},
{
"click": "button#axeptio_btn_acceptAll"
}
],
"optOut":
[

"optOut": [
{
"waitFor": ".axeptio-widget--open"
"waitFor": ".axeptio-widget--open"
},
{
"click": "button#axeptio_btn_dismiss"
}
],
"test":
[
"test": [
{
"eval": "document.cookie.includes('axeptio_authorized_vendors=%2C%2C')"
"eval": "AXEPTIO_0"
}
]
}
}
46 changes: 33 additions & 13 deletions rules/autoconsent/bing.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
{
"name": "bing.com",
"prehideSelectors": ["#bnp_container"],
"detectCmp": [{ "exists": "#bnp_cookie_banner"}],
"detectPopup": [{ "visible": "#bnp_cookie_banner" }],
"optIn": [{ "click": "#bnp_btn_accept" }],
"optOut": [
{ "click": "#bnp_btn_preference"},
{ "click": "#mcp_savesettings"}
],
"test": [
{ "eval": "document.cookie.includes('AL=0') && document.cookie.includes('AD=0') && document.cookie.includes('SM=0')"}
]
}
"name": "bing.com",
"prehideSelectors": [
"#bnp_container"
],
"detectCmp": [
{
"exists": "#bnp_cookie_banner"
}
],
"detectPopup": [
{
"visible": "#bnp_cookie_banner"
}
],
"optIn": [
{
"click": "#bnp_btn_accept"
}
],
"optOut": [
{
"click": "#bnp_btn_preference"
},
{
"click": "#mcp_savesettings"
}
],
"test": [
{
"eval": "BING_0"
}
]
}
Loading

0 comments on commit dd65be1

Please sign in to comment.