Index: lib/requestBlocker.js |
=================================================================== |
--- a/lib/requestBlocker.js |
+++ b/lib/requestBlocker.js |
@@ -20,17 +20,18 @@ |
"use strict"; |
const {Filter, RegExpFilter, BlockingFilter} = require("filterClasses"); |
const {Subscription} = require("subscriptionClasses"); |
const {defaultMatcher} = require("matcher"); |
const {FilterNotifier} = require("filterNotifier"); |
const {Prefs} = require("prefs"); |
const {checkWhitelisted, getKey} = require("whitelisting"); |
-const {stringifyURL, extractHostFromFrame, isThirdParty} = require("url"); |
+const {stringifyURL, getDecodedHostname, |
+ extractHostFromFrame, isThirdParty} = require("url"); |
const {port} = require("messaging"); |
const devtools = require("devtools"); |
// Chrome can't distinguish between OBJECT_SUBREQUEST and OBJECT requests. |
RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; |
function onBeforeRequestAsync(page, url, type, docDomain, |
thirdParty, sitekey, |
@@ -46,23 +47,28 @@ |
thirdParty, sitekey, |
specificOnly, filter |
); |
} |
} |
ext.webRequest.onBeforeRequest.addListener((url, type, page, frame) => |
{ |
- if (checkWhitelisted(page, frame)) |
- return true; |
+ let docDomain = getDecodedHostname(url); |
Sebastian Noack
2017/04/21 08:39:53
Is there a reason you derive the parent document's
Jon Sonesen
2017/04/24 08:40:56
I see, I misunderstood what I was doing here. I ju
|
+ let sitekey = null; |
+ if (frame && page) |
+ { |
+ if (checkWhitelisted(page, frame)) |
+ return true; |
+ docDomain = extractHostFromFrame(frame); |
+ sitekey = getKey(page, frame); |
+ } |
let urlString = stringifyURL(url); |
- let docDomain = extractHostFromFrame(frame); |
let thirdParty = isThirdParty(url, docDomain); |
- let sitekey = getKey(page, frame); |
let specificOnly = !!checkWhitelisted( |
page, frame, RegExpFilter.typeMap.GENERICBLOCK |
); |
let filter = defaultMatcher.matchesAny( |
urlString, RegExpFilter.typeMap[type], |
docDomain, thirdParty, sitekey, specificOnly |