3 ms·
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 deart
by ionfish 18y ago
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 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 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.
- ionfish 18y agoI decided to run a small test to see whether the comic's title was always the longest title of any image. Here's the screen scraper I wrote for it: http://gist.github.com/13315 http://gist.github.com/13315 I discovered that following comics don't have the longest title of any image on the page: 11, 18, 25, 27, 76, 82, 99, 126, 393, 412, 455.
- tocomment 18y agoWow I had no idea. Your way is probably smarter.