Program Firefox from outside
Yesterday I found a very interesting Firefox add-on called MozRepl. After installing it, you should start and activate it. Then you can connect via telnet through this module to your Firefox instance and you can program it from inside.
For instance, you want to query the number of tabs:
$ telnet localhost 4242 Trying 127.0.0.1... Connected to localhost. ... repl> gBrowser.tabContainer.childNodes.length 337 repl> repl.quit() Connection closed by foreign host. $
See this previous post some examples how to control Firefox from a Python script.
List of useful operations