Max Andruh
Max Andruh

Reputation: 43

How to detect when user open browser?

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

Answers (2)

holmberd
holmberd

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

Sebastian Speitel
Sebastian Speitel

Reputation: 7346

Chrome extensions have a background js file, which is run, when the browser starts.

Upvotes: 2

Related Questions