From 32695f71c1392e0eccafde7dc20dd948adb4414f Mon Sep 17 00:00:00 2001 From: festoney8 Date: Fri, 22 Nov 2024 22:57:28 +0800 Subject: [PATCH] update: comment filter sub comment --- .../filters/variety/comment/pages/common.ts | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/modules/filters/variety/comment/pages/common.ts b/src/modules/filters/variety/comment/pages/common.ts index b0ec744..7060fd0 100644 --- a/src/modules/filters/variety/comment/pages/common.ts +++ b/src/modules/filters/variety/comment/pages/common.ts @@ -185,6 +185,14 @@ const selectorFns = { .replace('@', '') .trim() }, + callUserNoReply: (comment: HTMLElement): SelectorResult => { + return (comment as any).__data?.content?.message + ?.trim() + ?.replace(/^回复\s?@[^@\s]+\s?:/, '') + ?.match(/@[^@\s]+/)?.[0] + .replace('@', '') + .trim() + }, callUserOnly: (comment: HTMLElement): SelectorResult => { return ( (comment as any).__data?.content?.message @@ -194,6 +202,15 @@ const selectorFns = { .trim() === '' ) }, + callUserOnlyNoReply: (comment: HTMLElement): SelectorResult => { + return ( + (comment as any).__data?.content?.message + ?.trim() + ?.replace(/^回复\s?@[^@\s]+\s?:/, '') + ?.replace(/@[^@\s]+/g, ' ') + .trim() === '' + ) + }, level: (comment: HTMLElement): SelectorResult => { return (comment as any).__data?.member?.level_info?.current_level }, @@ -376,7 +393,9 @@ class CommentFilterCommon implements IMainFilter { this.commentBotFilter.isEnable || this.commentCallBotFilter.isEnable || this.commentCallUserFilter.isEnable || - this.commentCallUserOnlyFilter.isEnable + this.commentCallUserNoReplyFilter.isEnable || + this.commentCallUserOnlyFilter.isEnable || + this.commentCallUserOnlyNoReplyFilter.isEnable ) ) { revertAll = true @@ -403,7 +422,9 @@ class CommentFilterCommon implements IMainFilter { `username: ${selectorFns.sub.username(v)}`, `content: ${selectorFns.sub.content(v)}`, `callUser: ${selectorFns.sub.callUser(v)}`, + `callUserNoReply: ${selectorFns.sub.callUserNoReply(v)}`, `callUserOnly: ${selectorFns.sub.callUserOnly(v)}`, + `callUserOnlyNoReply: ${selectorFns.sub.callUserOnlyNoReply(v)}`, `level: ${selectorFns.sub.level(v)}`, `isUp: ${selectorFns.sub.isUp(v)}`, `isLink: ${selectorFns.sub.isLink(v)}`, @@ -425,8 +446,12 @@ class CommentFilterCommon implements IMainFilter { this.commentBotFilter.isEnable && blackPairs.push([this.commentBotFilter, selectorFns.sub.username]) this.commentCallBotFilter.isEnable && blackPairs.push([this.commentCallBotFilter, selectorFns.sub.callUser]) this.commentCallUserFilter.isEnable && blackPairs.push([this.commentCallUserFilter, selectorFns.sub.callUser]) + this.commentCallUserNoReplyFilter.isEnable && + blackPairs.push([this.commentCallUserNoReplyFilter, selectorFns.sub.callUserNoReply]) this.commentCallUserOnlyFilter.isEnable && blackPairs.push([this.commentCallUserOnlyFilter, selectorFns.sub.callUserOnly]) + this.commentCallUserOnlyNoReplyFilter.isEnable && + blackPairs.push([this.commentCallUserOnlyNoReplyFilter, selectorFns.sub.callUserOnlyNoReply]) const whitePairs: SubFilterPair[] = [] this.commentIsUpFilter.isEnable && whitePairs.push([this.commentIsUpFilter, selectorFns.sub.isUp])