How do extensions like Lastpass and Traitsniper update the extension notification count when the extension is closed? Are there any extension processes that are running even when the extension is closed? I am currently updating this with events in background.js with manifest v3, which does not run when the extension is not open. extensions notifications example
Manifest.json:
{
"short_name": "test",
"name": "test",
"version": "1.3",
"manifest_version": 3,
"action": {
"default_popup": "index.html",
"default_title": "Open the popup"
},
"permissions": ["contextMenus", "notifications", "storage", "tabs"],
"icons": {
"512": "logo512.png"
},
"background": {
"service_worker": "./static/js/background.js"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["./static/js/content.js"]
}
],
"devtools_page": "index.html"
}
Snippet from background.js which currently is updating the notification count in the extension toolbar:
switch (unreadCount) {
case 0:
chrome.action.setBadgeBackgroundColor({
color: [110, 140, 180, 255],
})
chrome.action.setTitle({ title: 'No unread messages' })
chrome.action.setBadgeText({ text: '' })
break
case 1:
chrome.action.setBadgeBackgroundColor({
color: '#F00',
})
chrome.action.setTitle({
title: unreadCount + ' unread message',
})
chrome.action.setBadgeText({ text: unreadCount.toString() })
break
default:
chrome.action.setBadgeBackgroundColor({
color: '#F00',
})
chrome.action.setTitle({
title: unreadCount + ' unread messages',
})
chrome.action.setBadgeText({ text: unreadCount.toString() })
break
}