mirror of https://github.com/gorhill/uBlock.git
Fix icon title always showing `(0)` when badge is disabled
Related feedback: - https://www.reddit.com/r/uBlockOrigin/comments/d33d37/
This commit is contained in:
parent
a3504fc318
commit
e393a52442
|
@ -775,15 +775,18 @@ vAPI.setIcon = (( ) => {
|
|||
const { parts, state, badge, color } = details;
|
||||
|
||||
if ( browserAction.setIcon !== undefined ) {
|
||||
if ( parts === undefined || (parts & 0b001) !== 0 ) {
|
||||
if ( parts === undefined || (parts & 0b0001) !== 0 ) {
|
||||
browserAction.setIcon(
|
||||
Object.assign({ tabId: tab.id }, icons[state])
|
||||
);
|
||||
}
|
||||
if ( (parts & 0b010) !== 0 ) {
|
||||
browserAction.setBadgeText({ tabId: tab.id, text: badge });
|
||||
if ( (parts & 0b0010) !== 0 ) {
|
||||
browserAction.setBadgeText({
|
||||
tabId: tab.id,
|
||||
text: (parts & 0b1000) === 0 ? badge : ''
|
||||
});
|
||||
}
|
||||
if ( (parts & 0b100) !== 0 ) {
|
||||
if ( (parts & 0b0100) !== 0 ) {
|
||||
browserAction.setBadgeBackgroundColor({ tabId: tab.id, color });
|
||||
}
|
||||
}
|
||||
|
@ -800,8 +803,9 @@ vAPI.setIcon = (( ) => {
|
|||
};
|
||||
|
||||
// parts: bit 0 = icon
|
||||
// bit 1 = badge
|
||||
// bit 1 = badge text
|
||||
// bit 2 = badge color
|
||||
// bit 3 = hide badge
|
||||
|
||||
return function(tabId, details) {
|
||||
tabId = toChromiumTabId(tabId);
|
||||
|
|
|
@ -974,7 +974,7 @@ vAPI.tabs = new vAPI.Tabs();
|
|||
};
|
||||
|
||||
const updateBadge = (tabId) => {
|
||||
const parts = tabIdToDetails.get(tabId);
|
||||
let parts = tabIdToDetails.get(tabId);
|
||||
tabIdToDetails.delete(tabId);
|
||||
|
||||
let state = 0;
|
||||
|
@ -984,13 +984,13 @@ vAPI.tabs = new vAPI.Tabs();
|
|||
let pageStore = µb.pageStoreFromTabId(tabId);
|
||||
if ( pageStore !== null ) {
|
||||
state = pageStore.getNetFilteringSwitch() ? 1 : 0;
|
||||
if ( state === 1 && µb.userSettings.showIconBadge ) {
|
||||
if ( (parts & 0b010) !== 0 && pageStore.perLoadBlockedRequestCount ) {
|
||||
if ( state === 1 ) {
|
||||
if ( (parts & 0b0010) !== 0 && pageStore.perLoadBlockedRequestCount ) {
|
||||
badge = µb.formatCount(
|
||||
pageStore.perLoadBlockedRequestCount
|
||||
);
|
||||
}
|
||||
if ( (parts & 0b100) !== 0 ) {
|
||||
if ( (parts & 0b0100) !== 0 ) {
|
||||
color = computeBadgeColor(
|
||||
µb.blockingModeFromHostname(pageStore.tabHostname)
|
||||
);
|
||||
|
@ -998,14 +998,20 @@ vAPI.tabs = new vAPI.Tabs();
|
|||
}
|
||||
}
|
||||
|
||||
// https://www.reddit.com/r/uBlockOrigin/comments/d33d37/
|
||||
if ( µb.userSettings.showIconBadge === false ) {
|
||||
parts |= 0b1000;
|
||||
}
|
||||
|
||||
vAPI.setIcon(tabId, { parts, state, badge, color });
|
||||
};
|
||||
|
||||
// parts: bit 0 = icon
|
||||
// bit 1 = badge
|
||||
// bit 1 = badge text
|
||||
// bit 2 = badge color
|
||||
// bit 3 = hide badge
|
||||
|
||||
return function(tabId, newParts = 0b111) {
|
||||
return function(tabId, newParts = 0b0111) {
|
||||
if ( typeof tabId !== 'number' ) { return; }
|
||||
if ( vAPI.isBehindTheSceneTabId(tabId) ) { return; }
|
||||
let currentParts = tabIdToDetails.get(tabId);
|
||||
|
|
Loading…
Reference in New Issue