Description
Use the chrome.tabs API to interact with the browser's tab system. You can use this API to create, modify, and rearrange tabs in the browser.
The Tabs API not only offers features for manipulating and managing tabs, but can also detect the language of the tab, take a screenshot, and communicate with a tab's content scripts.
Permissions
Most features don't require any permissions to use. For example: creating a new tab, reloading a tab, navigating to another URL, etc.
There are three permissions developers should be aware of when working with the Tabs API.
- The "tabs" permission
This permission does not give access to the
browser.tabsnamespace. Instead, it grants an extension the ability to calltabs.query()against four sensitive properties ontabs.Tabinstances:url,pendingUrl,title, andfavIconUrl.{ "name": "My extension", ... "permissions": [ "tabs" ], ... }- Host permissions
Host permissions allow an extension to read and query a matching tab's four sensitive
tabs.Tabproperties. They can also interact directly with the matching tabs using methods such astabs.captureVisibleTab(),scripting.executeScript(),scripting.insertCSS(), andscripting.removeCSS().{ "name": "My extension", ... "host_permissions": [ "http://*/*", "https://*/*" ], ... }- The "activeTab" permission
activeTabgrants an extension temporary host permission for the current tab in response to a user invocation. Unlike host permissions,activeTabdoes not trigger any warnings.{ "name": "My extension", ... "permissions": [ "activeTab" ], ... }
Use cases
The following sections demonstrate some common use cases.
Open an extension page in a new tab
A common pattern for extensions is to open an onboarding page in a new tab when the extension is installed. The following example shows how to do this.
background.js: