mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 03:57:09 +03:00
Update for new related videos layout
This commit is contained in:
Submodule maze-utils updated: f12ac4f5f8...b7cc06c9d5
@@ -64,8 +64,18 @@ function thumbnailHoverListener(e: MouseEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLink(thumbnail: HTMLImageElement): HTMLAnchorElement | null {
|
||||||
|
if (isOnInvidious()) {
|
||||||
|
return thumbnail.parentElement as HTMLAnchorElement | null;
|
||||||
|
} else if (thumbnail.nodeName.toLowerCase() === "yt-thumbnail-view-model") {
|
||||||
|
return thumbnail.closest("yt-lockup-view-model")?.querySelector("a.yt-lockup-metadata-view-model-wiz__title");
|
||||||
|
} else {
|
||||||
|
return thumbnail.querySelector("#thumbnail");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function extractVideoID(thumbnail: HTMLImageElement): VideoID | null {
|
function extractVideoID(thumbnail: HTMLImageElement): VideoID | null {
|
||||||
const link = (isOnInvidious() ? thumbnail.parentElement : thumbnail.querySelector("#thumbnail")) as HTMLAnchorElement
|
const link = getLink(thumbnail);
|
||||||
if (!link || link.nodeName !== "A" || !link.href) return null; // no link found
|
if (!link || link.nodeName !== "A" || !link.href) return null; // no link found
|
||||||
|
|
||||||
return parseYouTubeVideoIDFromURL(link.href)?.videoID;
|
return parseYouTubeVideoIDFromURL(link.href)?.videoID;
|
||||||
|
|||||||
Reference in New Issue
Block a user