Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Extension Action on Browser Start

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.

like image 979
Devon Bernard Avatar asked Nov 17 '13 05:11

Devon Bernard


People also ask

What is a browser action extension?

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.

What is the difference between browser action and page action?

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.

How do I add a pop up extension to Chrome?

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.

What is the action button on Chrome?

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.


1 Answers

David Glibertson's answer didn't work for me.

onStartup works

chrome.runtime.onStartup.addListener(function() {
  console.log('open');
})
like image 181
Mega Proger Avatar answered Sep 25 '22 22:09

Mega Proger