Instead of trying to fix the bugs, maybe you should look at what I think would be better tools for accomplishing the job:
* PhantomJS[1] (with or without the facilitator CasperJS[2]) -- in fact I'm kinda motivated to write a script myself using CasperJS to save my communities, now that you remembered me they are there waiting to be saved;
* Selenium[3] (I never looked at this, but it seems interesting as it holds the slogan "Browser Automation").
[2]: http://casperjs.org/