Taking Advantage of Extensibility (my first Greasemonkey script)
Flickr: Love it, just starting to use it frequently.
Firefox: Love it, just starting to use it frequently.
Both Firefox and Flickr are extensible (via a web API and by extensions like Greasemonkey, respectively). As a user of Flickr, I realized there was a feature I'd like to have. So I built it using Greasemonkey.
The feature is "Show related tags" on the Flickr upload screen - when I'm uploading images, I'd like to see what other people are tagging similar things (for clarity, like "nyc" vs "newyork" - or for inclusion, like "cat", "kitty" and "kitten"). Well, now I can. I wrote a Greasemonkey script that inserts "Show related tags" into the upload page (
screenshot1). If you enter some tags, and click the link, the page will load up sets of related tags for you to browse and/or add by clicking (
screenshot2).
How does it work? Greasemonkey lets me inject script into any page (viewed in Firefox), and the script I injected is set up to fetch XML from Flickr's Web API, showing tags related to a chosen tag. It uses XmlHTTPRequest, Javascript & XML. (There's gotta be a catchy name for that technology somewhere.) The cool part is - cross-domain issues aren't an issue, since the host page and the XML both come from the same domain - 'flickr.com'.
How can you use this too? First, be a logged-in user of Flickr, Second, use Firefox, Third, make sure you have the
Greasemonkey extension
installed, Fourth, right-click on this link:
flickrelatedtags.user.js, and choose "Install User Script". Once that's done, navigate to
Flickr's upload page, and you should see the "See Related Tags" link show up below the "Add Tags" form field.
Please, feel free to send bugs, problems and/or suggestions
my way.
More about Greasemonkey
here and
here. More about Flickr's API
here. And another lovely app that uses Flickr's API to examine related tags is this
Flash Tag Browser.
5 Comments +
That's hands down the coolest grease monkey script I've seen to date. I'm going to go tell all my friends now.
Cool stuff, I searched for hours but couldn't find a name for that technology either;)
Just a note for people while most GreaseMonkey Scripts are pretty great so far, please take a moment to read the code to make sure their aren't any malicous lines of code. If you cant do this maybe find someone who can.
Totally seamless and absurdly cool.
Great stuff - thanks. I think the name you're looking for is Ajax (Asynchronous JavaScript+CSS+DOM+XMLHttpRequest). Here's a link:
Ajax: A New Approach to Web Applications
http://www.adaptivepath.com/publications/essays/archives/000385print.php
> The cool part is - cross-domain issues aren't an issue,
Incidentally, if you eventually find a situation where you need cross-domain ability (although I believe there is continuing discussion on the GreaseMonkey lists about how to handle this sort of thing), you might want to take a look at the "_XmlHttpRequestEx2" class here:
http://mygmaps.com/show/0.0.5/gmaps-standalone.jsIn tandem with a simple CGI script on a page's domain it allows XmlHttpRequest retrievals across domains.
I use it to provide a "standalone viewer" for Google Maps, and the custom maps created on
myGmaps.com. (Actually, it's not strictly necessary for the custom maps.)
--Phil.