mirror of
https://gitlab.com/SukkaW/ruleset.skk.moe.git
synced 2026-01-07 21:10:27 +00:00
deploy: 39f3dacf6e0a1459f4f46ccbd1677148a85ab07c
This commit is contained in:
@@ -148,24 +148,56 @@ const threads = require('os').cpus().length - 1;
|
||||
// Dedupe domainSets
|
||||
console.log(`Start deduping! (${previousSize})`);
|
||||
|
||||
const toBeRemoved = new Set();
|
||||
for (const domain of domainSets) {
|
||||
let isTobeRemoved = false;
|
||||
|
||||
for (const keyword of domainKeywordsSet) {
|
||||
if (domain.includes(keyword) || keyword.includes(domain)) {
|
||||
isTobeRemoved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isTobeRemoved) {
|
||||
for (const suffix of domainSuffixSet) {
|
||||
if (domain.endsWith(suffix)) {
|
||||
isTobeRemoved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isTobeRemoved) {
|
||||
for (const white of filterRuleWhitelistDomainSets) {
|
||||
if (domain.includes(white) || white.includes(domain)) {
|
||||
isTobeRemoved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isTobeRemoved) {
|
||||
toBeRemoved.add(domain);
|
||||
}
|
||||
}
|
||||
|
||||
toBeRemoved.forEach((removed) => {
|
||||
domainSets.delete(removed)
|
||||
});
|
||||
|
||||
// Dedupe domainSets
|
||||
console.log(`Deduped ${previousSize - domainSets.size} from black keywords and suffixes!`);
|
||||
|
||||
previousSize = domainSets.size;
|
||||
// Dedupe domainSets
|
||||
console.log(`Start deduping! (${previousSize})`);
|
||||
|
||||
const piscina = new Piscina({
|
||||
filename: pathResolve(__dirname, 'worker/build-reject-domainset-worker.js'),
|
||||
workerData: [...domainSets]
|
||||
});
|
||||
|
||||
(await Promise.all([
|
||||
piscina.run(
|
||||
{ keywords: domainKeywordsSet, suffixes: domainSuffixSet },
|
||||
{ name: 'dedupeKeywords' }
|
||||
),
|
||||
piscina.run(
|
||||
{ whiteList: filterRuleWhitelistDomainSets },
|
||||
{ name: 'whitelisted' }
|
||||
)
|
||||
])).forEach(set => {
|
||||
set.forEach(i => domainSets.delete(i));
|
||||
});
|
||||
|
||||
(await Promise.all(
|
||||
Array.from(domainSets)
|
||||
.reduce((result, element, index) => {
|
||||
|
||||
Reference in New Issue
Block a user