If you want to make a program for this, you can use the greasemonkey script and the local PHP server.
The Greasemonkey script will pick up chats when you visit them, parse them and send them to a local PHP server, which can then dump it to TXT, SQL, whatever.
Contact me if you want to help, it may be interesting to me, although I will be on vacation in the next months :)
source share