From 1a6a07744ec92acd2ecc3bbdca11c6a4289d660d Mon Sep 17 00:00:00 2001 From: Ajay Date: Sun, 26 Dec 2021 01:18:55 -0500 Subject: [PATCH] Don't break chapter bar when existing chapters are there --- src/js-components/previewBar.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index dc7c7d0b..7d58f861 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -255,7 +255,8 @@ class PreviewBar { const newChapterBar = chapterBar.cloneNode(true) as HTMLElement; newChapterBar.classList.add("sponsorBlockChapterBar"); 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.chaptersBarSegments = segments; @@ -273,7 +274,7 @@ class PreviewBar { // Hide old bar chapterBar.style.display = "none"; - originalSection.remove(); + originalSections.forEach((section) => section.remove()); if (this.container?.parentElement === progressBar) { progressBar.insertBefore(newChapterBar, this.container.nextSibling); } else {