Skip to content

Instantly share code, notes, and snippets.

@phstc
Created December 17, 2010 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phstc/744291 to your computer and use it in GitHub Desktop.
Save phstc/744291 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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