mirror of
https://gitlab.com/SukkaW/ruleset.skk.moe.git
synced 2026-04-20 19:04:01 +00:00
deploy: b3c5c4be84680e67c10d79e6fe4f8e047cee9270
This commit is contained in:
57
Build/worker/build-reject-domainset-worker.js
Normal file
57
Build/worker/build-reject-domainset-worker.js
Normal file
@@ -0,0 +1,57 @@
|
||||
exports.dedupe = ({ fullSet, input }) => {
|
||||
const output = new Set();
|
||||
|
||||
for (const domainFromInput of input) {
|
||||
for (const domainFromFullSet of fullSet) {
|
||||
if (
|
||||
domainFromFullSet.startsWith('.')
|
||||
&& domainFromFullSet !== domainFromInput
|
||||
&& (
|
||||
domainFromInput.endsWith(domainFromFullSet)
|
||||
|| `.${domainFromInput}` === domainFromFullSet
|
||||
)
|
||||
) {
|
||||
output.add(domainFromInput);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
exports.whitelisted = ({ whiteList, input }) => {
|
||||
const output = new Set();
|
||||
|
||||
for (const domain of input) {
|
||||
for (const white of whiteList) {
|
||||
if (domain.includes(white) || white.includes(domain)) {
|
||||
output.add(domain);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
exports.dedupeKeywords = ({ keywords, suffixes, input }) => {
|
||||
const output = new Set();
|
||||
|
||||
for (const domain of input) {
|
||||
for (const keyword of keywords) {
|
||||
if (domain.includes(keyword) || keyword.includes(domain)) {
|
||||
output.add(domain);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (const suffix of suffixes) {
|
||||
if (domain.endsWith(suffix)) {
|
||||
output.add(domain);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
Reference in New Issue
Block a user