@madpilot makes

You can’t do that on Twitter

Ok, I REALLY have to stop coming up with hare-brained ideas, and then listening to others when they convince me to implement them.

Spurred on my @cybner‘s new avatar, I thought it would be cool if you could slime people in Twitter if the say “I don’t know”.

So after a couple of hours of ruby hacking, I came up with: You can’t do that on twitter. Eveytime someone says the magic words, you should see their avatar get slimed! You can even try the public timeline or your own timeline (Click here and and change madpilot in the url to your username). Note though, that because this isn’t authenticated, your timeline will need to be public for it to work.

You can’t do that on Twitter

How it works

It is all very simple, using Ruby CGI, Mechanize and Hpricot. The steps are:

  1. Work out what page is requested (uses apache mod_rewrite for this)
  2. Build the twitter URL, and request it using Mechanize
  3. Parse the HTML using Hpricot
  4. Append a new JavaScript file, which inserts the slime image based on an inserted class name
  5. Iterate through the tweets, grepping for the term “I don’t know”. If it finds it, it inserts the “slime” class
  6. On window.load, the inserted JavaScript file finds all images with that class and dynamically inserts the slime.png image above it. Using the twitter prototype instance, it gets placed over the avatar image.

I started off using Mechanize, then realised I didn’t really need it, but left it in there as it does do the HTTP request thing quite well. Download the source. Enjoy!

Update: Some good old You can’t do that on television sliming: