Documentation:
A promise-based wrapper around Chromium's side panel (chrome.sidePanel, MV3) and Firefox/Opera sidebarAction APIs. Methods provide unified behavior to get/set options and behavior, open the panel, and, where supported, manage title and icon (Firefox & Opera) and badge (Opera). Support includes Chrome, Edge, Firefox, and Opera.
Custom error class thrown when an API method is not supported or fails.
- getSidebarOptions(tabId?) [Chromium]
- getSidebarBehavior() [Chromium]
- canOpenSidebar()
- canCloseSidebar()
- openSidebar(options)
- closeSidebar(options)
- setSidebarOptions(options?) [Chromium]
- setSidebarBehavior(behavior?) [Chromium]
- isOpenSidebar(windowId?)
- toggleSidebar() [Firefox]
- setSidebarPath(path, tabId?)
- getSidebarPath(tabId?)
- setSidebarTitle(title, tabId?) [Firefox, Opera]
- setSidebarIcon(details) [Firefox, Opera]
- setSidebarBadgeText(text, tabId?) [Opera]
- clearSidebarBadgeText(tabId?) [Opera]
- setSidebarBadgeTextColor(color, tabId?) [Opera]
- setSidebarBadgeBgColor(color, tabId?) [Opera]
- getSidebarTitle(tabId?) [Firefox, Opera]
- getSidebarBadgeText(tabId?) [Opera]
- getSidebarBadgeTextColor(tabId?) [Opera]
- getSidebarBadgeBgColor(tabId?) [Opera]
getSidebarOptions(tabId?: number): Promise<chrome.sidePanel.PanelOptions>
Retrieves the side panel options (e.g., path) for the specified tab. Throws if the Side Panel API isn't supported (requires Chromium-based browsers like Chrome, Edge, or Opera MV3). [MV3]
getSidebarBehavior(): Promise<chrome.sidePanel.PanelBehavior>
Gets the current side panel behavior settings. Throws if unsupported (requires Chromium-based browsers like Chrome, Edge, or Opera MV3). [MV3]
canOpenSidebar(): boolean
Returns true if chrome.sidePanel (Chromium MV3) is available, or if sidebarAction.open is available (Firefox/Opera).
canCloseSidebar(): boolean
Returns true if chrome.sidePanel (Chromium MV3) is available, or if sidebarAction.close is available (Firefox/Opera).
openSidebar(options: chrome.sidePanel.OpenOptions): Promise<void>
Opens the side panel with the given options in Chromium-based browsers (MV3). Falls back to sidebarAction.open() in Firefox/Opera. Throws if unsupported.
closeSidebar(options: chrome.sidePanel.CloseOptions): Promise<void>
Closes the side panel with the given options in Chromium-based browsers (MV3). Falls back to sidebarAction.close() in Firefox/Opera. Throws if unsupported.
setSidebarOptions(options?: chrome.sidePanel.PanelOptions): Promise<void>
Sets side panel options (e.g., path) in Chromium-based browsers (MV3). Throws if unsupported. [MV3]
setSidebarBehavior(behavior?: chrome.sidePanel.PanelBehavior): Promise<void>
Updates default panel behavior in Chromium-based browsers (MV3). Throws if unsupported. [MV3]
setSidebarPath(path: string, tabId?: number): Promise<void>
Sets the sidebar path in Chromium-based browsers via setOptions (MV3) or via sidebarAction.setPanel() in Firefox/Opera. Throws if unsupported.
getSidebarPath(tabId?: number): Promise<string | undefined>
Retrieves the sidebar path from Chromium-based browsers (MV3) or parses from sidebarAction.getPanel() in Firefox/Opera. Throws if unsupported.
isOpenSidebar(windowId?: number): Promise<boolean>
Checks if the sidebar is open for the given window in Chromium-based browsers (MV3) using getContexts and in Firefox/Opera using sidebarAction.isOpen(). Throws if unsupported.
toggleSidebar(): Promise<void>
Toggles the sidebar in Firefox. Throws if unsupported.
setSidebarTitle(title: string | number, tabId?: number): Promise<void>
Sets the sidebar title via sidebarAction.setTitle() (Firefox/Opera). Throws if unsupported.
setSidebarIcon(details: opr.sidebarAction.IconDetails): Promise<void>
Sets the sidebar icon via sidebarAction.setIcon() (Firefox/Opera). Throws if unsupported.
Known issue (Opera): The
opr.sidebarAction.setIconAPI is currently broken and may fail with "Access to extension API denied". See: https://forums.opera.com/topic/75680/opr-sidebaraction-seticon-api-is-broken-access-to-extension-api-denied
setSidebarBadgeText(text: string | number, tabId?: number): Promise<void>
Sets the sidebar badge text via opr.sidebarAction.setBadgeText() (Opera only). Throws if unsupported.
clearSidebarBadgeText(tabId?: number): Promise<void>
Clears the sidebar badge text (equivalent to setting an empty string) via opr.sidebarAction.setBadgeText() (Opera only).
setSidebarBadgeTextColor(color: string | [number, number, number, number], tabId?: number): Promise<void>
Sets the sidebar badge text color via opr.sidebarAction.setBadgeTextColor() (Opera only). Throws if unsupported.
setSidebarBadgeBgColor(color: string | [number, number, number, number], tabId?: number): Promise<void>
Sets the sidebar badge background color via opr.sidebarAction.setBadgeBackgroundColor() (Opera only). Throws if unsupported.
getSidebarTitle(tabId?: number): Promise<string>
Gets the sidebar title via sidebarAction.getTitle() (Firefox/Opera). Throws if unsupported.
getSidebarBadgeText(tabId?: number): Promise<string>
Gets the sidebar badge text via opr.sidebarAction.getBadgeText() (Opera only). Throws if unsupported.
getSidebarBadgeTextColor(tabId?: number): Promise<[number, number, number, number]>
Gets the sidebar badge text color via opr.sidebarAction.getBadgeTextColor() (Opera only). Throws if unsupported.
getSidebarBadgeBgColor(tabId?: number): Promise<[number, number, number, number]>
Gets the sidebar badge background color via opr.sidebarAction.getBadgeBackgroundColor() (Opera only). Throws if unsupported.