Open Synapse

Hi, I'm Abhay Kumar. I like to throw up interesting things I encounter here. You can also see the result of my mustache pact with my coworkers, check out what I'm up to or see the few photos I take. I like to receive email and instant messages (AIM / Jabber), as well. Some links of interest: Calais Text Tagger, Powerset

Jan 26
Permalink

Do you follow me?

Sometimes it’s nice to see which of your twitter friends are actually following you back. I like DoesFollow from @damon but I don’t want to go to another web page; I’d rather just click one button on a user’s feed and get the information immediately. I wrote a bookmarklet that does this for me. Here’s the source:


myName = 'abhaykumar';
thisPage = window.location.href;
if ((new RegExp('twitter.com')).test(thisPage)) {
  
  otherName = thisPage.split('/').pop();

  if (window.XMLHttpRequest) {
    xmlhttp = new XMLHttpRequest();
    if (typeof xmlhttp.overrideMimeType != 'undefined') {
      xmlhttp.overrideMimeType('text/xml');
    }
  } else if (window.ActiveXObject) {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
    alert("Your browser doesn't support XMLHTTPRequests and cannot use this bookmarklet.");
  }

  xmlhttp.open('GET', 'http://twitter.com/friendships/exists.json?user_a='+myName+'&user_b='+otherName, true);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      response = xmlhttp.responseText;
      if (response == 'true') {
        alert('Yes, '+otherName+' is following your tweets.');
      } else {
        alert('No, '+otherName+' is not following your tweets.');
      }
    }
  };
  
  xmlhttp.send(null);
} else {
  alert("It doesn't look like you are on a twitter page. You need to be in order to use this bookmarklet.")
};
To make you’re own, just replace first line and you should be good to go. Enjoy!