mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 12:37:05 +03:00
Rename timestamp to segment
This commit is contained in:
@@ -844,7 +844,7 @@ function updatePreviewBar() {
|
|||||||
if (segment.hidden !== SponsorHideType.Visible) return;
|
if (segment.hidden !== SponsorHideType.Visible) return;
|
||||||
|
|
||||||
previewBarSegments.push({
|
previewBarSegments.push({
|
||||||
timestamps: segment.segment as [number, number],
|
segment: segment.segment as [number, number],
|
||||||
category: segment.category,
|
category: segment.category,
|
||||||
preview: false,
|
preview: false,
|
||||||
});
|
});
|
||||||
@@ -853,7 +853,7 @@ function updatePreviewBar() {
|
|||||||
|
|
||||||
sponsorTimesSubmitting.forEach((segment) => {
|
sponsorTimesSubmitting.forEach((segment) => {
|
||||||
previewBarSegments.push({
|
previewBarSegments.push({
|
||||||
timestamps: segment.segment as [number, number],
|
segment: segment.segment as [number, number],
|
||||||
category: segment.category,
|
category: segment.category,
|
||||||
preview: true,
|
preview: true,
|
||||||
});
|
});
|
||||||
@@ -867,7 +867,7 @@ function updatePreviewBar() {
|
|||||||
return utils.getCategorySelection(segment.category)?.option === CategorySkipOption.AutoSkip;
|
return utils.getCategorySelection(segment.category)?.option === CategorySkipOption.AutoSkip;
|
||||||
});
|
});
|
||||||
|
|
||||||
const skippedDuration = utils.getTimestampsDuration(skippedSegments.map(({timestamps}) => timestamps));
|
const skippedDuration = utils.getTimestampsDuration(skippedSegments.map(({segment}) => segment));
|
||||||
|
|
||||||
showTimeWithoutSkips(skippedDuration);
|
showTimeWithoutSkips(skippedDuration);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const utils = new Utils();
|
|||||||
const TOOLTIP_VISIBLE_CLASS = 'sponsorCategoryTooltipVisible';
|
const TOOLTIP_VISIBLE_CLASS = 'sponsorCategoryTooltipVisible';
|
||||||
|
|
||||||
export interface PreviewBarSegment {
|
export interface PreviewBarSegment {
|
||||||
timestamps: [number, number];
|
segment: [number, number];
|
||||||
category: string;
|
category: string;
|
||||||
preview: boolean;
|
preview: boolean;
|
||||||
}
|
}
|
||||||
@@ -102,8 +102,8 @@ class PreviewBar {
|
|||||||
let currentSegmentLength = Infinity;
|
let currentSegmentLength = Infinity;
|
||||||
|
|
||||||
for (const seg of this.segments) {
|
for (const seg of this.segments) {
|
||||||
if (seg.timestamps[0] <= timeInSeconds && seg.timestamps[1] > timeInSeconds) {
|
if (seg.segment[0] <= timeInSeconds && seg.segment[1] > timeInSeconds) {
|
||||||
const segmentLength = seg.timestamps[1] - seg.timestamps[0];
|
const segmentLength = seg.segment[1] - seg.segment[0];
|
||||||
|
|
||||||
if (segmentLength < currentSegmentLength) {
|
if (segmentLength < currentSegmentLength) {
|
||||||
currentSegmentLength = segmentLength;
|
currentSegmentLength = segmentLength;
|
||||||
@@ -175,7 +175,7 @@ class PreviewBar {
|
|||||||
this.segments = segments;
|
this.segments = segments;
|
||||||
this.videoDuration = videoDuration;
|
this.videoDuration = videoDuration;
|
||||||
|
|
||||||
this.segments.sort(({timestamps: a}, {timestamps: b}) => {
|
this.segments.sort(({segment: a}, {segment: b}) => {
|
||||||
// Sort longer segments before short segments to make shorter segments render later
|
// Sort longer segments before short segments to make shorter segments render later
|
||||||
return (b[1] - b[0]) - (a[1] - a[0]);
|
return (b[1] - b[0]) - (a[1] - a[0]);
|
||||||
}).forEach((segment) => {
|
}).forEach((segment) => {
|
||||||
@@ -185,7 +185,7 @@ class PreviewBar {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createBar({category, preview, timestamps}: PreviewBarSegment): HTMLLIElement {
|
createBar({category, preview, segment}: PreviewBarSegment): HTMLLIElement {
|
||||||
const bar = document.createElement('li');
|
const bar = document.createElement('li');
|
||||||
bar.classList.add('previewbar');
|
bar.classList.add('previewbar');
|
||||||
bar.innerHTML = ' ';
|
bar.innerHTML = ' ';
|
||||||
@@ -198,8 +198,8 @@ class PreviewBar {
|
|||||||
if (!this.onMobileYouTube) bar.style.opacity = Config.config.barTypes[barSegmentType].opacity;
|
if (!this.onMobileYouTube) bar.style.opacity = Config.config.barTypes[barSegmentType].opacity;
|
||||||
|
|
||||||
bar.style.position = "absolute";
|
bar.style.position = "absolute";
|
||||||
bar.style.width = this.timeToPercentage(timestamps[1] - timestamps[0]);
|
bar.style.width = this.timeToPercentage(segment[1] - segment[0]);
|
||||||
bar.style.left = this.timeToPercentage(timestamps[0]);
|
bar.style.left = this.timeToPercentage(segment[0]);
|
||||||
|
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user