Index: lib/filterComposer.js |
diff --git a/lib/filterComposer.js b/lib/filterComposer.js |
index 1eb31b9bc075ee67c5e6250f0089803616f155bc..12b260f76bf3c4077e53693a3295045accc4baf7 100644 |
--- a/lib/filterComposer.js |
+++ b/lib/filterComposer.js |
@@ -20,6 +20,7 @@ |
let {extractHostFromFrame, stringifyURL, isThirdParty} = require("url"); |
let {getKey, isFrameWhitelisted} = require("whitelisting"); |
let {defaultMatcher} = require("matcher"); |
+let {RegExpFilter} = require("filterClasses"); |
function escapeChar(chr) |
{ |
@@ -87,8 +88,9 @@ exports.composeFilters = function(details) |
let page = details.page; |
let frame = details.frame; |
- if (!isFrameWhitelisted(page, frame, "DOCUMENT")) |
+ if (!isFrameWhitelisted(page, frame, RegExpFilter.typeMap.DOCUMENT)) |
{ |
+ let typeMask = RegExpFilter.typeMap[details.type]; |
let docDomain = extractHostFromFrame(frame); |
// Add a blocking filter for each URL of the element that can be blocked |
@@ -98,7 +100,7 @@ exports.composeFilters = function(details) |
url = stringifyURL(urlObj); |
let filter = defaultMatcher.whitelist.matchesAny( |
- url, details.type, docDomain, |
+ url, typeMask, docDomain, |
isThirdParty(urlObj, docDomain), |
getKey(page, frame) |
); |
@@ -114,7 +116,7 @@ exports.composeFilters = function(details) |
// If we couldn't generate any blocking filters, fallback to element hiding |
let selectors = []; |
- if (filters.length == 0 && !isFrameWhitelisted(page, frame, "ELEMHIDE")) |
+ if (filters.length == 0 && !isFrameWhitelisted(page, frame, RegExpFilter.typeMap.ELEMHIDE)) |
{ |
// Generate CSS selectors based on the element's "id" and "class" attribute |
if (details.id) |