Skip to content

Commit

Permalink
Fix a special case where some YouTube featured videos are linked as p…
Browse files Browse the repository at this point in the history
…laylists even though they display a normal video title
  • Loading branch information
ajayyy committed Dec 15, 2023
1 parent a516440 commit 2841da1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/videoBranding/videoBranding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export async function replaceVideoCardBranding(element: HTMLElement, brandingLoc

if (link) {
const videoID = await extractVideoID(link);
const isPlaylistOrClipTitleStatus = isPlaylistOrClipTitle(link);
const isPlaylistOrClipTitleStatus = isPlaylistOrClipTitle(element, link);
const isMovie = element.nodeName.includes("MOVIE");

if (verifyVideoID && videoID !== verifyVideoID) {
Expand Down Expand Up @@ -269,8 +269,10 @@ export async function extractVideoIDFromElement(element: HTMLElement, brandingLo
}
}

function isPlaylistOrClipTitle(link: HTMLAnchorElement) {
return (link.href?.match(/list=/)?.[0] !== undefined && link.href?.match(/index=/)?.[0] === undefined)
function isPlaylistOrClipTitle(element: HTMLElement, link: HTMLAnchorElement) {
return (link.href?.match(/list=/)?.[0] !== undefined
&& link.href?.match(/index=/)?.[0] === undefined
&& element.nodeName !== "YTD-RICH-GRID-MEDIA")
|| link.href?.match(/\/clip\//)?.[0] !== undefined;
}

Expand Down

0 comments on commit 2841da1

Please sign in to comment.