mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 13:37:04 +03:00
Fix small time differences between segments causing issues
This commit is contained in:
@@ -12,6 +12,7 @@ import { getCategoryActionType, getSkippingText } from "../utils/categoryUtils";
|
|||||||
const utils = new Utils();
|
const utils = new Utils();
|
||||||
|
|
||||||
const TOOLTIP_VISIBLE_CLASS = 'sponsorCategoryTooltipVisible';
|
const TOOLTIP_VISIBLE_CLASS = 'sponsorCategoryTooltipVisible';
|
||||||
|
const MIN_CHAPTER_SIZE = 0.003;
|
||||||
|
|
||||||
export interface PreviewBarSegment {
|
export interface PreviewBarSegment {
|
||||||
segment: [number, number];
|
segment: [number, number];
|
||||||
@@ -269,10 +270,10 @@ class PreviewBar {
|
|||||||
this.setupChapterSection(newSection, duration);
|
this.setupChapterSection(newSection, duration);
|
||||||
newChapterBar.appendChild(newSection);
|
newChapterBar.appendChild(newSection);
|
||||||
|
|
||||||
if (segment.segment[1] < this.videoDuration) {
|
|
||||||
const nextSegment = mergedSegments[i + 1];
|
const nextSegment = mergedSegments[i + 1];
|
||||||
const newBlankSection = originalSection.cloneNode(true) as HTMLElement;
|
|
||||||
const nextTime = nextSegment ? nextSegment.segment[0] : this.videoDuration;
|
const nextTime = nextSegment ? nextSegment.segment[0] : this.videoDuration;
|
||||||
|
if (this.timeToDecimal(nextTime - segment.segment[1]) > MIN_CHAPTER_SIZE) {
|
||||||
|
const newBlankSection = originalSection.cloneNode(true) as HTMLElement;
|
||||||
const blankDuration = nextTime - segment.segment[1];
|
const blankDuration = nextTime - segment.segment[1];
|
||||||
|
|
||||||
this.setupChapterSection(newBlankSection, blankDuration);
|
this.setupChapterSection(newBlankSection, blankDuration);
|
||||||
@@ -446,7 +447,7 @@ class PreviewBar {
|
|||||||
|
|
||||||
private chapterFilter(segment: PreviewBarSegment): boolean {
|
private chapterFilter(segment: PreviewBarSegment): boolean {
|
||||||
return getCategoryActionType(segment.category) !== CategoryActionType.POI
|
return getCategoryActionType(segment.category) !== CategoryActionType.POI
|
||||||
&& segment.segment.length === 2 && this.timeToDecimal(segment.segment[1] - segment.segment[0]) > 0.003;
|
&& segment.segment.length === 2 && this.timeToDecimal(segment.segment[1] - segment.segment[0]) > MIN_CHAPTER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
timeToPercentage(time: number): string {
|
timeToPercentage(time: number): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user