Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up How to mask unwanted words in site?

    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?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Try this SmutEngine:-

    Code:
    <html>
    <head>
    
    <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;
    }
    }
    }
    
    </script>
    </head>
    
    <body>
    
    <form name = "myForm">
    <textarea name="myText" rows="10" cols="50" onkeyup="checkWord(this)"></textarea>
    </form>
    
    </body>
    </html>
    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.
    Last edited by Philip M; 09-29-2012 at 07:10 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks for help!

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

    Code:
    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.

    Thanks!

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    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.
    Last edited by Philip M; 09-29-2012 at 07:28 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •