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.
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
)i18n
runtime
(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).