The way it works isn't terribly reliable, since it counts on the comic being the element on the page with the longest title. A quick View Source reveals a dearth of helpful hooks like classes or ids, but the comic image is the only one with a URL of the form http://imgs.xkcd.com/comics/comic_name.png, so it might be better to check for that. Here's some new bookmarklet code based on this approach.
http://gist.github.com/13311
Obviously this will break if there are ever two comics on the page, since it will just print an alert for the first one and execution will then halt.