GimmeAGUID bookmarklet

While I’m in the bookmarklet mode, here’s another one.

While writing yesterday’s bookmarklet, I needed a string that was sufficiently unlikely to by the selected text on the page that I could comfortably rely on it to be unique (I’m using it as part of the hack that determines if the browser is IE, since IE’s handling of functions as variables is a little wonky, see line 1 and line 11 of the gist). The first thing that came to mind was a guid, so I googled for an online resource to generate a guid. The first hit on te results page is this gist, which when executed in Firebug’s console got me the guid I needed for the bookmarklet I was writing.

Later in the day it occurred to me that this was another good candidate for a bookmarklet itself (not that I need guids all that often, but these are a ton of fun to write), so here it is:

GimmeAGuid

Click the bookmarklet and a prompt pops up with the guid in the entry field, preselected for a quick copy. I initially did this as an alert, but that didn’t give you any way to copy the guid. I also tried it in a new window, which worked fine except that the you have this extraneous window hanging about, and you still have to select the guid to copy it.

Expanded code in my fork of the aforementioned gist.