diff options
author | hackademix | 2020-02-29 19:03:39 +0100 |
---|---|---|
committer | hackademix | 2020-02-29 19:03:39 +0100 |
commit | e6af4b07c12156f67497917990a21070072e8bf6 (patch) | |
tree | a7fe5299fec74ace3c19e8abada96a3a1bcb8acc | |
parent | 9a664f7b3b6a5315983317b0e47128b809bc5531 (diff) | |
download | noscript-e6af4b07c12156f67497917990a21070072e8bf6.tar.gz noscript-e6af4b07c12156f67497917990a21070072e8bf6.tar.xz noscript-e6af4b07c12156f67497917990a21070072e8bf6.zip |
Minor adjustments for Firefox Preview (Fenix) compatibility.
-rw-r--r-- | src/bg/RequestGuard.js | 4 | ||||
-rw-r--r-- | src/bg/main.js | 11 | ||||
-rw-r--r-- | src/lib/UA.js | 5 | ||||
-rw-r--r-- | src/ui/options.css | 1 | ||||
-rw-r--r-- | src/ui/popup.js | 6 | ||||
-rw-r--r-- | src/ui/ui.css | 10 | ||||
-rw-r--r-- | src/ui/ui.js | 2 |
7 files changed, 23 insertions, 16 deletions
diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js index 10ccfdb..31d79f5 100644 --- a/src/bg/RequestGuard.js +++ b/src/bg/RequestGuard.js @@ -114,7 +114,7 @@ var RequestGuard = (() => { : (numAllowed ? "sub" : "no"); let showBadge = ns.local.showCountBadge && numBlocked > 0; let browserAction = browser.browserAction; - if (!browserAction.setIcon) { // mobile + if (!browserAction.setIcon) { // Fennec browserAction.setTitle({tabId, title: `NoScript (${numBlocked})`}); return; } @@ -123,7 +123,7 @@ var RequestGuard = (() => { browserAction.setBadgeText({tabId, text: showBadge ? numBlocked.toString() : ""}); browserAction.setBadgeBackgroundColor({tabId, color: [128, 0, 0, 160]}); browserAction.setTitle({tabId, - title: `${VERSION_LABEL} \n${enforced ? + title: UA.mobile ? "NoScript" : `${VERSION_LABEL} \n${enforced ? _("BlockedItems", [numBlocked, numAllowed + numBlocked]) + ` \n${report}` : _("NotEnforced")}` }); diff --git a/src/bg/main.js b/src/bg/main.js index b1874f4..b09dcb1 100644 --- a/src/bg/main.js +++ b/src/bg/main.js @@ -109,12 +109,12 @@ // wiring main UI let ba = browser.browserAction; if ("setIcon" in ba) { - //desktop + //desktop or Fenix ba.setPopup({ popup: popupURL }); } else { - // mobile + // Fennec ba.onClicked.addListener(async tab => { try { await browser.tabs.remove(await browser.tabs.query({ @@ -250,9 +250,10 @@ deferWebTraffic(this.initializing = init(), async () => { Commands.install(); - - this.devMode = (await browser.management.getSelf()).installType === "development"; - if (!this.local.debug) { + try { + this.devMode = (await browser.management.getSelf()).installType === "development"; + } catch(e) {} + if (!(this.local.debug || this.devMode)) { debug = () => {}; // suppress verbosity } }); diff --git a/src/lib/UA.js b/src/lib/UA.js index f679f95..57e98ae 100644 --- a/src/lib/UA.js +++ b/src/lib/UA.js @@ -1,10 +1,12 @@ { let mozWebExtUrl = document.URL.startsWith("moz-"); let isMozilla = mozWebExtUrl || typeof window.wrappedJSObject === "object"; + let mobile = false; if (isMozilla) { if (mozWebExtUrl) { // help browser-specific UI styling document.documentElement.classList.add("mozwebext"); + mobile = !("windows" in browser); } } else { // shims for non-Mozilla browsers @@ -14,6 +16,7 @@ } var UA = { - isMozilla + isMozilla, + mobile, }; } diff --git a/src/ui/options.css b/src/ui/options.css index 652a9bf..4653786 100644 --- a/src/ui/options.css +++ b/src/ui/options.css @@ -42,6 +42,7 @@ body { justify-content: flex-end; width: 100%; text-align: right; + margin: 0 0 2px 0; } #sect-general { diff --git a/src/ui/popup.js b/src/ui/popup.js index 07c21e4..63f9eee 100644 --- a/src/ui/popup.js +++ b/src/ui/popup.js @@ -65,7 +65,11 @@ addEventListener("unload", e => { { let clickHandlers = { "options": e => { - browser.runtime.openOptionsPage(); + if (UA.mobile) { // Fenix fails on openOptionsPage + browser.tabs.create({url: browser.extension.getURL("/ui/options.html")}); + } else { + browser.runtime.openOptionsPage(); + } close(); }, "close": close, diff --git a/src/ui/ui.css b/src/ui/ui.css index 1d40030..437758d 100644 --- a/src/ui/ui.css +++ b/src/ui/ui.css @@ -410,15 +410,13 @@ fieldset { legend { font-weight: bold; - display: inline; - position: absolute; - top: 0.25em; - left: 1em; - white-space: nowrap; + display: block; } .customizer legend { - font-weight: bold; font-size: 0.75em; + position: absolute; + top: 0.25em; + left: 1em; } #presets .https-only { diff --git a/src/ui/ui.js b/src/ui/ui.js index dafba4f..f562edd 100644 --- a/src/ui/ui.js +++ b/src/ui/ui.js @@ -21,7 +21,7 @@ var UI = (() => { "/lib/tld.js", "/common/Policy.js", ]; - this.mobile = !("windows" in browser); + this.mobile = UA.mobile; if (this.mobile) { document.documentElement.classList.toggle("mobile", true); scripts.push("/lib/fastclick.js"); |