Possible to add to menu in foreground script

I am pretty sure that you can only add a menu item to the “Edit” menu in a background script, but just want to confirm.

You mean in the Menu bar? I would say it’s not possible at all.
There is API only for context menus:

Yes, in the menu bar.

Oh, so extensions can’t add to the menu bar at all?
Did not know that since the old format extensions could.

Yes, the old extensions could do anything :smiley:, but that was also the problem causing compatibility issues between extensions and also browser.

Now the API is more restricted, but it has many other advantages.

Here is the list of all available API:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs

good reference. thanks

You can add items to the tools menu though: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/menus/create

Further, https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts#Content_script_environment lists all APIs available in “foreground” scripts, which we usually call content scripts. If you meant a script loaded in an extension page, then it has all the APIs.

I just looked quickly at your 2 links.
It sounds like it is not possible
" Note though that it’s not possible to create tools menu items ( contexts: ["tools_menu"] ) using the contextMenus namespace."

It’s not possible using browser.contextMenus, but browser.menus works.