diff options
author | Ajay Ramachandran <[email protected]> | 2021-06-11 13:28:42 -0400 |
---|---|---|
committer | Ajay Ramachandran <[email protected]> | 2021-06-11 13:28:42 -0400 |
commit | ac037c6f08c0f7978841d6749c1da91ea72ad19e (patch) | |
tree | 2207183fa3cecb514f6a9b6b96b6ec9bc81b9ee8 /src/content.ts | |
parent | b0400f98bec31ec9dddb420495c86df73e301e1b (diff) | |
download | SponsorBlock-ac037c6f08c0f7978841d6749c1da91ea72ad19e.tar.gz SponsorBlock-ac037c6f08c0f7978841d6749c1da91ea72ad19e.zip |
Make get_video_info work again
Resolve https://github.com/ajayyy/SponsorBlock/issues/751 for now
Potentially helps with https://github.com/ajayyy/SponsorBlock/issues/766 and https://github.com/ajayyy/SponsorBlock/issues/753
Diffstat (limited to 'src/content.ts')
-rw-r--r-- | src/content.ts | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/content.ts b/src/content.ts index 13843746..6ce82711 100644 --- a/src/content.ts +++ b/src/content.ts @@ -721,7 +721,7 @@ function startSkipScheduleCheckingForStartSponsors() { * Get the video info for the current tab from YouTube */ async function getVideoInfo(): Promise<void> { - const result = await utils.asyncRequestToCustomServer("GET", "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID); + const result = await utils.asyncRequestToCustomServer("GET", "https://www.youtube.com/get_video_info?video_id=" + sponsorVideoID + "&html5=1"); if (result.ok) { const decodedData = decodeURIComponent(result.responseText).match(/player_response=([^&]*)/)[1]; @@ -834,16 +834,19 @@ function updatePreviewBar(): void { async function whitelistCheck() { const whitelistedChannels = Config.config.whitelistedChannels; - const channelID = document.querySelector(".ytd-channel-name a")?.getAttribute("href")?.replace(/\/.+\//, "") // YouTube + 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 - if (channelID) { + try { + await utils.wait(() => !!getChannelID(), 6000, 20); + channelIDInfo = { status: ChannelIDStatus.Found, - id: channelID + id: getChannelID() } - } else { + } catch (e) { channelIDInfo = { status: ChannelIDStatus.Failed, id: null @@ -853,7 +856,7 @@ async function whitelistCheck() { } //see if this is a whitelisted channel - if (whitelistedChannels != undefined && whitelistedChannels.includes(channelID)) { + if (whitelistedChannels != undefined && whitelistedChannels.includes(getChannelID())) { channelWhitelisted = true; } |