Created
October 8, 2011 06:41
-
-
Save kopiro/1271953 to your computer and use it in GitHub Desktop.
Check names to Facebook Chat
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: | |
ytAlert = function() | |
{ | |
console.log("Alert!"); | |
window.open("http://www.youtube.com/watch?v=xRrfg_uAzwg&feature=grec_index"); | |
} | |
onlineString = function(b) | |
{ | |
return b ? "online" : "offline"; | |
} | |
sp_peoples = []; | |
while ( resp = prompt("Insert people:\n(Nothing to terminate)") ) | |
{ | |
sp_peoples.push( { name : resp, status : false } ); | |
} | |
sp_interval = setInterval(function() | |
{ | |
try | |
{ | |
sp_chat = document.querySelectorAll(".fbChatOrderedList li"); | |
for (var i=0; i<sp_chat.length; i++) | |
{ | |
var cperson = sp_chat[i]; | |
if ( !cperson || !cperson.querySelector(".name") ) | |
continue; | |
var cperson_status = Boolean( cperson.className.match("active") ); | |
var cperson_name = cperson.querySelector(".name").innerText; | |
if ( !cperson_name ) continue; | |
for (var j=0; j<sp_peoples.length; j++) | |
{ | |
var person = sp_peoples[j]; | |
if ( cperson_name.match( new RegExp(person.name, "i") )) | |
{ | |
console.log( person.name + " was " + onlineString(person.state) + ", and now is " + onlineString(cperson_status) ); | |
if ( cperson_status != person.status) | |
{ | |
person.status = cperson_status; | |
ytAlert(); | |
} | |
} | |
} | |
} | |
} catch(ex) { console.log("Exception!", ex); } | |
}, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment