American in Spain

Flickr Link Preview - A Greasemonkey Script

December 28, 2008

I've had this idea for a Greasemonkey script for a while. It seemed to me like, using the extensive Flickr API, I should be able to write a script that shows me a thumbnail of an image that was linked to in Flickr. When someone says, "Check out thesephotosonFlickr," with text hyperlinks, I'd like to be able to see what those pictures are without going all the way to Flickr. In my research into this goal, I discovered two reasons why my goal is unattainable using pure javascript:

  1. Due to very reasonable security restrictions on AJAX calls, a script running on this page, for example, cannot communicate with Flickr via an XMLHttpRequest.
  2. Even if I could get around #1, I would have to include my personal Flickr API key and secret in plain text in the javascript file. This is not only a bad idea, but against Flickr's Terms of Service.

The result is that the script must use a cross-site scripting technique to send information to a PHP program running on a server I host, which sends the request to Flickr and returns the remaining part of the script that knows what to do with the information from Flickr.

Video Demonstration

How do I get it?

Well, first you'll have to install Greasemonkey Firefox plugin. Then you can go to http://userscripts.org/scripts/show/39390 and click the Install button. That's it!

Enjoy.