Index: lib/filterComposer.js |
diff --git a/lib/filterComposer.js b/lib/filterComposer.js |
index 1eb31b9bc075ee67c5e6250f0089803616f155bc..dccf72adedbe10f16eab38169df830f8644598c4 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,9 +88,10 @@ 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 docDomain = extractHostFromFrame(frame); |
+ let typeMask = RegExpFilter.typeMap[details.type]; |
Sebastian Noack
2015/07/13 16:41:50
Nit: I'd declare the variables here in the order t
kzar
2015/07/14 09:22:23
Done.
|
// Add a blocking filter for each URL of the element that can be blocked |
for (let url of details.urls) |
@@ -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) |