Trac autologin Greasemonkey script

Written . Tagged Firefox, Greasemonkey, JavaScript.

I hate how Tracs never seem to remember your authorization. I usually need Trac right now for some new-sprung idea or a just-encountered bug, and having to log in again and again is a big bother.

To make this less annoying, I wrote a Trac autologin Greasemonkey script. The script works on Account Manager type logins (which covers e.g. DevjaVu and Rails Trac) and does this:

When you arrive at a Trac site, you’re sent to the log-in page. If Firefox has pre-populated the log-in form with a username and password, you’re logged in automatically and sent back whence you came. If the log-in form was not pre-populated, you’re presumed not to have an account and are just sent back.

If you explicitly log out by clicking the “Logout” link (i.e. you presumably don’t care to be logged in automatically for a while), or if you were assumed not to have an account, then the script won’t try to log you in automatically again until you restart your browser or visit the login page manually.

Obviously, if you’re running your own Trac installation, it’s better to just tweak that to keep session cookies around longer (and possibly remove expirations on the server side – I haven’t really looked into it).