Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.. :)

like image 248
Val Schuman Avatar asked Dec 10 '11 06:12

Val Schuman


2 Answers

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.

like image 157
Some Guy Avatar answered Nov 01 '22 08:11

Some Guy


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.

like image 35
Flak DiNenno Avatar answered Nov 01 '22 08:11

Flak DiNenno