Skip to content

Commit b928e0b

Browse files
committed
Improve compatibility across extensions reusing SyncMessage (issue #548).
1 parent 254543a commit b928e0b

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/bg/DNRPolicy.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
// Note: using '^' instead of '/' as a terminator
8282
// takes explicit port numbers in account
8383
if (Sites.isSecureDomainKey(siteKey)) {
84-
return `||${Sites.toggleSecureDomainKey(siteKey,false)}^`
84+
return `||${Sites.toggleSecureDomainKey(siteKey, false)}^`
8585
}
8686
const schemeLess = siteKey.replace(/^[\w-]+:\/*/, "");
8787
let urlFilter = `${siteKey == schemeLess ? "||" : "|"}${siteKey}`;
@@ -148,8 +148,18 @@
148148
condition: {
149149
resourceTypes: ["main_frame", "sub_frame"],
150150
},
151+
}, {
152+
id: 2,
153+
priority: MAX_PRIORITY,
154+
action: {
155+
type: "allow"
156+
},
157+
condition: {
158+
resourceTypes: ["xmlhttprequest"],
159+
urlFilter: browser.runtime.onSyncMessage.DNR_URL_FILTER,
160+
},
151161
}],
152-
lastId: 1,
162+
lastId: 2,
153163
add({capabilities, temp}, priority = SITE_PRIORITY, siteKey) {
154164
const urlFilter = siteKey ? toUrlFilter(siteKey) : undefined;
155165
forBlockAllow(capabilities, (type, resourceTypes) => {
@@ -200,6 +210,9 @@
200210
}
201211

202212
async function addTabRules(rules = []) {
213+
if (!ns.policy?.enforced) {
214+
return;
215+
}
203216
if (ns.unrestrictedTabs.size) {
204217
const tabIds = [...ns.unrestrictedTabs];
205218
tabIds.push(browser.tabs.TAB_ID_NONE); // for service workers

src/nscl

0 commit comments

Comments
 (0)