Index: lib/requestBlocker.js |
=================================================================== |
--- a/lib/requestBlocker.js |
+++ b/lib/requestBlocker.js |
@@ -64,27 +64,37 @@ |
thirdParty, sitekey, |
specificOnly, filter |
); |
} |
} |
ext.webRequest.onBeforeRequest.addListener((url, type, page, frame) => |
{ |
- if (checkWhitelisted(page, frame)) |
- return true; |
+ let docDomain = null; |
+ let sitekey = null; |
+ let specificOnly = false; |
Sebastian Noack
2017/05/30 11:10:49
Nit: The blank line above looks redundant, but ins
Jon Sonesen
2017/05/31 08:28:18
Acknowledged.
|
+ let thirdParty = false; |
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 |
+ if (frame && page) |
+ { |
+ if (checkWhitelisted(page, frame)) |
+ return true; |
+ |
+ docDomain = extractHostFromFrame(frame); |
+ sitekey = getKey(page, frame); |
+ thirdParty = isThirdParty(url, docDomain); |
+ specificOnly = !!checkWhitelisted( |
+ page, frame, RegExpFilter.typeMap.GENERICBLOCK |
); |
Sebastian Noack
2017/05/30 11:10:49
Nit: You added one level off indentation to the co
Jon Sonesen
2017/05/31 08:28:18
I will do it as you suggest.
|
+ } |
+ |
+ |
let mappedType = resourceTypes.get(type) || "OTHER"; |
let filter = defaultMatcher.matchesAny( |
urlString, RegExpFilter.typeMap[mappedType], |
docDomain, thirdParty, sitekey, specificOnly |
); |