Andy Delcambre
Software Engineer at GitHub. Ruby programmer. Photographer.

RubyURL Bookmarklet - Now with Google Maps Support07 Nov 2007

I use RubyURL fairly extensively for linking to long urls. It was written internally here at PLANET ARGON by Chris Griffin and Robby Russell.

The RubyURL bookmarklet is a god send, want to link somewhere that has a long url? Just click the RubyURL this link button and copy the address, the problem that I had is that it didn’t work with google maps, which have extremely long urls and requires many steps to generate a RubyURL. First you click, “link to this page”, copy the text from the little popup, go to rubyurl.com, paste the text and get your RubyURL.

I figured that there must be a way to grab that link from the document itself on the Google Maps site. I whipped out my Javascript book and got it working in short order.

The code looks like

javascript:void(location.host=='maps.google.com'?location.href='http://rubyurl.com/rubyurl/remote?website_url='+encodeURIComponent(document.getElementById('link').href):location.href='http://rubyurl.com/rubyurl/remote?website_url='+encodeURIComponent(location.href))

Which is ugly as it’s a bookmarklet. Drag this to your bookmark bar if you want to start using it: RubyURL this Link

You don’t even need to click the “Link to this page” link on google maps before using it, it grabs it right out of the document. I will try to get this added to the RubyURL site as the official bookmarklet as well.

Are there other sites that don’t work well with the bookmarklet? Let me know in the comments!