Simon Willison’s Weblog


More fun with the monkey

17th September 2005

Cory Doctorow points to America from the Great Depression to World War II: Color Photographs from the FSA-OWI, 1939-1945, with the following observation:

Unfortunately, the organizational back-end for this is so primitive (especially in comparison with modern image-sharing and organizing sites like Flickr) that it, too, seems to hail from 1939-1945, making the site a real pain to navigate and use.

Thanks to Greasemonkey, great content spoiled by poor navigation is a solvable problem.

americanmemoryfixer.user.js includes the following improvements:

  • Changes the colour scheme to black-on-white, and the typeface to Verdana.
  • Removes all table borders.
  • Adds headings to some pages, and fixes various title tags.
  • Sets the default gallery view to be a set of thumbnails, rather than a list of names.
  • Displays a large image (as opposed to a thumbnail) when you view a photograph.

The scariest hack in the script is the way in which subject page titles are passed around. In the current site, if you visit a category page (such as Sharecroppers) the title of the category is not displayed on the page—even though it has been passed as a parameter in the URL. If you click a link (say to the Galley thumbnail page) the information in the URL is lost as well.

My solution was to extract the subject from the URL on that first page, then rewrite the other links to include an additional “&subject=Sharecroppers” parameter. This new parameter is ignored by the CGI scripts that power the site, but my Greasemonkey script watches out for it on subsequent pages and uses it to display a title (and further propagate it to other links on the page). It’s not a very robust solution, but it’s good enough.

There’s plenty of scope for further improvement—if you want to use my script as a starting point, please feel free.

This is More fun with the monkey by Simon Willison, posted on 17th September 2005.

Next: Working for Yahoo!

Previous: Firefox 1.5 developer highlights

Previously hosted at