feat(browser-extension): add SET_BADGE handler to the background script and reset action badge text when disabling icon
This commit is contained in:
parent
c740b45e67
commit
ca57b55514
@ -107,6 +107,7 @@ chrome.runtime.onMessage.addListener((message, sender, callback) => {
|
|||||||
case 'DISABLE_ICON':
|
case 'DISABLE_ICON':
|
||||||
if (isPage && tabId) {
|
if (isPage && tabId) {
|
||||||
chrome.action.setIcon({ path: '/assets/icons/disabled.png', tabId }, suppressLastError);
|
chrome.action.setIcon({ path: '/assets/icons/disabled.png', tabId }, suppressLastError);
|
||||||
|
chrome.action.setBadgeText({ tabId, text: '' });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'ENABLE_ICON':
|
case 'ENABLE_ICON':
|
||||||
@ -158,6 +159,12 @@ chrome.runtime.onMessage.addListener((message, sender, callback) => {
|
|||||||
report(message, sender.tab);
|
report(message, sender.tab);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'SET_BADGE':
|
||||||
|
if (tabId) {
|
||||||
|
chrome.action.setBadgeBackgroundColor({ color: '#6b7280' });
|
||||||
|
chrome.action.setBadgeText({ tabId, text: message.value });
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'SET_HOSTNAME_STATE':
|
case 'SET_HOSTNAME_STATE':
|
||||||
if (hostname && message.state.enabled === false) {
|
if (hostname && message.state.enabled === false) {
|
||||||
storage.set({ [hostname]: message.state });
|
storage.set({ [hostname]: message.state });
|
||||||
|
Loading…
Reference in New Issue
Block a user