From a4bb17f935f23f3f9a5e9fb6340f14059ec8bcfa Mon Sep 17 00:00:00 2001 From: Ajay Date: Sat, 8 Mar 2025 03:56:19 -0500 Subject: [PATCH] Fix skipping accuracy with bluetooth headphones on firefox --- src/content.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content.ts b/src/content.ts index 937949c3..e1251957 100644 --- a/src/content.ts +++ b/src/content.ts @@ -772,7 +772,7 @@ async function startSponsorSchedule(includeIntersectingSegments = false, current // Use interval instead of timeout near the end to combat imprecise video time const startIntervalTime = forceStartIntervalTime || performance.now(); - const startVideoTime = Math.max(currentTime, getCurrentTime()); + const startVideoTime = Math.max(currentTime, getVirtualTime()); delayTime = (skipTime?.[0] - startVideoTime) * 1000 * (1 / getVideo().playbackRate); let startWaitingForReportedTimeToChange = true; @@ -791,7 +791,7 @@ async function startSponsorSchedule(includeIntersectingSegments = false, current } const intervalDuration = performance.now() - startIntervalTime; - if (intervalDuration + skipBuffer * 1000 >= delayTime || getCurrentTime() >= skipTime[0]) { + if (intervalDuration + skipBuffer * 1000 >= delayTime || getVirtualTime() + skipBuffer >= skipTime[0]) { clearInterval(currentSkipInterval); if (!isFirefoxOrSafari() && !getVideo().muted && !inMuteSegment(getCurrentTime(), true)) { // Workaround for more accurate skipping on Chromium @@ -842,7 +842,7 @@ function getVirtualTime(): number { (performance.now() - lastKnownVideoTime.preciseTime) * (getVideo()?.playbackRate || 1) / 1000 + lastKnownVideoTime.videoTime : null); if (Config.config.useVirtualTime && !isSafari() && virtualTime - && Math.abs(virtualTime - getCurrentTime()) < 0.2 && getCurrentTime() !== 0) { + && virtualTime > getCurrentTime() && virtualTime - getCurrentTime() < 0.2 && getCurrentTime() !== 0) { return Math.max(virtualTime, getCurrentTime()); } else { return getCurrentTime();