UNPKG

@mirawision/chrome-api

Version:

A comprehensive TypeScript library for Chrome Extension API, providing type-safe wrappers and utilities for bookmarks, commands, context menus, cookies, downloads, storage, notifications, runtime, scripting, and side panel functionalities.

23 lines (22 loc) 1.05 kB
/// <reference types="chrome" /> /** * A class that provides a type-safe wrapper around Chrome's context menu API. * This class allows you to create context menu items and handle their click events. * Context menus appear when users right-click in your extension's allowed contexts. */ declare class ContextMenu { /** * Creates a new context menu item. * @param id - Unique identifier for the menu item * @param title - Text to be displayed in the menu * @param contexts - Array of contexts where the menu item will appear (defaults to ['page']) */ static create(id: string, title: string, contexts?: chrome.contextMenus.CreateProperties['contexts']): void; /** * Adds a listener for context menu item clicks. * @param callback - Function called when a menu item is clicked * @returns A function that removes the listener when called */ static addClickListener(callback: (info: chrome.contextMenus.OnClickData, tab?: chrome.tabs.Tab) => void): () => void; } export { ContextMenu };