- commit
- 5d3a24f58c1223ca30d073fd1a9c91c67ed170ec
- parent
- 4737705ee614e5c171ceb328a3912ed772e3bc68
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-07-30 18:22
restrict rules that are sent to popup
Diffstat
| M | bg.js | 16 | +++++++++------- |
| M | popup.js | 8 | ++++---- |
2 files changed, 13 insertions, 11 deletions
diff --git a/bg.js b/bg.js
@@ -27,6 +27,13 @@ var setRule = function(context, hostname, type, rule) {
27 27 browser.storage.local.set({'rules': rules});
28 28 };
29 29
-1 30 var restrictRules = function(context) {
-1 31 var restricted = {};
-1 32 restricted['*'] = rules['*'] || {};
-1 33 restricted[context] = rules[context] || {};
-1 34 return restricted;
-1 35 };
-1 36
30 37 var pushRequest = function(tabId, hostname, type) {
31 38 if (!requests[tabId]) {
32 39 requests[tabId] = {};
@@ -57,14 +64,9 @@ browser.runtime.onMessage.addListener(msg => {
57 64 if (msg.type === 'get') {
58 65 return getCurrentTab().then(tab => {
59 66 var context = getHostname(tab.url);
60 -1
61 -1 var restrictedRules = {};
62 -1 restrictedRules['*'] = rules['*'] || {};
63 -1 restrictedRules[context] = rules[context] || {};
64 -1
65 67 return {
66 68 context: context,
67 -1 rules: restrictedRules,
-1 69 rules: restrictRules(context),
68 70 requests: requests[tab.id] || {},
69 71 };
70 72 });
@@ -72,7 +74,7 @@ browser.runtime.onMessage.addListener(msg => {
72 74 return getCurrentTab().then(tab => {
73 75 var context = getHostname(tab.url);
74 76 setRule(context, msg.data[0], msg.data[1], msg.data[2]);
75 -1 return rules;
-1 77 return restrictRules(context);
76 78 });
77 79 }
78 80 });
diff --git a/popup.js b/popup.js
@@ -123,12 +123,12 @@ sendMessage('get').then(data => {
123 123 return tr;
124 124 };
125 125
126 -1 table.append(createHeader(data.rules[data.context] || {}));
127 -1 table.append(createRow('inline', data.rules[data.context] || {}));
128 -1 table.append(createRow('first-party', data.rules['*'] || {}));
-1 126 table.append(createHeader(data.rules[data.context]));
-1 127 table.append(createRow('inline', data.rules[data.context]));
-1 128 table.append(createRow('first-party', data.rules['*']));
129 129
130 130 for (const hostname of getHostnames(data)) {
131 -1 table.append(createRow(hostname, data.rules[data.context] || {}));
-1 131 table.append(createRow(hostname, data.rules[data.context]));
132 132 }
133 133
134 134 updateInherit('*');