LibraryLookup for the San Francisco Public Library

Update 2017: Newer versions of Chrome require all extensions to be installed from the Google Chrome store. I forgot to update this site, but I’ve actually had it up there for some time now. You can install it here.

Update: I’ve written a new version of the script that works with Google’s Chrome browser. To install it, simply click this link. You do not need GreaseMonkey to get LibraryLookup working on Chrome. Note that LibraryLookup uses cross-site scripting, so it must run as a Background Page in Chrome. That means it’s running all of the time, even when you’re not browsing Amazon. It shouldn’t consume any significant resources, but it is there nonetheless. Note, also, that the Chrome version is a substantial rewrite from the Firefox version, so I’m particularly interested to hear any bug reports.

My former colleague at InfoWorld, Jon Udell, came up with a really clever JavaScript hack for avid readers who use Firefox,* called LibraryLookup. It cross-references product pages at Amazon.com with the catalog systems of public libraries. If the book you’re looking at on Amazon is available at the library, the script inserts a little notification in the header of the Web page, like so:

Jon originally wrote the script for the libraries in his hometown of Keene, New Hampshire, but his original idea has since been modified to work with the libraries of communities across the globe. I never found a good version for San Francisco, though, so I hacked together my own version to work with the SFPL’s unique quirks.

Installation
To get my version of the script working, you first need to install the latest version of the Greasemonkey add-on for Firefox. This allows the script to run automatically whenever you load an Amazon page.

With Greasemonkey installed, you should be able to click the following link to automatically install the LibraryLookup script for San Francisco public libraries. It should begin working immediately.

Note that the script is keyed off ISBN numbers. There is a unique ISBN for each edition of a book; so if you’re looking at the paperback version of a book on Amazon, try checking the hardcover version too. Libraries are more likely to stock hardcover editions, if available. (Earlier versions of the script tried to do this cross-checking for you, but I found they yielded too many false positives.)

The script isn’t perfect. It doesn’t sort the due dates on checked-out copies of books, for example, so you’re not always given the earliest date that a copy of a book will be back on a shelf. It also doesn’t understand books that are available for library use only. But in general, it should work most of the time. Take it for a spin and let me know if it’s useful to you.

Change Log
(27 November 2018) Another update to adjust to Amazon’s latest HTML layout. Also, library catalog windows now open in a new tab. For some time now, the Chrome version has been the only one I’ve maintained, and per Google’s current rules, the only place to get it is from the Chrome Web Store.

(24 July 2011) Added a version for the Google Chrome browser. This version is a substantially different code base and will need to be developed in parallel with the Firefox version as any further changes are made.

(12 Oct 2008) Version 1.5 now checks for books that are on order at the library but have not yet arrived. Also, clicking on the library link now sends you over to the more user-friendly search results page, even though the actual queries are still carried out using the advanced search. I removed the XISBN functionality; it’s a nice idea, but in practice it was returning far too many false positives and inconsistent results. Finally (and perhaps most importantly), I went ahead and did a thorough clean-up of the source code, getting rid of the unorthodox and inconsistent indentation and eliminating unused code.

(1 May 2008) Version 1.3 should now work with Firefox versions 2 and 3.

(2 April 2008) Version 1.2 uses a more complex query, which should return results for all of the branch libraries, instead of just the first few.

One thought on “LibraryLookup for the San Francisco Public Library

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.