Instantly share code, notes, and snippets.

Embed
What would you like to do?
isFollowing Bookmarklet – Who is following who?
javascript:(function(){
/*@author Pablo Cantero - http://pablocantero.com/blog/2010/12/20/isfollowing-bookmarklet-who-is-following-who*/
var isFollowing = function(twitterScreenNameA, twitterScreenNameB){
jQuery.getJSON('http://twitter.com/statuses/followers.json?screen_name=' + twitterScreenNameA + '&callback=?', function(data){
for(var i = 0; i < data.length; i++){
if(data[i].screen_name === twitterScreenNameB.replace('@', '')){
alert(twitterScreenNameB + ' is following ' + twitterScreenNameA);
return;
}
}
alert(twitterScreenNameB + ' is not following ' + twitterScreenNameA);
});
};
var isFollowingPrompt = function(){
var twitterScreenNameA = window.prompt('input the twitter screen name (a)', jQuery('.screen-name').text());
var twitterScreenNameB = window.prompt('input the twitter screen name (b)');
if(twitterScreenNameA === null || twitterScreenNameB === null){
alert('you must provide the screen names (a) and (b)');
} else {
isFollowing(twitterScreenNameA, twitterScreenNameB);
isFollowing(twitterScreenNameB, twitterScreenNameA);
}
};
if(typeof jQuery === 'undefined') {
var jQueryScript = document.createElement('script');
jQueryScript.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js');
jQueryScript.setAttribute('type','text/javascript');
jQueryScript.onreadystatechange= function () {
if (this.readyState === 'complete' || this.readyState === 'loaded'){
isFollowingPrompt();
}
};
document.getElementsByTagName('head')[0].appendChild(jQueryScript);
} else {
isFollowingPrompt();
}
})()
@phstc

This comment has been minimized.

Copy link
Owner

phstc commented Dec 21, 2010

How to use it?

Check out this post to get a more detailed explanation
http://pablocantero.com/blog/2010/12/20/isfollowing-bookmarklet-who-is-following-who

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment