From 70839bd4cebcaed95d4e10962af1634fb6cb0240 Mon Sep 17 00:00:00 2001 From: Izumiko Date: Fri, 23 Feb 2024 06:06:53 +0000 Subject: [PATCH] deploy: 4512187e997bd4931cea23751ca000153ef29830 --- ede.user.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/ede.user.js b/ede.user.js index eeff1b5..77fc84c 100644 --- a/ede.user.js +++ b/ede.user.js @@ -3,7 +3,7 @@ // @description Jellyfin弹幕插件 // @namespace https://github.com/RyoLee // @author RyoLee -// @version 1.28 +// @version 1.29 // @copyright 2022, RyoLee (https://github.com/RyoLee) // @license MIT; https://raw.githubusercontent.com/Izumiko/jellyfin-danmaku/jellyfin/LICENSE // @icon https://github.githubassets.com/pinned-octocat.svg @@ -886,20 +886,17 @@ const disableDandan = (danmakufilter & 4) === 4; const disableOther = (danmakufilter & 8) === 8; + let filterule = ''; + if (disableDandan) { filterule += '^(?!\\[)|\^.{0,3}\\]'; } + if (disableBilibili) { filterule += (filterule ? '|' : '') + '\^\\[BiliBili\\]'; } + if (disableGamer) { filterule += (filterule ? '|' : '') + '\^\\[Gamer\\]'; } + if (disableOther) { filterule += (filterule ? '|' : '') + '\^\\[\(\?\!\(BiliBili\|Gamer\)\).{3,}\\]'; } + if (filterule === '') { filterule = '!.*'; } + const danmakufilterule = new RegExp(filterule); + return $obj .filter(($comment) => { - const senderInfo = $comment.p.split(',').pop(); - if (disableDandan && (!/^\[/.test(senderInfo) || /^\[.{0,2}\]/.test(senderInfo))) { - return false; - } - if (disableOther && (/^\[(?!BiliBili|Gamer\]).{3,}\]/.test(senderInfo))) { - return false; - } - if ((disableBilibili && senderInfo.startsWith('[BiliBili]')) || - (disableGamer && senderInfo.startsWith('[Gamer]'))) { - return false; - } - return true; + return !danmakufilterule.test($comment.p.split(',').pop()); }) .map(($comment) => { const [time, modeId, colorValue] = $comment.p.split(',').map((v, i) => i === 0 ? parseFloat(v) : parseInt(v, 10));