webext-tools
Advanced tools
| export type ClickListener = (data: chrome.contextMenus.OnClickData, tab: chrome.tabs.Tab) => void; | ||
| /** Throws an error due to misconfiguration, unless misconfiguration can't be verified (Firefox cleans the manifest of unknown properties) */ | ||
| export declare function notifyOfMissingPermissions(): void; | ||
| export default function createContextMenu(settings: Omit<chrome.contextMenus.CreateProperties, 'contexts'> & { | ||
@@ -3,0 +5,0 @@ id: string; |
@@ -10,4 +10,8 @@ import chromeP from 'webext-polyfill-kinda'; | ||
| } | ||
| /* Throws an error due to misconfiguration, unless misconfiguration can't be verified (Firefox cleans the manifest of unknown properties) */ | ||
| function warnOrThrow() { | ||
| /** Throws an error due to misconfiguration, unless misconfiguration can't be verified (Firefox cleans the manifest of unknown properties) */ | ||
| export function notifyOfMissingPermissions() { | ||
| // Internal check before warning | ||
| if (chrome.contextMenus) { | ||
| return; | ||
| } | ||
| const manifest = chrome.runtime.getManifest(); | ||
@@ -27,3 +31,3 @@ if (!manifest.permissions?.includes('contextMenus') | ||
| if (!chrome.contextMenus) { | ||
| warnOrThrow(); | ||
| notifyOfMissingPermissions(); | ||
| return; | ||
@@ -30,0 +34,0 @@ } |
+1
-1
| { | ||
| "name": "webext-tools", | ||
| "version": "4.0.2", | ||
| "version": "4.1.0", | ||
| "description": "Utility functions for Web Extensions", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
13860
2.44%217
2.84%