user1928956
user1928956

Reputation:

Google Chrome Extension - How to generate a browser action without clicking?

I am developing a chrome extension.

I found the fact that we have to click on the "icon" to generate a browser action tedious.

Is there a way for us to call a function ( using javascript ) that could generate a browser action so that we do not need to click anymore?

Upvotes: 1

Views: 1700

Answers (2)

Juraj
Juraj

Reputation: 6638

The required API is now there, HOWEVER it's still experimental behind a flag:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction/openPopup

From version 67: this feature is behind the #extension-apis preference (needs to be set to Enabled). To change preferences in Chrome, visit chrome://flags.

Firefox supports this since 57 version.

Also this can be called only from a handler of some user action.

Upvotes: 0

Raghvendra Parashar
Raghvendra Parashar

Reputation: 4053

It's not possible, chrome doesn't give the way to do that. Because popup is for user interaction.

a popup cannot open by any action but clicking on it manually. If you want to open as a popup, you have to open that popup as a new tab with:

chrome.tabs.create({url: chrome.extension.getURL('popup.html')})

Which will run the exact same way as the popup but not within a popup.

Upvotes: 1

Related Questions