mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-06 19:47:04 +03:00
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
This commit is contained in:
@@ -721,7 +721,7 @@ function startSkipScheduleCheckingForStartSponsors() {
|
|||||||
* Get the video info for the current tab from YouTube
|
* Get the video info for the current tab from YouTube
|
||||||
*/
|
*/
|
||||||
async function getVideoInfo(): Promise<void> {
|
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) {
|
if (result.ok) {
|
||||||
const decodedData = decodeURIComponent(result.responseText).match(/player_response=([^&]*)/)[1];
|
const decodedData = decodeURIComponent(result.responseText).match(/player_response=([^&]*)/)[1];
|
||||||
@@ -834,16 +834,19 @@ function updatePreviewBar(): void {
|
|||||||
async function whitelistCheck() {
|
async function whitelistCheck() {
|
||||||
const whitelistedChannels = Config.config.whitelistedChannels;
|
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(".ytp-title-channel-logo")?.getAttribute("href")?.replace(/https:\/.+\//, "") // YouTube Embed
|
||||||
?? document.querySelector("a > .channel-profile")?.parentElement?.getAttribute("href")?.replace(/\/.+\//, ""); // Invidious
|
?? document.querySelector("a > .channel-profile")?.parentElement?.getAttribute("href")?.replace(/\/.+\//, ""); // Invidious
|
||||||
|
|
||||||
if (channelID) {
|
try {
|
||||||
|
await utils.wait(() => !!getChannelID(), 6000, 20);
|
||||||
|
|
||||||
channelIDInfo = {
|
channelIDInfo = {
|
||||||
status: ChannelIDStatus.Found,
|
status: ChannelIDStatus.Found,
|
||||||
id: channelID
|
id: getChannelID()
|
||||||
}
|
}
|
||||||
} else {
|
} catch (e) {
|
||||||
channelIDInfo = {
|
channelIDInfo = {
|
||||||
status: ChannelIDStatus.Failed,
|
status: ChannelIDStatus.Failed,
|
||||||
id: null
|
id: null
|
||||||
@@ -853,7 +856,7 @@ async function whitelistCheck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//see if this is a whitelisted channel
|
//see if this is a whitelisted channel
|
||||||
if (whitelistedChannels != undefined && whitelistedChannels.includes(channelID)) {
|
if (whitelistedChannels != undefined && whitelistedChannels.includes(getChannelID())) {
|
||||||
channelWhitelisted = true;
|
channelWhitelisted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user