Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
user2 = '';
if ($('.twitter-anywhere-tweet-box-editor').length){
// New Twitter textarea tweet entry
user1 = extractAt($('.twitter-anywhere-tweet-box-editor').val());
user2 = $('#screen-name').text().replace(/[\s\xA0]+/g,'');
} else {
if ($('.tweet.permalink-tweet').length){
// status page when logged in
user1 = $('.tweet.permalink-tweet').attr('data-screen-name');
user2 = extractAt($('.tweet-text.tweet-text-large').text());
}else{
//status page when not logged in
user1 = $('.tweet-url.screen-name').text();
user2 = extractAt($('.entry-content').text());
}
}
gtyp='edi';
url='http://socialgraph.apis.google.com/lookup?q=http://twitter.com/'+user1+',http://twitter.com/'+user2+'&'+gtyp+'=1&callback=?';
$.getJSON(url,
function(json){
if(json) {
alert(commonFollowers(json));
}
});
function extractAt(aMsg){
splitText = aMsg.split(' ');
if (splitText[0].substring(0,1)=='@'){
return splitText[0].replace('@','');
}
}
function commonFollowers(json){
var name=new Array();
nref='nodes_referenced_by'
followers=new Array();
for (u in json['nodes']) {
name[name.length]=u.replace('http://twitter.com/','')
lfollowers=new Array();
cofriends=new Array();
for (i in json['nodes'][u][nref])
lfollowers[lfollowers.length]=i
followers[followers.length]=lfollowers
}
for (i in followers[0]){
if (followers[1].indexOf(followers[0][i])>-1){
cofriends[cofriends.length]=followers[0][i]
}
}
output = user1+': has '+followers[0].length+' followers';
if (user2 != '') {
output += ' of which '+cofriends.length+' followers in common with '+user2;
}
return output
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment