View Full Version : How to mask unwanted words in site?

09-29-2012, 08:20 AM
I know a little bit of JS Codding but I have no idea how to mask words or numbers for selected site? For www.examplecode.exm
Containing words: sh*t or pe*. I don't want see those words. How can I make .js file which changes those words into for ex. Flower and water? Or 100 into 50? They won't change sites content but only my clientside browser's perception to those words!

I just need some ideas and suggestions? :thumbsup:

Philip M
09-29-2012, 08:38 AM
Try this SmutEngine:-


<script type="text/javascript">

var notAllowed = [["*"], [" sex"], [" rape"], ["damn"], [" ***]", ["arse"], ["porn"], ["intercourse"], ["erotic"], ["pervert"]];

// Filters sex but not Essex, filters rape but not drape, filters a*s*s (blocked on this site!) but not pass
// But then kinkysex, gangrape and fatass are not blocked. You can't win!

function checkWord(txt){
txt = " " + txt.value; // catch initial badwords starting with a space
lctxt = txt.toLowerCase();
for (var i = 0; i < notAllowed.length; i++) {
if (lctxt.indexOf(notAllowed[i]) != -1){
alert ('The word "' + notAllowed[i] + '" is not allowed!');
var rep = txt.substr(0, lctxt.indexOf(notAllowed[i]));
if (notAllowed[i] !="*") {
if (/[^\s]$/.test(rep)) { // add a space at end of text if not one already
rep = rep + " ";
rep = rep.replace (/^\s/, ""); // remove initial space again
document.getElementById("myText").value = rep;
return false;



<form name = "myForm">
<textarea name="myText" rows="10" cols="50" onkeyup="checkWord(this)"></textarea>


The advantage is that it is case insensitive and notAllowed words are removed as they are typed, which may help to discourage abusers. This is perhaps better than replacing the badwords by **** which the reader may guess. But as always bad-word or bad word or b.a.d.w.o.r.d will get through.

It is impossible to filter badwords completely. The script will filter for gangrape if the notAllowed word is 'rape' (no leading space) but that will also filter out drape and grape and scrape. I guess that might be accepted as drape, grape and scrape are uncommon words. Likewise kinkysex is filtered out if the notAllowed word is 'sex' (no leading space) but the penalty is that Essex and Sussex are also blocked.

If you mean erase badwords displayed on someone else's site, then that cannot be done. The remedy is obvious - don't visit sites which permit bad language.

09-29-2012, 08:51 AM
Thanks for help!

I didn't said change someone's else site, but only my own browsers reaction to it!

javascript:document.body.contentEditable='true'; document.designMode='on'; void 0

something like this, but added as addon in the browser somewhere and does job automaticaly.


Philip M
09-29-2012, 07:10 PM
As I say, if you mean erase badwords displayed on someone else's site (viewed in your browser), then that cannot be done.

The reason is the Same Origin Policy. Simply stated, the SOP states that JavaScript code running on a web page may not interact with any resource not originating from the same web site.