Replacing content_scripts – What to choose WebExtension API vs Tabs API

I’m converting my existing content_scripts based extension to activeTab permission based.

Along with that I’m also providing optional_permissions so that I can ask permission to users to inject my scripts the way it used to be, if user allows.

I’m currently curious to know what route should I take. I know there are two ways, either using webNavigation or using tabs permission.

For webNavigation permission I’m going to use:

chrome.webNavigation.onCompleted.addListener(loadCssAndJS, {url: [{urlPrefix : 'http'}]})

Also I’m programmatically filtering out the inner frames.

For tabs permission I’m going to use:

chrome.tabs.onUpdated.addListener(loadCssAndJS)

I’ve few questions, if someone can answer:

  • Which permission should I choose and why?
  • What are some best practices?
  • Any considerations I should keep in mind?

Source: Ask Javascript Questions

LEAVE A COMMENT