aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay <[email protected]>2024-10-23 20:14:37 -0400
committerAjay <[email protected]>2024-10-23 20:14:37 -0400
commitad7d3a320b338069f8ab356676fb529e56ba1f46 (patch)
treeb066a9114a4a85411550b48cafec7d98630cb063
parent875ec357d9f352f5b1b32ded0b51e27b5805e32a (diff)
downloadSponsorBlock-ad7d3a320b338069f8ab356676fb529e56ba1f46.tar.gz
SponsorBlock-ad7d3a320b338069f8ab356676fb529e56ba1f46.zip
Update for new related videos layout
m---------maze-utils0
-rw-r--r--src/utils/thumbnails.ts12
2 files changed, 11 insertions, 1 deletions
diff --git a/maze-utils b/maze-utils
-Subproject f12ac4f5f8c0dd073426a413568bcdd58ccbf8e
+Subproject b7cc06c9d5f95db346984c38c346eba7e83e5d5
diff --git a/src/utils/thumbnails.ts b/src/utils/thumbnails.ts
index 0fb2579e..68ad8169 100644
--- a/src/utils/thumbnails.ts
+++ b/src/utils/thumbnails.ts
@@ -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 {
- 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
return parseYouTubeVideoIDFromURL(link.href)?.videoID;