More informative / useful popup on (semi)privileged pages.

This commit is contained in:
hackademix 2018-07-06 00:59:12 +02:00
parent 57eaa94dde
commit 1ee85084f7
1 changed files with 34 additions and 19 deletions

View File

@ -107,8 +107,10 @@ addEventListener("unload", e => {
let mainFrame = UI.seen && UI.seen.find(thing => thing.request.type === "main_frame"); let mainFrame = UI.seen && UI.seen.find(thing => thing.request.type === "main_frame");
debug("Seen: %o", UI.seen); debug("Seen: %o", UI.seen);
if (!mainFrame) { if (!mainFrame) {
let isHttp = /^https?:/.test(tab.url);
if (/^https?:/.test(tab.url) && !tab.url.startsWith("https://addons.mozilla.org/")) { try {
await browser.tabs.executeScript(tabId, { code: "" });
if (isHttp) {
document.body.classList.add("disabled"); document.body.classList.add("disabled");
showMessage("warning", _("freshInstallReload")); showMessage("warning", _("freshInstallReload"));
let buttons = document.querySelector("#buttons"); let buttons = document.querySelector("#buttons");
@ -125,9 +127,22 @@ addEventListener("unload", e => {
buttons.appendChild(b); buttons.appendChild(b);
return; return;
} }
} catch (e) {
error(e, "Could not run scripts on %s: privileged page?", tab.url);
}
if (!isHttp) {
showMessage("warning", _("privilegedPage")); showMessage("warning", _("privilegedPage"));
document.getElementById("temp-trust-page").disabled = true; let tempTrust = document.getElementById("temp-trust-page");
if (!UI.seen) return; tempTrust.disabled = true;
}
if (!UI.seen) {
if (!isHttp) return;
UI.seen = [
mainFrame = {
request: { url: tab.url, documentUrl: tab.url, type: "main_frame" }
}
];
}
} }
let justDomains = !UI.local.showFullAddresses; let justDomains = !UI.local.showFullAddresses;