aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/pageUtils.ts
diff options
context:
space:
mode:
authorAjay <[email protected]>2024-12-08 20:02:32 -0500
committerAjay <[email protected]>2024-12-08 20:02:32 -0500
commit15976777ed95699df46251f792d19f07a32ecb30 (patch)
treecc14f2d0441ad301f0a80f73275d6219ce913198 /src/utils/pageUtils.ts
parent9ad636fdadc5709d7205e81d12ae80334ed08a3a (diff)
downloadSponsorBlock-15976777ed95699df46251f792d19f07a32ecb30.tar.gz
SponsorBlock-15976777ed95699df46251f792d19f07a32ecb30.zip
Add option to hide autogenerated chapters by YouTube
Diffstat (limited to 'src/utils/pageUtils.ts')
-rw-r--r--src/utils/pageUtils.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/utils/pageUtils.ts b/src/utils/pageUtils.ts
index 69c9d7f4..4727ecc5 100644
--- a/src/utils/pageUtils.ts
+++ b/src/utils/pageUtils.ts
@@ -1,5 +1,6 @@
import { ActionType, Category, SponsorSourceType, SponsorTime, VideoID } from "../types";
import { getFormattedTimeToSeconds } from "../../maze-utils/src/formating";
+import Config from "../config";
export function getControls(): HTMLElement {
const controlsSelectors = [
@@ -55,10 +56,15 @@ export function getHashParams(): Record<string, unknown> {
return {};
}
+export function hasAutogeneratedChapters(): boolean {
+ return !!document.querySelector("ytd-engagement-panel-section-list-renderer ytd-macro-markers-list-renderer #menu");
+}
+
export function getExistingChapters(currentVideoID: VideoID, duration: number): SponsorTime[] {
const chaptersBox = document.querySelector("ytd-macro-markers-list-renderer");
const title = chaptersBox?.closest("ytd-engagement-panel-section-list-renderer")?.querySelector("#title-text.ytd-engagement-panel-title-header-renderer");
if (title?.textContent?.includes("Key moment")) return [];
+ if (!Config.config.showAutogeneratedChapters && hasAutogeneratedChapters()) return [];
const chapters: SponsorTime[] = [];
// .ytp-timed-markers-container indicates that key-moments are present, which should not be divided