Stuff like this has been available for add-on authors for a while,
https://developer.mozilla.org/en-US/Add-ons/Code_snippets/In...
Remember, the browser chrome/front-end for Firefox and add-ons is implemented using Web technologies (XUL, JavaScript and CSS) with more or less privileges.
Edit: Fun tip: Choose the Hamburger menu -> DevTools (wrench icon) -> Browser Toolbox and inspect the chrome document like you inspect a web document.