Skip to content

Instantly share code, notes, and snippets.

@rlemon
Created March 12, 2015 20:59
Show Gist options
  • Save rlemon/7876fcd497d82ea86b86 to your computer and use it in GitHub Desktop.
Save rlemon/7876fcd497d82ea86b86 to your computer and use it in GitHub Desktop.
nick like css classes. this shuts him up about them
(function() {
"use strict";
// setup
var userid = "1408759";
var phrase = "css class";
var chat = document.getElementById('chat'),
room = document.forms[0].elements.room.value;
new MutationObserver(function(records) {
records.forEach(function(record) {
[].forEach.call(record.addedNodes, function parseNode(node) {
if (node.classList && node.classList.contains('user-' + userid)) {
var message = node.querySelector('.message');
var re = new RegExp(phrase, "gi");
if (re.test(node.textContent)) {
var id = message.id.split('-')[1];
$.post("/admin/movePosts/" + room, fkey({
ids: [id],
to: 23262
}));
}
}
});
});
}).observe(chat, {
childList: true,
subtree: true
});
}());
@patsy-issa
Copy link

*likes

@sippylabs
Copy link

You could use something like this so you never have to see another person say Java when they mean JavaScript 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment