Nice hack. I tend to use Phantom.js for such fun and games (headless version of webkit) – this this requires much less set up! 🙂