Created
September 27, 2008 10:00
-
-
Save beastaugh/13311 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){var e="http://imgs.xkcd.com/comics/",t=document.getElementsByTagName("img"),n=t.length;while(n--){if(t[n].src.substring(0,e.length)===e){alert(t[n].title);return;}}})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Run this on any http://xkcd.com/ comic page to pop up an alert with the comic title. | |
* | |
* Code inspired by this article and bookmarklet: | |
* http://www.blendedtechnologies.com/read-xkcd-on-the-iphone-finally/223 | |
* | |
* Also see this Hacker News posting: http://news.ycombinator.com/item?id=316621 | |
* | |
* In order to run it as a bookmarklet, the code needs to be prefixed with javascript: | |
* You should probably also run it through something to remove comments and whitespace. | |
*/ | |
(function() { | |
var comics_url = 'http://imgs.xkcd.com/comics/'; | |
var imgs = document.getElementsByTagName('img'); | |
var i = imgs.length; | |
while (i--) { | |
if (imgs[i].src.substring(0, comics_url.length) === comics_url) { | |
alert(imgs[i].title); | |
return; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment