Skip to content

Commit

Permalink
Update for new related videos layout
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayyy committed Oct 24, 2024
1 parent 875ec35 commit ad7d3a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion maze-utils
12 changes: 11 additions & 1 deletion src/utils/thumbnails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ad7d3a3

Please sign in to comment.