let toolbarButtons = document.getElementsByTagName('toolbarbutton'); let toolbarButtonCompletions = []; for (i = 0; i < toolbarButtons.length; i++) { if (toolbarButtons[i].id) toolbarButtonCompletions.push([toolbarButtons[i].id, toolbarButtons[i].label]); } commands.addUserCommand( ['toolbarButton'], 'Simulate a click event on a toolbar button', function (args) { document.getElementById(args.string).click(); },{ completer: function (context, args) { context.title = ['id', 'label']; context.completions = toolbarButtonCompletions; } }, true);