Reputation: 43
I am writing a chrome extension and I need to detect when the user opens his/her browser, but I do not know how.
Can you please help me with it?
Upvotes: 1
Views: 137
Reputation: 2609
You will need to register a listener for the onStartup
event in your background script with chrome.runtime.onStartup.addListener(callback)
In your manifest file make sure you have a entry specifying which script file to run in your background page, and whether it should be persistent or not.
"background": {
"scripts": ["js/event.js"],
"persistent": false
},
Upvotes: 0
Reputation: 7346
Chrome extensions have a background js file, which is run, when the browser starts.
Upvotes: 2