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

33
src/permissions.ts Normal file
View File

@@ -0,0 +1,33 @@
import Config from "./config";
import Utils from "./utils";
const utils = new Utils();
// This is needed, if Config is not imported before Utils, things break.
// Probably due to cyclic dependencies
Config.config;
window.addEventListener('DOMContentLoaded', init);
async function init() {
utils.localizeHtmlPage();
const domains = document.location.hash.replace("#", "").split(",");
const acceptButton = document.getElementById("acceptPermissionButton");
acceptButton.addEventListener("click", () => {
chrome.permissions.request({
origins: utils.getPermissionRegex(domains),
permissions: []
}, (granted) => {
if (granted) {
alert(chrome.i18n.getMessage("permissionRequestSuccess"));
chrome.tabs.getCurrent((tab) => {
chrome.tabs.remove(tab.id);
});
} else {
alert(chrome.i18n.getMessage("permissionRequestFailed"));
}
});
});
}