Skip to content

Commit dd3ba27

Browse files
authored
Bundle tracker lookup and config with extension scripts (#212)
1 parent 71456ed commit dd3ba27

File tree

16 files changed

+361
-460
lines changed

16 files changed

+361
-460
lines changed

.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"globals": {
55
"$USER_PREFERENCES$": "readonly",
66
"$USER_UNPROTECTED_DOMAINS$": "readonly",
7-
"$CONTENT_SCOPE$": "readonly"
7+
"$CONTENT_SCOPE$": "readonly",
8+
"$TRACKER_LOOKUP$": "readonly",
9+
"$BUNDLED_CONFIG$": "readonly"
810
},
911
"rules": {
1012
"indent": ["error", 4]

Sources/ContentScopeScripts/dist/contentScope.js

Lines changed: 22 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4313,59 +4313,14 @@
43134313
}
43144314
}
43154315

4316-
/* eslint-disable quote-props */
4317-
/* eslint-disable quotes */
4318-
/* eslint-disable indent */
4319-
/* eslint-disable eol-last */
4320-
/* eslint-disable no-trailing-spaces */
4321-
/* eslint-disable no-multiple-empty-lines */
4322-
const exceptions = [
4323-
{
4324-
"domain": "nespresso.com",
4325-
"reason": "Clicking 'Continue' after filling out details for account creation yields an error."
4326-
}
4327-
];
4328-
const excludedCookieDomains = [
4329-
{
4330-
"domain": "accounts.google.com",
4331-
"reason": "On some Google sign-in flows, there is an error after entering username and proceeding: 'Your browser has cookies disabled. Make sure that your cookies are enabled and try again.'"
4332-
},
4333-
{
4334-
"domain": "pay.google.com",
4335-
"reason": "After sign-in for Google Pay flows, there is repeated flickering and a loading spinner, preventing the flow from proceeding."
4336-
},
4337-
{
4338-
"domain": "payments.google.com",
4339-
"reason": "After sign-in for Google Pay flows (after flickering is resolved), blocking this causes the loading spinner to spin indefinitely, and the payment flow cannot proceed."
4340-
},
4341-
{
4342-
"domain": "shutterfly.com",
4343-
"reason": "https://github.com/duckduckgo/privacy-configuration/issues/544"
4344-
}
4345-
];
4346-
4347-
let protectionExempted = true;
4348-
const tabHostname = getTabHostname();
4349-
let tabExempted = true;
4350-
4351-
if (tabHostname != null) {
4352-
tabExempted = exceptions.some((exception) => {
4353-
return matchHostname(tabHostname, exception.domain)
4354-
});
4355-
}
4356-
const frameExempted = excludedCookieDomains.some((exception) => {
4357-
return matchHostname(globalThis.location.hostname, exception.domain)
4358-
});
4359-
protectionExempted = frameExempted || tabExempted;
4360-
43614316
// Initial cookie policy pre init
43624317
let cookiePolicy = {
43634318
debug: false,
43644319
isFrame: isBeingFramed(),
43654320
isTracker: false,
4366-
shouldBlock: !protectionExempted,
4321+
shouldBlock: true,
43674322
shouldBlockTrackerCookie: true,
4368-
shouldBlockNonTrackerCookie: true,
4323+
shouldBlockNonTrackerCookie: false,
43694324
isThirdParty: isThirdParty(),
43704325
policy: {
43714326
threshold: 604800, // 7 days
@@ -4414,6 +4369,26 @@
44144369
if (args.platform.name !== 'extension') {
44154370
return
44164371
}
4372+
if (args.documentOriginIsTracker) {
4373+
cookiePolicy.isTracker = true;
4374+
}
4375+
if (args.bundledConfig) {
4376+
// use the bundled config to get a best-effort at the policy, before the background sends the real one
4377+
const { exceptions, settings } = args.bundledConfig.features.cookie;
4378+
const tabHostname = getTabHostname();
4379+
let tabExempted = true;
4380+
4381+
if (tabHostname != null) {
4382+
tabExempted = exceptions.some((exception) => {
4383+
return matchHostname(tabHostname, exception.domain)
4384+
});
4385+
}
4386+
const frameExempted = settings.excludedCookieDomains.some((exception) => {
4387+
return matchHostname(globalThis.location.hostname, exception.domain)
4388+
});
4389+
cookiePolicy.shouldBlock = !frameExempted && !tabExempted;
4390+
cookiePolicy.policy = settings.firstPartyCookiePolicy;
4391+
}
44174392
trackerHosts.clear();
44184393

44194394
// The cookie policy is injected into every frame immediately so that no cookie will

build/android/contentScope.js

Lines changed: 22 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/chrome-mv3/inject.js

Lines changed: 46 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)