From f9380c71c2a40934bf523249b6c2ffb5925a9fa8 Mon Sep 17 00:00:00 2001 From: HanYaodong Date: Sun, 3 Mar 2024 22:26:23 +0800 Subject: [PATCH] Add preview bar to small progress bar on the bottom --- src/content.ts | 14 +++++++------- src/js-components/previewBar.ts | 19 ++++++++++++++++--- src/utils/pageCleaner.ts | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/content.ts b/src/content.ts index 855255d7..b8652aaa 100644 --- a/src/content.ts +++ b/src/content.ts @@ -431,20 +431,20 @@ function createPreviewBar(): void { const progressElementOptions = [{ // For Desktop Bilibili selector: ".bpx-player-progress-schedule-wrap", + shadowSelector: ".bpx-player-shadow-progress-area", isVisibleCheck: true - } - ]; + }]; for (const option of progressElementOptions) { const allElements = document.querySelectorAll(option.selector) as NodeListOf; - const el = option.isVisibleCheck ? findValidElement(allElements) : allElements[0]; + const parent = option.isVisibleCheck ? findValidElement(allElements) : allElements[0]; + const allshadowSelectorElements = document.querySelectorAll(option.shadowSelector) as NodeListOf; + const shadowParent = allshadowSelectorElements[0]; - if (el) { + if (parent) { const chapterVote = new ChapterVote(voteAsync); - previewBar = new PreviewBar(el, chapterVote); - + previewBar = new PreviewBar(parent, shadowParent, chapterVote); updatePreviewBar(); - break; } } diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index c5dff29a..82563368 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -25,7 +25,10 @@ export interface PreviewBarSegment { } class PreviewBar { + // main progress bar container: HTMLUListElement; + // small progress bar on the bottom of