I have a chrome extension running various content and background scripts and I was curious if there is a "browser start" action I can listen for and act upon...
For instance in my application there are some basic scripts that I have run on every page load (within content scripts); but it would be much more efficient if there was some way I can run an action only when the browser first opens.
I've been reading around trying to find something but couldn't come up with anything similar. Any guidance or assistance would be greatly appreciated. Thank you in advance for your time.
A browser action is a button that your extension adds to the browser's toolbar. The button has an icon, and may optionally have a popup whose content is specified using HTML, CSS, and JavaScript.
Page actions represent actions that can be taken on the current page, but that aren't applicable to all pages. Page actions appear grayed out when inactive. Like browser actions, page actions can have an icon, a tooltip, and popup; they can't have badges, however. In addition, page actions can be grayed out.
setPopup({popup: "logged_in. html"}); You can do this when you understand that the user is logged in; however, you may want to restore this state when extension is restarted. To do so, you should save the fact that you are logged in (or out) in persistent storage and call this function on initialization.
browserAction. Use browser actions to put icons in the main Google Chrome toolbar, to the right of the address bar. In addition to its icon, a browser action can have a tooltip, a badge, and a popup.
David Glibertson's answer didn't work for me.
onStartup works
chrome.runtime.onStartup.addListener(function() {
console.log('open');
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With