The web is full of scripts that are "compressed" with all whitespace removed to make them download faster. Such scripts are hard to debug..
Note: this script is converted from PHP in a quick and messy way – apologies for any PHPisms, and for the variables that are still prefixed with a dollar sign. I've been using it for a while but I still find bugs and scripts that the formatter can not handle, so be prepared that there may still be some work to do.. Let's call it an alpha release 🙂
Update: two years later, the script now finds a home here