Properly ask for permissions when changing the server address

This commit is contained in:
Ajay Ramachandran
2020-03-10 00:48:53 -04:00
parent 2ec47d52cd
commit f0bf051259

View File

@@ -72,7 +72,7 @@ async function init() {
textChangeInput.value = Config.config[textChangeOption]; textChangeInput.value = Config.config[textChangeOption];
textChangeSetButton.addEventListener("click", () => { textChangeSetButton.addEventListener("click", async () => {
// See if anything extra must be done // See if anything extra must be done
switch (textChangeOption) { switch (textChangeOption) {
case "serverAddress": case "serverAddress":
@@ -84,6 +84,18 @@ async function init() {
return; return;
} }
// Permission needed on Firefox
if (utils.isFirefox()) {
let permissionSuccess = await new Promise((resolve, reject) => {
chrome.permissions.request({
origins: [textChangeInput.value + "/"],
permissions: []
}, resolve);
});
if (!permissionSuccess) return;
}
break; break;
} }