Skip to content

Instantly share code, notes, and snippets.

@rlemon
Created April 14, 2016 17:09
Show Gist options
  • Save rlemon/a9433fbe84c80144a4d4b9773a0f46ef to your computer and use it in GitHub Desktop.
Save rlemon/a9433fbe84c80144a4d4b9773a0f46ef to your computer and use it in GitHub Desktop.
php poptart
NodeList.prototype[Symbol.iterator] = [][Symbol.iterator];
new MutationObserver( rec => rec.map( n => [...n.addedNodes].map(parser) ) )
.observe(document.body, { childList: true, subtree: true });
[...document.querySelectorAll('.user-container .message')].map(parser);
function parser(node) {
if( node.classList && node.classList.contains('message') && !node.classList.contains('pending') ) {
if( /\bphp\b/gi.test(node.textContent ) ) {
node.innerHTML = node.innerHTML.replace(/\bphp\b/gi, 'Poptart');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment