mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 11:37:02 +03:00
Fix chapter titles still showing on hover after they've been removed from the seek bar
This commit is contained in:
@@ -52,6 +52,7 @@ class PreviewBar {
|
|||||||
progressBar: HTMLElement;
|
progressBar: HTMLElement;
|
||||||
|
|
||||||
segments: PreviewBarSegment[] = [];
|
segments: PreviewBarSegment[] = [];
|
||||||
|
hasYouTubeChapters = false;
|
||||||
existingChapters: PreviewBarSegment[] = [];
|
existingChapters: PreviewBarSegment[] = [];
|
||||||
videoDuration = 0;
|
videoDuration = 0;
|
||||||
updateExistingChapters: () => void;
|
updateExistingChapters: () => void;
|
||||||
@@ -136,7 +137,7 @@ class PreviewBar {
|
|||||||
|
|
||||||
// Find the segment at that location, using the shortest if multiple found
|
// Find the segment at that location, using the shortest if multiple found
|
||||||
const [normalSegments, chapterSegments] =
|
const [normalSegments, chapterSegments] =
|
||||||
partition(this.segments.filter((s) => s.source !== SponsorSourceType.YouTube),
|
partition(this.segments,
|
||||||
(segment) => segment.actionType !== ActionType.Chapter);
|
(segment) => segment.actionType !== ActionType.Chapter);
|
||||||
let mainSegment = this.getSmallestSegment(timeInSeconds, normalSegments, "normal");
|
let mainSegment = this.getSmallestSegment(timeInSeconds, normalSegments, "normal");
|
||||||
let secondarySegment = this.getSmallestSegment(timeInSeconds, chapterSegments, "chapter");
|
let secondarySegment = this.getSmallestSegment(timeInSeconds, chapterSegments, "chapter");
|
||||||
@@ -145,9 +146,19 @@ class PreviewBar {
|
|||||||
secondarySegment = this.getSmallestSegment(timeInSeconds, chapterSegments.filter((s) => s !== secondarySegment));
|
secondarySegment = this.getSmallestSegment(timeInSeconds, chapterSegments.filter((s) => s !== secondarySegment));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasAYouTubeChapterRemoved = this.hasYouTubeChapters
|
||||||
|
|| (!Config.config.showAutogeneratedChapters && hasAutogeneratedChapters());
|
||||||
|
if (hasAYouTubeChapterRemoved) {
|
||||||
|
// Hide original tooltip if some chapter has been filtered out
|
||||||
|
originalTooltip.style.display = "none";
|
||||||
|
noYoutubeChapters = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (mainSegment === null && secondarySegment === null) {
|
if (mainSegment === null && secondarySegment === null) {
|
||||||
this.categoryTooltipContainer.classList.remove(TOOLTIP_VISIBLE_CLASS);
|
if (!hasAYouTubeChapterRemoved) {
|
||||||
originalTooltip.style.removeProperty("display");
|
this.categoryTooltipContainer.classList.remove(TOOLTIP_VISIBLE_CLASS);
|
||||||
|
originalTooltip.style.removeProperty("display");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.categoryTooltipContainer.classList.add(TOOLTIP_VISIBLE_CLASS);
|
this.categoryTooltipContainer.classList.add(TOOLTIP_VISIBLE_CLASS);
|
||||||
if (mainSegment !== null && secondarySegment !== null) {
|
if (mainSegment !== null && secondarySegment !== null) {
|
||||||
@@ -172,16 +183,16 @@ class PreviewBar {
|
|||||||
originalTooltip.style.removeProperty("display");
|
originalTooltip.style.removeProperty("display");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to prevent overlapping
|
|
||||||
this.categoryTooltip.classList.toggle("ytp-tooltip-text-no-title", noYoutubeChapters);
|
|
||||||
this.chapterTooltip.classList.toggle("ytp-tooltip-text-no-title", noYoutubeChapters);
|
|
||||||
|
|
||||||
// To prevent offset issue
|
// To prevent offset issue
|
||||||
this.categoryTooltip.style.right = titleTooltip.style.right;
|
this.categoryTooltip.style.right = titleTooltip.style.right;
|
||||||
this.chapterTooltip.style.right = titleTooltip.style.right;
|
this.chapterTooltip.style.right = titleTooltip.style.right;
|
||||||
this.categoryTooltip.style.textAlign = titleTooltip.style.textAlign;
|
this.categoryTooltip.style.textAlign = titleTooltip.style.textAlign;
|
||||||
this.chapterTooltip.style.textAlign = titleTooltip.style.textAlign;
|
this.chapterTooltip.style.textAlign = titleTooltip.style.textAlign;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used to prevent overlapping
|
||||||
|
this.categoryTooltip.classList.toggle("ytp-tooltip-text-no-title", noYoutubeChapters);
|
||||||
|
this.chapterTooltip.classList.toggle("ytp-tooltip-text-no-title", noYoutubeChapters);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,6 +243,7 @@ class PreviewBar {
|
|||||||
set(segments: PreviewBarSegment[], videoDuration: number): void {
|
set(segments: PreviewBarSegment[], videoDuration: number): void {
|
||||||
this.segments = segments ?? [];
|
this.segments = segments ?? [];
|
||||||
this.videoDuration = videoDuration ?? 0;
|
this.videoDuration = videoDuration ?? 0;
|
||||||
|
this.hasYouTubeChapters = segments.some((segment) => segment.source === SponsorSourceType.YouTube);
|
||||||
|
|
||||||
// Remove unnecessary original chapters if submitted replacements exist
|
// Remove unnecessary original chapters if submitted replacements exist
|
||||||
for (const chapter of this.segments.filter((s) => s.actionType === ActionType.Chapter && s.source === SponsorSourceType.Server)) {
|
for (const chapter of this.segments.filter((s) => s.actionType === ActionType.Chapter && s.source === SponsorSourceType.Server)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user