Skip to content

Latest commit

 

History

History
265 lines (167 loc) · 7.88 KB

File metadata and controls

265 lines (167 loc) · 7.88 KB

sidebar

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.

Classes

SidebarError

Custom error class thrown when an API method is not supported or fails.

Methods


getSidebarOptions [Chromium]

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 [Chromium]

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

canOpenSidebar(): boolean

Returns true if chrome.sidePanel (Chromium MV3) is available, or if sidebarAction.open is available (Firefox/Opera).

canCloseSidebar

canCloseSidebar(): boolean

Returns true if chrome.sidePanel (Chromium MV3) is available, or if sidebarAction.close is available (Firefox/Opera).

openSidebar

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

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 [Chromium]

setSidebarOptions(options?: chrome.sidePanel.PanelOptions): Promise<void>

Sets side panel options (e.g., path) in Chromium-based browsers (MV3). Throws if unsupported. [MV3]

setSidebarBehavior [Chromium]

setSidebarBehavior(behavior?: chrome.sidePanel.PanelBehavior): Promise<void>

Updates default panel behavior in Chromium-based browsers (MV3). Throws if unsupported. [MV3]

setSidebarPath

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

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

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 [Firefox]

toggleSidebar(): Promise<void>

Toggles the sidebar in Firefox. Throws if unsupported.

setSidebarTitle [Firefox, Opera]

setSidebarTitle(title: string | number, tabId?: number): Promise<void>

Sets the sidebar title via sidebarAction.setTitle() (Firefox/Opera). Throws if unsupported.

setSidebarIcon [Firefox, Opera]

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.setIcon API 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 [Opera]

setSidebarBadgeText(text: string | number, tabId?: number): Promise<void>

Sets the sidebar badge text via opr.sidebarAction.setBadgeText() (Opera only). Throws if unsupported.

clearSidebarBadgeText [Opera]

clearSidebarBadgeText(tabId?: number): Promise<void>

Clears the sidebar badge text (equivalent to setting an empty string) via opr.sidebarAction.setBadgeText() (Opera only).

setSidebarBadgeTextColor [Opera]

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 [Opera]

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 [Firefox, Opera]

getSidebarTitle(tabId?: number): Promise<string>

Gets the sidebar title via sidebarAction.getTitle() (Firefox/Opera). Throws if unsupported.

getSidebarBadgeText [Opera]

getSidebarBadgeText(tabId?: number): Promise<string>

Gets the sidebar badge text via opr.sidebarAction.getBadgeText() (Opera only). Throws if unsupported.

getSidebarBadgeTextColor [Opera]

getSidebarBadgeTextColor(tabId?: number): Promise<[number, number, number, number]>

Gets the sidebar badge text color via opr.sidebarAction.getBadgeTextColor() (Opera only). Throws if unsupported.

getSidebarBadgeBgColor [Opera]

getSidebarBadgeBgColor(tabId?: number): Promise<[number, number, number, number]>

Gets the sidebar badge background color via opr.sidebarAction.getBadgeBackgroundColor() (Opera only). Throws if unsupported.