So I recently switched from Bloglines over to the newly-redesigned Google Reader. I miss having email subscriptions, but Google reader is so much better in other ways that it's totally worth it.
Being who I am, it wasn't long before I figured out how to write a greasemonkey script to do much the same thing as I already did for bloglines. Google (being the cunning folks that they are) don't make it easy. Their javascript code is immense, and it's clearly been run through a compressor which strips out any verbosity (and meaning) in the code - all variables are random sequences of one or two characters, and there are no comments or formatting.
But I managed, eventually. The problem is now that every time google makes the slightest change to their code, the variable and function names all jump around again, and I have to re-do my script. This is incredibly frustrating. Does anyone know how people got around this when making gmail greasemonkey extensions?
Update: Huzzah, I got it working :)





4 Comments:
Your script sounds interesting. Is it posted anywhere? As for dealing with our ever-changing JavaScript, I posted about this on our blog:
http://googlereader.blogspot.com/2005/11/warning-geekery-ahead.html
It basically boils down to using the DOM instead of the JavaScript to manipulate Reader. In the case of unread counts, you should be able to get them from the text of the subscriptions tree.
Mihai Parparita
Google Reader Engineer
Hi Mihai,
I've updated the post with a link to the current version of the script.
I initially tried to use the DOM, but the problem was that when greasemonkey executes, nothing of importance is actually loaded into the DOM yet. Is there some concrete event I can latch onto which will trigger whenever the subscription list changes?
(and if so, how? I don't have much experience with javascript event-based stuff :/)
You may be able to use CSS and XBL to attach yourself to the unread count nodes and update the styles of their ancestor nodes. I did this for my Gmail Filter hack:
http://persistent.info/archives/2006/04/23/gmail-filter
Cheers, I'll have to take a look at this XBL stuff sometime then...