From 0e0ae9165e7c825b1b5040895ff2be5b5cec60b2 Mon Sep 17 00:00:00 2001 From: Ajay Date: Fri, 4 Nov 2022 17:01:23 -0400 Subject: [PATCH] Fix segments really close to eachother not skipping Also combine segments that are closer than skip buffer Fix #1510 --- src/content.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/content.ts b/src/content.ts index 35d282c2..5fb34c3b 100644 --- a/src/content.ts +++ b/src/content.ts @@ -45,6 +45,8 @@ const utils = new Utils(); // Hack to get the CSS loaded on permission-based sites (Invidious) utils.wait(() => Config.config !== null, 5000, 10).then(addCSS); +const skipBuffer = 0.003; + //was sponsor data found when doing SponsorsLookup let sponsorDataFound = false; //the actual sponsorTimes if loaded and UUIDs associated with them @@ -608,7 +610,6 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?: const skipTime: number[] = [currentSkip?.scheduledTime, skipInfo.array[skipInfo.endIndex]?.segment[1]]; const timeUntilSponsor = skipTime?.[0] - currentTime; const videoID = sponsorVideoID; - const skipBuffer = 0.003; if (videoMuted && !inMuteSegment(currentTime, skipInfo.index !== -1 && timeUntilSponsor < skipBuffer && shouldAutoSkip(currentSkip))) { @@ -1532,7 +1533,7 @@ function getLatestEndTimeIndex(sponsorTimes: SponsorTime[], index: number, hideH const currentSegment = sponsorTimes[i].segment; const latestEndTime = sponsorTimes[latestEndTimeIndex].segment[1]; - if (currentSegment[0] <= latestEndTime && currentSegment[1] > latestEndTime + if (currentSegment[0] - skipBuffer <= latestEndTime && currentSegment[1] > latestEndTime && (!hideHiddenSponsors || sponsorTimes[i].hidden === SponsorHideType.Visible) && shouldAutoSkip(sponsorTimes[i]) && sponsorTimes[i].actionType === ActionType.Skip) { @@ -1573,7 +1574,8 @@ function getStartTimes(sponsorTimes: SponsorTime[], includeIntersectingSegments: // Schedule at the end time to know when to unmute and remove title from seek bar sponsorTimes.forEach(sponsorTime => { - if (!possibleTimes.some((time) => sponsorTime.segment[1] === time.scheduledTime)) { + if (!possibleTimes.some((time) => sponsorTime.segment[1] === time.scheduledTime) + && (minimum === undefined || sponsorTime.segment[1] > minimum)) { possibleTimes.push({ ...sponsorTime, scheduledTime: sponsorTime.segment[1]