From 45611e2473a9ec8ded9726928efd565bfd68f8e0 Mon Sep 17 00:00:00 2001 From: WakelessSloth56 Date: Sun, 8 Oct 2023 18:00:15 +0800 Subject: [PATCH] feat(player): danmaku font size offset Co-authored-by: lainio24 --- public/index.html | 5 +++++ src/player.player.ts | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/public/index.html b/public/index.html index 12af695..353e5ba 100644 --- a/public/index.html +++ b/public/index.html @@ -30,6 +30,10 @@ + + Size Offset: + + Auto Play: @@ -77,6 +81,7 @@ fullscreen: id('fullscreen').checked, muted: id('muted').checked, danmakuTimeOffset: parseFloat(id('danmaku-time-offset').value), + danmakuSizeOffset: parseInt(id('danmaku-size-offset').value), }); window.player = player; id('start-panel').remove(); diff --git a/src/player.player.ts b/src/player.player.ts index a2c5c3a..6cf1109 100644 --- a/src/player.player.ts +++ b/src/player.player.ts @@ -252,6 +252,17 @@ const __player_metadata__: PlayerMetadata = { .selfEvents({ create: (P, E) => { P.commentManager = initDanmaku(E, P.danmakuUrl, () => P.firePlayerEvent('danmakuload')); + if (P.options.danmakuSizeOffset) { + P.commentManager.filter.addModifier(function (commentData: StrAnyKV) { + const override = commentData; + const size = commentData['size']; + if (size && !override['sizeOverridden']) { + override['size'] = size + P.options.danmakuSizeOffset; + override['sizeOverridden'] = true; + } + return override; + }); + } P._dyn.danmakuOn = true; P.setContainerData('danmakuOn', true); if (!P.options.danmakuTimeOffset) P.options.danmakuTimeOffset = 0;