mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-09 04:57:09 +03:00
Prompt to accept youtube.com permission if video info fails to load
Should fix #698, #687, #611 and #635
(cherry picked from commit 3ff5fdb3a1)
This commit is contained in:
@@ -258,7 +258,7 @@ async function videoIDChange(id) {
|
||||
try {
|
||||
await utils.wait(() => !!videoInfo, 5000, 1);
|
||||
} catch (err) {
|
||||
alert(chrome.i18n.getMessage("adblockerIssue") + "\n\n" + chrome.i18n.getMessage("adblockerIssueUnlistedVideosInfo"));
|
||||
await videoInfoFetchFailed("adblockerIssueUnlistedVideosInfo");
|
||||
}
|
||||
|
||||
if (isUnlisted()) {
|
||||
@@ -268,7 +268,11 @@ async function videoIDChange(id) {
|
||||
}
|
||||
|
||||
// Update whitelist data when the video data is loaded
|
||||
utils.wait(() => !!videoInfo, 5000, 10).then(whitelistCheck);
|
||||
utils.wait(() => !!videoInfo, 5000, 10).then(whitelistCheck).catch(() => {
|
||||
if (Config.config.forceChannelCheck) {
|
||||
videoInfoFetchFailed("adblockerIssueWhitelist");
|
||||
}
|
||||
});
|
||||
|
||||
//setup the preview bar
|
||||
if (previewBar === null) {
|
||||
@@ -727,6 +731,21 @@ async function getVideoInfo(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function videoInfoFetchFailed(errorMessage: string): Promise<void> {
|
||||
console.log("failed\t" + errorMessage)
|
||||
if (utils.isFirefox()) {
|
||||
// Attempt to ask permission for youtube.com domain
|
||||
alert(chrome.i18n.getMessage("youtubePermissionRequest"));
|
||||
|
||||
chrome.runtime.sendMessage({
|
||||
message: "openPage",
|
||||
url: "permissions/index.html#youtube.com"
|
||||
});
|
||||
} else {
|
||||
alert(chrome.i18n.getMessage("adblockerIssue") + "\n\n" + chrome.i18n.getMessage(errorMessage));
|
||||
}
|
||||
}
|
||||
|
||||
function getYouTubeVideoID(url: string) {
|
||||
// For YouTube TV support
|
||||
if(url.startsWith("https://www.youtube.com/tv#/")) url = url.replace("#", "");
|
||||
|
||||
Reference in New Issue
Block a user