Skip to content

Commit

Permalink
Drop addOptionsContextMenu
Browse files Browse the repository at this point in the history
It will be moved to `webext-bugs`
  • Loading branch information
fregante committed Jan 21, 2025
1 parent 1fb6aaf commit b165f5e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 38 deletions.
25 changes: 0 additions & 25 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import chromeP from 'webext-polyfill-kinda';
import {executeFunction} from 'webext-content-scripts';
import {isChrome} from 'webext-detect';

export type Target = {
tabId: number;
Expand Down Expand Up @@ -102,27 +101,3 @@ function onContextMenuClick({menuItemId}: chrome.contextMenus.OnClickData): void
void chrome.runtime.openOptionsPage();
}
}

export function addOptionsContextMenu(): void {
if (isChrome()) {
return;
}

if (!(chrome.action ?? chrome.browserAction)) {
console.warn('Add `action` or `browser_action` to your manifest to enable `addOptionsContextMenu`.');
return;
}

if (!chrome.contextMenus) {
// Silently ignore if the API is not available, like in Firefox Android
// https://github.com/fregante/webext-permission-toggle/pull/53
return;
}

chrome.contextMenus.onClicked.addListener(onContextMenuClick);
chrome.contextMenus.create({
id: optionsShortcut,
title: 'Options…',
contexts: 'action' in chrome ? ['action'] : ['browser_action'],
});
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
},
"dependencies": {
"webext-content-scripts": "^2.7.0",
"webext-detect": "^5.0.2",
"webext-polyfill-kinda": "^1.0.2"
},
"devDependencies": {
Expand Down
12 changes: 0 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ npm install webext-tools
// This module is only offered as a ES Module
import {
getTabUrl,
addOptionsContextMenu,
} from 'webext-tools';
```

Expand Down Expand Up @@ -85,17 +84,6 @@ setActionPopup(tabUrl => {
})
```

### `addOptionsContextMenu()`

Chrome lets user reach the options via browser action context menu. However in Safari and Firefox you need a few more clicks to reach it.

This helper will automatically add an "Options…" menu item to the browser action context menu to both Safari and Firefox. Nothing happens in Chrome.

Requirements:

- `action` or `browser_action` specified in your manifest.json
- `contextMenu` permission

## Related

- [webext-content-scripts](https://github.com/fregante/webext-content-scripts) - Utility functions to inject content scripts in WebExtensions.
Expand Down

0 comments on commit b165f5e

Please sign in to comment.