Created
February 2, 2012 21:51
-
-
Save kopiro/1725996 to your computer and use it in GitHub Desktop.
Get online Facebook friends too if you are offline!
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
if (!window['ChatVisibility']) { | |
alert("Are you in the Facebook window?\nExecute this script only in the FBW!"); | |
} else { try { | |
/* Usual jQuery Incapsulation method */ | |
jQueryOnLoad = function(callback){ | |
var jQs = document.createElement('script'); | |
jQs.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"); | |
document.body.appendChild(jQs); | |
var jQi = setInterval(function() | |
{ | |
if (!window['jQuery']) return; | |
console.log('jQuery is ready!'); | |
clearInterval(jQi); | |
jQuery.noConflict(); | |
callback.apply(); | |
}, 100); | |
} | |
/* end */ | |
jQueryOnLoad(function(){ | |
d = new Dialog(); | |
d.showLoading(); | |
getAvailableNames = function(callback) | |
{ | |
var onlineUsersNames = []; | |
var onlineUsersID = []; | |
var isOnline = ChatVisibility.isOnline(); | |
if (!isOnline) ChatVisibility.goOnline(); | |
var oI = setInterval(function(){ | |
onlineUsersID = AvailableList.getAvailableIDs(); | |
console.log("Checking.."); | |
if (!onlineUsersID) return; | |
clearInterval(oI); | |
if (!isOnline) ChatVisibility.goOffline(); | |
console.log("The users: ", onlineUsersID); | |
jQuery(onlineUsersID).each(function(k, uID){ | |
jQuery.getJSON("//graph.facebook.com/"+uID, function(info) { | |
console.log("Processed "+uID); | |
onlineUsersNames.push({ id:uID, name:info.name }); | |
if (k==onlineUsersID.length-1) | |
callback(onlineUsersNames); | |
}); | |
}); | |
}, 100); | |
} | |
getAvailableNames(function(userList) | |
{ | |
d.setTitle("Online List (by Kopiro Whison)"); | |
d.setButtons(Dialog.OK); | |
var db = '<ul class="fbChatOrderedList">'; | |
jQuery(userList).each(function(k, u){ | |
db += '<li class="item invis" style="opacity:1;width: 210px;"><a class="clearfix">'; | |
db += '<img class="pic" src="//graph.facebook.com/'+u.id+'/picture">'; | |
db += '<span class="name">'+u.name+'</span>'; | |
db += '</a></li>'; | |
}); | |
db += '</ul>'; | |
db += '<div style="clear:both"></div>'; | |
d.setBody(db); | |
d.show(); | |
}); | |
}); | |
} catch (ex) { | |
alert("Exception:\n"+ex+"\n\nPlease report this error to [email protected]"); | |
} } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment