www.byjp.me/content/posts/tumblr-musings/twitter-links-in-tumblr.md
JP Hastings-Spital dd38d6b9fa More tumblr posts
Also updated accurate timestamps of tumblr posts
2023-05-23 08:21:26 +01:00

1.9 KiB
Raw Blame History

title date draft emoji images tags
Twitter links in Tumblr 2009-05-20T21:43:00+01:00 false 🐤
javascript
code
tumblr
twitter
from-tumblr

When writing a post the other day1, I wanted to be able to use the tumblr chat where the participants were twitter users. Tumblr doesnt 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. ↩︎