Index: lib/requestBlocker.js |
=================================================================== |
--- a/lib/requestBlocker.js |
+++ b/lib/requestBlocker.js |
@@ -64,27 +64,35 @@ |
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; |
+ 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) |
Sebastian Noack
2017/06/01 17:32:21
Nit: As mentioned before, I'd add a blank line abo
Jon Sonesen
2017/06/02 05:02:58
Acknowledged.
|
+ { |
+ 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/06/01 17:32:21
Nit: One blank line is sufficient here.
Jon Sonesen
2017/06/02 05:02:58
Acknowledged.
|
+ |
let mappedType = resourceTypes.get(type) || "OTHER"; |
let filter = defaultMatcher.matchesAny( |
urlString, RegExpFilter.typeMap[mappedType], |
docDomain, thirdParty, sitekey, specificOnly |
); |