mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 21:17:20 +03:00
Add more checks to prevent double seek bar or no seek bar
This commit is contained in:
@@ -230,7 +230,14 @@ class PreviewBar {
|
|||||||
const allProgressBars = document.querySelectorAll('.ytp-progress-bar') as NodeListOf<HTMLElement>;
|
const allProgressBars = document.querySelectorAll('.ytp-progress-bar') as NodeListOf<HTMLElement>;
|
||||||
this.progressBar = findValidElement(allProgressBars) ?? allProgressBars?.[0];
|
this.progressBar = findValidElement(allProgressBars) ?? allProgressBars?.[0];
|
||||||
|
|
||||||
this.originalChapterBar = this.progressBar.querySelector(".ytp-chapters-container:not(.sponsorBlockChapterBar)") as HTMLElement;
|
const newChapterBar = this.progressBar.querySelector(".ytp-chapters-container:not(.sponsorBlockChapterBar)") as HTMLElement;
|
||||||
|
if (this.originalChapterBar !== newChapterBar) {
|
||||||
|
// Make sure changes are undone on old bar
|
||||||
|
this.originalChapterBar?.style?.removeProperty("display");
|
||||||
|
|
||||||
|
this.originalChapterBar = newChapterBar;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private update(): void {
|
private update(): void {
|
||||||
@@ -299,7 +306,10 @@ class PreviewBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createChaptersBar(segments: PreviewBarSegment[]): void {
|
createChaptersBar(segments: PreviewBarSegment[]): void {
|
||||||
if (!this.progressBar || !this.originalChapterBar || this.originalChapterBar.childElementCount <= 0) return;
|
if (!this.progressBar || !this.originalChapterBar || this.originalChapterBar.childElementCount <= 0) {
|
||||||
|
if (this.customChaptersBar) this.customChaptersBar.style.display = "none";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (segments.every((segments) => segments.source === SponsorSourceType.YouTube)
|
if (segments.every((segments) => segments.source === SponsorSourceType.YouTube)
|
||||||
|| (!Config.config.renderSegmentsAsChapters
|
|| (!Config.config.renderSegmentsAsChapters
|
||||||
|
|||||||
Reference in New Issue
Block a user