Zipcar Greasemonkey Script

23:32 Sat 10 Feb 2007. Updated: 23:21 11 Feb 2007
[, , ]

I made a Greasemonkey script that shows you more cars per reservation page than the measly 5 that Zipcar gives you.

This is the first thing I mentioned in Improving Zipcar’s User Interface. I’ll have to email them to suggest that they give the user the option of seeing more cars at once. I like their “search by time” function, but it’s not their default page, it’s fairly slow itself, and it doesn’t let you scan over approximate time and approximate location, which is often what you need.

This user script attempts to fill that need. It grabs n more pages, where n can be changed in the script, but I have it set to 2, for a total of 15 cars. So you get to see on one page the cars you would normally have to click “more cars” (twice) to see. All of the functionality works, i.e. you can click on a chunk of free time and have that time set in the reservation form below the main table.

It’s not that fast, though, and most likely you’ll notice a slight lag as it loads each extra set of cars. But you can start using the page before it’s finished (if you really want to), and it’s a lot quicker than actually clicking on the “more cars” link.

In addition, when you do click on “more cars”, it will bring you to the first page with cars you haven’t seen reservations for yet.

I suspect I’ll find this rather useful; I hope other Zipcar users do too. I learned a lot of interesting things while writing it, such as that Greasemonkey’s XPCNativeWrapper approach limited me significantly until I started using its wrappedJSObject functionality. If you do e.g. var myElement = document.getElementById(“someID”) within a Greasemonkey script, it won’t actually give you that element, but rather a “wrapper” around it, as a security measure. That’s enough for a lot of things, but (unless I’m missing something) in order to access a lot of properties I needed, I had to access the object within, e.g. myElement.wrappedJSObject.someProperty instead of myElement.someProperty.

I also needed to use the unsafeWindow object in order to give Greasemonkey access to the scripts on the page itself, because otherwise I couldn’t give the imported table cells event handlers which called the same functions as the original table cells. That was fairly weird, because you would have event handlers that appeared to be calling the same function (h_click, one of the functions that Zipcar has on the page, in this case) but were in fact calling separate functions, one behind in the Greasemonkey domain and one in the page domain—and since the Greasemonkey domain didn’t have a h_click function, the event handlers would fail. (The alternative to using unsafeWindow was to create my own clone of h_click and put it in the Greasemonkey user script itself.)

Once again, I love the fact that I’m able to significantly enhance their UI for my purposes without having any access to their source code, their developers, their server, or their database—just my browser.

The ZipcarMoreCars script.

Without the script:
Before: 5 Cars

With the script:
After: 15 Cars

Leave a Reply