Skip to content

Instantly share code, notes, and snippets.

@MylesBorins
Created September 23, 2014 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MylesBorins/3ff920eb73174427ee21 to your computer and use it in GitHub Desktop.
Save MylesBorins/3ff920eb73174427ee21 to your computer and use it in GitHub Desktop.
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