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:
Ajay Ramachandran
2021-03-24 20:13:33 -04:00
parent abe3f0532a
commit bf84139ea7
9 changed files with 483 additions and 21 deletions

View File

@@ -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("#", "");