mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
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;
|
const { parts, state, badge, color } = details;
|
||||||
|
|
||||||
if ( browserAction.setIcon !== undefined ) {
|
if ( browserAction.setIcon !== undefined ) {
|
||||||
if ( parts === undefined || (parts & 0b001) !== 0 ) {
|
if ( parts === undefined || (parts & 0b0001) !== 0 ) {
|
||||||
browserAction.setIcon(
|
browserAction.setIcon(
|
||||||
Object.assign({ tabId: tab.id }, icons[state])
|
Object.assign({ tabId: tab.id }, icons[state])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ( (parts & 0b010) !== 0 ) {
|
if ( (parts & 0b0010) !== 0 ) {
|
||||||
browserAction.setBadgeText({ tabId: tab.id, text: badge });
|
browserAction.setBadgeText({
|
||||||
|
tabId: tab.id,
|
||||||
|
text: (parts & 0b1000) === 0 ? badge : ''
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if ( (parts & 0b100) !== 0 ) {
|
if ( (parts & 0b0100) !== 0 ) {
|
||||||
browserAction.setBadgeBackgroundColor({ tabId: tab.id, color });
|
browserAction.setBadgeBackgroundColor({ tabId: tab.id, color });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -800,8 +803,9 @@ vAPI.setIcon = (( ) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// parts: bit 0 = icon
|
// parts: bit 0 = icon
|
||||||
// bit 1 = badge
|
// bit 1 = badge text
|
||||||
// bit 2 = badge color
|
// bit 2 = badge color
|
||||||
|
// bit 3 = hide badge
|
||||||
|
|
||||||
return function(tabId, details) {
|
return function(tabId, details) {
|
||||||
tabId = toChromiumTabId(tabId);
|
tabId = toChromiumTabId(tabId);
|
||||||
|
@ -974,7 +974,7 @@ vAPI.tabs = new vAPI.Tabs();
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateBadge = (tabId) => {
|
const updateBadge = (tabId) => {
|
||||||
const parts = tabIdToDetails.get(tabId);
|
let parts = tabIdToDetails.get(tabId);
|
||||||
tabIdToDetails.delete(tabId);
|
tabIdToDetails.delete(tabId);
|
||||||
|
|
||||||
let state = 0;
|
let state = 0;
|
||||||
@ -984,13 +984,13 @@ vAPI.tabs = new vAPI.Tabs();
|
|||||||
let pageStore = µb.pageStoreFromTabId(tabId);
|
let pageStore = µb.pageStoreFromTabId(tabId);
|
||||||
if ( pageStore !== null ) {
|
if ( pageStore !== null ) {
|
||||||
state = pageStore.getNetFilteringSwitch() ? 1 : 0;
|
state = pageStore.getNetFilteringSwitch() ? 1 : 0;
|
||||||
if ( state === 1 && µb.userSettings.showIconBadge ) {
|
if ( state === 1 ) {
|
||||||
if ( (parts & 0b010) !== 0 && pageStore.perLoadBlockedRequestCount ) {
|
if ( (parts & 0b0010) !== 0 && pageStore.perLoadBlockedRequestCount ) {
|
||||||
badge = µb.formatCount(
|
badge = µb.formatCount(
|
||||||
pageStore.perLoadBlockedRequestCount
|
pageStore.perLoadBlockedRequestCount
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ( (parts & 0b100) !== 0 ) {
|
if ( (parts & 0b0100) !== 0 ) {
|
||||||
color = computeBadgeColor(
|
color = computeBadgeColor(
|
||||||
µb.blockingModeFromHostname(pageStore.tabHostname)
|
µ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 });
|
vAPI.setIcon(tabId, { parts, state, badge, color });
|
||||||
};
|
};
|
||||||
|
|
||||||
// parts: bit 0 = icon
|
// parts: bit 0 = icon
|
||||||
// bit 1 = badge
|
// bit 1 = badge text
|
||||||
// bit 2 = badge color
|
// bit 2 = badge color
|
||||||
|
// bit 3 = hide badge
|
||||||
|
|
||||||
return function(tabId, newParts = 0b111) {
|
return function(tabId, newParts = 0b0111) {
|
||||||
if ( typeof tabId !== 'number' ) { return; }
|
if ( typeof tabId !== 'number' ) { return; }
|
||||||
if ( vAPI.isBehindTheSceneTabId(tabId) ) { return; }
|
if ( vAPI.isBehindTheSceneTabId(tabId) ) { return; }
|
||||||
let currentParts = tabIdToDetails.get(tabId);
|
let currentParts = tabIdToDetails.get(tabId);
|
||||||
|
Loading…
Reference in New Issue
Block a user