Skip to content

Instantly share code, notes, and snippets.

@spullara
Created November 21, 2010 20:30
Show Gist options
  • Select an option

  • Save spullara/709119 to your computer and use it in GitHub Desktop.

Select an option

Save spullara/709119 to your computer and use it in GitHub Desktop.
var $javarants = jQuery.noConflict(true);
$javarants(document).ready(function($) {
function replacetext(node) {
if (node.nodeType == 3 && node.parentNode.nodeName != "SCRIPT") {
var wordlist = [
"d***", "s***", "f***", "f***", "a***", "a***", "f***",
"f***", "h***", "d***", "c***", "f***", "g***", "g***", "s***",
"c***", "c***", "s***"
];
if (node.nodeValue.replace(/\s/g, '') == "") {
return;
}
$(wordlist).each(function() {
node.nodeValue = node.nodeValue.replace(new RegExp("\\b" + this + "\\b", "igm"), this.substring(0, 1) + "***");
});
}
}
$("*").each(function() {
this.addEventListener('DOMSubtreeModified', function(e) {
e.stopPropagation();
$(e.target).find("*").contents().each(function() {
replacetext(this);
});
}, false);
$(this).contents().each(function() {
replacetext(this);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment