https://github.com/addonbone/browser
A TypeScript promise-based wrapper for Chrome Extension APIs, supporting both Manifest V2 and V3 across Chrome, Opera, Edge, and other Chromium-based browsers.
https://github.com/addonbone/browser
addon api chrome chrome-extension edge firefox opera safari
Last synced: 11 months ago
JSON representation
A TypeScript promise-based wrapper for Chrome Extension APIs, supporting both Manifest V2 and V3 across Chrome, Opera, Edge, and other Chromium-based browsers.
- Host: GitHub
- URL: https://github.com/addonbone/browser
- Owner: addonbone
- Created: 2025-06-18T18:34:19.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-01T16:19:33.000Z (12 months ago)
- Last Synced: 2025-07-01T16:21:23.913Z (12 months ago)
- Topics: addon, api, chrome, chrome-extension, edge, firefox, opera, safari
- Language: TypeScript
- Homepage:
- Size: 136 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# @adnbn/browser
[](https://www.npmjs.com/package/@adnbn/browser)
[](https://www.npmjs.com/package/@adnbn/browser)
A TypeScript promise-based wrapper for Chrome Extension APIs, supporting both Manifest V2 and V3 across Chrome, Opera, Edge, and other Chromium-based browsers.
## Installation
```bash
npm install @adnbn/browser
```
## Supported Chrome APIs
- [action](#action)
- [alarms](#alarms)
- [audio](#audio)
- [browsingData](#browsingdata)
- [commands](#commands)
- [contextMenus](#contextmenus)
- [cookies](#cookies)
- [documentScan](#documentscan)
- [downloads](#downloads)
- [extension](#extension)
- [fileBrowserHandler](#filebrowserhandler)
- [history](#history)
- [i18n](#i18n)
- [idle](#idle)
- [management](#management)
- [notifications](#notifications)
- [offscreen](#offscreen)
- [permissions](#permissions)
- [runtime](#runtime)
- [scripting](#scripting)
- [sidebar](#sidebar)
- [tabCapture](#tabcapture)
- [tabs](#tabs)
- [userScripts](#userscripts)
- [webNavigation](#webnavigation)
- [webRequest](#webrequest)
## action
**Documentation:** [Chrome Action API](https://developer.chrome.com/docs/extensions/reference/action)
A unified interface to the Chrome `action` API (`chrome.action` in Manifest V3, `chrome.browserAction` in Manifest V2), with Promise-based methods.
### Methods
- [disableAction(tabId)](#disableAction)
- [enableAction(tabId)](#enableAction)
- [getBadgeBgColor(tabId)](#getBadgeBgColor)
- [getBadgeText(tabId)](#getBadgeText)
- [getBadgeTextColor(tabId)](#getBadgeTextColor) [MV3]
- [getActionPopup(tabId)](#getActionPopup)
- [getActionTitle(tabId)](#getActionTitle)
- [getActionUserSetting()](#getActionUserSetting) [MV3]
- [isActionEnabled(tabId)](#isActionEnabled)
- [openActionPopup(windowId)](#openActionPopup) [MV3]
- [setBadgeBgColor(color, tabId)](#setBadgeBgColor)
- [setBadgeText(text, tabId)](#setBadgeText)
- [setBadgeTextColor(color, tabId)](#setBadgeTextColor) [MV3]
- [setActionIcon(details)](#setActionIcon)
- [setActionPopup(popup, tabId)](#setActionPopup)
- [setActionTitle(title, tabId)](#setActionTitle)
- [getDefaultPopup()](#getDefaultPopup)
- [clearBadgeText(tabId)](#clearBadgeText)
### Events
- [onActionClicked(callback)](#onActionClicked)
- [onActionUserSettingsChanged(callback)](#onActionUserSettingsChanged) [MV3]
### disableAction
```
disableAction(tabId: number): Promise
```
Disables the extension action for the specified tab. Falls back to `chrome.browserAction.disable` in Manifest V2.
### enableAction
```
enableAction(tabId: number): Promise
```
Enables the extension action for the specified tab. Falls back to `chrome.browserAction.enable` in Manifest V2.
### getBadgeBgColor
```
getBadgeBgColor(tabId?: number): Promise<[number, number, number, number]>
```
Retrieves the badge background color for a given tab.
### getBadgeText
```
getBadgeText(tabId?: number): Promise
```
Retrieves the badge text for a given tab.
### getBadgeTextColor [MV3]
```
getBadgeTextColor(tabId?: number): Promise<[number, number, number, number]>
```
Retrieves the badge text color for a given tab (Manifest V3 only).
### getActionPopup
```
getActionPopup(tabId?: number): Promise
```
Retrieves the popup URL set for the action in a given tab.
### getActionTitle
```
getActionTitle(tabId?: number): Promise
```
Retrieves the title set for the action in a given tab.
### getActionUserSetting [MV3]
```
getActionUserSetting(): Promise
```
Retrieves the user settings for the action (Manifest V3 only).
### isActionEnabled
```
isActionEnabled(tabId: number): Promise
```
Checks whether the action is enabled for the specified tab.
### openActionPopup [MV3]
```
openActionPopup(windowId?: number): Promise
```
Programmatically opens the action popup (Manifest V3 only).
### setBadgeBgColor
```
setBadgeBgColor(color: string | [number, number, number, number], tabId?: number): Promise
```
Sets the badge background color for a given tab.
### setBadgeText
```
setBadgeText(text: string | number, tabId?: number): Promise
```
Sets the badge text for a given tab.
### setBadgeTextColor [MV3]
```
setBadgeTextColor(color: string | [number, number, number, number], tabId?: number): Promise
```
Sets the badge text color for a given tab (Manifest V3 only).
### setActionIcon
```
setActionIcon(details: chrome.action.TabIconDetails): Promise
```
Sets the action icon for a tab or globally.
### setActionPopup
```
setActionPopup(popup: string, tabId?: number): Promise
```
Sets the popup URL for the action in a given tab.
### setActionTitle
```
setActionTitle(title: string, tabId?: number): Promise
```
Sets the title for the action in a given tab.
### getDefaultPopup
```
getDefaultPopup(): string
```
Returns the default popup URL from the manifest (`action.default_popup` in MV3 or `browser_action.default_popup` in MV2).
### clearBadgeText
```
clearBadgeText(tabId?: number): Promise
```
Clears the badge text for a given tab.
### onActionClicked
```
onActionClicked(callback: (tab: chrome.tabs.Tab) => void): () => void
```
Adds a listener for the action clicked event.
### onActionUserSettingsChanged [MV3]
```
onActionUserSettingsChanged(callback: (settings: chrome.action.UserSettings) => void): () => void
```
Adds a listener for user settings changes on the action (Manifest V3 only).
## alarms
**Documentation:** [Chrome Alarms API](https://developer.chrome.com/docs/extensions/reference/alarms)
A promise-based wrapper for the Chrome `alarms` API.
### Methods
- [clearAlarm(name)](#clearAlarm)
- [clearAllAlarm()](#clearAllAlarm)
- [createAlarm(name, info)](#createAlarm)
- [getAlarm(name)](#getAlarm)
- [getAllAlarm()](#getAllAlarm)
### Events
- [onAlarm(callback)](#onAlarm)
### clearAlarm
```
clearAlarm(name: string): Promise
```
Clears the alarm with the specified name, returning true if an existing alarm was found and cleared.
### clearAllAlarm
```
clearAllAlarm(): Promise
```
Clears all alarms, returning true if any alarms were found and cleared.
### createAlarm
```
createAlarm(name: string, info: chrome.alarms.AlarmCreateInfo): Promise
```
Creates a new alarm or updates an existing one with the given name and scheduling options.
### getAlarm
```
getAlarm(name: string): Promise
```
Retrieves details for the alarm with the specified name.
### getAllAlarm
```
getAllAlarm(): Promise
```
Retrieves all set alarms.
### onAlarm
```
onAlarm(callback: (alarm: chrome.alarms.Alarm) => void): () => void
```
Adds a listener that triggers when an alarm goes off.
## audio
**Documentation:** [Chrome Audio API](https://developer.chrome.com/docs/extensions/reference/audio)
A promise-based wrapper for the Chrome `audio` API.
### Methods
- [getAudioDevices(filter)](#getAudioDevices)
- [getAudioMute(streamType)](#getAudioMute)
- [setAudioActiveDevices(ids)](#setAudioActiveDevices)
- [setAudioMute(streamType, isMuted)](#setAudioMute)
- [setAudioProperties(id, properties)](#setAudioProperties)
### Events
- [onAudioDeviceListChanged(callback)](#onAudioDeviceListChanged)
- [onAudioLevelChanged(callback)](#onAudioLevelChanged)
- [onAudioMuteChanged(callback)](#onAudioMuteChanged)
### getAudioDevices
```
getAudioDevices(filter?: chrome.audio.DeviceFilter): Promise
```
Retrieves the list of available audio devices, optionally filtered.
### getAudioMute
```
getAudioMute(streamType: chrome.audio.StreamType): Promise
```
Retrieves the mute state of the specified audio stream.
### setAudioActiveDevices
```
setAudioActiveDevices(ids?: chrome.audio.DeviceIdLists): Promise
```
Sets the list of active audio devices.
### setAudioMute
```
setAudioMute(streamType: chrome.audio.StreamType, isMuted: boolean): Promise
```
Sets the mute state for the specified audio stream.
### setAudioProperties
```
setAudioProperties(id: string, properties?: chrome.audio.DeviceProperties): Promise
```
Updates properties for the specified audio device.
### onAudioDeviceListChanged
```
onAudioDeviceListChanged(callback: () => void): () => void
```
Adds a listener for changes in the list of audio devices.
### onAudioLevelChanged
```
onAudioLevelChanged(callback: (level: number) => void): () => void
```
Adds a listener for changes in audio level.
### onAudioMuteChanged
```
onAudioMuteChanged(callback: (isMuted: boolean) => void): () => void
```
Adds a listener for changes in audio mute state.
## browsingData
**Documentation:** [Chrome Browsing Data API](https://developer.chrome.com/docs/extensions/reference/browsingData)
A promise-based wrapper for the Chrome `browsingData` API.
### Methods
- [removeBrowsingData(options, dataToRemove)](#removeBrowsingData)
- [removeAppcacheData(options)](#removeAppcacheData)
- [removeCacheData(options)](#removeCacheData)
- [removeCacheStorageData(options)](#removeCacheStorageData)
- [removeCookiesData(options)](#removeCookiesData)
- [removeDownloadsData(options)](#removeDownloadsData)
- [removeFileSystemsData(options)](#removeFileSystemsData)
- [removeFormData(options)](#removeFormData)
- [removeHistoryData(options)](#removeHistoryData)
- [removeIndexedDBData(options)](#removeIndexedDBData)
- [removeLocalStorageData(options)](#removeLocalStorageData)
- [removePasswordsData(options)](#removePasswordsData)
- [removeServiceWorkersData(options)](#removeServiceWorkersData)
- [removeWebSQLData(options)](#removeWebSQLData)
- [getBrowsingDataSettings()](#getBrowsingDataSettings)
### removeBrowsingData
```
removeBrowsingData(options: chrome.browsingData.RemovalOptions, dataToRemove: chrome.browsingData.DataTypeSet): Promise
```
Clears the specified types of browsing data within the given time range.
### removeAppcacheData
```
removeAppcacheData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears the application cache.
### removeCacheData
```
removeCacheData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears the browser cache.
### removeCacheStorageData
```
removeCacheStorageData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears Cache Storage.
### removeCookiesData
```
removeCookiesData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears all cookies.
### removeDownloadsData
```
removeDownloadsData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears download history.
### removeFileSystemsData
```
removeFileSystemsData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears file system data.
### removeFormData
```
removeFormData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears data entered into forms.
### removeHistoryData
```
removeHistoryData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears browsing history.
### removeIndexedDBData
```
removeIndexedDBData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears IndexedDB data.
### removeLocalStorageData
```
removeLocalStorageData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears Local Storage data.
### removePasswordsData
```
removePasswordsData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears saved passwords.
### removeServiceWorkersData
```
removeServiceWorkersData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears Service Worker registrations.
### removeWebSQLData
```
removeWebSQLData(options?: chrome.browsingData.RemovalOptions): Promise
```
Clears WebSQL data.
### getBrowsingDataSettings
```
getBrowsingDataSettings(): Promise
```
Retrieves the current browsing data removal settings.
## commands
**Documentation:** [Chrome Commands API](https://developer.chrome.com/docs/extensions/reference/commands)
A promise-based wrapper for the Chrome `commands` API.
### Methods
- [getAllCommands()](#getAllCommands)
### Events
- [onCommand(callback)](#onCommand)
### getAllCommands
```
getAllCommands(): Promise
```
Retrieves all registered extension commands.
### onCommand
```
onCommand(callback: (command: string, tab: chrome.tabs.Tab) => void): () => void
```
Adds a listener for extension command events.
## contextMenus
**Documentation:** [Chrome Context Menus API](https://developer.chrome.com/docs/extensions/reference/contextMenus)
A promise-based wrapper for the Chrome `contextMenus` API.
### Methods
- [createContextMenus(createProperties)](#createContextMenus)
- [removeContextMenus(menuItemId)](#removeContextMenus)
- [removeAllContextMenus()](#removeAllContextMenus)
- [updateContextMenus(id, updateProperties)](#updateContextMenus)
### Events
- [onContextMenusClicked(callback)](#onContextMenusClicked)
### createContextMenus
```
createContextMenus(createProperties?: chrome.contextMenus.CreateProperties): Promise
```
Creates a new context menu item with the specified properties.
### removeContextMenus
```
removeContextMenus(menuItemId: string | number): Promise
```
Removes the context menu item with the given ID.
### removeAllContextMenus
```
removeAllContextMenus(): Promise
```
Removes all context menu items added by the extension.
### updateContextMenus
```
updateContextMenus(id: string | number, updateProperties?: Omit): Promise
```
Updates the specified context menu item with new properties.
### onContextMenusClicked
```
onContextMenusClicked(callback: (info: chrome.contextMenus.OnClickData, tab: chrome.tabs.Tab) => void): () => void
```
Adds a listener that triggers when a context menu item is clicked.
## cookies
**Documentation:** [Chrome Cookies API](https://developer.chrome.com/docs/extensions/reference/cookies)
A promise-based wrapper for the Chrome `cookies` API.
### Methods
- [getCookie(details)](#getCookie)
- [getAllCookie(details)](#getAllCookie)
- [getAllCookieStores()](#getAllCookieStores)
- [getCookiePartitionKey(details)](#getCookiePartitionKey)
- [removeCookie(details)](#removeCookie)
- [setCookie(details)](#setCookie)
### Events
- [onCookieChanged(callback)](#onCookieChanged)
### getCookie
```
getCookie(details: chrome.cookies.CookieDetails): Promise
```
Retrieves the cookie matching the specified details, or `null` if not found.
### getAllCookie
```
getAllCookie(details?: chrome.cookies.GetAllDetails): Promise
```
Retrieves all cookies that match the given filter details.
### getAllCookieStores
```
getAllCookieStores(): Promise
```
Retrieves all cookie stores accessible to the extension.
### getCookiePartitionKey [MV3]
```
getCookiePartitionKey(details: chrome.cookies.FrameDetails): Promise
```
Retrieves the partition key for the cookie associated with the given frame (Manifest V3 only).
### removeCookie
```
removeCookie(details: chrome.cookies.CookieDetails): Promise
```
Removes the cookie matching the specified details, returning the details of the removed cookie.
### setCookie
```
setCookie(details: chrome.cookies.SetDetails): Promise
```
Sets a cookie with the given details, returning the created cookie or `null` on failure.
### onCookieChanged
```
onCookieChanged(callback: (changeInfo: chrome.cookies.CookieChangeInfo) => void): () => void
```
Adds a listener that triggers when a cookie change event occurs.
## documentscan
**Documentation:** [Chrome Document Scan API](https://developer.chrome.com/docs/extensions/reference/documentScan)
A promise-based wrapper for the Chrome `documentScan` API.
### Methods
- [cancelDocScanning](#cancelDocScanning)
- [closeDocScanner](#closeDocScanner)
- [getDocScannerOptionGroups](#getDocScannerOptionGroups)
- [getDocScannerList](#getDocScannerList)
- [openDocScanner](#openDocScanner)
- [readDocScanningData](#readDocScanningData)
- [docScanning](#docScanning)
- [setDocScannerOptions](#setDocScannerOptions)
- [startDocScanning](#startDocScanning)
### cancelDocScanning
```
cancelDocScanning(job: string): Promise>
```
Cancels an ongoing document scan job.
### closeDocScanner
```
closeDocScanner(scannerHandle: string): Promise>
```
Closes the document scanner associated with the specified scanner handle.
### getDocScannerOptionGroups
```
getDocScannerOptionGroups(scannerHandle: string): Promise>
```
Retrieves the available option groups for the specified document scanner.
### getDocScannerList
```
getDocScannerList(filter: chrome.documentScan.DeviceFilter): Promise
```
Fetches a list of document scanners matching the given filter criteria.
### openDocScanner
```
openDocScanner(scannerId: string): Promise>
```
Opens a document scanner by its ID, returning a handle for further operations.
### readDocScanningData
```
readDocScanningData(job: string): Promise>
```
Reads a chunk of data from an ongoing scan job.
### docScanning
```
docScanning(options: chrome.documentScan.ScanOptions): Promise
```
Performs a document scan with the specified options and returns the scan results.
### setDocScannerOptions
```
setDocScannerOptions(scannerHandle: string, options: chrome.documentScan.OptionSetting[]): Promise>
```
Sets the scanner options for the given scanner handle.
### startDocScanning
```
startDocScanning(scannerHandle: string, options: chrome.documentScan.StartScanOptions): Promise>
```
Starts a scan operation on an open scanner with the provided settings.
## downloads
**Documentation:** [Chrome Downloads API](https://developer.chrome.com/docs/extensions/reference/downloads)
A promise-based wrapper for the Chrome `downloads` API.
### Methods
- [acceptDownloadDanger](#acceptDownloadDanger)
- [cancelDownload](#cancelDownload)
- [download](#download)
- [eraseDownload](#eraseDownload)
- [getDownloadFileIcon](#getDownloadFileIcon)
- [openDownload](#openDownload)
- [pauseDownload](#pauseDownload)
- [removeDownloadFile](#removeDownloadFile)
- [resumeDownload](#resumeDownload)
- [searchDownloads](#searchDownloads)
- [setDownloadsUiOptions](#setDownloadsUiOptions)
- [showDownloadFolder](#showDownloadFolder)
- [showDownload](#showDownload)
- [findDownload](#findDownload)
- [isDownloadExists](#isDownloadExists)
- [getDownloadState](#getDownloadState)
### Events
- [onDownloadsChanged](#onDownloadsChanged)
- [onDownloadsCreated](#onDownloadsCreated)
- [onDownloadsDeterminingFilename](#onDownloadsDeterminingFilename)
### acceptDownloadDanger
```
acceptDownloadDanger(downloadId: number): Promise
```
Accepts a dangerous download, allowing it to proceed.
### cancelDownload
```
cancelDownload(downloadId: number): Promise
```
Cancels the specified download.
### download
```
download(options: chrome.downloads.DownloadOptions): Promise
```
Initiates a download with the given options, resolving to the download ID. This function automatically uniquifies filenames on conflict and verifies the download's completion, throwing a `BlockDownloadError` if the download is interrupted or requires additional permissions.
### eraseDownload
```
eraseDownload(query: chrome.downloads.DownloadQuery): Promise
```
Removes the download history entries that match the given query, returning the list of erased download IDs.
### getDownloadFileIcon
```
getDownloadFileIcon(downloadId: number, options: chrome.downloads.GetFileIconOptions): Promise
```
Retrieves the icon for the downloaded file.
### openDownload
```
openDownload(downloadId: number): void
```
Opens the downloaded file.
### pauseDownload
```
pauseDownload(downloadId: number): Promise
```
Pauses an active download.
### removeDownloadFile
```
removeDownloadFile(downloadId: number): Promise
```
Deletes the downloaded file from the local disk.
### resumeDownload
```
resumeDownload(downloadId: number): Promise
```
Resumes a paused download.
### searchDownloads
```
searchDownloads(query: chrome.downloads.DownloadQuery): Promise
```
Searches for downloads matching the specified query.
### setDownloadsUiOptions
```
setDownloadsUiOptions(enabled: boolean): Promise
```
Enables or disables the browser's default download UI.
### showDownloadFolder
```
showDownloadFolder(): void
```
Shows the default download folder in the file explorer.
### showDownload
```
showDownload(downloadId: number): Promise
```
Attempts to reveal the specified download in the file explorer, returning `true` if it exists.
### findDownload
```
findDownload(downloadId: number): Promise
```
Retrieves the download item for the given download ID, if it exists.
### isDownloadExists
```
isDownloadExists(downloadId: number): Promise
```
Checks whether a download with the specified ID exists.
### getDownloadState
```
getDownloadState(downloadId?: number): Promise
```
Retrieves the state (`in_progress`, `complete`, or `interrupted`) of the given download.
### onDownloadsChanged
```
onDownloadsChanged(callback: Parameters[0]): () => void
```
Adds a listener triggered when a download's state or properties change.
### onDownloadsCreated
```
onDownloadsCreated(callback: Parameters[0]): () => void
```
Adds a listener triggered when a new download is created.
### onDownloadsDeterminingFilename
```
onDownloadsDeterminingFilename(callback: Parameters[0]): () => void
```
Adds a listener triggered when a download's filename is being determined.
## extension
**Documentation:** [Chrome Extension API](https://developer.chrome.com/docs/extensions/reference/extension)
A promise-based wrapper for the Chrome `extension` API.
### Methods
- [getBackgroundPage](#getBackgroundPage)
- [getViews](#getViews)
- [isAllowedFileSchemeAccess](#isAllowedFileSchemeAccess)
- [isAllowedIncognitoAccess](#isAllowedIncognitoAccess)
- [setUpdateUrlData](#setUpdateUrlData)
### getBackgroundPage
```
getBackgroundPage(): Window | null
```
Returns the `window` object of the extension's background page, or `null` if no background page exists.
### getViews
```
getViews(properties?: chrome.extension.FetchProperties): Window[]
```
Retrieves all active extension views (e.g., background, popup, options), optionally filtered by the specified properties.
### isAllowedFileSchemeAccess
```
isAllowedFileSchemeAccess(): Promise
```
Checks if the extension has permission to access file system URLs (`file://`).
### isAllowedIncognitoAccess
```
isAllowedIncognitoAccess(): Promise
```
Determines whether the extension is allowed to operate in incognito mode.
### setUpdateUrlData
```
setUpdateUrlData(data: string): void
```
Sets the data string to be sent as part of the extension's update check URL.
## fileBrowserHandler
**Documentation:** [Chrome File Browser Handler API](https://developer.chrome.com/docs/extensions/reference/fileBrowserHandler)
A wrapper for the Chrome `fileBrowserHandler` API to manage file browser actions.
### Events
- [onExecute](#onExecute)
### onExecute
```
onExecute(callback: (id: string, details: chrome.fileBrowserHandler.FileBrowserHandlerExecuteDetails) => void): () => void
```
Adds a listener triggered when the user invokes the extension via the file browser. Returns a function to remove the listener.
## history
**Documentation:** [Chrome History API](https://developer.chrome.com/docs/extensions/reference/history)
A promise-based wrapper for the Chrome `history` API to manage browser history.
### Methods
- [addHistoryUrl](#addHistoryUrl)
- [deleteAllHistory](#deleteAllHistory)
- [deleteRangeHistory](#deleteRangeHistory)
- [deleteHistoryUrl](#deleteHistoryUrl)
- [getHistoryVisits](#getHistoryVisits)
- [searchHistory](#searchHistory)
### Events
- [onHistoryVisited](#onHistoryVisited)
- [onHistoryVisitRemoved](#onHistoryVisitRemoved)
### addHistoryUrl
```
addHistoryUrl(url: string): Promise
```
Adds the specified URL to the browser history.
### deleteAllHistory
```
deleteAllHistory(): Promise
```
Deletes all entries from the browser history.
### deleteRangeHistory
```
deleteRangeHistory(range: chrome.history.Range): Promise
```
Removes all history entries within the specified time range.
### deleteHistoryUrl
```
deleteHistoryUrl(details: chrome.history.Url): Promise
```
Deletes all occurrences of the given URL from the history.
### getHistoryVisits
```
getHistoryVisits(url: string): Promise
```
Retrieves the visit history for the specified URL.
### searchHistory
```
searchHistory(query: chrome.history.HistoryQuery): Promise
```
Searches the browser history with the given query, returning matching history items.
### onHistoryVisited
```
onHistoryVisited(callback: (result: chrome.history.HistoryItem) => void): () => void
```
Adds a listener triggered when the browser records a page visit.
### onHistoryVisitRemoved
```
onHistoryVisitRemoved(callback: (removed: chrome.history.RemoveInfo) => void): () => void
```
Adds a listener triggered when URLs are removed from the history, providing details of the removal.
## i18n
**Documentation:** [Chrome i18n API](https://developer.chrome.com/docs/extensions/reference/i18n)
A promise-based wrapper for the Chrome `i18n` API to manage localization.
### Methods
- [detectI18Language](#detectI18Language)
- [getI18nAcceptLanguages](#getI18nAcceptLanguages)
- [getI18nUILanguage](#getI18nUILanguage)
- [getI18nMessage](#getI18nMessage)
- [getDefaultLanguage](#getDefaultLanguage)
### detectI18Language
```
detectI18Language(text: string): Promise
```
Detects the primary language of the provided text.
### getI18nAcceptLanguages
```
getI18nAcceptLanguages(): Promise
```
Retrieves the user's preferred accept languages list.
### getI18nUILanguage
```
getI18nUILanguage(): string | undefined
```
Returns the browser's UI language code.
### getI18nMessage
```
getI18nMessage(key: string): string | undefined
```
Retrieves the localized message for the specified key.
### getDefaultLanguage
```
getDefaultLanguage(): string | undefined
```
Extracts the default locale as declared in the extension manifest.
## idle
**Documentation:** [Chrome Idle API](https://developer.chrome.com/docs/extensions/reference/idle)
A promise-based wrapper for the Chrome `idle` API to monitor user idle state.
### Methods
- [getIdleAutoLockDelay](#getIdleAutoLockDelay)
- [queryIdleState](#queryIdleState)
- [setIdleDetectionInterval](#setIdleDetectionInterval)
### Events
- [onIdleStateChanged](#onIdleStateChanged)
### getIdleAutoLockDelay
```
getIdleAutoLockDelay(): Promise
```
Retrieves the number of seconds before the system auto-locks due to inactivity.
### queryIdleState
```
queryIdleState(detectionIntervalInSeconds: number): Promise
```
Queries the user's idle state within the specified detection interval.
### setIdleDetectionInterval
```
setIdleDetectionInterval(intervalInSeconds: number): void
```
Sets the interval, in seconds, used to detect idle state changes.
### onIdleStateChanged
```
onIdleStateChanged(callback: (newState: chrome.idle.IdleState) => void): () => void
```
Adds a listener that fires when the user's idle state changes, returning a function to remove the listener.
## management
**Documentation:** [Chrome Management API](https://developer.chrome.com/docs/extensions/reference/management)
A promise-based wrapper for the Chrome `management` API to manage extensions and apps.
### Methods
- [createAppShortcut](#createAppShortcut)
- [generateAppForLink](#generateAppForLink)
- [getExtensionInfo](#getExtensionInfo)
- [getAllExtensionInfo](#getAllExtensionInfo)
- [getPermissionWarningsById](#getPermissionWarningsById)
- [getPermissionWarningsByManifest](#getPermissionWarningsByManifest)
- [getCurrentExtension](#getCurrentExtension)
- [launchExtensionApp](#launchExtensionApp)
- [setExtensionEnabled](#setExtensionEnabled)
- [setExtensionLaunchType](#setExtensionLaunchType)
- [uninstallExtension](#uninstallExtension)
- [uninstallCurrentExtension](#uninstallCurrentExtension)
### Events
- [onExtensionDisabled](#onExtensionDisabled)
- [onExtensionEnabled](#onExtensionEnabled)
- [onExtensionInstalled](#onExtensionInstalled)
- [onExtensionUninstalled](#onExtensionUninstalled)
### createAppShortcut
```
createAppShortcut(id: string): Promise
```
Creates a desktop shortcut for the specified app ID.
### generateAppForLink
```
generateAppForLink(url: string, title: string): Promise
```
Generates a Chrome app for the given URL and title, returning its extension info.
### getExtensionInfo
```
getExtensionInfo(id: string): Promise
```
Retrieves information about the extension or app with the specified ID.
### getAllExtensionInfo
```
getAllExtensionInfo(): Promise
```
Retrieves information about all installed extensions and apps.
### getPermissionWarningsById
```
getPermissionWarningsById(id: string): Promise
```
Gets permission warning messages for the specified extension ID.
### getPermissionWarningsByManifest
```
getPermissionWarningsByManifest(manifestStr: string): Promise
```
Gets permission warning messages for the given manifest string.
### getCurrentExtension
```
getCurrentExtension(): Promise
```
Retrieves information about the current extension.
### launchExtensionApp
```
launchExtensionApp(id: string): Promise
```
Launches the specified extension app by ID.
### setExtensionEnabled
```
setExtensionEnabled(id: string, enabled: boolean): Promise
```
Enables or disables the specified extension or app.
### setExtensionLaunchType
```
setExtensionLaunchType(id: string, launchType: string): Promise
```
Sets the launch type (e.g., regular, pinned) for the specified extension.
### uninstallExtension
```
uninstallExtension(id: string, showConfirmDialog?: boolean): Promise
```
Uninstalls the extension with the given ID, optionally showing a confirmation dialog.
### uninstallCurrentExtension
```
uninstallCurrentExtension(showConfirmDialog?: boolean): Promise
```
Uninstalls the current extension, optionally showing a confirmation dialog.
### onExtensionDisabled
```
onExtensionDisabled(callback: (info: chrome.management.ExtensionInfo) => void): () => void
```
Fires when an extension or app is disabled.
### onExtensionEnabled
```
onExtensionEnabled(callback: (info: chrome.management.ExtensionInfo) => void): () => void
```
Fires when an extension or app is enabled.
### onExtensionInstalled
```
onExtensionInstalled(callback: (info: chrome.management.ExtensionInfo) => void): () => void
```
Fires when an extension or app is installed.
### onExtensionUninstalled
```
onExtensionUninstalled(callback: (extensionId: string) => void): () => void
```
Fires when an extension or app is uninstalled, passing its ID.
## notifications
**Documentation:** [Chrome Notifications API](https://developer.chrome.com/docs/extensions/reference/notifications)
A promise-based wrapper for the Chrome `notifications` API to create and manage desktop notifications.
### Methods
- [clearNotification](#clearNotification)
- [createNotification](#createNotification)
- [getAllNotification](#getAllNotification)
- [getNotificationPermissionLevel](#getNotificationPermissionLevel)
- [updateNotification](#updateNotification)
- [isSupportNotifications](#isSupportNotifications)
- [clearAllNotification](#clearAllNotification)
### Events
- [onNotificationsButtonClicked](#onNotificationsButtonClicked)
- [onNotificationsClicked](#onNotificationsClicked)
- [onNotificationsClosed](#onNotificationsClosed)
- [onNotificationsPermissionLevelChanged](#onNotificationsPermissionLevelChanged)
### clearNotification
```
clearNotification(notificationId: string): Promise
```
Clears the notification with the specified ID, resolving to `true` if the notification existed and was cleared.
### createNotification
```
createNotification(options: chrome.notifications.NotificationOptions, notificationId?: string): Promise
```
Creates a notification with the given options and optional ID, returning the notification ID.
### getAllNotification
```
getAllNotification(): Promise<{ [notificationId: string]: chrome.notifications.NotificationOptions }>
```
Retrieves all notifications currently displayed, returned as a map of notification IDs to their options.
### getNotificationPermissionLevel
```
getNotificationPermissionLevel(): Promise
```
Gets the current permission level for notifications.
### updateNotification
```
updateNotification(options: chrome.notifications.NotificationOptions, notificationId: string): Promise
```
Updates an existing notification with new options, resolving to `true` if the notification was updated.
### isSupportNotifications
```
isSupportNotifications(): boolean
```
Checks if the Notifications API is supported in the current browser.
### clearAllNotification
```
clearAllNotification(): Promise
```
Clears all currently displayed notifications.
### onNotificationsButtonClicked
```
onNotificationsButtonClicked(callback: (notificationId: string, buttonIndex: number) => void): () => void
```
Adds a listener for when a button on a notification is clicked, returning a function to remove the listener.
### onNotificationsClicked
```
onNotificationsClicked(callback: (notificationId: string) => void): () => void
```
Adds a listener for when a notification itself is clicked.
### onNotificationsClosed
```
onNotificationsClosed(callback: (notificationId: string, byUser: boolean) => void): () => void
```
Adds a listener for when a notification is closed, including whether it was closed by the user.
### onNotificationsPermissionLevelChanged
```
onNotificationsPermissionLevelChanged(callback: (level: string) => void): () => void
```
Adds a listener for when notification permission level changes.
## offscreen
**Documentation:** [Chrome Offscreen API](https://developer.chrome.com/docs/extensions/reference/offscreen) [MV3]
A promise-based wrapper for the Chrome `offscreen` API to create and manage offscreen documents.
### Methods
- [createOffscreen](#createOffscreen)
- [closeOffscreen](#closeOffscreen)
- [hasOffscreen](#hasOffscreen)
### createOffscreen
```
createOffscreen(parameters: chrome.offscreen.CreateParameters): Promise
```
Creates an offscreen document with the specified parameters.
### closeOffscreen
```
closeOffscreen(): Promise
```
Closes the existing offscreen document.
### hasOffscreen
```
hasOffscreen(): Promise
```
Checks whether an offscreen document is currently open.
## permissions
**Documentation:** [Chrome Permissions API](https://developer.chrome.com/docs/extensions/reference/permissions)
A promise-based wrapper for the Chrome `permissions` API to request and manage extension permissions.
### Methods
- [containsPermissions](#containsPermissions)
- [getAllPermissions](#getAllPermissions)
- [requestPermissions](#requestPermissions)
- [removePermissions](#removePermissions)
- [addHostAccessRequest](#addHostAccessRequest) [MV3]
- [removeHostAccessRequest](#removeHostAccessRequest) [MV3]
### Events
- [onPermissionsAdded](#onPermissionsAdded)
- [onPermissionsRemoved](#onPermissionsRemoved)
### containsPermissions
```
containsPermissions(permissions: chrome.permissions.Permissions): Promise
```
Checks whether the extension has the specified permissions.
### getAllPermissions
```
getAllPermissions(): Promise
```
Retrieves all granted permissions.
### requestPermissions
```
requestPermissions(permissions: chrome.permissions.Permissions): Promise
```
Prompts the user to grant additional permissions.
### removePermissions
```
removePermissions(permissions: chrome.permissions.Permissions): Promise
```
Removes the specified permissions if granted.
### addHostAccessRequest [MV3]
```
addHostAccessRequest(request?: chrome.permissions.AddHostAccessRequest): Promise
```
Requests additional host access at runtime (Manifest V3 only).
### removeHostAccessRequest [MV3]
```
removeHostAccessRequest(request?: chrome.permissions.RemoveHostAccessRequest): Promise
```
Clears a previously requested host access (Manifest V3 only).
### onPermissionsAdded
```
onPermissionsAdded(callback: (permissions: chrome.permissions.Permissions) => void): () => void
```
Fires when new permissions are granted.
### onPermissionsRemoved
```
onPermissionsRemoved(callback: (permissions: chrome.permissions.Permissions) => void): () => void
```
Fires when permissions are removed.
## runtime
**Documentation:** [Chrome Runtime API](https://developer.chrome.com/docs/extensions/reference/runtime)
A wrapper for the Chrome `runtime` API, including messaging, updates, and lifecycle events.
### Methods
- [connect](#connect)
- [connectNative](#connectNative)
- [getContexts](#getContexts) [MV3]
- [getManifest](#getManifest)
- [getId](#getId)
- [getManifestVersion](#getManifestVersion)
- [isManifestVersion3](#isManifestVersion3)
- [getPackageDirectoryEntry](#getPackageDirectoryEntry)
- [getPlatformInfo](#getPlatformInfo)
- [getBrowserInfo](#getBrowserInfo) [Firefox]
- [getUrl](#getUrl)
- [openOptionsPage](#openOptionsPage)
- [reload](#reload)
- [requestUpdateCheck](#requestUpdateCheck)
- [restart](#restart) [MV3]
- [restartAfterDelay](#restartAfterDelay) [MV3]
- [sendMessage](#sendMessage)
- [setUninstallUrl](#setUninstallUrl)
### Events
- [onConnect](#onConnect)
- [onConnectExternal](#onConnectExternal)
- [onInstalled](#onInstalled)
- [onMessage](#onMessage)
- [onMessageExternal](#onMessageExternal)
- [onRestartRequired](#onRestartRequired)
- [onStartup](#onStartup)
- [onSuspend](#onSuspend)
- [onSuspendCanceled](#onSuspendCanceled)
- [onUpdateAvailable](#onUpdateAvailable)
- [onUserScriptConnect](#onUserScriptConnect)
- [onUserScriptMessage](#onUserScriptMessage)
### connect
```
connect(extensionId: string, connectInfo?: object): chrome.runtime.Port
```
Opens a long-lived connection to another extension or app.
### connectNative
```
connectNative(application: string): chrome.runtime.Port
```
Connects to a native application.
### getContexts [MV3]
```
getContexts(filter: chrome.runtime.ContextFilter): Promise
```
Retrieves extension contexts matching the filter (Manifest V3 only).
### getManifest
```
getManifest(): chrome.runtime.Manifest
```
Returns the extension's manifest details.
### getId
```
getId(): string
```
Returns the extension ID.
### getManifestVersion
```
getManifestVersion(): 2 | 3
```
Retrieves the manifest version (2 or 3).
### isManifestVersion3
```
isManifestVersion3(): boolean
```
Checks if the extension uses Manifest V3.
### getPackageDirectoryEntry
```
getPackageDirectoryEntry(): Promise
```
Gets the root directory of the extension package.
### getPlatformInfo
```
getPlatformInfo(): Promise
```
Returns information about the current platform.
### getBrowserInfo
```
getBrowserInfo(): Promise<{ name: string; vendor: string; version: string; buildID: string;}>
```
Returns information about browser. Only for Firefox
### getUrl
```
getUrl(path: string): string
```
Converts a relative path to an absolute extension URL.
### openOptionsPage
```
openOptionsPage(): Promise
```
Opens the extension's options page.
### reload
```
reload(): void
```
Reloads the extension.
### requestUpdateCheck
```
requestUpdateCheck(): Promise<{status: chrome.runtime.RequestUpdateCheckStatus; details?: chrome.runtime.UpdateCheckDetails;}>
```
Checks for an update and returns status and details.
### restart [MV3]
```
restart(): void
```
Restarts the browser to apply updates (Manifest V3 only).
### restartAfterDelay [MV3]
```
restartAfterDelay(seconds: number): Promise
```
Schedules a browser restart after the given delay in seconds (Manifest V3 only).
### sendMessage
```
sendMessage(message: M): Promise
```
Sends a single message to the extension or app and awaits a response.
### setUninstallUrl
```
setUninstallUrl(url: string): Promise
```
Sets a URL to be opened upon uninstallation.
### onConnect
```
onConnect(callback: (port: chrome.runtime.Port) => void): () => void
```
Fires when a connection is made by another extension or content script.
### onConnectExternal
```
onConnectExternal(callback: (port: chrome.runtime.Port) => void): () => void
```
Fires when an external extension connects.
### onInstalled
```
onInstalled(callback: chrome.runtime.InstalledDetails): () => void
```
Fires when the extension is installed or updated.
### onMessage
```
onMessage(callback: (message: any, sender: chrome.runtime.MessageSender) => void): () => void
```
Fires when a message is received.
### onMessageExternal
```
onMessageExternal(callback: (message: any, sender: chrome.runtime.MessageSender) => void): () => void
```
Fires when an external extension sends a message.
### onRestartRequired
```
onRestartRequired(callback: (reason: chrome.runtime.OnRestartRequiredReason) => void): () => void
```
Fires when the extension requires a browser restart.
### onStartup
```
onStartup(callback: () => void): () => void
```
Fires when the browser starts up.
### onSuspend
```
onSuspend(callback: () => void): () => void
```
Fires when the event page is about to be unloaded.
### onSuspendCanceled
```
onSuspendCanceled(callback: () => void): () => void
```
Fires when a suspend is canceled.
### onUpdateAvailable
```
onUpdateAvailable(callback: chrome.runtime.UpdateAvailableDetails): () => void
```
Fires when an update is available.
### onUserScriptConnect
```
onUserScriptConnect(callback: (port: chrome.runtime.Port) => void): () => void
```
Fires when a user script establishes a connection.
### onUserScriptMessage
```
onUserScriptMessage(callback: (message: any, sender: chrome.runtime.MessageSender) => void): () => void
```
Fires when a message arrives from a user script.
## scripting
**Documentation:** [Chrome Scripting API](https://developer.chrome.com/docs/extensions/reference/scripting)
A promise-based wrapper for the Chrome `scripting` API to inject scripts and styles, and manage content scripts.
### Methods
- [executeScript](#executeScript)
- [getRegisteredContentScripts](#getRegisteredContentScripts)
- [insertCss](#insertCss)
- [registerContentScripts](#registerContentScripts)
- [removeCss](#removeCss)
- [unregisterContentScripts](#unregisterContentScripts)
- [updateContentScripts](#updateContentScripts)
- [isAvailableScripting](#isAvailableScripting)
### executeScript
```
executeScript(injection: chrome.scripting.ScriptInjection): Promise>[]>
```
Executes a script in the specified target and returns the injection results.
### getRegisteredContentScripts
```
getRegisteredContentScripts(filter?: chrome.scripting.ContentScriptFilter): Promise
```
Retrieves registered content scripts, optionally filtered by criteria.
### insertCss
```
insertCss(injection: chrome.scripting.CSSInjection): Promise
```
Injects CSS into specified target pages.
### registerContentScripts
```
registerContentScripts(scripts: chrome.scripting.RegisteredContentScript[]): Promise
```
Registers one or more content scripts programmatically.
### removeCss
```
removeCss(injection: chrome.scripting.CSSInjection): Promise
```
Removes previously injected CSS from specified target pages.
### unregisterContentScripts
```
unregisterContentScripts(filter?: chrome.scripting.ContentScriptFilter): Promise
```
Unregisters content scripts matching the given filter.
### updateContentScripts
```
updateContentScripts(scripts: chrome.scripting.RegisteredContentScript[]): Promise
```
Updates existing content scripts with new definitions.
### isAvailableScripting
```
isAvailableScripting(): boolean
```
Checks if the Scripting API is available in the current browser.
## sidebar
**Documentation:**
- [Chrome Side Panel API](https://developer.chrome.com/docs/extensions/reference/sidePanel) [MV3]
- [Opera Sidebar Action API](https://help.opera.com/en/extensions/sidebar-action-api/)
- [Firefox Sidebar Action API](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/sidebarAction)
A promise-based wrapper for the Chrome `sidePanel` API and the `sidebarAction` API in Firefox/Opera. Provides methods to get and set side panel options, behavior, path, title, and badge.
### Methods
- [getSidebarOptions](#getSidebarOptions)
- [getSidebarBehavior](#getSidebarBehavior)
- [canOpenSidebar](#canOpenSidebar)
- [openSidebar](#openSidebar)
- [setSidebarOptions](#setSidebarOptions)
- [setSidebarBehavior](#setSidebarBehavior)
- [setSidebarPath](#setSidebarPath)
- [getSidebarPath](#getSidebarPath)
- [setSidebarTitle](#setSidebarTitle) [Opera]
- [setSidebarBadgeText](#setSidebarBadgeText) [Opera]
- [setSidebarBadgeTextColor](#setSidebarBadgeTextColor) [Opera]
- [setSidebarBadgeBgColor](#getSidebarBadgeBgColor) [Opera]
- [getSidebarTitle](#getSidebarTitle) [Opera]
- [getSidebarBadgeText](#getSidebarBadgeText) [Opera]
- [getSidebarBadgeTextColor](#getSidebarBadgeTextColor) [Opera]
- [getSidebarBadgeBgColor](#getSidebarBadgeBgColor) [Opera]
### getSidebarOptions
```
getSidebarOptions(tabId?: number): Promise
```
Retrieves the panel options (such as `path` and other settings) for the specified tab's side panel. Throws an error if the Side Panel API is not supported. [MV3]
### getSidebarBehavior
```
getSidebarBehavior(): Promise
```
Fetches the current behavior settings of the side panel (e.g., default open state). Throws an error if the API is not supported. [MV3]
### canOpenSidebar
```
canOpenSidebar(): boolean
```
Returns `true` if the side panel (Chrome MV3) or sidebar action (Firefox/Opera) APIs are available, indicating the extension can programmatically open the sidebar.
### openSidebar
```
openSidebar(options: chrome.sidePanel.OpenOptions): Promise
```
Opens the side panel with the specified options in Chrome (Manifest V3). Falls back to `browser.sidebarAction.open()` in Firefox. Logs a warning if unsupported.
### setSidebarOptions
```
setSidebarOptions(options?: chrome.sidePanel.PanelOptions): Promise
```
Sets new panel options (e.g., `path`) for the side panel in Chrome (Manifest V3). Logs a warning if unsupported. [MV3]
### setSidebarBehavior
```
setSidebarBehavior(behavior?: chrome.sidePanel.PanelBehavior): Promise
```
Updates the panel behavior settings in Chrome (Manifest V3). Logs a warning if unsupported. [MV3]
### setSidebarPath
```
setSidebarPath(path: string, tabId?: number): Promise
```
Sets the URL path of the sidebar panel. Uses Chrome `setOptions` in MV3 or `sidebarAction.setPanel()` in Firefox/Opera. Throws if unsupported.
### getSidebarPath
```
getSidebarPath(tabId?: number): Promise
```
Retrieves the current sidebar panel path from Chrome MV3 or parses it from the `sidebarAction.getPanel()` result in Firefox/Opera. Throws if unsupported.
### setSidebarTitle
```
setSidebarTitle(title: string | number, tabId?: number): Promise
```
Sets the sidebar title in Opera via `opr.sidebarAction.setTitle()`. Logs a warning if unsupported. [Opera]
### setSidebarBadgeText
```
setSidebarBadgeText(text: string | number, tabId?: number): Promise
```
Sets the sidebar badge text in Opera via `opr.sidebarAction.setBadgeText()`. Logs a warning if unsupported. [Opera]
### setSidebarBadgeTextColor
```
setSidebarBadgeTextColor(color: string | number[] | chrome.action.ColorArray, tabId?: number): Promise
```
Sets the sidebar badge text color in Opera via `opr.sidebarAction.setBadgeTextColor()`. Logs a warning if unsupported. [Opera]
### setSidebarBadgeBgColor
```
setSidebarBadgeBgColor(color: string | number[] | chrome.action.ColorArray, tabId?: number): Promise
```
Sets the sidebar badge background color in Opera via `opr.sidebarAction.setBadgeBackgroundColor()`. Logs a warning if unsupported. [Opera]
### getSidebarTitle
```
getSidebarTitle(tabId?: number): Promise
```
Retrieves the sidebar title in Opera via `opr.sidebarAction.getTitle()`. Throws an error if unsupported. [Opera]
### getSidebarBadgeText
```
getSidebarBadgeText(tabId?: number): Promise
```
Retrieves the sidebar badge text in Opera via `opr.sidebarAction.getBadgeText()`. Throws an error if unsupported. [Opera]
### getSidebarBadgeTextColor
```
getSidebarBadgeTextColor(tabId?: number): Promise
```
Retrieves the sidebar badge text color in Opera via `opr.sidebarAction.getBadgeTextColor()`. Throws an error if unsupported. [Opera]
### getSidebarBadgeBgColor
```
getSidebarBadgeBgColor(tabId?: number): Promise
```
Retrieves the sidebar badge background color in Opera via `opr.sidebarAction.getBadgeBackgroundColor()`. Throws an error if unsupported. [Opera]
## tabCapture
**Documentation:** [Chrome Tab Capture API](https://developer.chrome.com/docs/extensions/reference/tabCapture)
A promise-based wrapper for the Chrome `tabCapture` API to capture and retrieve tab media streams.
### Methods
- [createTabCapture](#createTabCapture)
- [getCapturedTabs](#getCapturedTabs)
- [getCaptureMediaStreamId](#getCaptureMediaStreamId)
### Events
- [onCaptureStatusChanged](#onCaptureStatusChanged)
### createTabCapture
```
createTabCapture(options: chrome.tabCapture.CaptureOptions): Promise
```
Captures the visible media stream of a tab based on the specified options. Resolves with the `MediaStream` if successful, or `null` otherwise. Rejects if an error occurs.
### getCapturedTabs
```
getCapturedTabs(): Promise
```
Retrieves details of all active tab capture sessions. Resolves with an array of `CaptureInfo` objects.
### getCaptureMediaStreamId
```
getCaptureMediaStreamId(options: chrome.tabCapture.GetMediaStreamOptions): Promise
```
Generates a media stream ID for capturing a tab via `navigator.mediaDevices.getUserMedia`. Resolves with the stream ID.
### onCaptureStatusChanged
```
onCaptureStatusChanged(callback: (info: chrome.tabCapture.CaptureInfo) => void): () => void
```
Adds a listener for tab capture status changes (started, stopped, source changed). Returns a function to remove the listener.
## tabs
**Documentation:** [Chrome Tabs API](https://developer.chrome.com/docs/extensions/reference/tabs)
A promise-based wrapper for the Chrome `tabs` API, providing core tab operations, messaging, and utility methods.
### Methods
- [captureVisibleTab](#captureVisibleTab)
- [connectTab](#connectTab)
- [createTab](#createTab)
- [detectTabLanguage](#detectTabLanguage)
- [discardTab](#discardTab)
- [duplicateTab](#duplicateTab)
- [getTab](#getTab)
- [getCurrentTab](#getCurrentTab)
- [getTabZoom](#getTabZoom)
- [getTabZoomSettings](#getTabZoomSettings)
- [goTabBack](#goTabBack)
- [goTabForward](#goTabForward)
- [groupTabs](#groupTabs)
- [highlightTab](#highlightTab)
- [moveTab](#moveTab)
- [moveTabs](#moveTabs)
- [queryTabs](#queryTabs)
- [reloadTab](#reloadTab)
- [removeTab](#removeTab)
- [sendTabMessage](#sendTabMessage)
- [setTabZoom](#setTabZoom)
- [setTabZoomSettings](#setTabZoomSettings)
- [ungroupTab](#ungroupTab)
- [updateTab](#updateTab)
- [executeScriptTab](#executeScriptTab) [MV2]
- [insertCssTab](#insertCssTab) [MV2]
- [removeCssTab](#removeCssTab) [MV2]
- [getTabUrl](#getTabUrl)
- [getActiveTab](#getActiveTab)
- [queryTabIds](#queryTabIds)
- [findTab](#findTab)
- [findTabById](#findTabById)
- [updateTabAsSelected](#updateTabAsSelected)
- [updateTabAsActive](#updateTabAsActive)
- [openOrCreateTab](#openOrCreateTab)
### Events
- [onTabActivated](#onTabActivated)
- [onTabAttached](#onTabAttached)
- [onTabCreated](#onTabCreated)
- [onTabDetached](#onTabDetached)
- [onTabHighlighted](#onTabHighlighted)
- [onTabMoved](#onTabMoved)
- [onTabRemoved](#onTabRemoved)
- [onTabReplaced](#onTabReplaced)
- [onTabUpdated](#onTabUpdated)
- [onTabZoomChange](#onTabZoomChange)
### captureVisibleTab
```
captureVisibleTab(windowId: number, options: chrome.extensionTypes.ImageDetails): Promise
```
Captures the visible area of the specified window as an image and returns a data URL string. Resolves with the image `data:image/png;base64,...`.
### connectTab
```
connectTab(tabId: number, connectInfo?: chrome.tabs.ConnectInfo): chrome.runtime.Port
```
Creates a long-lived connection to the specified tab for message passing. Returns a `Port` object.
### createTab
```
createTab(properties: chrome.tabs.CreateProperties): Promise
```
Creates a new tab with the given properties. Resolves with the created `Tab` object.
### detectTabLanguage
```
detectTabLanguage(tabId: number): Promise
```
Detects the language of the specified tab's content. Resolves with a language code (e.g., `"en"` or `"und"`).
### discardTab
```
discardTab(tabId: number): Promise
```
Discards the specified tab to free up system resources. Resolves with the updated `Tab` object.
### duplicateTab
```
duplicateTab(tabId: number): Promise
```
Duplicates the specified tab, opening a copy. Resolves with the new `Tab`, or `undefined` if duplication fails.
### getTab
```
getTab(tabId: number): Promise
```
Retrieves information about the specified tab. Resolves with the `Tab` object.
### getCurrentTab
```
getCurrentTab(): Promise
```
Retrieves the tab in which the script is running (e.g., popup or content script). Resolves with the `Tab` or `undefined` if not called in a tab context.
### getTabZoom
```
getTabZoom(tabId: number): Promise
```
Gets the zoom factor of the specified tab. Resolves with the zoom level (e.g., `1.0`).
### getTabZoomSettings
```
getTabZoomSettings(tabId: number): Promise
```
Retrieves the zoom settings of the specified tab. Resolves with a `ZoomSettings` object.
### goTabBack
```
goTabBack(tabId: number): Promise
```
Navigates the specified tab one step backward in its history.
### goTabForward
```
goTabForward(tabId: number): Promise
```
Navigates the specified tab one step forward in its history.
### groupTabs
```
groupTabs(options: chrome.tabs.GroupOptions): Promise
```
Groups one or more tabs into a single tab group. Resolves with the group ID.
### highlightTab
```
highlightTab(highlightInfo: chrome.tabs.HighlightInfo): Promise
```
Highlights (selects) the specified tabs within a window. Resolves with the updated `Window`.
### moveTab
```
moveTab(tabId: number, moveProperties: chrome.tabs.MoveProperties): Promise
```
Moves a tab to a new index or window. Resolves with the moved `Tab`.
### moveTabs
```
moveTabs(tabIds: number[], moveProperties: chrome.tabs.MoveProperties): Promise
```
Moves multiple tabs to new positions. Resolves with an array of updated `Tab` objects.
### queryTabs
```
queryTabs(queryInfo?: chrome.tabs.QueryInfo): Promise
```
Retrieves all tabs that match the given query filters. Resolves with an array of `Tab` objects.
### reloadTab
```
reloadTab(tabId: number, bypassCache?: boolean): Promise
```
Reloads the specified tab. If `bypassCache` is `true`, forces resource revalidation.
### removeTab
```
removeTab(tabId: number): Promise
```
Closes the specified tab.
### sendTabMessage
```
sendTabMessage(tabId: number, message: M, options?: chrome.tabs.MessageSendOptions): Promise
```
Sends a one-time message to the content script in the specified tab. Resolves with the response.
### setTabZoom
```
setTabZoom(tabId: number, zoomFactor: number): Promise
```
Sets the zoom factor for the specified tab.
### setTabZoomSettings
```
setTabZoomSettings(tabId: number, zoomSettings: chrome.tabs.ZoomSettings): Promise
```
Updates the zoom settings for the specified tab.
### ungroupTab
```
ungroupTab(tabIds: number | number[]): Promise
```
Removes one or more tabs from their group.
### updateTab
```
updateTab(tabId: number, updateProperties: chrome.tabs.UpdateProperties): Promise
```
Updates properties of the specified tab (e.g., URL, active state). Resolves with the updated `Tab` or `undefined`.
### executeScriptTab
```
executeScriptTab(tabId: number, details: chrome.extensionTypes.InjectDetails): Promise
```
Injects JavaScript into the specified tab and returns execution results. (Manifest V2 only).
### insertCssTab
```
insertCssTab(tabId: number, details: chrome.extensionTypes.InjectDetails): Promise
```
Injects CSS into a page. (Manifest V2 only).
### removeCssTab
```
removeCssTab(tabId: number, details: chrome.extensionTypes.InjectDetails): Promise
```
Removes from a page CSS that was previously injected by a call to `insertCssTab`. (Manifest V2 only).
### getTabUrl
```
getTabUrl(tabId: number): Promise
```
Retrieves the URL of the specified tab. Rejects if the tab does not exist or has no URL.
### getActiveTab
```
getActiveTab(): Promise
```
Gets the currently active tab in the current window. Rejects if no active tab is found.
### queryTabIds
```
queryTabIds(queryInfo?: chrome.tabs.QueryInfo): Promise
```
Retrieves IDs of tabs matching the given query.
### findTab
```
findTab(queryInfo?: chrome.tabs.QueryInfo): Promise
```
Finds the first tab matching the query. Resolves with the `Tab` or `undefined`.
### findTabById
```
findTabById(tabId: number): Promise
```
Finds a tab by its ID, or resolves with `undefined` if not found.
### updateTabAsSelected
```
updateTabAsSelected(tabId: number): Promise
```
Highlights the specified tab, making it selected.
### updateTabAsActive
```
updateTabAsActive(tabId: number): Promise
```
Sets the specified tab as active.
### openOrCreateTab
```
openOrCreateTab(tab: chrome.tabs.Tab): Promise
```
If a tab with the same URL exists, activates it; otherwise, creates a new tab.
### onTabActivated
```
onTabActivated(callback: (activeInfo: chrome.tabs.TabActiveInfo) => void): () => void
```
Fires when the active tab in a window changes. Returns a function to remove the listener.
### onTabAttached
```
onTabAttached(callback: (info: chrome.tabs.TabAttachedInfo) => void): () => void
```
Fires when a tab is attached to a window. Returns a function to remove the listener.
### onTabCreated
```
onTabCreated(callback: (tab: chrome.tabs.Tab) => void): () => void
```
Fires when a new tab is created. Returns a function to remove the listener.
### onTabDetached
```
onTabDetached(callback: (info: chrome.tabs.TabDetachedInfo) => void): () => void
```
Fires when a tab is detached from a window. Returns a function to remove the listener.
### onTabHighlighted
```
onTabHighlighted(callback: (highlightInfo: chrome.tabs.TabHighlightInfo) => void): () => void
```
Fires when the highlighted status of tabs in a window changes. Returns a function to remove the listener.
### onTabMoved
```
onTabMoved(callback: (moveInfo: chrome.tabs.TabMoveInfo) => void): () => void
```
Fires when a tab is moved within a window. Returns a function to remove the listener.
### onTabRemoved
```
onTabRemoved(callback: (tabId: number, removeInfo: chrome.tabs.TabRemoveInfo) => void): () => void
```
Fires when a tab is closed. Returns a function to remove the listener.
### onTabReplaced
```
onTabReplaced(callback: (addedTabId: number, removedTabId: number) => void): () => void
```
Fires when one tab replaces another. Returns a function to remove the listener.
### onTabUpdated
```
onTabUpdated(callback: (tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab) => void): () => void
```
Fires when a tab is updated (e.g., URL change, status). Returns a function to remove the listener.
### onTabZoomChange
```
onTabZoomChange(callback: (zoomChangeInfo: chrome.tabs.ZoomChangeInfo) => void): () => void
```
Fires when the zoom level of a tab changes. Returns a function to remove the listener.
- [onTabActivated](#onTabActivated)
- [onTabAttached](#onTabAttached)
- [onTabCreated](#onTabCreated)
- [onTabDetached](#onTabDetached)
- [onTabHighlighted](#onTabHighlighted)
- [onTabMoved](#onTabMoved)
- [onTabRemoved](#onTabRemoved)
- [onTabReplaced](#onTabReplaced)
- [onTabUpdated](#onTabUpdated)
- [onTabZoomChange](#onTabZoomChange)
## userScripts
**Documentation:** [Chrome User Scripts API](https://developer.chrome.com/docs/extensions/reference/userScripts)
A promise-based wrapper for the Chrome `userScripts` API, providing methods to configure worlds, register, retrieve, update, and unregister user scripts.
### Methods
- [configureUserScriptsWorld(properties)](#configureUserScriptsWorld)
- [getUserScripts(ids)](#getUserScripts)
- [getUserScriptsWorldConfigs()](#getUserScriptsWorldConfigs)
- [registerUserScripts(scripts)](#registerUserScripts)
- [resetUserScriptsWorldConfigs(worldId)](#resetUserScriptsWorldConfigs)
- [unregisterUserScripts(ids)](#unregisterUserScripts)
- [updateUserScripts(scripts)](#updateUserScripts)
### configureUserScriptsWorld
```
configureUserScriptsWorld(properties?: chrome.userScripts.WorldProperties): Promise
```
Configures the execution context for user scripts by setting world properties. Must be called before registering or executing scripts.
### getUserScripts
```
getUserScripts(ids?: string[]): Promise
```
Retrieves registered user scripts, optionally filtered by script IDs.
### getUserScriptsWorldConfigs
```
getUserScriptsWorldConfigs(): Promise
```
Returns configurations for all script execution worlds.
### registerUserScripts
```
registerUserScripts(scripts: chrome.userScripts.RegisteredUserScript[]): Promise
```
Registers one or more user scripts with the browser.
### resetUserScriptsWorldConfigs
```
resetUserScriptsWorldConfigs(worldId: string): Promise
```
Resets the configuration of a specific world back to default settings.
### unregisterUserScripts
```
unregisterUserScripts(ids?: string[]): Promise
```
Unregisters user scripts by ID. If no IDs provided, all scripts are unregistered.
### updateUserScripts
```
updateUserScripts(scripts: chrome.userScripts.RegisteredUserScript[]): Promise
```
Updates existing user scripts with new definitions or metadata.
## webNavigation
**Documentation:** [Chrome WebNavigation API](https://developer.chrome.com/docs/extensions/reference/webNavigation)
A promise-based wrapper for the Chrome `webNavigation` API, providing methods to retrieve frame information and listen to navigation events.
### Methods
- [getAllFrames(tabId)](#getAllFrames)
- [getFrame(details)](#getFrame)
### Events
- [onWebNavigationBeforeNavigate(callback, filters)](#onWebNavigationBeforeNavigate)
- [onWebNavigationCommitted(callback, filters)](#onWebNavigationCommitted)
- [onWebNavigationCompleted(callback, filters)](#onWebNavigationCompleted)
- [onWebNavigationCreatedNavigationTarget(callback, filters)](#onWebNavigationCreatedNavigationTarget)
- [onWebNavigationDOMContentLoaded(callback, filters)](#onWebNavigationDOMContentLoaded)
- [onWebNavigationErrorOccurred(callback, filters)](#onWebNavigationErrorOccurred)
- [onWebNavigationHistoryStateUpdated(callback, filters)](#onWebNavigationHistoryStateUpdated)
- [onWebNavigationReferenceFragmentUpdated(callback, filters)](#onWebNavigationReferenceFragmentUpdated)
- [onWebNavigationTabReplaced(callback)](#onWebNavigationTabReplaced)
### getAllFrames
```
getAllFrames(tabId: number): Promise
```
Retrieves information about all frames in the specified tab.
### getFrame
```
getFrame(details: chrome.webNavigation.GetFrameDetails): Promise
```
Retrieves information about a specific frame. Rejects if the frame is not found.
### onWebNavigationBeforeNavigate
```
onWebNavigationBeforeNavigate(callback: (details: chrome.webNavigation.WebNavigationParentedCallbackDetails) => void, filters?: chrome.webNavigation.WebNavigationEventFilter): () => void
```
Adds a listener that is called before a navigation occurs.
### onWebNavigationCommitted
```
onWebNavigationCommitted(callback: (details: chrome.webNavigation.WebNavigationTransitionCallbackDetails) => void, filters?: chrome.webNavigation.WebNavigationEventFilter): () => void
```
Adds a listener that is called when a navigation is committed.
### onWebNavigationCompleted
```
onWebNavigationCompleted(callback: (details: chrome.webNavigation.WebNavigationFramedCallbackDetails) => void, filters?: chrome.webNavigation.WebNavigationEventFilter): () => void
```
Adds a listener that is called when a document, including its resources, is completely loaded.
### onWebNavigationCreatedNavigationTarget
```
onWebNavigationCreatedNavigationTarget(callback: (details: chrome.webNavigation.WebNavigationSourceCallbackDetails) => void, filters?: chrome.webNavigation.WebNavigationEventFilter): () => void
```
Adds a listener that is called when a new window or tab is created to host a navigation.
### onWebNavigationDOMContentLoaded
```
onWebNavigationDOMContentLoaded(callback: (details: chrome.webNavigation.WebNavigationFramedCallbackDetails) => void, filters?: chrome.webNavigation.WebNavigationEventFilter): () => void
```
Adds a listener that is called when the page's DOM is fully constructed.
### onWebNavigationErrorOccurred
```
onWebNavigationErrorOccurred(callback: (details: chrome.webNavigation.WebNavigationFramedErrorCallbackDetails) => void, filters?: chrome.webNavigation.WebNavigationEventFilter): () => void
```
Adds a listener that is called when an error occurs and a navigation is aborted.
### onWebNavigationHistoryStateUpdated
```
onWebNavigationHistoryStateUpdated(callback: (details: chrome.webNavigation.WebNavigationTransitionCallbackDetails) => void, filters?: chrome.webNavigation.WebNavigationEventFilter): () => void
```
Adds a listener that is called when a frame's history is updated to a new URL.
### onWebNavigationReferenceFragmentUpdated
```
onWebNavigationReferenceFragmentUpdated(callback: (details: chrome.webNavigation.WebNavigationTransitionCallbackDetails) => void, filters?: chrome.webNavigation.WebNavigationEventFilter): () => void
```
Adds a listener that is called when the reference fragment of a frame is updated.
### onWebNavigationTabReplaced
```
onWebNavigationTabReplaced(callback: (details: chrome.webNavigation.WebNavigationReplacementCallbackDetails) => void): () => void
```
Adds a listener that is called when a tab is replaced by another tab.
## webRequest
**Documentation:** [Chrome WebRequest API](https://developer.chrome.com/docs/extensions/reference/webRequest)
A promise-based wrapper for the Chrome `webRequest` API, providing methods to observe and modify network requests through various lifecycle events.
### Methods
- [handlerWebRequestBehaviorChanged](#handlerWebRequestBehaviorChanged)
### Events
- [onWebRequestAuthRequired](#onWebRequestAuthRequired)
- [onWebRequestBeforeRedirect](#onWebRequestBeforeRedirect)
- [onWebRequestBeforeRequest](#onWebRequestBeforeRequest)
- [onWebRequestBeforeSendHeaders](#onWebRequestBeforeSendHeaders)
- [onWebRequestSendHeaders](#onWebRequestSendHeaders)
- [onWebRequestHeadersReceived](#onWebRequestHeadersReceived)
- [onWebRequestResponseStarted](#onWebRequestResponseStarted)
- [onWebRequestCompleted](#onWebRequestCompleted)
- [onWebRequestErrorOccurred](#onWebRequestErrorOccurred)
### handlerWebRequestBehaviorChanged
```
handlerWebRequestBehaviorChanged(): Promise
```
Notifies the browser that the extension's webRequest handling logic (filters or listeners) has changed, prompting the browser to update its internal event routing.
### onWebRequestAuthRequired
```
onWebRequestAuthRequired(callback: (details: chrome.webRequest.OnAuthRequiredDetails, asyncCallback?: (response: chrome.webRequest.BlockingResponse) => void) => chrome.webRequest.BlockingResponse | void, filter: chrome.webRequest.RequestFilter, extraInfoSpec?: string[]): () => void
```
Adds a listener for authentication challenges. You can provide credentials, cancel the request, or take no action. Returns a function to remove the listener.
### onWebRequestBeforeRedirect
```
onWebRequestBeforeRedirect(callback: (details: chrome.webRequest.OnBeforeRedirectDetails) => void, filter: chrome.webRequest.RequestFilter, extraInfoSpec?: string[]): () => void
```
Adds a listener fired before a server-initiated redirect occurs. Returns a function to remove the listener.
### onWebRequestBeforeRequest
```
onWebRequestBeforeRequest(callback: (details: chrome.webRequest.OnBeforeRequestDetails) => chrome.webRequest.BlockingResponse | void, filter: chrome.webRequest.RequestFilter, extraInfoSpec?: string[]): () => void
```
Adds a listener fired before a request is made. Can cancel or redirect the request by returning a BlockingResponse. Returns a function to remove the listener.
### onWebRequestBeforeSendHeaders
```
onWebRequestBeforeSendHeaders(callback: (details: chrome.webRequest.OnBeforeSendHeadersDetails) => chrome.webRequest.BlockingResponse | void, filter: chrome.webRequest.RequestFilter, extraInfoSpec?: string[]): () => void
```
Adds a listener fired before HTTP request headers are sent. Can modify or cancel the request headers. Returns a function to remove the listener.
### onWebRequestSendHeaders
```
onWebRequestSendHeaders(callback: (details: chrome.webRequest.OnSendHeadersDetails) => void, filter: chrome.webRequest.RequestFilter, extraInfoSpec?: string[]): () => void
```
Adds a listener fired after HTTP request headers are sent. Returns a function to remove the listener.
### onWebRequestHeadersReceived
```
onWebRequestHeadersReceived(callback: (details: chrome.webRequest.OnHeadersReceivedDetails) => chrome.webRequest.BlockingResponse | void, filter: chrome.webRequest.RequestFilter, extraInfoSpec?: string[]): () => void
```
Adds a listener fired when HTTP response headers are received. Can modify response headers or cancel the request. Returns a function to remove the listener.
### onWebRequestResponseStarted
```
onWebRequestResponseStarted(callback: (details: chrome.webRequest.OnResponseStartedDetails) => void, filter: chrome.webRequest.RequestFilter, extraInfoSpec?: string[]): () => void
```
Adds a listener fired when the first byte of the response body is received. Returns a function to remove the listener.
### onWebRequestCompleted
```
onWebRequestCompleted(callback: (details: chrome.webRequest.OnCompletedDetails) => void, filter: chrome.webRequest.RequestFilter, extraInfoSpec?: string[]): () => void
```
Adds a listener fired when a request is completed successfully. Returns a function to remove the listener.
### onWebRequestErrorOccurred
```
onWebRequestErrorOccurred(callback: (details: chrome.webRequest.OnErrorOccurredDetails) => void, filter: chrome.webRequest.RequestFilter, extraInfoSpec?: string[]): () => void
```
Adds a listener fired when a request encounters an error and is aborted. Returns a function to remove the listener.