- commit
- 89e73a91609166dfacaa3e02b4b4764337551b57
- parent
- 02c9d282b17f0bbc714f6cac06d2dcfa12044090
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-07-30 19:32
allow to load different context in popup
Diffstat
| M | bg.js | 2 | +- |
| M | popup.js | 31 | ++++++++++++++++++------------- |
2 files changed, 19 insertions, 14 deletions
diff --git a/bg.js b/bg.js
@@ -68,7 +68,7 @@ var getCurrentTab = function() {
68 68 browser.runtime.onMessage.addListener(msg => {
69 69 if (msg.type === 'get') {
70 70 return getCurrentTab().then(tab => {
71 -1 var context = getHostname(tab.url);
-1 71 var context = msg.data || getHostname(tab.url);
72 72 return {
73 73 context: context,
74 74 rules: restrictRules(context),
diff --git a/popup.js b/popup.js
@@ -118,18 +118,23 @@ var createRow = function(hostname) {
118 118 return tr;
119 119 };
120 120
121 -1 sendMessage('get').then(data => {
122 -1 context = data.context;
123 -1 requests = data.requests;
124 -1 rules = data.rules;
125 -1
126 -1 table.append(createHeader());
127 -1 table.append(createRow('inline'));
128 -1 table.append(createRow('first-party'));
-1 121 var loadContext = function(c) {
-1 122 sendMessage('get', c).then(data => {
-1 123 context = data.context;
-1 124 requests = data.requests;
-1 125 rules = data.rules;
-1 126
-1 127 table.innerHTML = '';
-1 128 table.append(createHeader());
-1 129 table.append(createRow('inline'));
-1 130 table.append(createRow('first-party'));
-1 131
-1 132 for (const hostname of getHostnames()) {
-1 133 table.append(createRow(hostname));
-1 134 }
129 135
130 -1 for (const hostname of getHostnames()) {
131 -1 table.append(createRow(hostname));
132 -1 }
-1 136 updateInherit('*');
-1 137 });
-1 138 };
133 139
134 -1 updateInherit('*');
135 -1 });
-1 140 loadContext();