Skip to content

Latest commit

 

History

History
87 lines (56 loc) · 2.02 KB

File metadata and controls

87 lines (56 loc) · 2.02 KB

contextMenus

Documentation: Chrome Context Menus API

A promise-based wrapper for the Chrome contextMenus API.

Methods

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.

createOrUpdateContextMenu

createOrUpdateContextMenu(
  id: string | number,
  properties: Omit<chrome.contextMenus.CreateProperties, "id">
): Promise<void>

Tries to create a context menu item. If it already exists (e.g., after service worker wake up), it updates the existing item instead.

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. Returns an unsubscribe function.