Build your own Firefox extension

http://webmonkey.com/webmonkey/06/25/index3a.html?tw=programming

There's also two other guides that the above points to. One at Born Geek, and another at XUL Planet.