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