Skip to content

Instantly share code, notes, and snippets.

@rlemon
Created October 23, 2014 17:38
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 rlemon/e431a9c061b7575d84b2 to your computer and use it in GitHub Desktop.
Save rlemon/e431a9c061b7575d84b2 to your computer and use it in GitHub Desktop.
(function() {
"use strict";
var chat = document.getElementById('chat');
String.prototype.toJadenCase = function() { return this.split(' ').map(function(w) {return w.slice(0, 1).toUpperCase() + w.slice(1); }).join(' ');};
function parseNode(node) {
if (node.classList && node.classList.contains('message') && !node.classList.contains('pending') && !node.querySelector('.onebox') && !node.querySelector('pre')) {
var inner = node.querySelector('.content .full') || node.querySelector('.content');
[].forEach.call(inner.childNodes, function jadenThisShit(tnode) {
if (tnode.nodeType === 3) {
tnode.textContent = tnode.textContent.toJadenCase();
}
});
}
}
[].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