Last active
December 12, 2015 07:19
-
-
Save jeffalexander/4735750 to your computer and use it in GitHub Desktop.
XKCD Bookmarklet that on click 1) takes you to xkcd.com then click 2) inserts the image title under comic, scrolling into view if needed, and click 3) takes you to explainxkcd.com.
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: | |
cd=document.getElementById('comic'); | |
if(cd) { | |
if(cd.childElementCount==2) { | |
window.location='http://explainxkcd.com'; | |
} else { | |
p=document.createElement('p'); | |
i=cd.children[0]; | |
if(i.tagName=='A') { | |
i=i.children[0]; | |
} | |
p.innerText='Title: '+i.title; | |
cd.insertBefore(p, null); | |
p.scrollIntoView(false); | |
} | |
} else { | |
window.location='http://xkcd.com'; | |
} |
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
To use, copy and paste into an existing bookmark's URL. | |
Bugs: | |
For chrome users this (and any other bookmarklet) won't work on the New Tab Page. | |
http://code.google.com/p/chromium/issues/detail?id=98871 | |
Work-around: | |
1. Only use the bookmarklet on open pages. Use apple+click to open in a new tab. | |
2. Replace New Tab with about:blank | |
https://chrome.google.com/webstore/detail/pfdloiaebhgmjpaclbbodcmlmppkakjh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment