Skip to content

Instantly share code, notes, and snippets.

@akjetma
Last active December 27, 2015 23:29
Show Gist options
  • Save akjetma/7406264 to your computer and use it in GitHub Desktop.
Save akjetma/7406264 to your computer and use it in GitHub Desktop.
remeat control. change the meatword to whatever you want to listen for then plop it in your console.
var observer,
callback,
options,
meats;
var meatword = "meatlejuice meatlejuice meatlejuice",
queued = false;
callback = function( recordqueue ) {
var meatspeaks = recordqueue[0].addedNodes,
triggers = 0;
for ( var i = 0; i < meatspeaks.length; i++ ) {
if ( meatspeaks[i].children[1].innerHTML.indexOf( meatword ) !== -1 ) {
triggers++;
} else {
console.log( "no match" );
}
}
if ( triggers > 0 && queued === false ) {
queued = true;
setTimeout( function() {
$('#add-chat-form').trigger("submit");
queued = false;
}, 4000 );
}
};
observer = new MutationObserver( callback );
options = {
'childList': true
};
meats = document.querySelector( '.chats ul' );
observer.observe( meats, options );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment