From 76aa3a78b46cd380f0f867521422dedbdced7879 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sat, 21 Sep 2024 04:16:21 +0800 Subject: [PATCH] Feat: add kwfilter to ruleset as well --- Build/lib/create-file-new.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Build/lib/create-file-new.ts b/Build/lib/create-file-new.ts index 552464c0..368bc8a8 100644 --- a/Build/lib/create-file-new.ts +++ b/Build/lib/create-file-new.ts @@ -181,16 +181,18 @@ export class DomainsetOutput extends RuleOutput { if (!this.$dumped) { const kwfilter = createKeywordFilter(this.domainKeywords); + const results: string[] = []; + const dumped = this.domainTrie.dump(); - const set = new Set(dumped); + for (let i = 0, len = dumped.length; i < len; i++) { const domain = dumped[i]; - if (kwfilter(domain)) { - set.delete(domain); + if (!kwfilter(domain)) { + results.push(domain); } } - this.$dumped = Array.from(set); + this.$dumped = results; } return this.$dumped; } @@ -339,9 +341,14 @@ export class RulesetOutput extends RuleOutput { '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); for (let i = 0, len = sortedDomains.length; i < len; i++) { const domain = sortedDomains[i]; + if (kwfilter(domain)) { + continue; + } if (domain[0] === '.') { results.push(`DOMAIN-SUFFIX,${domain.slice(1)}`); } else {