Skip to content

Commit 0e0ae91

Browse files
committed
Fix segments really close to eachother not skipping
Also combine segments that are closer than skip buffer Fix #1510
1 parent ff2cec6 commit 0e0ae91

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/content.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const utils = new Utils();
4545
// Hack to get the CSS loaded on permission-based sites (Invidious)
4646
utils.wait(() => Config.config !== null, 5000, 10).then(addCSS);
4747

48+
const skipBuffer = 0.003;
49+
4850
//was sponsor data found when doing SponsorsLookup
4951
let sponsorDataFound = false;
5052
//the actual sponsorTimes if loaded and UUIDs associated with them
@@ -608,7 +610,6 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
608610
const skipTime: number[] = [currentSkip?.scheduledTime, skipInfo.array[skipInfo.endIndex]?.segment[1]];
609611
const timeUntilSponsor = skipTime?.[0] - currentTime;
610612
const videoID = sponsorVideoID;
611-
const skipBuffer = 0.003;
612613

613614
if (videoMuted && !inMuteSegment(currentTime, skipInfo.index !== -1
614615
&& timeUntilSponsor < skipBuffer && shouldAutoSkip(currentSkip))) {
@@ -1532,7 +1533,7 @@ function getLatestEndTimeIndex(sponsorTimes: SponsorTime[], index: number, hideH
15321533
const currentSegment = sponsorTimes[i].segment;
15331534
const latestEndTime = sponsorTimes[latestEndTimeIndex].segment[1];
15341535

1535-
if (currentSegment[0] <= latestEndTime && currentSegment[1] > latestEndTime
1536+
if (currentSegment[0] - skipBuffer <= latestEndTime && currentSegment[1] > latestEndTime
15361537
&& (!hideHiddenSponsors || sponsorTimes[i].hidden === SponsorHideType.Visible)
15371538
&& shouldAutoSkip(sponsorTimes[i])
15381539
&& sponsorTimes[i].actionType === ActionType.Skip) {
@@ -1573,7 +1574,8 @@ function getStartTimes(sponsorTimes: SponsorTime[], includeIntersectingSegments:
15731574

15741575
// Schedule at the end time to know when to unmute and remove title from seek bar
15751576
sponsorTimes.forEach(sponsorTime => {
1576-
if (!possibleTimes.some((time) => sponsorTime.segment[1] === time.scheduledTime)) {
1577+
if (!possibleTimes.some((time) => sponsorTime.segment[1] === time.scheduledTime)
1578+
&& (minimum === undefined || sponsorTime.segment[1] > minimum)) {
15771579
possibleTimes.push({
15781580
...sponsorTime,
15791581
scheduledTime: sponsorTime.segment[1]

0 commit comments

Comments
 (0)