Background Tasks
Helpful tutorials about how to create Chrome Extensions
1 post
Page 1 of 1
Hello Coders,
Let's say you want to create an extension that needs to do some work in the background, a good example would be an RSS feed. Now you'll probably want your extension to check every now and then to see if anything new has been added to the feed and alert the user that new content is available.
This is quite easy to accomplish.
In your manifest.json file add the background permission:
Here's an example background.js file which updates the extension badge text every second:
Happy coding
Let's say you want to create an extension that needs to do some work in the background, a good example would be an RSS feed. Now you'll probably want your extension to check every now and then to see if anything new has been added to the feed and alert the user that new content is available.
This is quite easy to accomplish.
In your manifest.json file add the background permission:
Code: Select all
Now you simply add your code, which you want to run in the background, in to a new file called background.js "background": {
"scripts": ["background.js"]
},
Here's an example background.js file which updates the extension badge text every second:
Code: Select all
That is all you needvar i = 0;
window.setInterval(function () {
chrome.browserAction.setBadgeText({ text: String(i) });
i = i + 1;
}, 1000);
Happy coding
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023