[Mobile] Blocked scripts count displayed in the browser action menu item.

This commit is contained in:
hackademix 2019-10-25 22:42:54 +01:00
parent 810c607e6b
commit d84ff782c2
1 changed files with 5 additions and 3 deletions

View File

@ -111,6 +111,11 @@ var RequestGuard = (() => {
: (numAllowed ? "sub" : "no");
let showBadge = ns.local.showCountBadge && numBlocked > 0;
let browserAction = browser.browserAction;
if (!browserAction.setIcon) { // mobile
browserAction.setTitle({tabId, title: `NoScript (${numBlocked})`});
return;
}
browserAction.setIcon({tabId, path: {64: `/img/ui-${icon}64.png`}});
browserAction.setBadgeText({tabId, text: showBadge ? numBlocked.toString() : ""});
browserAction.setBadgeBackgroundColor({tabId, color: [128, 0, 0, 160]});
@ -165,9 +170,6 @@ var RequestGuard = (() => {
}
browser.tabs.onActivated.addListener(TabStatus.onActivatedTab);
browser.tabs.onRemoved.addListener(TabStatus.onRemovedTab);
if (!("setIcon" in browser.browserAction)) { // unsupported on Android
TabStatus._updateTabNow = TabStatus.updateTab = () => {};
}
let messageHandler = {
async pageshow(message, sender) {
TabStatus.recordAll(sender.tab.id, message.seen);