From 2b665d742b70b88d4f24e8fe322a3255a5474283 Mon Sep 17 00:00:00 2001 From: Izumiko Date: Wed, 12 Jun 2024 20:27:38 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=BC=B9=E5=B9=95=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E6=9D=A1=E4=BB=B6=E8=B0=83=E6=95=B4=EF=BC=9A=20?= =?UTF-8?q?=E7=94=B1cid=E6=94=B9=E4=B8=BA=E5=BC=B9=E5=B9=95=E6=97=B6?= =?UTF-8?q?=E9=97=B4+=E5=8F=91=E9=80=81=E8=80=85+=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ede.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ede.js b/ede.js index 88b3961..c2f527c 100644 --- a/ede.js +++ b/ede.js @@ -3,7 +3,7 @@ // @description Jellyfin弹幕插件 // @namespace https://github.com/RyoLee // @author RyoLee -// @version 1.41 +// @version 1.42 // @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 @@ -1244,9 +1244,19 @@ if (filterule === '') { filterule = '!.*'; } const danmakufilterule = new RegExp(filterule); - return all_cmts - .filter((comment, index, self) => { - return !danmakufilterule.test(comment.p.split(',').pop()) && index === self.findIndex((t) => t.cid === comment.cid); + // 使用Map去重 + const unique_cmts = []; + const cmtMap = new Map(); + all_cmts.forEach((comment) => { + if (!cmtMap.has(comment.p + comment.m)) { + cmtMap.set(comment.p + comment.m, true); + unique_cmts.push(comment); + } + }); + + return unique_cmts + .filter((comment) => { + 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));