use oncommand to menuitem Rated 3 out of 5 stars

menuitem.onclick=function(){ ... }
menuitem.setAttribute('oncommand', 'this.onclick();');

This review is for a previous version of the add-on (2.0.0).