Package Exports
- @adnbn/browser
Readme
@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
npm install @adnbn/browserSupported Chrome APIs
- action
- alarms
- audio
- browsingData
- commands
- contextMenus
- cookies
- documentScan
- downloads
- extension
- fileBrowserHandler
- history
- i18n
- idle
- management
- notifications
- offscreen
- permissions
- runtime
- scripting
- sidebar
- tabCapture
- tabs
- userScripts
- webNavigation
- webRequest
action
Documentation: Chrome Action API
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)
- enableAction(tabId)
- getBadgeBgColor(tabId)
- getBadgeText(tabId)
- getBadgeTextColor(tabId) [MV3]
- getActionPopup(tabId)
- getActionTitle(tabId)
- getActionUserSetting() [MV3]
- isActionEnabled(tabId)
- openActionPopup(windowId) [MV3]
- setBadgeBgColor(color, tabId)
- setBadgeText(text, tabId)
- setBadgeTextColor(color, tabId) [MV3]
- setActionIcon(details)
- setActionPopup(popup, tabId)
- setActionTitle(title, tabId)
- getDefaultPopup()
- clearBadgeText(tabId)
Events
disableAction
disableAction(tabId: number): Promise<void>Disables the extension action for the specified tab. Falls back to chrome.browserAction.disable in Manifest V2.
enableAction
enableAction(tabId: number): Promise<void>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<string>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<string>Retrieves the popup URL set for the action in a given tab.
getActionTitle
getActionTitle(tabId?: number): Promise<string>Retrieves the title set for the action in a given tab.
getActionUserSetting [MV3]
getActionUserSetting(): Promise<chrome.action.UserSettings>Retrieves the user settings for the action (Manifest V3 only).
isActionEnabled
isActionEnabled(tabId: number): Promise<boolean>Checks whether the action is enabled for the specified tab.
openActionPopup [MV3]
openActionPopup(windowId?: number): Promise<void>Programmatically opens the action popup (Manifest V3 only).
setBadgeBgColor
setBadgeBgColor(color: string | [number, number, number, number], tabId?: number): Promise<void>Sets the badge background color for a given tab.
setBadgeText
setBadgeText(text: string | number, tabId?: number): Promise<void>Sets the badge text for a given tab.
setBadgeTextColor [MV3]
setBadgeTextColor(color: string | [number, number, number, number], tabId?: number): Promise<void>Sets the badge text color for a given tab (Manifest V3 only).
setActionIcon
setActionIcon(details: chrome.action.TabIconDetails): Promise<void>Sets the action icon for a tab or globally.
setActionPopup
setActionPopup(popup: string, tabId?: number): Promise<void>Sets the popup URL for the action in a given tab.
setActionTitle
setActionTitle(title: string, tabId?: number): Promise<void>Sets the title for the action in a given tab.
getDefaultPopup
getDefaultPopup(): stringReturns the default popup URL from the manifest (action.default_popup in MV3 or browser_action.default_popup in MV2).
clearBadgeText
clearBadgeText(tabId?: number): Promise<void>Clears the badge text for a given tab.
onActionClicked
onActionClicked(callback: (tab: chrome.tabs.Tab) => void): () => voidAdds a listener for the action clicked event.
onActionUserSettingsChanged [MV3]
onActionUserSettingsChanged(callback: (settings: chrome.action.UserSettings) => void): () => voidAdds a listener for user settings changes on the action (Manifest V3 only).
alarms
Documentation: Chrome Alarms API
A promise-based wrapper for the Chrome alarms API.
Methods
Events
clearAlarm
clearAlarm(name: string): Promise<boolean>Clears the alarm with the specified name, returning true if an existing alarm was found and cleared.
clearAllAlarm
clearAllAlarm(): Promise<boolean>Clears all alarms, returning true if any alarms were found and cleared.
createAlarm
createAlarm(name: string, info: chrome.alarms.AlarmCreateInfo): Promise<void>Creates a new alarm or updates an existing one with the given name and scheduling options.
getAlarm
getAlarm(name: string): Promise<chrome.alarms.Alarm>Retrieves details for the alarm with the specified name.
getAllAlarm
getAllAlarm(): Promise<chrome.alarms.Alarm[]>Retrieves all set alarms.
onAlarm
onAlarm(callback: (alarm: chrome.alarms.Alarm) => void): () => voidAdds a listener that triggers when an alarm goes off.
audio
Documentation: Chrome Audio API
A promise-based wrapper for the Chrome audio API.
Methods
- getAudioDevices(filter)
- getAudioMute(streamType)
- setAudioActiveDevices(ids)
- setAudioMute(streamType, isMuted)
- setAudioProperties(id, properties)
Events
getAudioDevices
getAudioDevices(filter?: chrome.audio.DeviceFilter): Promise<chrome.audio.AudioDeviceInfo[]>Retrieves the list of available audio devices, optionally filtered.
getAudioMute
getAudioMute(streamType: chrome.audio.StreamType): Promise<boolean>Retrieves the mute state of the specified audio stream.
setAudioActiveDevices
setAudioActiveDevices(ids?: chrome.audio.DeviceIdLists): Promise<void>Sets the list of active audio devices.
setAudioMute
setAudioMute(streamType: chrome.audio.StreamType, isMuted: boolean): Promise<void>Sets the mute state for the specified audio stream.
setAudioProperties
setAudioProperties(id: string, properties?: chrome.audio.DeviceProperties): Promise<void>Updates properties for the specified audio device.
onAudioDeviceListChanged
onAudioDeviceListChanged(callback: () => void): () => voidAdds a listener for changes in the list of audio devices.
onAudioLevelChanged
onAudioLevelChanged(callback: (level: number) => void): () => voidAdds a listener for changes in audio level.
onAudioMuteChanged
onAudioMuteChanged(callback: (isMuted: boolean) => void): () => voidAdds a listener for changes in audio mute state.
browsingData
Documentation: Chrome Browsing Data API
A promise-based wrapper for the Chrome browsingData API.
Methods
- removeBrowsingData(options, dataToRemove)
- removeAppcacheData(options)
- removeCacheData(options)
- removeCacheStorageData(options)
- removeCookiesData(options)
- removeDownloadsData(options)
- removeFileSystemsData(options)
- removeFormData(options)
- removeHistoryData(options)
- removeIndexedDBData(options)
- removeLocalStorageData(options)
- removePasswordsData(options)
- removeServiceWorkersData(options)
- removeWebSQLData(options)
- getBrowsingDataSettings()
removeBrowsingData
removeBrowsingData(options: chrome.browsingData.RemovalOptions, dataToRemove: chrome.browsingData.DataTypeSet): Promise<void>Clears the specified types of browsing data within the given time range.
removeAppcacheData
removeAppcacheData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears the application cache.
removeCacheData
removeCacheData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears the browser cache.
removeCacheStorageData
removeCacheStorageData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears Cache Storage.
removeCookiesData
removeCookiesData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears all cookies.
removeDownloadsData
removeDownloadsData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears download history.
removeFileSystemsData
removeFileSystemsData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears file system data.
removeFormData
removeFormData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears data entered into forms.
removeHistoryData
removeHistoryData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears browsing history.
removeIndexedDBData
removeIndexedDBData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears IndexedDB data.
removeLocalStorageData
removeLocalStorageData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears Local Storage data.
removePasswordsData
removePasswordsData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears saved passwords.
removeServiceWorkersData
removeServiceWorkersData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears Service Worker registrations.
removeWebSQLData
removeWebSQLData(options?: chrome.browsingData.RemovalOptions): Promise<void>Clears WebSQL data.
getBrowsingDataSettings
getBrowsingDataSettings(): Promise<chrome.browsingData.SettingsResult>Retrieves the current browsing data removal settings.
commands
Documentation: Chrome Commands API
A promise-based wrapper for the Chrome commands API.
Methods
Events
getAllCommands
getAllCommands(): Promise<chrome.commands.Command[]>Retrieves all registered extension commands.
onCommand
onCommand(callback: (command: string, tab: chrome.tabs.Tab) => void): () => voidAdds a listener for extension command events.
contextMenus
Documentation: Chrome Context Menus API
A promise-based wrapper for the Chrome contextMenus API.
Methods
- createContextMenus(createProperties)
- removeContextMenus(menuItemId)
- removeAllContextMenus()
- updateContextMenus(id, updateProperties)
Events
createContextMenus
createContextMenus(createProperties?: chrome.contextMenus.CreateProperties): Promise<void>Creates a new context menu item with the specified properties.
removeContextMenus
removeContextMenus(menuItemId: string | number): Promise<void>Removes the context menu item with the given ID.
removeAllContextMenus
removeAllContextMenus(): Promise<void>Removes all context menu items added by the extension.
updateContextMenus
updateContextMenus(id: string | number, updateProperties?: Omit<chrome.contextMenus.CreateProperties, 'id'>): Promise<void>Updates the specified context menu item with new properties.
onContextMenusClicked
onContextMenusClicked(callback: (info: chrome.contextMenus.OnClickData, tab: chrome.tabs.Tab) => void): () => voidAdds a listener that triggers when a context menu item is clicked.
cookies
Documentation: Chrome Cookies API
A promise-based wrapper for the Chrome cookies API.
Methods
- getCookie(details)
- getAllCookie(details)
- getAllCookieStores()
- getCookiePartitionKey(details)
- removeCookie(details)
- setCookie(details)
Events
getCookie
getCookie(details: chrome.cookies.CookieDetails): Promise<chrome.cookies.Cookie | null>Retrieves the cookie matching the specified details, or null if not found.
getAllCookie
getAllCookie(details?: chrome.cookies.GetAllDetails): Promise<chrome.cookies.Cookie[]>Retrieves all cookies that match the given filter details.
getAllCookieStores
getAllCookieStores(): Promise<chrome.cookies.CookieStore[]>Retrieves all cookie stores accessible to the extension.
getCookiePartitionKey [MV3]
getCookiePartitionKey(details: chrome.cookies.FrameDetails): Promise<chrome.cookies.CookiePartitionKey>Retrieves the partition key for the cookie associated with the given frame (Manifest V3 only).
removeCookie
removeCookie(details: chrome.cookies.CookieDetails): Promise<chrome.cookies.CookieDetails>Removes the cookie matching the specified details, returning the details of the removed cookie.
setCookie
setCookie(details: chrome.cookies.SetDetails): Promise<chrome.cookies.Cookie | null>Sets a cookie with the given details, returning the created cookie or null on failure.
onCookieChanged
onCookieChanged(callback: (changeInfo: chrome.cookies.CookieChangeInfo) => void): () => voidAdds a listener that triggers when a cookie change event occurs.
documentscan
Documentation: Chrome Document Scan API
A promise-based wrapper for the Chrome documentScan API.
Methods
- cancelDocScanning
- closeDocScanner
- getDocScannerOptionGroups
- getDocScannerList
- openDocScanner
- readDocScanningData
- docScanning
- setDocScannerOptions
- startDocScanning
cancelDocScanning
cancelDocScanning(job: string): Promise<chrome.documentScan.CancelScanResponse<string>>Cancels an ongoing document scan job.
closeDocScanner
closeDocScanner(scannerHandle: string): Promise<chrome.documentScan.CloseScannerResponse<string>>Closes the document scanner associated with the specified scanner handle.
getDocScannerOptionGroups
getDocScannerOptionGroups(scannerHandle: string): Promise<chrome.documentScan.GetOptionGroupsResponse<string>>Retrieves the available option groups for the specified document scanner.
getDocScannerList
getDocScannerList(filter: chrome.documentScan.DeviceFilter): Promise<chrome.documentScan.GetScannerListResponse>Fetches a list of document scanners matching the given filter criteria.
openDocScanner
openDocScanner(scannerId: string): Promise<chrome.documentScan.OpenScannerResponse<string>>Opens a document scanner by its ID, returning a handle for further operations.
readDocScanningData
readDocScanningData(job: string): Promise<chrome.documentScan.ReadScanDataResponse<string>>Reads a chunk of data from an ongoing scan job.
docScanning
docScanning(options: chrome.documentScan.ScanOptions): Promise<chrome.documentScan.ScanResults>Performs a document scan with the specified options and returns the scan results.
setDocScannerOptions
setDocScannerOptions(scannerHandle: string, options: chrome.documentScan.OptionSetting[]): Promise<chrome.documentScan.SetOptionsResponse<string>>Sets the scanner options for the given scanner handle.
startDocScanning
startDocScanning(scannerHandle: string, options: chrome.documentScan.StartScanOptions): Promise<chrome.documentScan.StartScanResponse<string>>Starts a scan operation on an open scanner with the provided settings.
downloads
Documentation: Chrome Downloads API
A promise-based wrapper for the Chrome downloads API.
Methods
- acceptDownloadDanger
- cancelDownload
- download
- eraseDownload
- getDownloadFileIcon
- openDownload
- pauseDownload
- removeDownloadFile
- resumeDownload
- searchDownloads
- setDownloadsUiOptions
- showDownloadFolder
- showDownload
- findDownload
- isDownloadExists
- getDownloadState
Events
acceptDownloadDanger
acceptDownloadDanger(downloadId: number): Promise<void>Accepts a dangerous download, allowing it to proceed.
cancelDownload
cancelDownload(downloadId: number): Promise<void>Cancels the specified download.
download
download(options: chrome.downloads.DownloadOptions): Promise<number>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<number[]>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<string>Retrieves the icon for the downloaded file.
openDownload
openDownload(downloadId: number): voidOpens the downloaded file.
pauseDownload
pauseDownload(downloadId: number): Promise<void>Pauses an active download.
removeDownloadFile
removeDownloadFile(downloadId: number): Promise<void>Deletes the downloaded file from the local disk.
resumeDownload
resumeDownload(downloadId: number): Promise<void>Resumes a paused download.
searchDownloads
searchDownloads(query: chrome.downloads.DownloadQuery): Promise<chrome.downloads.DownloadItem[]>Searches for downloads matching the specified query.
setDownloadsUiOptions
setDownloadsUiOptions(enabled: boolean): Promise<void>Enables or disables the browser's default download UI.
showDownloadFolder
showDownloadFolder(): voidShows the default download folder in the file explorer.
showDownload
showDownload(downloadId: number): Promise<boolean>Attempts to reveal the specified download in the file explorer, returning true if it exists.
findDownload
findDownload(downloadId: number): Promise<chrome.downloads.DownloadItem | undefined>Retrieves the download item for the given download ID, if it exists.
isDownloadExists
isDownloadExists(downloadId: number): Promise<boolean | undefined>Checks whether a download with the specified ID exists.
getDownloadState
getDownloadState(downloadId?: number): Promise<chrome.downloads.DownloadState | undefined>Retrieves the state (in_progress, complete, or interrupted) of the given download.
onDownloadsChanged
onDownloadsChanged(callback: Parameters<typeof chrome.downloads.onChanged.addListener>[0]): () => voidAdds a listener triggered when a download's state or properties change.
onDownloadsCreated
onDownloadsCreated(callback: Parameters<typeof chrome.downloads.onCreated.addListener>[0]): () => voidAdds a listener triggered when a new download is created.
onDownloadsDeterminingFilename
onDownloadsDeterminingFilename(callback: Parameters<typeof chrome.downloads.onDeterminingFilename.addListener>[0]): () => voidAdds a listener triggered when a download's filename is being determined.
extension
Documentation: Chrome Extension API
A promise-based wrapper for the Chrome extension API.
Methods
getBackgroundPage
getBackgroundPage(): Window | nullReturns 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<boolean>Checks if the extension has permission to access file system URLs (file://).
isAllowedIncognitoAccess
isAllowedIncognitoAccess(): Promise<boolean>Determines whether the extension is allowed to operate in incognito mode.
setUpdateUrlData
setUpdateUrlData(data: string): voidSets the data string to be sent as part of the extension's update check URL.
fileBrowserHandler
Documentation: Chrome File Browser Handler API
A wrapper for the Chrome fileBrowserHandler API to manage file browser actions.
Events
onExecute
onExecute(callback: (id: string, details: chrome.fileBrowserHandler.FileBrowserHandlerExecuteDetails) => void): () => voidAdds 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
A promise-based wrapper for the Chrome history API to manage browser history.
Methods
Events
addHistoryUrl
addHistoryUrl(url: string): Promise<void>Adds the specified URL to the browser history.
deleteAllHistory
deleteAllHistory(): Promise<void>Deletes all entries from the browser history.
deleteRangeHistory
deleteRangeHistory(range: chrome.history.Range): Promise<void>Removes all history entries within the specified time range.
deleteHistoryUrl
deleteHistoryUrl(details: chrome.history.Url): Promise<void>Deletes all occurrences of the given URL from the history.
getHistoryVisits
getHistoryVisits(url: string): Promise<chrome.history.VisitItem[]>Retrieves the visit history for the specified URL.
searchHistory
searchHistory(query: chrome.history.HistoryQuery): Promise<chrome.history.HistoryItem[]>Searches the browser history with the given query, returning matching history items.
onHistoryVisited
onHistoryVisited(callback: (result: chrome.history.HistoryItem) => void): () => voidAdds a listener triggered when the browser records a page visit.
onHistoryVisitRemoved
onHistoryVisitRemoved(callback: (removed: chrome.history.RemoveInfo) => void): () => voidAdds a listener triggered when URLs are removed from the history, providing details of the removal.
i18n
Documentation: Chrome i18n API
A promise-based wrapper for the Chrome i18n API to manage localization.
Methods
detectI18Language
detectI18Language(text: string): Promise<chrome.i18n.LanguageDetectionResult>Detects the primary language of the provided text.
getI18nAcceptLanguages
getI18nAcceptLanguages(): Promise<string[]>Retrieves the user's preferred accept languages list.
getI18nUILanguage
getI18nUILanguage(): string | undefinedReturns the browser's UI language code.
getI18nMessage
getI18nMessage(key: string): string | undefinedRetrieves the localized message for the specified key.
getDefaultLanguage
getDefaultLanguage(): string | undefinedExtracts the default locale as declared in the extension manifest.
idle
Documentation: Chrome Idle API
A promise-based wrapper for the Chrome idle API to monitor user idle state.
Methods
Events
getIdleAutoLockDelay
getIdleAutoLockDelay(): Promise<number>Retrieves the number of seconds before the system auto-locks due to inactivity.
queryIdleState
queryIdleState(detectionIntervalInSeconds: number): Promise<chrome.idle.IdleState>Queries the user's idle state within the specified detection interval.
setIdleDetectionInterval
setIdleDetectionInterval(intervalInSeconds: number): voidSets the interval, in seconds, used to detect idle state changes.
onIdleStateChanged
onIdleStateChanged(callback: (newState: chrome.idle.IdleState) => void): () => voidAdds a listener that fires when the user's idle state changes, returning a function to remove the listener.
management
Documentation: Chrome Management API
A promise-based wrapper for the Chrome management API to manage extensions and apps.
Methods
- createAppShortcut
- generateAppForLink
- getExtensionInfo
- getAllExtensionInfo
- getPermissionWarningsById
- getPermissionWarningsByManifest
- getCurrentExtension
- launchExtensionApp
- setExtensionEnabled
- setExtensionLaunchType
- uninstallExtension
- uninstallCurrentExtension
Events
createAppShortcut
createAppShortcut(id: string): Promise<void>Creates a desktop shortcut for the specified app ID.
generateAppForLink
generateAppForLink(url: string, title: string): Promise<chrome.management.ExtensionInfo>Generates a Chrome app for the given URL and title, returning its extension info.
getExtensionInfo
getExtensionInfo(id: string): Promise<chrome.management.ExtensionInfo>Retrieves information about the extension or app with the specified ID.
getAllExtensionInfo
getAllExtensionInfo(): Promise<chrome.management.ExtensionInfo[]>Retrieves information about all installed extensions and apps.
getPermissionWarningsById
getPermissionWarningsById(id: string): Promise<string[]>Gets permission warning messages for the specified extension ID.
getPermissionWarningsByManifest
getPermissionWarningsByManifest(manifestStr: string): Promise<string[]>Gets permission warning messages for the given manifest string.
getCurrentExtension
getCurrentExtension(): Promise<chrome.management.ExtensionInfo>Retrieves information about the current extension.
launchExtensionApp
launchExtensionApp(id: string): Promise<void>Launches the specified extension app by ID.
setExtensionEnabled
setExtensionEnabled(id: string, enabled: boolean): Promise<void>Enables or disables the specified extension or app.
setExtensionLaunchType
setExtensionLaunchType(id: string, launchType: string): Promise<void>Sets the launch type (e.g., regular, pinned) for the specified extension.
uninstallExtension
uninstallExtension(id: string, showConfirmDialog?: boolean): Promise<void>Uninstalls the extension with the given ID, optionally showing a confirmation dialog.
uninstallCurrentExtension
uninstallCurrentExtension(showConfirmDialog?: boolean): Promise<void>Uninstalls the current extension, optionally showing a confirmation dialog.
onExtensionDisabled
onExtensionDisabled(callback: (info: chrome.management.ExtensionInfo) => void): () => voidFires when an extension or app is disabled.
onExtensionEnabled
onExtensionEnabled(callback: (info: chrome.management.ExtensionInfo) => void): () => voidFires when an extension or app is enabled.
onExtensionInstalled
onExtensionInstalled(callback: (info: chrome.management.ExtensionInfo) => void): () => voidFires when an extension or app is installed.
onExtensionUninstalled
onExtensionUninstalled(callback: (extensionId: string) => void): () => voidFires when an extension or app is uninstalled, passing its ID.
notifications
Documentation: Chrome Notifications API
A promise-based wrapper for the Chrome notifications API to create and manage desktop notifications.
Methods
- clearNotification
- createNotification
- getAllNotification
- getNotificationPermissionLevel
- updateNotification
- isSupportNotifications
- clearAllNotification
Events
- onNotificationsButtonClicked
- onNotificationsClicked
- onNotificationsClosed
- onNotificationsPermissionLevelChanged
clearNotification
clearNotification(notificationId: string): Promise<boolean>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<string>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<string>Gets the current permission level for notifications.
updateNotification
updateNotification(options: chrome.notifications.NotificationOptions, notificationId: string): Promise<boolean>Updates an existing notification with new options, resolving to true if the notification was updated.
isSupportNotifications
isSupportNotifications(): booleanChecks if the Notifications API is supported in the current browser.
clearAllNotification
clearAllNotification(): Promise<void>Clears all currently displayed notifications.
onNotificationsButtonClicked
onNotificationsButtonClicked(callback: (notificationId: string, buttonIndex: number) => void): () => voidAdds a listener for when a button on a notification is clicked, returning a function to remove the listener.
onNotificationsClicked
onNotificationsClicked(callback: (notificationId: string) => void): () => voidAdds a listener for when a notification itself is clicked.
onNotificationsClosed
onNotificationsClosed(callback: (notificationId: string, byUser: boolean) => void): () => voidAdds a listener for when a notification is closed, including whether it was closed by the user.
onNotificationsPermissionLevelChanged
onNotificationsPermissionLevelChanged(callback: (level: string) => void): () => voidAdds a listener for when notification permission level changes.
offscreen
Documentation: Chrome Offscreen API [MV3]
A promise-based wrapper for the Chrome offscreen API to create and manage offscreen documents.
Methods
createOffscreen
createOffscreen(parameters: chrome.offscreen.CreateParameters): Promise<void>Creates an offscreen document with the specified parameters.
closeOffscreen
closeOffscreen(): Promise<void>Closes the existing offscreen document.
hasOffscreen
hasOffscreen(): Promise<boolean>Checks whether an offscreen document is currently open.
permissions
Documentation: Chrome Permissions API
A promise-based wrapper for the Chrome permissions API to request and manage extension permissions.
Methods
- containsPermissions
- getAllPermissions
- requestPermissions
- removePermissions
- addHostAccessRequest [MV3]
- removeHostAccessRequest [MV3]
Events
containsPermissions
containsPermissions(permissions: chrome.permissions.Permissions): Promise<boolean>Checks whether the extension has the specified permissions.
getAllPermissions
getAllPermissions(): Promise<chrome.permissions.Permissions>Retrieves all granted permissions.
requestPermissions
requestPermissions(permissions: chrome.permissions.Permissions): Promise<boolean>Prompts the user to grant additional permissions.
removePermissions
removePermissions(permissions: chrome.permissions.Permissions): Promise<boolean>Removes the specified permissions if granted.
addHostAccessRequest [MV3]
addHostAccessRequest(request?: chrome.permissions.AddHostAccessRequest): Promise<void>Requests additional host access at runtime (Manifest V3 only).
removeHostAccessRequest [MV3]
removeHostAccessRequest(request?: chrome.permissions.RemoveHostAccessRequest): Promise<void>Clears a previously requested host access (Manifest V3 only).
onPermissionsAdded
onPermissionsAdded(callback: (permissions: chrome.permissions.Permissions) => void): () => voidFires when new permissions are granted.
onPermissionsRemoved
onPermissionsRemoved(callback: (permissions: chrome.permissions.Permissions) => void): () => voidFires when permissions are removed.
runtime
Documentation: Chrome Runtime API
A wrapper for the Chrome runtime API, including messaging, updates, and lifecycle events.
Methods
- connect
- connectNative
- getContexts [MV3]
- getManifest
- getId
- getManifestVersion
- isManifestVersion3
- getPackageDirectoryEntry
- getPlatformInfo
- getBrowserInfo [Firefox]
- getUrl
- openOptionsPage
- reload
- requestUpdateCheck
- restart [MV3]
- restartAfterDelay [MV3]
- sendMessage
- setUninstallUrl
Events
- onConnect
- onConnectExternal
- onInstalled
- onMessage
- onMessageExternal
- onRestartRequired
- onStartup
- onSuspend
- onSuspendCanceled
- onUpdateAvailable
- onUserScriptConnect
- onUserScriptMessage
connect
connect(extensionId: string, connectInfo?: object): chrome.runtime.PortOpens a long-lived connection to another extension or app.
connectNative
connectNative(application: string): chrome.runtime.PortConnects to a native application.
getContexts [MV3]
getContexts(filter: chrome.runtime.ContextFilter): Promise<chrome.runtime.ExtensionContext[]>Retrieves extension contexts matching the filter (Manifest V3 only).
getManifest
getManifest(): chrome.runtime.ManifestReturns the extension's manifest details.
getId
getId(): stringReturns the extension ID.
getManifestVersion
getManifestVersion(): 2 | 3Retrieves the manifest version (2 or 3).
isManifestVersion3
isManifestVersion3(): booleanChecks if the extension uses Manifest V3.
getPackageDirectoryEntry
getPackageDirectoryEntry(): Promise<FileSystemDirectoryEntry>Gets the root directory of the extension package.
getPlatformInfo
getPlatformInfo(): Promise<chrome.runtime.PlatformInfo>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): stringConverts a relative path to an absolute extension URL.
openOptionsPage
openOptionsPage(): Promise<void>Opens the extension's options page.
reload
reload(): voidReloads 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(): voidRestarts the browser to apply updates (Manifest V3 only).
restartAfterDelay [MV3]
restartAfterDelay(seconds: number): Promise<void>Schedules a browser restart after the given delay in seconds (Manifest V3 only).
sendMessage
sendMessage<M = any, R = any>(message: M): Promise<R>Sends a single message to the extension or app and awaits a response.
setUninstallUrl
setUninstallUrl(url: string): Promise<void>Sets a URL to be opened upon uninstallation.
onConnect
onConnect(callback: (port: chrome.runtime.Port) => void): () => voidFires when a connection is made by another extension or content script.
onConnectExternal
onConnectExternal(callback: (port: chrome.runtime.Port) => void): () => voidFires when an external extension connects.
onInstalled
onInstalled(callback: chrome.runtime.InstalledDetails): () => voidFires when the extension is installed or updated.
onMessage
onMessage(callback: (message: any, sender: chrome.runtime.MessageSender) => void): () => voidFires when a message is received.
onMessageExternal
onMessageExternal(callback: (message: any, sender: chrome.runtime.MessageSender) => void): () => voidFires when an external extension sends a message.
onRestartRequired
onRestartRequired(callback: (reason: chrome.runtime.OnRestartRequiredReason) => void): () => voidFires when the extension requires a browser restart.
onStartup
onStartup(callback: () => void): () => voidFires when the browser starts up.
onSuspend
onSuspend(callback: () => void): () => voidFires when the event page is about to be unloaded.
onSuspendCanceled
onSuspendCanceled(callback: () => void): () => voidFires when a suspend is canceled.
onUpdateAvailable
onUpdateAvailable(callback: chrome.runtime.UpdateAvailableDetails): () => voidFires when an update is available.
onUserScriptConnect
onUserScriptConnect(callback: (port: chrome.runtime.Port) => void): () => voidFires when a user script establishes a connection.
onUserScriptMessage
onUserScriptMessage(callback: (message: any, sender: chrome.runtime.MessageSender) => void): () => voidFires when a message arrives from a user script.
scripting
Documentation: Chrome Scripting API
A promise-based wrapper for the Chrome scripting API to inject scripts and styles, and manage content scripts.
Methods
- executeScript
- getRegisteredContentScripts
- insertCss
- registerContentScripts
- removeCss
- unregisterContentScripts
- updateContentScripts
- isAvailableScripting
executeScript
executeScript<T = any>(injection: chrome.scripting.ScriptInjection<any, T>): Promise<chrome.scripting.InjectionResult<chrome.scripting.Awaited<T>>[]>Executes a script in the specified target and returns the injection results.
getRegisteredContentScripts
getRegisteredContentScripts(filter?: chrome.scripting.ContentScriptFilter): Promise<chrome.scripting.RegisteredContentScript[]>Retrieves registered content scripts, optionally filtered by criteria.
insertCss
insertCss(injection: chrome.scripting.CSSInjection): Promise<void>Injects CSS into specified target pages.
registerContentScripts
registerContentScripts(scripts: chrome.scripting.RegisteredContentScript[]): Promise<void>Registers one or more content scripts programmatically.
removeCss
removeCss(injection: chrome.scripting.CSSInjection): Promise<void>Removes previously injected CSS from specified target pages.
unregisterContentScripts
unregisterContentScripts(filter?: chrome.scripting.ContentScriptFilter): Promise<void>Unregisters content scripts matching the given filter.
updateContentScripts
updateContentScripts(scripts: chrome.scripting.RegisteredContentScript[]): Promise<void>Updates existing content scripts with new definitions.
isAvailableScripting
isAvailableScripting(): booleanChecks if the Scripting API is available in the current browser.
sidebar
Documentation:
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
- getSidebarBehavior
- canOpenSidebar
- openSidebar
- setSidebarOptions
- setSidebarBehavior
- setSidebarPath
- getSidebarPath
- setSidebarTitle [Opera]
- setSidebarBadgeText [Opera]
- setSidebarBadgeTextColor [Opera]
- setSidebarBadgeBgColor [Opera]
- getSidebarTitle [Opera]
- getSidebarBadgeText [Opera]
- getSidebarBadgeTextColor [Opera]
- getSidebarBadgeBgColor [Opera]
getSidebarOptions
getSidebarOptions(tabId?: number): Promise<chrome.sidePanel.PanelOptions>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<chrome.sidePanel.PanelBehavior>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(): booleanReturns 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<void>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<void>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<void>Updates the panel behavior settings in Chrome (Manifest V3). Logs a warning if unsupported. [MV3]
setSidebarPath
setSidebarPath(path: string, tabId?: number): Promise<void>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<string | undefined>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<void>Sets the sidebar title in Opera via opr.sidebarAction.setTitle(). Logs a warning if unsupported. [Opera]
setSidebarBadgeText
setSidebarBadgeText(text: string | number, tabId?: number): Promise<void>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<void>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<void>Sets the sidebar badge background color in Opera via opr.sidebarAction.setBadgeBackgroundColor(). Logs a warning if unsupported. [Opera]
getSidebarTitle
getSidebarTitle(tabId?: number): Promise<string>Retrieves the sidebar title in Opera via opr.sidebarAction.getTitle(). Throws an error if unsupported. [Opera]
getSidebarBadgeText
getSidebarBadgeText(tabId?: number): Promise<string>Retrieves the sidebar badge text in Opera via opr.sidebarAction.getBadgeText(). Throws an error if unsupported. [Opera]
getSidebarBadgeTextColor
getSidebarBadgeTextColor(tabId?: number): Promise<chrome.action.ColorArray>Retrieves the sidebar badge text color in Opera via opr.sidebarAction.getBadgeTextColor(). Throws an error if unsupported. [Opera]
getSidebarBadgeBgColor
getSidebarBadgeBgColor(tabId?: number): Promise<chrome.action.ColorArray>Retrieves the sidebar badge background color in Opera via opr.sidebarAction.getBadgeBackgroundColor(). Throws an error if unsupported. [Opera]
tabCapture
Documentation: Chrome Tab Capture API
A promise-based wrapper for the Chrome tabCapture API to capture and retrieve tab media streams.
Methods
Events
createTabCapture
createTabCapture(options: chrome.tabCapture.CaptureOptions): Promise<MediaStream | null>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<chrome.tabCapture.CaptureInfo[]>Retrieves details of all active tab capture sessions. Resolves with an array of CaptureInfo objects.
getCaptureMediaStreamId
getCaptureMediaStreamId(options: chrome.tabCapture.GetMediaStreamOptions): Promise<string>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): () => voidAdds a listener for tab capture status changes (started, stopped, source changed). Returns a function to remove the listener.
tabs
Documentation: Chrome Tabs API
A promise-based wrapper for the Chrome tabs API, providing core tab operations, messaging, and utility methods.
Methods
- captureVisibleTab
- connectTab
- createTab
- detectTabLanguage
- discardTab
- duplicateTab
- getTab
- getCurrentTab
- getTabZoom
- getTabZoomSettings
- goTabBack
- goTabForward
- groupTabs
- highlightTab
- moveTab
- moveTabs
- queryTabs
- reloadTab
- removeTab
- sendTabMessage
- setTabZoom
- setTabZoomSettings
- ungroupTab
- updateTab
- executeScriptTab [MV2]
- insertCssTab [MV2]
- removeCssTab [MV2]
- getTabUrl
- getActiveTab
- queryTabIds
- findTab
- findTabById
- updateTabAsSelected
- updateTabAsActive
- openOrCreateTab
Events
- onTabActivated
- onTabAttached
- onTabCreated
- onTabDetached
- onTabHighlighted
- onTabMoved
- onTabRemoved
- onTabReplaced
- onTabUpdated
- onTabZoomChange
captureVisibleTab
captureVisibleTab(windowId: number, options: chrome.extensionTypes.ImageDetails): Promise<string>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.PortCreates a long-lived connection to the specified tab for message passing. Returns a Port object.
createTab
createTab(properties: chrome.tabs.CreateProperties): Promise<chrome.tabs.Tab>Creates a new tab with the given properties. Resolves with the created Tab object.
detectTabLanguage
detectTabLanguage(tabId: number): Promise<string>Detects the language of the specified tab's content. Resolves with a language code (e.g., "en" or "und").
discardTab
discardTab(tabId: number): Promise<chrome.tabs.Tab>Discards the specified tab to free up system resources. Resolves with the updated Tab object.
duplicateTab
duplicateTab(tabId: number): Promise<chrome.tabs.Tab | undefined>Duplicates the specified tab, opening a copy. Resolves with the new Tab, or undefined if duplication fails.
getTab
getTab(tabId: number): Promise<chrome.tabs.Tab>Retrieves information about the specified tab. Resolves with the Tab object.
getCurrentTab
getCurrentTab(): Promise<chrome.tabs.Tab | undefined>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<number>Gets the zoom factor of the specified tab. Resolves with the zoom level (e.g., 1.0).
getTabZoomSettings
getTabZoomSettings(tabId: number): Promise<chrome.tabs.ZoomSettings>Retrieves the zoom settings of the specified tab. Resolves with a ZoomSettings object.
goTabBack
goTabBack(tabId: number): Promise<void>Navigates the specified tab one step backward in its history.
goTabForward
goTabForward(tabId: number): Promise<void>Navigates the specified tab one step forward in its history.
groupTabs
groupTabs(options: chrome.tabs.GroupOptions): Promise<number>Groups one or more tabs into a single tab group. Resolves with the group ID.
highlightTab
highlightTab(highlightInfo: chrome.tabs.HighlightInfo): Promise<chrome.windows.Window>Highlights (selects) the specified tabs within a window. Resolves with the updated Window.
moveTab
moveTab(tabId: number, moveProperties: chrome.tabs.MoveProperties): Promise<chrome.tabs.Tab>Moves a tab to a new index or window. Resolves with the moved Tab.
moveTabs
moveTabs(tabIds: number[], moveProperties: chrome.tabs.MoveProperties): Promise<chrome.tabs.Tab[]>Moves multiple tabs to new positions. Resolves with an array of updated Tab objects.
queryTabs
queryTabs(queryInfo?: chrome.tabs.QueryInfo): Promise<chrome.tabs.Tab[]>Retrieves all tabs that match the given query filters. Resolves with an array of Tab objects.
reloadTab
reloadTab(tabId: number, bypassCache?: boolean): Promise<void>Reloads the specified tab. If bypassCache is true, forces resource revalidation.
removeTab
removeTab(tabId: number): Promise<void>Closes the specified tab.
sendTabMessage
sendTabMessage<M = any, R = any>(tabId: number, message: M, options?: chrome.tabs.MessageSendOptions): Promise<R>Sends a one-time message to the content script in the specified tab. Resolves with the response.
setTabZoom
setTabZoom(tabId: number, zoomFactor: number): Promise<void>Sets the zoom factor for the specified tab.
setTabZoomSettings
setTabZoomSettings(tabId: number, zoomSettings: chrome.tabs.ZoomSettings): Promise<void>Updates the zoom settings for the specified tab.
ungroupTab
ungroupTab(tabIds: number | number[]): Promise<void>Removes one or more tabs from their group.
updateTab
updateTab(tabId: number, updateProperties: chrome.tabs.UpdateProperties): Promise<chrome.tabs.Tab | undefined>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<any[]>Injects JavaScript into the specified tab and returns execution results. (Manifest V2 only).
insertCssTab
insertCssTab(tabId: number, details: chrome.extensionTypes.InjectDetails): Promise<void>Injects CSS into a page. (Manifest V2 only).
removeCssTab
removeCssTab(tabId: number, details: chrome.extensionTypes.InjectDetails): Promise<void>Removes from a page CSS that was previously injected by a call to insertCssTab. (Manifest V2 only).
getTabUrl
getTabUrl(tabId: number): Promise<string>Retrieves the URL of the specified tab. Rejects if the tab does not exist or has no URL.
getActiveTab
getActiveTab(): Promise<chrome.tabs.Tab>Gets the currently active tab in the current window. Rejects if no active tab is found.
queryTabIds
queryTabIds(queryInfo?: chrome.tabs.QueryInfo): Promise<number[]>Retrieves IDs of tabs matching the given query.
findTab
findTab(queryInfo?: chrome.tabs.QueryInfo): Promise<chrome.tabs.Tab | undefined>Finds the first tab matching the query. Resolves with the Tab or undefined.
findTabById
findTabById(tabId: number): Promise<chrome.tabs.Tab | undefined>Finds a tab by its ID, or resolves with undefined if not found.
updateTabAsSelected
updateTabAsSelected(tabId: number): Promise<chrome.tabs.Tab | undefined>Highlights the specified tab, making it selected.
updateTabAsActive
updateTabAsActive(tabId: number): Promise<chrome.tabs.Tab | undefined>Sets the specified tab as active.
openOrCreateTab
openOrCreateTab(tab: chrome.tabs.Tab): Promise<void>If a tab with the same URL exists, activates it; otherwise, creates a new tab.
onTabActivated
onTabActivated(callback: (activeInfo: chrome.tabs.TabActiveInfo) => void): () => voidFires when the active tab in a window changes. Returns a function to remove the listener.
onTabAttached
onTabAttached(callback: (info: chrome.tabs.TabAttachedInfo) => void): () => voidFires when a tab is attached to a window. Returns a function to remove the listener.
onTabCreated
onTabCreated(callback: (tab: chrome.tabs.Tab) => void): () => voidFires when a new tab is created. Returns a function to remove the listener.
onTabDetached
onTabDetached(callback: (info: chrome.tabs.TabDetachedInfo) => void): () => voidFires when a tab is detached from a window. Returns a function to remove the listener.
onTabHighlighted
onTabHighlighted(callback: (highlightInfo: chrome.tabs.TabHighlightInfo) => void): () => voidFires 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): () => voidFires 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): () => voidFires when a tab is closed. Returns a function to remove the listener.
onTabReplaced
onTabReplaced(callback: (addedTabId: number, removedTabId: number) => void): () => voidFires 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): () => voidFires 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): () => voidFires when the zoom level of a tab changes. Returns a function to remove the listener.
- onTabActivated
- onTabAttached
- onTabCreated
- onTabDetached
- onTabHighlighted
- onTabMoved
- onTabRemoved
- onTabReplaced
- onTabUpdated
- onTabZoomChange
userScripts
Documentation: Chrome User Scripts API
A promise-based wrapper for the Chrome userScripts API, providing methods to configure worlds, register, retrieve, update, and unregister user scripts.
Methods
- configureUserScriptsWorld(properties)
- getUserScripts(ids)
- getUserScriptsWorldConfigs()
- registerUserScripts(scripts)
- resetUserScriptsWorldConfigs(worldId)
- unregisterUserScripts(ids)
- updateUserScripts(scripts)
configureUserScriptsWorld
configureUserScriptsWorld(properties?: chrome.userScripts.WorldProperties): Promise<void>Configures the execution context for user scripts by setting world properties. Must be called before registering or executing scripts.
getUserScripts
getUserScripts(ids?: string[]): Promise<chrome.userScripts.RegisteredUserScript[]>Retrieves registered user scripts, optionally filtered by script IDs.
getUserScriptsWorldConfigs
getUserScriptsWorldConfigs(): Promise<chrome.userScripts.WorldProperties[]>Returns configurations for all script execution worlds.
registerUserScripts
registerUserScripts(scripts: chrome.userScripts.RegisteredUserScript[]): Promise<void>Registers one or more user scripts with the browser.
resetUserScriptsWorldConfigs
resetUserScriptsWorldConfigs(worldId: string): Promise<void>Resets the configuration of a specific world back to default settings.
unregisterUserScripts
unregisterUserScripts(ids?: string[]): Promise<void>Unregisters user scripts by ID. If no IDs provided, all scripts are unregistered.
updateUserScripts
updateUserScripts(scripts: chrome.userScripts.RegisteredUserScript[]): Promise<void>Updates existing user scripts with new definitions or metadata.
webNavigation
Documentation: Chrome WebNavigation API
A promise-based wrapper for the Chrome webNavigation API, providing methods to retrieve frame information and listen to navigation events.
Methods
Events
- onWebNavigationBeforeNavigate(callback, filters)
- onWebNavigationCommitted(callback, filters)
- onWebNavigationCompleted(callback, filters)
- onWebNavigationCreatedNavigationTarget(callback, filters)
- onWebNavigationDOMContentLoaded(callback, filters)
- onWebNavigationErrorOccurred(callback, filters)
- onWebNavigationHistoryStateUpdated(callback, filters)
- onWebNavigationReferenceFragmentUpdated(callback, filters)
- onWebNavigationTabReplaced(callback)
getAllFrames
getAllFrames(tabId: number): Promise<chrome.webNavigation.GetAllFrameResultDetails[]>Retrieves information about all frames in the specified tab.
getFrame
getFrame(details: chrome.webNavigation.GetFrameDetails): Promise<chrome.webNavigation.GetFrameResultDetails | null>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): () => voidAdds a listener that is called before a navigation occurs.
onWebNavigationCommitted
onWebNavigationCommitted(callback: (details: chrome.webNavigation.WebNavigationTransitionCallbackDetails) => void, filters?: chrome.webNavigation.WebNavigationEventFilter): () => voidAdds a listener that is called when a navigation is committed.
onWebNavigationCompleted
onWebNavigationCompleted(callback: (details: chrome.webNavigation.WebNavigationFramedCallbackDetails) => void, filters?: chrome.webNavigation.WebNavigationEventFilter): () => voidAdds 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): () => voidAdds 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): () => voidAdds 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): () => voidAdds 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): () => voidAdds 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): () => voidAdds a listener that is called when the reference fragment of a frame is updated.
onWebNavigationTabReplaced
onWebNavigationTabReplaced(callback: (details: chrome.webNavigation.WebNavigationReplacementCallbackDetails) => void): () => voidAdds a listener that is called when a tab is replaced by another tab.
webRequest
Documentation: Chrome WebRequest API
A promise-based wrapper for the Chrome webRequest API, providing methods to observe and modify network requests through various lifecycle events.
Methods
Events
- onWebRequestAuthRequired
- onWebRequestBeforeRedirect
- onWebRequestBeforeRequest
- onWebRequestBeforeSendHeaders
- onWebRequestSendHeaders
- onWebRequestHeadersReceived
- onWebRequestResponseStarted
- onWebRequestCompleted
- onWebRequestErrorOccurred
handlerWebRequestBehaviorChanged
handlerWebRequestBehaviorChanged(): Promise<void>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[]): () => voidAdds 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[]): () => voidAdds 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[]): () => voidAdds 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[]): () => voidAdds 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[]): () => voidAdds 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[]): () => voidAdds 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[]): () => voidAdds 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[]): () => voidAdds 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[]): () => voidAdds a listener fired when a request encounters an error and is aborted. Returns a function to remove the listener.