I'm currently working on an extension that adds a new menu item which allows for easy access to extension actions. For that I'm creating a new menu with some submenus, add it to the mainMenuItems array, sort the array and force a refresh:
Code: Select all
let newMenu = {
action: {
title: function () {
return _('&Extensions');
},
visible: !webApp,
submenu: _this.menu
},
order: 55,
grouporder: 10,
}
window.mainMenuItems.push(newMenu);
window.mainMenuItems = window.mainMenuItems.sort((a,b) => a.order > b.order);
uitools.switchMainMenu(false);
uitools.switchMainMenu(true);
Code: Select all
window.mainMenuItems
(9) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0: {action: {…}, order: 10, grouporder: 10, identifier: 1}
1: {action: {…}, order: 20, grouporder: 10, identifier: 8}
2: {action: {…}, order: 30, grouporder: 10, identifier: 22}
3: {action: {…}, order: 40, grouporder: 10, identifier: 39}
4: {action: {…}, order: 50, grouporder: 10, identifier: 66}
5: {action: {…}, order: 60, grouporder: 10, identifier: 81}
6: {action: {…}, identifier: 82}
7: {action: {…}, order: 55, grouporder: 10}
8: {action: {…}, order: 100, grouporder: 10, identifier: 85}
length: 9
__proto__: Array(0)
window.mainMenuItems[6].action
{title: "MediaMonkey Gold", visible: ƒ, submenu: Array(2), order: 70, grouporder: 10}
Is this a bug or is there a different method for extensions to add a main menu item?
Update: I just noticed that the mediamonkey gold item is generally a bit different from the other ones. Its title property contains a plain string instead of returning the title via function as the other items do.