From 22ebccc47cb3b328c3f39652b2a111af08300ae6 Mon Sep 17 00:00:00 2001 From: leko Date: Sun, 6 Oct 2024 23:03:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E8=A8=82=E5=AD=97=E9=AB=94?= =?UTF-8?q?=E8=88=87=E5=AD=97=E9=AB=94=E9=81=B8=E9=A0=85=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=20(#61)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: login api @ no-cors mode * fix: typo * fix: login @ no-cors mode * feat: 新增字體修改選項 * feat: font options * fix: font options not applied --- ede.js | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/ede.js b/ede.js index 8e624f0..5222810 100644 --- a/ede.js +++ b/ede.js @@ -3,7 +3,7 @@ // @description Jellyfin弹幕插件 // @namespace https://github.com/RyoLee // @author RyoLee -// @version 1.47 +// @version 1.49 // @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 @@ -157,10 +157,18 @@ 弹幕速度: +
+ +
+
字体大小:
+
+ +
+
高度比例: @@ -279,6 +287,12 @@ window.ede.curEpOffset = epOffset; showDebugInfo(`设置弹幕偏移时间:${window.ede.curEpOffset}`); } + window.ede.fontFamily = document.getElementById("danmakuFontFamily").value || "sans-serif"; + window.localStorage.setItem('danmakuFontFamily', window.ede.fontFamily); + showDebugInfo(`字体:${window.ede.fontFamily}`); + window.ede.fontOptions = document.getElementById("danmakuFontOptions").value; + window.localStorage.setItem('danmakuFontOptions', window.ede.fontOptions); + showDebugInfo(`字体选項:${window.ede.fontOptions}`); reloadDanmaku('reload'); closeModal(); } catch (e) { @@ -480,6 +494,12 @@ // 当前剧集弹幕偏移时间 this.curEpOffset = 0; this.curEpOffsetModified = false; + // 字體 + const fontFamily = window.localStorage.getItem('danmakuFontFamily'); + this.fontFamily = fontFamily ?? "sans-serif"; + // 字体选項 + const fontOptions = window.localStorage.getItem('danmakuFontOptions'); + this.fontOptions = fontOptions ?? ""; this.danmaku = null; this.episode_info = null; @@ -719,7 +739,7 @@ mode: modemap, time: time, style: { - font: `${window.ede.fontSize}px sans-serif`, + font: `${window.ede.fontOptions} ${window.ede.fontSize}px ${window.ede.fontFamily}`, fillStyle: `#${colorStr}`, strokeStyle: colorStr === '000000' ? '#fff' : '#000', lineWidth: 2.0, @@ -1144,6 +1164,8 @@ showDebugInfo(`弹幕来源过滤:${window.ede.danmakuFilter}`); showDebugInfo(`弹幕模式过滤:${window.ede.danmakuModeFilter}`); showDebugInfo(`弹幕字号:${window.ede.fontSize}`); + showDebugInfo(`弹幕字体:${window.ede.fontFamily}`); + showDebugInfo(`弹幕字体选項:${window.ede.fontOptions}`); showDebugInfo(`屏幕分辨率:${window.screen.width}x${window.screen.height}`); if (window.ede.curEpOffset !== 0) showDebugInfo(`当前弹幕偏移:${window.ede.curEpOffset} 秒`); @@ -1374,7 +1396,7 @@ } function danmakuParser(all_cmts) { - const { fontSize, danmakuFilter, danmakuModeFilter, curEpOffset } = window.ede; + const { fontSize, fontOptions, fontFamily, danmakuFilter, danmakuModeFilter, curEpOffset } = window.ede; const disableBilibili = (danmakuFilter & 1) === 1; const disableGamer = (danmakuFilter & 2) === 2; @@ -1422,7 +1444,7 @@ mode, time: time + curEpOffset, style: { - font: `${fontSize}px sans-serif`, + font: `${fontOptions} ${fontSize}px ${fontFamily}`, fillStyle: `#${color}`, strokeStyle: color === '000000' ? '#fff' : '#000', lineWidth: 2.0,