Last active
August 29, 2015 14:18
-
-
Save fearenales/9e5c519c2eb29f9d436b to your computer and use it in GitHub Desktop.
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
var msgCount = document.getElementsByClassName('msg').length; | |
var personName = document.getElementsByTagName("title")[0].innerHTML; | |
$('#composerInput').onkeypress = function(event){ | |
if(event.which == 13){ | |
event.preventDefault(); | |
$('button._5y14._52cp').click(); | |
} | |
} | |
function notify() { | |
var msgs = document.getElementsByClassName('msg'); | |
var lastMsg = msgs[msgs.length-1]; | |
var senderName = lastMsg.getElementsByClassName("actor")[0].innerHTML; | |
if (senderName !== personName.replace(/\ \(\d+\)/, '')) { | |
return; | |
} | |
var y = lastMsg.getElementsByTagName('div'); | |
var z = (y[y.length-1]).getElementsByTagName('span'); | |
var message = (z[z.length - 1]).innerHTML; | |
var personPic = lastMsg.parentNode.parentNode.getElementsByTagName("img")[0].getAttribute("src"); | |
return new Notification(senderName, {body: message, icon: personPic}); | |
} | |
$('#messageGroup').addEventListener('DOMSubtreeModified',function(){ | |
if (msgCount != document.getElementsByClassName('msg').length){ | |
msgCount = document.getElementsByClassName('msg').length; | |
notify(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment