mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 17:20:35 +08:00
Feat: add kwfilter to ruleset as well
This commit is contained in:
parent
4808ed8d27
commit
76aa3a78b4
@ -181,16 +181,18 @@ export class DomainsetOutput extends RuleOutput {
|
|||||||
if (!this.$dumped) {
|
if (!this.$dumped) {
|
||||||
const kwfilter = createKeywordFilter(this.domainKeywords);
|
const kwfilter = createKeywordFilter(this.domainKeywords);
|
||||||
|
|
||||||
|
const results: string[] = [];
|
||||||
|
|
||||||
const dumped = this.domainTrie.dump();
|
const dumped = this.domainTrie.dump();
|
||||||
const set = new Set<string>(dumped);
|
|
||||||
for (let i = 0, len = dumped.length; i < len; i++) {
|
for (let i = 0, len = dumped.length; i < len; i++) {
|
||||||
const domain = dumped[i];
|
const domain = dumped[i];
|
||||||
if (kwfilter(domain)) {
|
if (!kwfilter(domain)) {
|
||||||
set.delete(domain);
|
results.push(domain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$dumped = Array.from(set);
|
this.$dumped = results;
|
||||||
}
|
}
|
||||||
return this.$dumped;
|
return this.$dumped;
|
||||||
}
|
}
|
||||||
@ -339,9 +341,14 @@ export class RulesetOutput extends RuleOutput {
|
|||||||
'DOMAIN,this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'
|
'DOMAIN,this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const kwfilter = createKeywordFilter(this.domainKeywords);
|
||||||
|
|
||||||
const sortedDomains = sortDomains(this.domainTrie.dump(), this.apexDomainMap, this.subDomainMap);
|
const sortedDomains = sortDomains(this.domainTrie.dump(), this.apexDomainMap, this.subDomainMap);
|
||||||
for (let i = 0, len = sortedDomains.length; i < len; i++) {
|
for (let i = 0, len = sortedDomains.length; i < len; i++) {
|
||||||
const domain = sortedDomains[i];
|
const domain = sortedDomains[i];
|
||||||
|
if (kwfilter(domain)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (domain[0] === '.') {
|
if (domain[0] === '.') {
|
||||||
results.push(`DOMAIN-SUFFIX,${domain.slice(1)}`);
|
results.push(`DOMAIN-SUFFIX,${domain.slice(1)}`);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user