Created
September 23, 2014 09:29
-
-
Save MylesBorins/3ff920eb73174427ee21 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
document.body.appendChild(document.createElement('script')).src='https://rawgit.com/tommoor/tinycon/master/tinycon.min.js'; | |
document.body.appendChild(document.createElement('script')).src='//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js'; | |
// select the target node | |
var target = document.querySelector('#chat-list'); | |
var count = 0; | |
// create an observer instance | |
var observer = new MutationObserver(function(mutations) { | |
var message = mutations[0].addedNodes[0].getElementsByTagName('p')[0].innerHTML | |
_.each(message.split(' '), function (word) { | |
if (word === 'meow') { | |
console.log(word); | |
count++; | |
Tinycon.setBubble(count); | |
} | |
}); | |
}); | |
// configuration of the observer: | |
var config = { attributes: true, childList: true, characterData: true }; | |
// pass in the target node, as well as the observer options | |
observer.observe(target, config); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment