Index: lib/requestBlocker.js |
=================================================================== |
--- a/lib/requestBlocker.js |
+++ b/lib/requestBlocker.js |
@@ -86,25 +86,24 @@ |
devtools.logRequest( |
page, url, type, docDomain, |
thirdParty, sitekey, |
specificOnly, filter |
); |
} |
} |
-ext.webRequest.onBeforeRequest.addListener((url, type, page, frame) => |
+function shouldAllowRequest(url, type, page, frame) |
{ |
let docDomain = null; |
let sitekey = null; |
let specificOnly = false; |
let thirdParty = false; |
let urlString = stringifyURL(url); |
- |
if (frame && page) |
{ |
if (checkWhitelisted(page, frame)) |
return true; |
docDomain = extractHostFromFrame(frame); |
sitekey = getKey(page, frame); |
thirdParty = isThirdParty(url, docDomain); |
@@ -120,17 +119,19 @@ |
); |
setTimeout(onBeforeRequestAsync, 0, page, urlString, |
mappedType, docDomain, |
thirdParty, sitekey, |
specificOnly, filter); |
return !(filter instanceof BlockingFilter); |
-}); |
+} |
+ |
+ext.webRequest.onBeforeRequest.addListener(shouldAllowRequest); |
port.on("filters.collapse", (message, sender) => |
{ |
if (checkWhitelisted(sender.page, sender.frame)) |
return false; |
let typeMask = RegExpFilter.typeMap[message.mediatype]; |
let documentHost = extractHostFromFrame(sender.frame); |
@@ -213,15 +214,11 @@ |
// Edge supports neither webRequest.ResourceType nor WebSocket blocking yet: |
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10297376/ |
if (browser.webRequest.ResourceType && |
(msg.requestType.toUpperCase() in browser.webRequest.ResourceType)) |
{ |
return false; |
} |
- return ext.webRequest.onBeforeRequest._dispatch( |
- new URL(msg.url), |
- msg.requestType, |
- sender.page, |
- sender.frame |
- ).includes(false); |
+ return !shouldAllowRequest(new URL(msg.url), msg.requestType, sender.page, |
+ sender.frame); |
}); |