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;
|
||||
|
||||
previewBarSegments.push({
|
||||
timestamps: segment.segment as [number, number],
|
||||
segment: segment.segment as [number, number],
|
||||
category: segment.category,
|
||||
preview: false,
|
||||
});
|
||||
@@ -853,7 +853,7 @@ function updatePreviewBar() {
|
||||
|
||||
sponsorTimesSubmitting.forEach((segment) => {
|
||||
previewBarSegments.push({
|
||||
timestamps: segment.segment as [number, number],
|
||||
segment: segment.segment as [number, number],
|
||||
category: segment.category,
|
||||
preview: true,
|
||||
});
|
||||
@@ -867,7 +867,7 @@ function updatePreviewBar() {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ const utils = new Utils();
|
||||
const TOOLTIP_VISIBLE_CLASS = 'sponsorCategoryTooltipVisible';
|
||||
|
||||
export interface PreviewBarSegment {
|
||||
timestamps: [number, number];
|
||||
segment: [number, number];
|
||||
category: string;
|
||||
preview: boolean;
|
||||
}
|
||||
@@ -102,8 +102,8 @@ class PreviewBar {
|
||||
let currentSegmentLength = Infinity;
|
||||
|
||||
for (const seg of this.segments) {
|
||||
if (seg.timestamps[0] <= timeInSeconds && seg.timestamps[1] > timeInSeconds) {
|
||||
const segmentLength = seg.timestamps[1] - seg.timestamps[0];
|
||||
if (seg.segment[0] <= timeInSeconds && seg.segment[1] > timeInSeconds) {
|
||||
const segmentLength = seg.segment[1] - seg.segment[0];
|
||||
|
||||
if (segmentLength < currentSegmentLength) {
|
||||
currentSegmentLength = segmentLength;
|
||||
@@ -175,7 +175,7 @@ class PreviewBar {
|
||||
this.segments = segments;
|
||||
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
|
||||
return (b[1] - b[0]) - (a[1] - a[0]);
|
||||
}).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');
|
||||
bar.classList.add('previewbar');
|
||||
bar.innerHTML = ' ';
|
||||
@@ -198,8 +198,8 @@ class PreviewBar {
|
||||
if (!this.onMobileYouTube) bar.style.opacity = Config.config.barTypes[barSegmentType].opacity;
|
||||
|
||||
bar.style.position = "absolute";
|
||||
bar.style.width = this.timeToPercentage(timestamps[1] - timestamps[0]);
|
||||
bar.style.left = this.timeToPercentage(timestamps[0]);
|
||||
bar.style.width = this.timeToPercentage(segment[1] - segment[0]);
|
||||
bar.style.left = this.timeToPercentage(segment[0]);
|
||||
|
||||
return bar;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user