var words=['词语1','词语2','词语3'];//单引号中填写敏感词,逗号分隔不分大小写
function extractDocument(el) {
var childNodes = el.childNodes;
for (var i = 0; i < childNodes.length; i ++) {
var c = childNodes[i];
switch(c.nodeType) {
case 1:
if(c.nodeName=="A")c;
extractDocument(c);
break;
case 3:
if (trim(c.nodeValue).length == 0) break;
for(var i=0;i c.nodeValue=c.nodeValue.replace(new RegExp(words[i],'ig'),'***'); }; break; } } } function trim(str) { return str.replace(/(^\s*)|(\s*$)/g, ""); }