I need the toolbar button to execute my custom JavaScript code in Firefox. Currently I just copy-paste this JS into console, but it is annoying. What is the best way to create such button?
Use a https://en.wikipedia.org/wiki/Bookmarklet.
Example - create a shortcut to any site on in your browser and replace the URL address with similar code:
javascript:(function(){ alert('Hello!'); })();