Google Calendar Hack and Notes

Hack Zero : Class and Function Reference

If you want to start hacking Google Calendar you might want to look at the Google Calendar Class and Function Reference.

Hack One : Gimme another date picker

Missing the ability to show more than one month in the navigation bar date picker? Simply add another with the AddCal bookmarklet. (Only tested in FF. Very brittle. Making it into a GreaseMonkey script is left as an exercise for the reader.)

Hack Two : Event storage

From initial investigation it looks like for version 20060413030129 of the code event information is stored in an array named lb. This array contains event (display?) objects of the class ib.

The actual event class seems to be named Aa.

If you have the JavaScript Shell (or similar) installed, running this piece of code:

for (x in lb) {var i=lb[x].e; print(i.text + " " + i.start + " " + i.end)}
will produce a list of the event items' text and start/end times. e.g.:
Foo immediately 20060415T073000 20060415T083000
Foo then. 20060415T090000 20060415T100000

Events also seem to be stored in an object Y and you can retrieve a specific event by supplying its event id to the method _byEid().

Hack Three : "Make Event Reminder Button" Bookmarklet

If you don't feel inclined to follow the Instructions for making Google Calendar event reminder buttons (or re-enter information for the Calendar Event URL Generator) then you might want to drag this bookmarklet to your bookmark bar:
Make Event Reminder Button Bookmarklet

Instructions for use:

  1. Drag the bookmarklet above to your bookmark bar.
  2. In Google Calendar, create the event for which you want the reminder button.
  3. Click on the event's linked text in planner view (or edit the event details).
  4. Click on the bookmarklet, a "code window" should appear in the page.
  5. Copy the displayed HTML to your page.
  6. Close the "code window".

Your web page or blog should now display a button like this:

(Obviously your button won't remind you to attend May's The Valley in Christchurch meeting. But you if live in Christchurch, New Zealand you should probably go.)

I haven't tried to minimise the size of the bookmarklet so it may not work in IE--I've only tested it in Firefox.

Hack Four : QuickAdd bookmarklet (incomplete)

In regards to a "QuickAdd" bookmarklet, I think I have the two halves of the equation working:

http://www.google.com/calendar/compose?ctext=Dinner%20with%20Michael%207pm%20tomorrow

will return this (thus parsing the sentence):
[['_SpawnQuickAddEvent','Dinner with Michael','','','20060416T190000','????????T??????',[],'',null,[],[]]]

While this:

http://www.google.com/calendar/event?text=Dinner%20with%20Michael%207pm%20tomorrow&pprop=HowCreated%3AQUICKADD&action=TEMPLATE
will return a pre-populated "edit event page".

So, the latter will be enough for a Firefox-style keyword add (with no "intelligent" parsing) but the former still needs to routed via a compose request.

It may not take much to hack this up in GreaseMonkey, but I'll continue looking at the bookmarklet approach.

Update 1: If you want to look into the QuickAdd code it's in functions like Mp (Callback for the XHR request), Dl (Parses response text), Hn (Creates "compose" post and sends it), ir (Handles date/time formatting?), ql (Constructs most of "compose" post).


Remember kiddies, it's probably in your best interest to use and support open standards and free/open source software. </psa>

a_google_ate_my_baby@rancidbacon.com