From 2eb0a34858bca09a3d68a0b73a9379a54d9fb1be Mon Sep 17 00:00:00 2001 From: Ajay Date: Sun, 10 Jul 2022 00:56:31 -0400 Subject: [PATCH] Always import chapters when segments --- src/content.ts | 6 +----- src/js-components/previewBar.ts | 8 +++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/content.ts b/src/content.ts index b71162e5..3b1fda27 100644 --- a/src/content.ts +++ b/src/content.ts @@ -958,11 +958,7 @@ async function sponsorsLookup(keepOldSubmissions = true) { } function importExistingChapters(wait: boolean) { - const containsChapter = sponsorTimes?.some((segment) => segment.actionType === ActionType.Chapter) - || sponsorTimesSubmitting.some((segment) => segment.actionType === ActionType.Chapter); - - if ((Config.config.renderSegmentsAsChapters || containsChapter) - && !existingChaptersImported + if (!existingChaptersImported && (sponsorTimes?.length > 0 || sponsorTimesSubmitting.length > 0)) { GenericUtils.wait(() => video && getExistingChapters(sponsorVideoID, video.duration), wait ? 5000 : 0, 100, (c) => c?.length > 0).then((chapters) => { diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index b93ba60f..e11391e2 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -220,8 +220,8 @@ class PreviewBar { this.createChaptersBar(segments.sort((a, b) => a.segment[0] - b.segment[0])); const chapterChevron = document.querySelector(".ytp-chapter-title-chevron") as HTMLElement; - if (!Config.config.renderSegmentsAsChapters - || segments.some((segment) => segment.source === SponsorSourceType.YouTube)) { + if (segments.some((segment) => segment.actionType !== ActionType.Chapter + && segment.source === SponsorSourceType.YouTube)) { chapterChevron.style.removeProperty("display"); } else { chapterChevron.style.display = "none"; @@ -258,7 +258,9 @@ class PreviewBar { const chapterBar = document.querySelector(".ytp-chapters-container:not(.sponsorBlockChapterBar)") as HTMLElement; if (!progressBar || !chapterBar || chapterBar.childElementCount <= 0) return; - if (!Config.config.renderSegmentsAsChapters && segments.every((segment) => segment.actionType !== ActionType.Chapter)) { + if (!Config.config.renderSegmentsAsChapters + && segments.every((segment) => segment.actionType !== ActionType.Chapter + || segment.source === SponsorSourceType.YouTube)) { if (this.customChaptersBar) this.customChaptersBar.style.display = "none"; chapterBar.style.removeProperty("display"); return;