| 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, |
|
Sebastian Noack
2017/04/29 23:07:59
It seems the newly imported function (i.e. getDeco
Jon Sonesen
2017/05/04 10:26:05
Done.
|
| + 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,27 +47,36 @@ |
| 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) |
| + { |
| + if (checkWhitelisted(page, frame)) |
| + return true; |
|
Sebastian Noack
2017/04/29 23:08:00
Nit: I'd always add a blank line when returning be
Jon Sonesen
2017/05/04 10:26:06
Done.
|
| + docDomain = extractHostFromFrame(frame); |
| + sitekey = getKey(page, frame); |
| + isThirdParty(url, docDomain); |
|
Sebastian Noack
2017/04/29 23:07:59
As this code stands, this call is redundant. Did y
Jon Sonesen
2017/05/04 10:26:05
Yeah that's what happened there.
Thanks.
Done.
|
| + specificOnly = !!checkWhitelisted( |
| + page, frame, RegExpFilter.typeMap.GENERICBLOCK |
| ); |
| + } |
| + |
| + |
| let filter = defaultMatcher.matchesAny( |
| urlString, RegExpFilter.typeMap[type], |
| docDomain, thirdParty, sitekey, specificOnly |
| ); |
| setTimeout(onBeforeRequestAsync, 0, page, urlString, |
| type, docDomain, |