adambullmer / vue-cli-plugin-browser-extension

Browser extension development plugin for vue-cli 3.0
GNU Lesser General Public License v3.0
426 stars 76 forks source link

open extension in new tab #86

Open realrecordzLab opened 4 years ago

realrecordzLab commented 4 years ago

I've started using this plugin with vue cli ui. I want to create a new tab when the extension button is clicked, so I've selected standalone when I've configured the project in the ui. The problem is that nothing will happen if I click the extension button so now I'm confused on how to proceed with the project setup. I've added the tab permission in the manifest, is there any other step I need to do?

adambullmer commented 4 years ago

I think you'll need to make a background script that is responsible for opening a new tab when the browser action button is clicked. I recommend scaffolding the app with background and standalone to get the relevant manifest and boilerplate background script generated for you, and then tweaking the background handler to open a new tab

realrecordzLab commented 4 years ago

Found the solution

browser.browserAction.onClicked.addListener( tab => {
  browser.tabs.create({ ... });
});

This will create a new tab when the extension icon is clicked.