summaryrefslogtreecommitdiff
path: root/src/ui/popup.js
diff options
context:
space:
mode:
authorhackademix2018-07-06 00:59:12 +0200
committerhackademix2018-07-06 00:59:12 +0200
commit1ee85084f75f59fe83aeed17e5a1c59837e1db92 (patch)
tree905b8a09f840ab4b604fd0dc3cd55d03a90fe4f3 /src/ui/popup.js
parent57eaa94dde7f2a2865c74dbb6c895fdf93162cab (diff)
downloadnoscript-1ee85084f75f59fe83aeed17e5a1c59837e1db92.tar.gz
noscript-1ee85084f75f59fe83aeed17e5a1c59837e1db92.tar.xz
noscript-1ee85084f75f59fe83aeed17e5a1c59837e1db92.zip
More informative / useful popup on (semi)privileged pages.
Diffstat (limited to 'src/ui/popup.js')
-rw-r--r--src/ui/popup.js53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/ui/popup.js b/src/ui/popup.js
index 3f84549..8ca4f44 100644
--- a/src/ui/popup.js
+++ b/src/ui/popup.js
@@ -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;