Don't break chapter bar when existing chapters are there

This commit is contained in:
Ajay
2021-12-26 01:18:55 -05:00
parent 4a19fececf
commit 1a6a07744e

View File

@@ -255,7 +255,8 @@ class PreviewBar {
const newChapterBar = chapterBar.cloneNode(true) as HTMLElement; const newChapterBar = chapterBar.cloneNode(true) as HTMLElement;
newChapterBar.classList.add("sponsorBlockChapterBar"); newChapterBar.classList.add("sponsorBlockChapterBar");
newChapterBar.style.removeProperty("display"); newChapterBar.style.removeProperty("display");
const originalSection = newChapterBar.querySelector(".ytp-chapter-hover-container"); const originalSections = newChapterBar.querySelectorAll(".ytp-chapter-hover-container");
const originalSection = originalSections[0];
this.customChaptersBar = newChapterBar; this.customChaptersBar = newChapterBar;
this.chaptersBarSegments = segments; this.chaptersBarSegments = segments;
@@ -273,7 +274,7 @@ class PreviewBar {
// Hide old bar // Hide old bar
chapterBar.style.display = "none"; chapterBar.style.display = "none";
originalSection.remove(); originalSections.forEach((section) => section.remove());
if (this.container?.parentElement === progressBar) { if (this.container?.parentElement === progressBar) {
progressBar.insertBefore(newChapterBar, this.container.nextSibling); progressBar.insertBefore(newChapterBar, this.container.nextSibling);
} else { } else {