'How to set the badge text in a chrome extension from the content script?
It is possible to set the badge text from a background script. I was wondering if it was possible to do so from a content script.
Solution 1:[1]
No, it's not possible. You need to message a background page to do it for you.
However, content scripts have some limitations. They cannot:
Use
chrome.*APIs, with the exception of:
extension(getURL,inIncognitoContext,lastError,onRequest,sendRequest)i18nruntime(connect,getManifest,getURL,id,onConnect,onMessage,sendMessage)storage
If you don't have a background page yet and are worried about possible performance impacts, look into Event pages (manifest V2) or Event pages (manifest V3).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | kano |
