I wrote a simple Chrome Extension that pulls a string (price) from my webserver, every few seconds. When I install Chrome Extension, it works great. To achieve this I use this line in manifest.json:
"background": {
"service_worker": "loadPriceInterval.js"
},
In that .js file I have setInterval function which is triggered every 10 seconds. It pulls new price and displays it as badge text, that's all. The problem happens when I close Chrome and run it again few hours later. My extension is still visible but price isn't updated. It looks like the extension won't pull new price. Seems like the extension is not loading loadPriceInterval.js and this few lines I have in loadPriceInterval.js:
(function() {
setInterval(function() {
readPriceFun();
}, 9000); // 9 seconds
})();
How do I make sure extension would continue with this setInterval thing whenever Chrome is restarted, not only when I add extension?