mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-10 21:47:06 +03:00
Merge pull request #1710 from mini-bomba/controls-skip-inline-players
Don't attach controls to inline preview players
This commit is contained in:
@@ -14,9 +14,9 @@ export function getControls(): HTMLElement {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const controlsSelector of controlsSelectors) {
|
for (const controlsSelector of controlsSelectors) {
|
||||||
const controls = document.querySelectorAll(controlsSelector);
|
const controls = Array.from(document.querySelectorAll(controlsSelector)).filter(el => !isInPreviewPlayer(el));
|
||||||
|
|
||||||
if (controls && controls.length > 0) {
|
if (controls.length > 0) {
|
||||||
return <HTMLElement> controls[controls.length - 1];
|
return <HTMLElement> controls[controls.length - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,10 @@ export function getControls(): HTMLElement {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isInPreviewPlayer(element: Element): boolean {
|
||||||
|
return !!element.closest("#inline-preview-player");
|
||||||
|
}
|
||||||
|
|
||||||
export function isVisible(element: HTMLElement): boolean {
|
export function isVisible(element: HTMLElement): boolean {
|
||||||
return element && element.offsetWidth > 0 && element.offsetHeight > 0;
|
return element && element.offsetWidth > 0 && element.offsetHeight > 0;
|
||||||
}
|
}
|
||||||
@@ -65,12 +69,12 @@ export function getExistingChapters(currentVideoID: VideoID, duration: number):
|
|||||||
if (timeElement && description?.innerText?.length > 0 && link.getAttribute("href")?.includes(currentVideoID)) {
|
if (timeElement && description?.innerText?.length > 0 && link.getAttribute("href")?.includes(currentVideoID)) {
|
||||||
const time = getFormattedTimeToSeconds(timeElement.innerText.replace(".", ":"));
|
const time = getFormattedTimeToSeconds(timeElement.innerText.replace(".", ":"));
|
||||||
if (time === null) return [];
|
if (time === null) return [];
|
||||||
|
|
||||||
if (lastSegment) {
|
if (lastSegment) {
|
||||||
lastSegment.segment[1] = time;
|
lastSegment.segment[1] = time;
|
||||||
chapters.push(lastSegment);
|
chapters.push(lastSegment);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastSegment = {
|
lastSegment = {
|
||||||
segment: [time, null],
|
segment: [time, null],
|
||||||
category: "chapter" as Category,
|
category: "chapter" as Category,
|
||||||
@@ -112,4 +116,4 @@ export function getLocalizedMessage(text: string): string | false {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user