| Index: lib/abp2blocklist.js |
| =================================================================== |
| --- a/lib/abp2blocklist.js |
| +++ b/lib/abp2blocklist.js |
| @@ -357,16 +357,17 @@ |
| * @constructor |
| */ |
| exports.ContentBlockerList = function () |
| { |
| this.requestFilters = []; |
| this.requestExceptions = []; |
| this.elemhideFilters = []; |
| this.elemhideExceptions = []; |
| + this.generichideExceptions = []; |
| this.elemhideSelectorExceptions = new Map(); |
| }; |
| /** |
| * Add Adblock Plus filter to be converted |
| * |
| * @param {Filter} filter Filter to convert |
| */ |
| @@ -383,16 +384,18 @@ |
| if (filter instanceof filterClasses.WhitelistFilter) |
| { |
| if (filter.contentType & (typeMap.DOCUMENT | whitelistableRequestTypes)) |
| this.requestExceptions.push(filter); |
| if (filter.contentType & typeMap.ELEMHIDE) |
| this.elemhideExceptions.push(filter); |
| + else if (filter.contentType & typeMap.GENERICHIDE) |
| + this.generichideExceptions.push(filter); |
| } |
| if (filter instanceof filterClasses.ElemHideFilter) |
| this.elemhideFilters.push(filter); |
| if (filter instanceof filterClasses.ElemHideException) |
| { |
| let domains = this.elemhideSelectorExceptions[filter.selector]; |
| @@ -408,16 +411,21 @@ |
| * |
| * @returns {Filter} filter Filter to convert |
| */ |
| ContentBlockerList.prototype.generateRules = function(filter) |
| { |
| let rules = []; |
| let groupedElemhideFilters = new Map(); |
| + |
| + // Make sure the generic element hiding filters are first in the map so they |
| + // get generated first. |
| + groupedElemhideFilters.set("^https?://", []); |
|
Sebastian Noack
2017/05/17 06:37:10
I'm not sure if it is a good idea, to split up gen
|
| + |
| for (let filter of this.elemhideFilters) |
| { |
| let result = convertElemHideFilter(filter, this.elemhideSelectorExceptions); |
| if (!result) |
| continue; |
| if (result.matchDomains.length == 0) |
| result.matchDomains = ["^https?://"]; |
| @@ -442,16 +450,24 @@ |
| rules.push({ |
| trigger: {"url-filter": matchDomain, |
| "url-filter-is-case-sensitive": true}, |
| action: {type: "css-display-none", |
| selector: selector} |
| }); |
| } |
| + |
| + if (matchDomain == "^https?://") |
| + { |
| + // Right after the generic element hiding filters, add the exceptions |
| + // that should apply only to those filters. |
| + for (let filter of this.generichideExceptions) |
| + convertFilterAddRules(rules, filter, "ignore-previous-rules", false); |
| + } |
| }); |
| for (let filter of this.elemhideExceptions) |
| convertFilterAddRules(rules, filter, "ignore-previous-rules", false); |
| for (let filter of this.requestFilters) |
| convertFilterAddRules(rules, filter, "block", true); |
| for (let filter of this.requestExceptions) |
| convertFilterAddRules(rules, filter, "ignore-previous-rules", true); |