From ce3f77ed20a3fd12ca5fa2ff0d26e0a75b30928f Mon Sep 17 00:00:00 2001 From: Ajay Date: Mon, 7 Nov 2022 21:15:04 -0500 Subject: [PATCH] Better key moments check by not importing when no 0 second chapter --- src/utils/pageUtils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/pageUtils.ts b/src/utils/pageUtils.ts index 94c58bfc..6b262236 100644 --- a/src/utils/pageUtils.ts +++ b/src/utils/pageUtils.ts @@ -71,8 +71,7 @@ export function getExistingChapters(currentVideoID: VideoID, duration: number): const chapters: SponsorTime[] = []; // .ytp-timed-markers-container indicates that key-moments are present, which should not be divided - if (chaptersBox && !(getControls()?.parentElement?.parentElement - ?.querySelector(".ytp-timed-markers-container")?.childElementCount > 0)) { + if (chaptersBox) { let lastSegment: SponsorTime = null; const links = chaptersBox.querySelectorAll("ytd-macro-markers-list-item-renderer > a"); for (const link of links) { @@ -104,6 +103,11 @@ export function getExistingChapters(currentVideoID: VideoID, duration: number): } } + if (chapters[0] && chapters[0].segment[0] !== 0) { + // This is key moments instead of chapters, don't import as they are not full sections + return []; + } + return chapters; }