Created
September 24, 2014 19:58
-
-
Save rlemon/ab7117b9c872480d737d to your computer and use it in GitHub Desktop.
broscript
This file contains 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
(function() { | |
"use strict"; | |
var chat = document.getElementById('chat'); | |
function parseNode(node) { | |
if (node.classList && node.classList.contains('message') && !node.classList.contains('pending') && | |
!node.querySelector('.onebox') && !node.querySelector('pre') ) { | |
node.textContent = node.textContent.replace(/[\s\!\?\.]+$/, '') + ', bro.'; | |
} | |
} | |
[].forEach.call(chat.querySelectorAll('.user-container .message'), parseNode); | |
new MutationObserver(function(records) { | |
records.forEach(function(record) { | |
[].forEach.call(record.addedNodes, parseNode); | |
}); | |
}).observe(chat, { | |
childList: true, | |
subtree: true | |
}); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now with more sugar bro!
EDIT: Updated RegEx