Greasemonkeying with IE

I’ve long been fascinated with Greasemonkey, the Firefox extension that hosts scripts for rewriting web pages to achieve a variety of effects. I’ve written a number of these scripts. One of my favorites was this version of LibraryLookup which orchestrates a trio of services: Amazon, the OCLC’s xISBN, and my local library’s catalog.

I think these kinds of lightweight, client-side service orchestrations are interesting and important, but they haven’t been accessible to very many people. Greasemonkey appeals only to a minority of those who use Firefox, who are themselves a minority of those who browse the web. Running Greasemonkey scripts in Internet Explorer would at least enable those scripts to reach a larger minority, so I’d been meaning to explore that option and I finally got around to it.

Here’s a picture of Firefox and IE running the same Greasemonkey script to do the same thing: Rewrite the Amazon page for my book to show that it’s available in the Keene Public Library.

In this case, the Greasemonkey support in IE is provided by Reify Software’s Turnabout. There have been several Greasemonkey-for-Internet-Explorer projects. This is the one that Chris Wilson recommended in my interview with him. What Chris particularly liked about this implementation was the fact that it comes in two versions: basic and advanced. If you download the basic version it only runs a small set of scripts that the Reify folks have blessed. You have to download the advanced version in order to be able to install other scripts, such as my LibraryLookup script.

I realize that relatively few IE users are likely to run Turnabout, just as relatively few Firefox users run Greasemonkey. But a small fraction of IE’s large share is still a healthy number, and I’d like to do what I can to encourage interesting, important, and of course safe and responsible uses of this technology.

Notes for adapters

If you want to adapt this script to work with another library that uses the Innovative catalog, like my Keene library does, it’s easy, just change this:

var libraryBaseURL = '';
var libraryName = 'Keene';

to, in the case of the Kings County libraries around Seattle:

var libraryBaseURL = '';
var libraryName = 'Kings County';

If you want to adapt this script to work with one of the other catalog systems supported by the LibraryLookup bookmarklet generator, you can use that page as a guide to forming the necessary queries. You’ll also need to inspect the responses to those queries for text that, when matched, indicates a successful query.

Notes for developers

Here’s what I learned when I converted my script so that it works identically in Greasemonkey and Firefox.

XPath. As noted on Turnabout’s page for developers, you can’t use XPath to perform structured searches of web pages. In the original script, I used Firefox’s XPath feature to locate the title of the book in the Amazon page, in order to be able to append a message to that title if the book turns out to be available in the library. In the new version I rely on more basic capabilities: searching the DOM (document object model) using the getElementsByTagName method, and then scanning the found subset for the element with a particular class name.

AddEventListener. In the original script I used this advanced feature to asynchronously notify my script that the call to the OCLC’s xISBN service had completed. The feature unsupported in IE. In this particular case, though, my use of it was gratuitous, and made my script more complicated than it needed to be. Why’d I do that? I think the idea was simply to explore what was possible with AddEventListener. In any event, Greasemonkey’s encapsulation of the core AJAX component, XMLHTTPRequest, was all that was really needed. And Turnabout emulates that same encapsulation.

Redirection. There was one glitch with Turnabout’s GM_xmlhttpRequest, however. The original URL I was using for the OCLC xISBN service was That URL now redirects to, but Turnabout doesn’t follow the redirect so I had to encode the latter URL in the script to make it work in both browsers.

Debugging. Reify’s page for developers points to the Microsoft Script Debugger. I installed it, and I’m able to debug other scripts using it, but haven’t figured out how to get it to debug Turnabout scripts.

Posted in .

15 thoughts on “Greasemonkeying with IE

  1. I wonder if the percentage of IE+Turnabout users will rival the the percentage of Firefox+Greasemonkey users. I bet not. Firefox users are already early adopters/geeks, so I’m not sure a non-geek using IE (the default browser) is likely to use Turnabout any more than Firefox+Greasemonkey.

  2. “I’m not sure a non-geek using IE (the default browser) is likely to use Turnabout any more than Firefox+Greasemonkey.”

    Not until/unless there are safe and responsible uses of the technology that come to be seen as interesting and important.

  3. You might be interested in IE7Pro, — a user scripting plugin for IE 6 onwards, which seems to have a live and bustling user community growing around it. It seemably also has much functionality of its own straying from the Greasemonkey path. I tried doing a brief summary outline of my little insights so far (as another standards advocate minding the cross-browser user scripting experience) at

  4. Pingback: Neil McAllister
  5. I’m trying to decide between recommending people to use IE7Pro or Turnabout for using Greasemonkey with IE.

    So far is sadly looks like IE7Pro hasn’t tried very hard to make it easy for GM scripts to plug-and-play. I’m going to have to give Turnabout a try.

  6. Pingback: health

Leave a Reply