Val Schuman
Val Schuman

Reputation: 1818

How to control order of extension item in Chrome context menu

Is there a way to control the order that my Chrome extension's context menu item appears in?

It probably can't appear above any of the Chrome's built in context menu items (like "Open link in new tab", etc.), but maybe there is a way to control where it appears among other extensions' context menu entries?

Probably not, because in all likelihood all makers of extensions want their's to be above all others, but just in case I'm wrong.. :)

Upvotes: 5

Views: 3239

Answers (2)

Flak DiNenno
Flak DiNenno

Reputation: 2352

The accepted answer is only partially correct:

When you create multiple context menus(items) in your extension, and their contexts are set, such that they appear simultaneously, then the order in which they appear in the menu is dependent on the order in which the items(menus) are created.

Therefore, you can control order, by being mindful of not only the order you create them in, but then setting the contexts parameter to hide them upon creation, then display them when needed using chrome.contextMenus.update() with a different contexts value... this will give the appearance of inserting menus and/or moving them around if done properly.

Upvotes: 2

Some Guy
Some Guy

Reputation: 16210

The context menu entries are ordered alphabetically. This means that if you name your context entry something like AAWhatever, the likelihood of your entry being at the top is pretty high. I know of no other way to control the position of your entry using only your extension.

Upvotes: 3

Related Questions