From 3da6a57e42211c41cd28ffcdd8194eceeb3ab74a Mon Sep 17 00:00:00 2001 From: Michael C Date: Tue, 10 May 2022 21:56:01 -0400 Subject: [PATCH 1/2] shorcut creating preview bar on invidious --- src/content.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/content.ts b/src/content.ts index d969fc32..c3796cb9 100644 --- a/src/content.ts +++ b/src/content.ts @@ -391,6 +391,16 @@ function handleMobileControlsMutations(): void { function createPreviewBar(): void { if (previewBar !== null) return; + if (onInvidious) { // shortut invidious + // skip isVisible check for invidious + const el = document.querySelector(".vjs-progress-holder"); + if (el) { + previewBar = new PreviewBar(el, onMobileYouTube, onInvidious); + updatePreviewBar(); + return; + } + } + const progressElementSelectors = [ // For mobile YouTube ".progress-bar-background", From e4be99c3d777dc12e2765e6e71c7f2abad5289d4 Mon Sep 17 00:00:00 2001 From: Ajay Date: Tue, 17 May 2022 14:04:25 -0400 Subject: [PATCH 2/2] Clean up isVisible shortcut --- src/content.ts | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/content.ts b/src/content.ts index c3796cb9..aa225ac7 100644 --- a/src/content.ts +++ b/src/content.ts @@ -391,30 +391,32 @@ function handleMobileControlsMutations(): void { function createPreviewBar(): void { if (previewBar !== null) return; - if (onInvidious) { // shortut invidious - // skip isVisible check for invidious - const el = document.querySelector(".vjs-progress-holder"); - if (el) { - previewBar = new PreviewBar(el, onMobileYouTube, onInvidious); - updatePreviewBar(); - return; + const progressElementOptions = [{ + // For mobile YouTube + selector: ".progress-bar-background", + isVisibleCheck: true + }, { + // For new mobile YouTube (#1287) + selector: ".ytm-progress-bar", + isVisibleCheck: true + }, { + // For Desktop YouTube + selector: ".ytp-progress-bar-container", + isVisibleCheck: true + }, { + // For Desktop YouTube + selector: ".no-model.cue-range-marker", + isVisibleCheck: true + }, { + // For Invidious/VideoJS + selector: ".vjs-progress-holder", + isVisibleCheck: false } - } - - const progressElementSelectors = [ - // For mobile YouTube - ".progress-bar-background", - // for new mobile YouTube (#1287) - ".ytm-progress-bar", - // For YouTube - ".ytp-progress-bar-container", - ".no-model.cue-range-markers", - // For Invidious/VideoJS - ".vjs-progress-holder" ]; - for (const selector of progressElementSelectors) { - const el = findValidElement(document.querySelectorAll(selector)); + for (const option of progressElementOptions) { + const allElements = document.querySelectorAll(option.selector) as NodeListOf; + const el = option.isVisibleCheck ? findValidElement(allElements) : allElements[0]; if (el) { previewBar = new PreviewBar(el, onMobileYouTube, onInvidious);