aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2022-03-28 15:43:59 -0400
committerGitHub <[email protected]>2022-03-28 15:43:59 -0400
commit0d31b8276c0b439b866bae1207a8ba8e3323113e (patch)
treee2a105496670d37f86072e01fb318ce889106049
parentb15a8db6516cfed7a99be5d0eff50470cf98ceab (diff)
parent9f1f9f84d408d787b800f359dc0f0f8d6bf322af (diff)
downloadSponsorBlock-0d31b8276c0b439b866bae1207a8ba8e3323113e.tar.gz
SponsorBlock-0d31b8276c0b439b866bae1207a8ba8e3323113e.zip
Merge pull request #1250 from zedseven/channel-id-lookup-optimisations
Improve the channel ID lookup.
-rw-r--r--src/content.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/content.ts b/src/content.ts
index d62b0be7..2212945b 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -1126,11 +1126,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);