Greasemonkey as a lightweight intermediary
30th March 2005
In The architecture of intermediation, Jon Udell discusses the need for a mechanism for a high-level tool for adding custom features to web applications. In Jon’s case, he wants to add a private bookmarks feature to del.icio.us. Jon thought about using a web proxy to intercept and modify del.icio.us pages, but ruled it out as too low-level.
Jon, you need Greasemonkey.
The latest release of the swiss army knife of Firefox extensions adds support for cross-domain XMLHttpRequest calls from greasemonkey scripts. What that means is that you can create a user script (a short JavaScript that will be executed whenever your browser loads specific pages) that can then pull extra data in from another server. This new ability is described in the greasemonkey documentation.
I’m using this for my final year project, a decentralised web annotation system that lets you annotate pages, storing your annotations locally and then sharing your public annotations as a feed (similar to the way RSS aggregators work). The trick there is to run a local web server on some port, then have the Greasemonkey user script (eventually a full extension) communicate with that local server to store and retrieve data. I’m using Ruby on Rails’ built in WEBrick server to prototype the service, and it’s working a treat.
This architecture could be easily adapted to add private bookmarks to del.icio.us—or to add any number of cool features to any number of other sites. Here’s another example: Google’s Desktop Search integrates results from your local drive with the search results page on Google. Using greasemonkey and a local web server tied in to OS X Tiger’s Spotlight indexer, you could add this functionality to any search site you wanted to. Just be sure to lock down the web server to only serve requests from localhost, to avoid sharing search results for your data with anyone on the network who can see your machine.
When people asked me what I was excited about at SxSW, one of my answers was Greasemonkey. This kind of stuff is the reason why.
More recent articles
- Weeknotes: Llama 3, AI for Data Journalism, llm-evals and datasette-secrets - 23rd April 2024
- Options for accessing Llama 3 from the terminal using LLM - 22nd April 2024
- AI for Data Journalism: demonstrating what we can do with this stuff right now - 17th April 2024
- Three major LLM releases in 24 hours (plus weeknotes) - 10th April 2024
- Building files-to-prompt entirely using Claude 3 Opus - 8th April 2024
- Running OCR against PDFs and images directly in your browser - 30th March 2024
- llm cmd undo last git commit - a new plugin for LLM - 26th March 2024
- Building and testing C extensions for SQLite with ChatGPT Code Interpreter - 23rd March 2024
- Claude and ChatGPT for ad-hoc sidequests - 22nd March 2024
- Weeknotes: the aftermath of NICAR - 16th March 2024