Index: lib/abp2blocklist.js |
=================================================================== |
--- a/lib/abp2blocklist.js |
+++ b/lib/abp2blocklist.js |
@@ -15,17 +15,16 @@ |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
/** @module abp2blocklist */ |
"use strict"; |
let filterClasses = require("filterClasses"); |
-let tldjs = require("tldjs"); |
let punycode = require("punycode"); |
const selectorLimit = 5000; |
const typeMap = filterClasses.RegExpFilter.typeMap; |
const whitelistableRequestTypes = (typeMap.IMAGE |
| typeMap.STYLESHEET |
| typeMap.SCRIPT |
| typeMap.FONT |
@@ -210,45 +209,30 @@ |
typeMap.OTHER)) |
types.push("raw"); |
if (filter.contentType & typeMap.SUBDOCUMENT) |
types.push("document"); |
return types; |
} |
-function addDomainPrefix(domains) |
-{ |
- let result = []; |
- |
- for (let domain of domains) |
- { |
- result.push(domain); |
- |
- if (tldjs.getDomain(domain) == domain) |
- result.push("www." + domain); |
- } |
- |
- return result; |
-} |
- |
function convertFilterAddRules(rules, filter, action, withResourceTypes) |
{ |
let parsed = parseFilterRegexpSource(filter.regexpSource); |
// For the special case of $document whitelisting filters with just a domain |
// we can generate an equivalent blocking rule exception using if-domain. |
if (filter instanceof filterClasses.WhitelistFilter && |
filter.contentType & typeMap.DOCUMENT && |
parsed.justHostname) |
{ |
rules.push({ |
trigger: { |
"url-filter": ".*", |
- "if-domain": addDomainPrefix([parsed.hostname]) |
+ "if-domain": ["*" + parsed.hostname] |
}, |
action: {type: "ignore-previous-rules"} |
}); |
// If the filter contains other supported options we'll need to generate |
// further rules for it, but if not we can simply return now. |
if (!(filter.contentType & whitelistableRequestTypes)) |
return; |
} |
@@ -279,19 +263,19 @@ |
if (trigger["resource-type"].length == 0) |
return; |
} |
if (filter.thirdParty != null) |
trigger["load-type"] = [filter.thirdParty ? "third-party" : "first-party"]; |
if (included.length > 0) |
- trigger["if-domain"] = addDomainPrefix(included); |
+ trigger["if-domain"] = included.map(name => "*" + name); |
else if (excluded.length > 0) |
- trigger["unless-domain"] = addDomainPrefix(excluded); |
+ trigger["unless-domain"] = excluded.map(name => "*" + name); |
rules.push({trigger: trigger, action: {type: action}}); |
} |
function hasNonASCI(obj) |
{ |
if (typeof obj == "string") |
{ |