My first Greasemonkey Script

flickr_logo_gammaIt’s been years since I did any Javascript programing, but I had a simple problem and decided to dive into it.

Like many of the little programs I write, I had a “problem” and wanted to solve it. I wanted a convenient link on the photo page to cut and paste the short URL of FLickr Images.  Look at this URL for a nice photo my wife took:

http://www.flickr.com/photos/s_d/3665619548/

As a URL goes, not too bad, but suppose you wanted to insert the link in
Twitter or Facebook? It’s a little verbose.  Wouldn’t this be better?

http://flic.kr/p/6zVfZ3

Yep, I think so too and so does Flickr:
http://www.flickr.com/services/api/misc.urls.html#short
http://www.flickr.com/groups/api/discuss/72157616713786392/
This thread showed how to do it: http://www.flickr.com/groups/api/discuss/72157616713786392/

The FlickrBase58 function in the script was written entirely by ‘Xenocryst @ Antares Scorpii’
http://www.flickr.com/people/antares/

Other than reformating, taken verbatim from link here
http://www.flickr.com/groups/api/discuss/72157616713786392/72157620673064673/

The Original way *I* wrote it was to retrieve the HTML, Parse it for
<link rev=”canonical” type=”text/html” src=”//flic.kr/p/6zVfZ3″ >

And use that link. While fun to write, that’s the wrong way to do it so I rewrote it to use the function written by ‘Xenocryst @ Antares Scorpii’ .  When installed on Firefox running the Greasemonkey extension, it will insert a link on the page on the right side just under “Flag your photo” that says:

The Flic.kr link is: http://flic.kr/p/6zVfZ3

This will allow you to right click the URL, copy it and paste into Twitter or Facebook.

Here is the script.

NOTE: I’m pretty certain it’s harmless, but use at your own risk. It’s hardly great programming and I’m sure someone else would have done it too, if not better.

Music I’m listening to right Now:
Paralyzer ” by Finger Eleven from the “Them VS. You VS. Me” Album.

4 responses to “My first Greasemonkey Script

  1. Stefan, the “@namespace” you provided in the script does not link to (http://www.epyon-1.com/gm/) does not work. Maybe you should link it to a redirect to this posting.

    • Well, the namespace is typically used to differentiate scripts with the same name but by different authors. In this case, the namespace is used to show where to get it from. See here at “Dive into Greasemonkey”.
      😉

  2. Is there a way to get a link similar to this to go to a Set or a Collection?

    Or does the site just not work that way?

  3. Well, I’ve played with it a bit and so far, it looks like nope.
    😉