diff --git a/src/content.ts b/src/content.ts index 1caaf907..cd073a56 100644 --- a/src/content.ts +++ b/src/content.ts @@ -569,6 +569,7 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?: openNotice: skipInfo.openNotice }); + // These are segments that start at the exact same time but need seperate notices for (const extra of skipInfo.extraIndexes) { const extraSkip = skipInfo.array[extra]; if (shouldSkip(extraSkip)) { @@ -1222,10 +1223,13 @@ function getNextSkipIndex(currentTime: number, includeIntersectingSegments: bool getStartTimes(sponsorTimes, includeIntersectingSegments, includeNonIntersectingSegments); const { scheduledTimes: sponsorStartTimesAfterCurrentTime } = getStartTimes(sponsorTimes, includeIntersectingSegments, includeNonIntersectingSegments, currentTime, true, true); + // This is an array in-case multiple segments have the exact same start time const minSponsorTimeIndexes = GenericUtils.indexesOf(sponsorStartTimes, Math.min(...sponsorStartTimesAfterCurrentTime)); + // Find auto skipping segments if possible, sort by duration otherwise const minSponsorTimeIndex = minSponsorTimeIndexes.sort( (a, b) => ((autoSkipSorter(submittedArray[a]) - autoSkipSorter(submittedArray[b])) || (submittedArray[a].segment[1] - submittedArray[a].segment[0]) - (submittedArray[b].segment[1] - submittedArray[b].segment[0])))[0] ?? -1; + // Store extra indexes for the non-auto skipping segments if others occur at the exact same start time const extraIndexes = minSponsorTimeIndexes.filter((i) => i === minSponsorTimeIndex || autoSkipSorter(submittedArray[i]) !== 0); const endTimeIndex = getLatestEndTimeIndex(submittedArray, minSponsorTimeIndex);