Interact with the browser's tab system.
You can use this API to get a list of opened tabs, filtered by various criteria, and to open, update, move, reload, and remove tabs. You can't directly access the content hosted by tabs using this API, but you can insert JavaScript and CSS into tabs using the tabs.executeScript()
or tabs.insertCSS()
APIs.
You can use most of this API without any special permission. However:
- To access
Tab.url
,Tab.title
, andTab.favIconUrl
(or to filter by these properties viatabs.query()
), you need to have the"tabs"
permission, or have host permissions that matchTab.url
.- Access to these properties by host permissions is supported since Firefox 86 and Chrome 50. In Firefox 85 and earlier, the "tabs" permission was required instead.
- To use
tabs.executeScript()
ortabs.insertCSS()
, you must have the host permission for the tab
Alternatively, you can get these permissions temporarily, only for the currently active tab and only in response to an explicit user action, by asking for the "activeTab"
permission.
Many tab operations use a Tab id
. Tab id
s are guaranteed to be unique to a single tab only within a browser session. If the browser is restarted, then it can and will reuse tab id
s. To associate information with a tab across browser restarts, use sessions.setTabValue()
.