1

I want to use some JS Scripts to replace some bad words automatically on my Wikia site. Here my code:

$(function () {
    var str = document.getElementById("WikiaPage").innerHTML; 
    var res = str.replace(/badword1/gi, "beep").replace(/badword2/gi, "beep");
    document.getElementById("WikiaPage").innerHTML = res;
});

Then it works. But this code causes crash on Wikia Comments Section, Recent Wiki Section in WIkia Rail and some issues may I don't know yet.

How can i do now? Any help is appreciated. Thank everyone.

Dcsuper
  • 25
  • 4
  • These sections doesn't show after many Ctrl F5 – Dcsuper Feb 18 '15 at 07:08
  • Resetting `innerHTML` removes all the events handlers. That's probably what's happening in that document. Try with filtering the `textNode`s and replacing their `nodeValue` property instead. – Ram Feb 18 '15 at 07:32
  • Can you tell me more details what exactly I have to change this code. Sorry if I've troubled you. Thank you for helping me. ^ ^ – Dcsuper Feb 18 '15 at 07:51
  • No problem. Please read [this blog post](http://james.padolsey.com/javascript/replacing-text-in-the-dom-its-not-that-simple/). The author also has created a library that does what you want. – Ram Feb 18 '15 at 12:28

0 Answers0