I’ve been reading Chrome migration guide and there is one piece of code that’s puzzling me:
// background.js
chrome.alarms.create({ delayInMinutes: 3 });
chrome.alarms.onAlarm.addListener(() => {
chrome.action.setIcon({
path: getRandomIconPath(),
});
});
If one would put this code inside a non-persistent background script (or a service worker), the alarm would fire not only 3 minutes after the extension start, BUT also 3 minutes after each waking up of the background event page, right? So this could fire once or 100 times.
So how do I run code only on extension start?
Maybe something like runtime.onStartup but for extensions (since some browsers keeps running even after closing them). Also it would probably not fire after installing extension.