Minor adjustments for Firefox Preview (Fenix) compatibility.

This commit is contained in:
hackademix 2020-02-29 19:03:39 +01:00
parent 9a664f7b3b
commit e6af4b07c1
7 changed files with 23 additions and 16 deletions

View File

@ -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")}`
});

View File

@ -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
}
});

View File

@ -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,
};
}

View File

@ -42,6 +42,7 @@ body {
justify-content: flex-end;
width: 100%;
text-align: right;
margin: 0 0 2px 0;
}
#sect-general {

View File

@ -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,

View File

@ -410,15 +410,13 @@ fieldset {
legend {
font-weight: bold;
display: inline;
display: block;
}
.customizer legend {
font-size: 0.75em;
position: absolute;
top: 0.25em;
left: 1em;
white-space: nowrap;
}
.customizer legend {
font-weight: bold;
font-size: 0.75em;
}
#presets .https-only {

View File

@ -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");