Jmaxxz vulgar word blocker

By Jmaxxz(tm) Last update Mar 7, 2010 — Installed 6,244 times.

Repeating characters

in
Subscribe to Repeating characters 3 posts, 3 voices



Stephen S Scriptwright
FirefoxWindows

I noticed this script doesn't account for words with repeating characters. For example, if I want to filter out "wooooorrrrrrdddd", I would have to put in a new entry for it.

I wrote up a function to replace each bad "word" with "(w+o+r+d+)+". This will detect "word", "wooorrrd", "wordwordwordword", and "woorddddddddwordwwwword", etc.

All you do is add the function at the end of this post, and then change the line of
bad.push(new RegExp(word, flags));
to
bad.push(new RegExp(returnRepeatingCharactersRegex(word), flags));

Just thought I'd let you know what I added for myself in case you wanted to add it to your script.

function returnRepeatingCharactersRegex(strWord) {
// This takes a string and then turns it into a regular expression that
// searches for repeating characters and repeating instances of the word.
// For example, you pass in "word".
// The function will return "w+o+r+d+".
//
// The purpose is so that it will find examples of "wooooorrrrd" and replace it.
// It also looks for repeating "wordwordwooorrrdddddddd" words.
var strNewWord;
strNewWord = ""
for(var i=0; i < strWord.length; i++) {
// loop through each character of strWord
strNewWord = strNewWord + strWord.charAt(i) + "+"; //adds each character, and then appends the "+" sign
}

return "(" + strNewWord + ")+"; // this lets it find multiples of the same word
}

 
fredscript User
FirefoxWindows

Wow, thank you very much for sharing that code!!!! This has blocked some more instances of words I don't like!

I added it to my already-personalised-over-time melon's censor, which looks to be the same identical code [works anyway] :D.

 
cocomonk22 Scriptwright
ChromeWindows

Those changes don't seem to work.