Handle badfilter syntax correctly

This commit is contained in:
SukkaW 2022-05-13 14:19:23 +08:00
parent 9ca81d4ab7
commit 138245154d
2 changed files with 7 additions and 2 deletions

View File

@ -10,7 +10,7 @@ const threads = Math.max(require('os').cpus().length, 12);
// Parse from remote hosts & domain lists // Parse from remote hosts & domain lists
(await Promise.all([ (await Promise.all([
// processHosts('https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext', true), processHosts('https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext', true),
processHosts('https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt'), processHosts('https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt'),
processHosts('https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt') processHosts('https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt')
])).forEach(hosts => { ])).forEach(hosts => {

View File

@ -97,7 +97,12 @@ async function processFilterRules(filterRulesUrl) {
return; return;
} }
if (line.startsWith('@@||') if (line.startsWith('||') && line.endsWith('^$badfilter')) {
const domain = line.replaceAll('||', '').replaceAll('^$badfilter', '').trim();
if (rDomain.test(domain)) {
whitelistDomainSets.add(domain);
}
} else if (line.startsWith('@@||')
&& ( && (
line.endsWith('^') line.endsWith('^')
|| line.endsWith('^|') || line.endsWith('^|')