Is it possible to add timer in badge on the icon for MV3?

I wanted to try plasmo but not sure if the MV3 which supported by plasmo can have this kind of feature. When user click on a button on the Content script, it will add a badge showing the timer until the timer runs out. I’m aware that we can persist the timer by saving the endTime for the timer. But not sure about having a timer running on the service worker. Or is it only possible on in MV2?
No description
13 Replies
lab
lab•15mo ago
how was this possible in MV2 btw? Also, Plasmo can be bundled for Mv2 as well Was it possible for Mv2 to mount non-png icons? Otherwise, it's likely that dev would have to manually add a timer
umar
umarOP•15mo ago
I think because MV2 has the persistent option so the timer in the “background” can persist Thats great, thanks
YAGPDB.xyz
YAGPDB.xyz•15mo ago
Gave +1 Rep to @louisgv
umar
umarOP•15mo ago
Actually what I meant by the badge using this https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction/setBadgeText Apologies for the confusing
browserAction.setBadgeText() - Mozilla | MDN
Sets the badge text for the browser action. The badge is displayed on top of the icon.
umar
umarOP•15mo ago
We already done it in MV2 but not with plasmo. Was thinking is it possible to implement that kind of feature in MV3? Sorry if wrong channel
Arcane
Arcane•15mo ago
@marlqm has reached level 1. GG!
lab
lab•15mo ago
I'm not entirely sure, but one way I can think of is to use the alert API to keep setting the badge text?
filthytone
filthytone•15mo ago
you can technically persist the background page w/ hacks (look at https://github.com/PlasmoHQ/plasmo/tree/main/api/persistent) .. but otherwise you can do setTimeout from bg AND/OR an every minute alert that coordinates
Arcane
Arcane•15mo ago
@filthytone has reached level 2. GG!
filthytone
filthytone•15mo ago
one thing to note though w/ that persistent hack (i still want to test this, but i think it's accurate) .. since it keeps the bg worker alive, if you depend on chrome web store updates, it simply won't update until chrome restarts (instead of when the bg worker naturally reloads)
lab
lab•15mo ago
yup that's correct
umar
umarOP•15mo ago
That’s awesome. Never thought Plasmo have that kind of feature. Thanks guys @filthytone @louisgv I will try it
YAGPDB.xyz
YAGPDB.xyz•15mo ago
Gave +1 Rep to @filthytone
Want results from more Discord servers?
Add your server