It's called bootstrap addon. Search my _ff-addon-template files at my gists on github:
https://gist.github.com/search?q=%40Noitidart+addon
You'll probably be interested in: _ff-addon-template-BootstrapWatchHostEventListenerInjectFiles.xpi
which watches sites load then do stuff with them on load. basic bootstrap skeleton: https://gist.github.com/Noitidart/9025999