问题
I'm writing a google chrome extension that gives the user a new word everyday. This word appears in the popup and is inserted into an array so they can study them later. In my background.js I have the classic setInterval, like below:
setInterval(function(){
...code to get new word and push to array
}, (12*3600000));
The problem however is that this functions works on every tab open! So I left it for a day with 10 tabs open and I had 10 new words. How can I have a function within a google chrome extension that only runs once a day, independent of how many tabs are open? Should this function live in another page? The only other js pages I have are popup.js and options.js and I believe those only run when popup.html and options.html are open. Thanks!
来源:https://stackoverflow.com/questions/31094918/set-interval-in-google-chrome-extension