Created
December 17, 2010 00:38
-
-
Save phstc/744291 to your computer and use it in GitHub Desktop.
isFollowing Bookmarklet – Who is following who?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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