From d3034cb8cda805b106862f8e87c603b0a3bee32c Mon Sep 17 00:00:00 2001 From: HanYaodong Date: Tue, 30 Jan 2024 16:10:41 +0800 Subject: [PATCH] Fix duration text width update on fullscreen change --- src/content.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/content.ts b/src/content.ts index d65838ff..1834beb3 100644 --- a/src/content.ts +++ b/src/content.ts @@ -2567,14 +2567,20 @@ function showTimeWithoutSkips(skippedDuration: number): void { const durationAfterSkips = getFormattedTime(getVideo()?.duration - skippedDuration); - if (durationAfterSkips != null && skippedDuration > 0) { - duration.innerText = " (" + durationAfterSkips + ")"; - + const refreshDurationTextWidth = () => { // some hacks to change the min-width of the time control area, // so it won't overlap with chapters on the right display.style.width = "auto"; display.parentElement.style.minWidth = `${display.clientWidth - 11}px`; } + + if (durationAfterSkips != null && skippedDuration > 0) { + duration.innerText = " (" + durationAfterSkips + ")"; + + refreshDurationTextWidth(); + // re-calculate text position after entering and exiting full screen + window.addEventListener("fullscreenchange", refreshDurationTextWidth); + } } function checkForPreloadedSegment() {