diff options
author | Ajay <[email protected]> | 2024-05-24 03:15:58 -0400 |
---|---|---|
committer | Ajay <[email protected]> | 2024-05-24 03:15:58 -0400 |
commit | a6695254b6aa13f2ce2cbc78d17385402bf0431d (patch) | |
tree | e01585470729f760ef41e817ec1b404ca48907e3 /src/js-components | |
parent | e8a82eddcae08b44c13f26fdeb229c1ce4bf5a2d (diff) | |
download | SponsorBlock-a6695254b6aa13f2ce2cbc78d17385402bf0431d.tar.gz SponsorBlock-a6695254b6aa13f2ce2cbc78d17385402bf0431d.zip |
Fix skipping and preview bar on "add to queue", miniplayer and hover preview
Fixes #1486
Diffstat (limited to 'src/js-components')
-rw-r--r-- | src/js-components/previewBar.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/js-components/previewBar.ts b/src/js-components/previewBar.ts index db452bfa..a014d606 100644 --- a/src/js-components/previewBar.ts +++ b/src/js-components/previewBar.ts @@ -13,6 +13,7 @@ import { DEFAULT_CATEGORY, shortCategoryName } from "../utils/categoryUtils"; import { normalizeChapterName } from "../utils/exporter"; import { findValidElement } from "../../maze-utils/src/dom"; import { addCleanupListener } from "../../maze-utils/src/cleanup"; +import { isVisible } from "../utils/pageUtils"; const TOOLTIP_VISIBLE_CLASS = 'sponsorCategoryTooltipVisible'; const MIN_CHAPTER_SIZE = 0.003; @@ -225,10 +226,12 @@ class PreviewBar { this.segments = segments ?? []; this.videoDuration = videoDuration ?? 0; + this.updatePageElements(); // Sometimes video duration is inaccurate, pull from accessibility info const ariaDuration = parseInt(this.progressBar?.getAttribute('aria-valuemax')) ?? 0; - if (ariaDuration && Math.abs(ariaDuration - this.videoDuration) > 3) { + const multipleActiveVideos = [...document.querySelectorAll("video")].filter((v) => isVisible(v)).length > 1; + if (!multipleActiveVideos && ariaDuration && Math.abs(ariaDuration - this.videoDuration) > 3) { this.videoDuration = ariaDuration; } @@ -236,7 +239,7 @@ class PreviewBar { } private updatePageElements(): void { - const allProgressBars = document.querySelectorAll('.ytp-progress-bar') as NodeListOf<HTMLElement>; + const allProgressBars = document.querySelectorAll(".ytp-progress-bar") as NodeListOf<HTMLElement>; this.progressBar = findValidElement(allProgressBars) ?? allProgressBars?.[0]; if (this.progressBar) { |