Documentation: Chrome Context Menus API
A promise-based wrapper for the Chrome contextMenus API.
- createContextMenus(createProperties?)
- removeContextMenus(menuItemId)
- removeAllContextMenus()
- updateContextMenus(id, updateProperties?)
- createOrUpdateContextMenu(id, properties)
createContextMenus(createProperties?: chrome.contextMenus.CreateProperties): Promise<void>
Creates a new context menu item with the specified properties.
removeContextMenus(menuItemId: string | number): Promise<void>
Removes the context menu item with the given ID.
removeAllContextMenus(): Promise<void>
Removes all context menu items added by the extension.
updateContextMenus(
id: string | number,
updateProperties?: Omit<chrome.contextMenus.CreateProperties, "id">
): Promise<void>
Updates the specified context menu item with new properties.
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(
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.