mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 09:07:45 +01:00
Clean up isVisible shortcut
This commit is contained in:
parent
3da6a57e42
commit
e4be99c3d7
1 changed files with 23 additions and 21 deletions
|
@ -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<HTMLElement>(".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<HTMLElement>;
|
||||
const el = option.isVisibleCheck ? findValidElement(allElements) : allElements[0];
|
||||
|
||||
if (el) {
|
||||
previewBar = new PreviewBar(el, onMobileYouTube, onInvidious);
|
||||
|
|
Loading…
Reference in a new issue