From 0874c3b8bc6d04d8a85469e1a9b6fffc588b9eda Mon Sep 17 00:00:00 2001 From: xiaoxuan010 <2592053474@qq.com> Date: Sun, 5 Jan 2025 00:05:23 +0800 Subject: [PATCH 1/2] feat(Components): optimize player button tooltips MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化播放栏按钮提示条的样式,适配B站风格 --- public/content.css | 23 +++++++++++++++++++ .../playerButtons/PlayerButtonComponent.tsx | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/public/content.css b/public/content.css index 5fa9f062..b48f4ebf 100644 --- a/public/content.css +++ b/public/content.css @@ -91,6 +91,29 @@ display: none !important; } +/* Tooltip 编码灵感源于:the1812/Bilibili-Evolved + * https://github.com/the1812/Bilibili-Evolved + */ +.playerButtonTooltip { + pointer-events: none; + font-size: 12px; + padding: 6px 8px; + line-height: 1.5; + white-space: nowrap; + color: var(--bpx-tooltip-color, #fff); + background-color: var(--bpx-tooltip-bgcolor, #000); + border-radius: 4px; + position: absolute; + transform: translateX(calc(-50% + 20px)) translateY(calc(-100% - 36px)); + opacity: 0; +} + +.playerButton:hover .playerButtonTooltip { + transition: all 0.2s ease-out 0.1s; + opacity: 1; + transform: translateX(calc(-50% + 20px)) translateY(calc(-100% - 41px)); +} + /* Removes auto width from being a ytp-player-button */ .sbPlayerDownvote { width: auto !important; diff --git a/src/components/playerButtons/PlayerButtonComponent.tsx b/src/components/playerButtons/PlayerButtonComponent.tsx index 919fd9ed..2a25e397 100644 --- a/src/components/playerButtons/PlayerButtonComponent.tsx +++ b/src/components/playerButtons/PlayerButtonComponent.tsx @@ -21,7 +21,6 @@ const PlayerButtonComponent = forwardRef(f id={baseID + "Button"} className="playerButton bpx-player-ctrl-btn" style={{ maxWidth: "40px", display: show ? "unset" : "none" }} - title={chrome.i18n.getMessage(title)} draggable={isDraggable} onClick={onClick} > @@ -31,6 +30,7 @@ const PlayerButtonComponent = forwardRef(f src={chrome.runtime.getURL("icons/" + getIconLink(imageName))} draggable={isDraggable} > +
{chrome.i18n.getMessage(title)}
); }); From 56b1d5da66428275678d62a2d2c5f78fb653fcd2 Mon Sep 17 00:00:00 2001 From: xiaoxuan010 <2592053474@qq.com> Date: Tue, 31 Dec 2024 18:33:50 +0800 Subject: [PATCH 2/2] fix(Utils): fix VideoID URL parsing error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复由“协议相对URL”引起的解析错误 --- src/utils/parseVideoID.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/parseVideoID.ts b/src/utils/parseVideoID.ts index 032a2a68..a0a380d7 100644 --- a/src/utils/parseVideoID.ts +++ b/src/utils/parseVideoID.ts @@ -35,7 +35,7 @@ export async function getBvIDFromURL(url: string): Promise { //Attempt to parse url let urlObject: URL | null = null; try { - urlObject = new URL(url); + urlObject = new URL(url, window.location.origin); } catch (e) { console.error("[BSB] Unable to parse URL: " + url); return null;