When writing a post the other day1, I wanted to be able to use the tumblr chat where the participants were twitter users. Tumblr doesn’t support HTML in chat usernames, so I wrote a tiny javascript chunk to automatically troll any elements you give it and replace @twitter-username with a link to their account. (You can see it in action on the aforementioned post2) You can find the code in this github gist, all you need to do is link in mootools (you only need to have the selectors part available, for now) and this script in the head of your template like this:

<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript" src="tumblrtweets.js"></script>

Then add a small javascript section at the end of your template (inside the body):

<script type="text/javascipt"> tumblrTweets("span.label"); </script>

Where span.label is the CSS Selector for the elements you wish to scan. You can link to these files from my web server if you like3 (check the source of any of these pages), but if you have your own hosting please use that instead, I only have limited bandwidth!

  1. Import note: this post was originally written on Tumblr, which feels like a pretty crucial piece of information for this post to make sense! ↩︎

  2. Sadly you can't! See the footnote above. ↩︎

  3. I doubt that you'd still want to, but that server doesn't exist any more. You can always load directly from the raw gist on Github. ↩︎