Created
March 12, 2015 20:59
-
-
Save rlemon/7876fcd497d82ea86b86 to your computer and use it in GitHub Desktop.
nick like css classes. this shuts him up about them
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"; | |
// 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 | |
}); | |
}()); |
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
*likes