chester's blog

technology, travel, comics, books, math, web, software and random thoughts

Tweet xkcd bookmarklet

20 Apr 2009 | Comments

UPDATE: This was fun thing I did back when it wasn’t so trivial to post things to social media (and we had to worry about IE6 😂). The bookmarklet isn’t draggable anymore, but the code is formatted for posteriority.

Since people love to post their favorite xkcd strips on Twitter, I thought this might help: drag the link below onto your links toolbar (it will create a button). Whenever you read an xkcd comic you want to share, just click the button: it will use the “secret message” text (cutting words to fit 140 chars, if needed) to produce a nice tweet about the strip that you can review and send directly from your Twitter home page:

  <a href="javascript:(function(){var%20c=document.images;tv='';for(var%20i=0;i<c.length;i++){t=c[i].title;if(t&&(t!='')){tv=t;break}}l=location.href;h='';if(tv!=''){while(tv&&(l.length+tv.length+4>140)){tv=tv.match(/.*\s/);if(tv){tv=tv[0].substring(0,tv[0].length-1)};h='...';}location.href="'http://twitter.com/home?status='+tv+h+'%20'+l;}else{alert('No%20xkcd%20strip%20found')}})();"">Tweet xkcd</a>
(if you are using IE6, right-click, add to favorites, select links bar, then ok. Or do yourself a favor and switch to Firefox.)

Feel free to tweet about this or send me feedback!

Comments