From 9f1f9f84d408d787b800f359dc0f0f8d6bf322af Mon Sep 17 00:00:00 2001 From: Zacchary Dempsey-Plante Date: Sat, 26 Mar 2022 23:09:24 -0400 Subject: [PATCH] Improve the channel ID lookup. --- src/content.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/content.ts b/src/content.ts index a3352b3b..c9abca76 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1120,11 +1120,12 @@ function updatePreviewBar(): void { async function whitelistCheck() { const whitelistedChannels = Config.config.whitelistedChannels; - const getChannelID = () => videoInfo?.videoDetails?.channelId - ?? document.querySelector(".ytd-channel-name a")?.getAttribute("href")?.replace(/\/.+\//, "") // YouTube - ?? document.querySelector(".ytp-title-channel-logo")?.getAttribute("href")?.replace(/https:\/.+\//, "") // YouTube Embed - ?? document.querySelector("a > .channel-profile")?.parentElement?.getAttribute("href")?.replace(/\/.+\//, "") // Invidious - ?? document.querySelector("a.slim-owner-icon-and-title")?.getAttribute("href")?.replace(/\/.+\//, ""); // Mobile YouTube + const getChannelID = () => + (document.querySelector("a.ytd-video-owner-renderer") // YouTube + ?? document.querySelector("a.ytp-title-channel-logo") // YouTube Embed + ?? document.querySelector(".channel-profile #channel-name")?.parentElement.parentElement // Invidious + ?? document.querySelector("a.slim-owner-icon-and-title")) // Mobile YouTube + ?.getAttribute("href")?.match(/\/channel\/(UC[a-zA-Z0-9_-]{22})/)[1]; try { await utils.wait(() => !!getChannelID(), 6000, 20);