Skip to content

Instantly share code, notes, and snippets.

@CS1000
Created September 24, 2014 23:20
Show Gist options
  • Save CS1000/7d9826ab0d9f72bfec82 to your computer and use it in GitHub Desktop.
Save CS1000/7d9826ab0d9f72bfec82 to your computer and use it in GitHub Desktop.
Bro Script (so chat)
Paste in SO chat room console bro:
(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')
) {
var regex = /((?:^|\s*)(?:[a-z'-]+))([\?\!\.]+$|[\?\!\.]+\s|\s*:.|\s*$)/gi;
node.textContent = node.textContent.replace(regex, '$1 bro$2');
}
}
[].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