Skip to content

Commit 9fe204d

Browse files
committed
Add tracking domains to managed storage
1 parent be32ff9 commit 9fe204d

4 files changed

Lines changed: 47 additions & 1 deletion

File tree

doc/sample-admin-policies/jid1-MnnxcxisBPnSXQ@jetpack.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"showIntroPage": false,
77
"disabledSites": [
88
"example.com"
9+
],
10+
"trackingDomains": [
11+
{ "action": "block", "domain": "youtube.com" }
912
]
1013
}
1114
}

doc/sample-admin-policies/sample-managed-storage-manifest-chrome.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"showIntroPage": false,
66
"disabledSites": [
77
"example.com"
8+
],
9+
"trackingDomains": [
10+
{ "action": "block", "domain": "youtube.com" }
811
]
912
}
1013
}

src/data/schema.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"disabledSites": {
1010
"title": "Websites to disable Privacy Badger on",
11-
"description": "This is a list of website domains where Privacy Badger will be disabled. This means that Privacy Badger will not block anything or send DNT/GPC signals to anything when you visit a website on this list. This is NOT a list of tracker domains for Privacy Badger to always allow to load.",
11+
"description": "This is a list of website domains where Privacy Badger will be disabled. This means that Privacy Badger will not block anything or send DNT/GPC signals to anything when you visit a website on this list. If you want to customize tracking domain settings, use trackingDomains, not disabledSites.",
1212
"type": "array",
1313
"items": {
1414
"type": "string"
@@ -38,6 +38,23 @@
3838
"title": "Show intro page",
3939
"description": "If set to false then do not open the new user intro page upon install.",
4040
"type": "boolean"
41+
},
42+
"trackingDomains": {
43+
"title": "Tracking Domains",
44+
"description": "This list lets you specify actions for tracking domains.",
45+
"type": "array",
46+
"items": {
47+
"type": "object",
48+
"properties": {
49+
"domain": {
50+
"type": "string"
51+
},
52+
"action": {
53+
"type": "string",
54+
"enum": ["block", "cookieblock", "allow"]
55+
}
56+
}
57+
}
4158
}
4259
}
4360
}

src/js/storage.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,29 @@ function ingestManagedStorage(managedStore) {
8787
}
8888
}
8989
badger.getSettings().merge(settings);
90+
91+
if (managedStore.trackingDomains) {
92+
let knownActions = new Set([
93+
constants.BLOCK,
94+
constants.COOKIEBLOCK,
95+
constants.ALLOW]);
96+
for (let item of managedStore.trackingDomains) {
97+
// validate action
98+
if (!knownActions.has(item.action)) {
99+
continue;
100+
}
101+
// validate domain
102+
try {
103+
let { hostname } = new URL("https://" + item.domain);
104+
if (hostname != item.domain) {
105+
continue;
106+
}
107+
} catch (err) {
108+
continue;
109+
}
110+
badger.saveAction(item.action, item.domain);
111+
}
112+
}
90113
}
91114

92115
let pollForManagedStorage = (function () {

0 commit comments

Comments
 (0)