DEV Community

Derrick Richard
Derrick Richard

Posted on

Introducing CensorCore | JavaScript Language Censoring Library

Introducing CensorCore

As a high school developer, I aim to create solutions to problems. My most recent project is called CensorCore. CensorCore is a lightweight JavaScript library designed to prevent explicit or vulgar messages to be sent in platforms that require user input, such as chatrooms, forms, etc...

CensorCore Version History

v2.0.0

CensorCore is currently in version 2.0.0. This version is a major step from version 1.1.0, as it now has a more advanced filtering method. The current version introduces phrase detection, severity levels (Low, Medium, High), and a rich analysis API. Developers can now see exactly why a message was blocked, and it adds support for custom rules via censor.extend() and async loading events.

v1.1.0

Version 1.1.0 did not have as many features, and was still somewhat basic. Some of the improvements from v1.0.0 are listed below:

  • Wordlist processed before detection needed
  • Quicker language detection
  • Verification if the wordlist has been loaded

This version made CensorCore more reliable, and was a small step towards perfecting CensorCore.

v1.0.0

Version 1.0.0 eas the initial release of CensorCore, and was about as basic as it could get. All this version had was very basic filtering and a small wordlist. For a word to get blocked, it had to match the spelling and case of the word in the wordist, making it unreliable. Users could just spell "A" with a "4", or an "S" with a "5", making it easy to bypass the filter.

Installation

Installing CensorCore is about as easy as counting to three.

To install CensorCore, include the script tag in the

of your HTML file to ensure it loads before your application code runs:

<script src="https://cdn.jsdelivr.net/gh/DerrickRichard/CensorCore-Library@latest/CensorCore.js"></script>

If you place the script near the closing tag, the library may load after your code runs, which can prevent the wordlist from initializing correctly.

After the script loads, a global object named censor will be available for use in your JavaScript.

Make sure your internet connection allows loading scripts from the CDN at:

https://cdn.jsdelivr.net

Basic Integration

Inside your message‑sending logic, add this check:

JavaScript

// Block explicit messages using the CensorCore library
if (censor.isBlocked(text)) {
    alert("Message blocked: Inappropriate Content");
    return;
}

Enter fullscreen mode Exit fullscreen mode

A full example:

JavaScript

function sendMessage() {
    const text = input.value;

    // Block explicit messages using the CensorCore library
    if (censor.isBlocked(text)) {
        alert("Message blocked: Inappropriate Content");
        return;
    }

    addMessage(text);
    input.value = '';
    input.focus();
}

Enter fullscreen mode Exit fullscreen mode

Advanced Usage (Version 2.0)

Use the new analyze() API for detailed moderation results:

JavaScript

const result = censor.analyze(text);

if (result.blocked) {
    console.log("Blocked severity:", result.severity);
    console.log("Category:", result.category);
    console.log("Matches:", result.matches);
}

Enter fullscreen mode Exit fullscreen mode

Custom Rules

You can add your own rules without modifying the main wordlist:

JavaScript

censor.extend([
    { text: "my custom phrase", category: "custom", severity: "medium" }
]);

Enter fullscreen mode Exit fullscreen mode

Wordlist Structure

CensorCore loads a JSON file structured by category. Your actual wordlist includes categories such as:

  • profanity
  • hate_speech
  • harassment
  • sexual_content
  • violence
  • self_harm
  • drugs
  • weapons
  • extremism
  • terrorism
  • disallowed_phrases
  • custom

Each category is automatically assigned a severity level (low, medium, or high). All categories are merged into a single internal rule engine.

The CensorCore wordlist is curated solely by Derrick Richard to ensure consistency and quality. Community members cannot directly edit the wordlist. To request a new word or phrase, please use the Word Request section in the repository's Discussions page.

API Reference

censor.isBlocked(text) - Returns true if the text contains any blocked content.

censor.analyze(text) Returns a detailed moderation result including: - whether the text is blocked - highest severity - category - all matched rules

censor.extend(rules) - Adds custom moderation rules at runtime.

censor.isReady() - Returns true when the wordlist has finished loading.

censor.isFailed() - Returns true if the wordlist failed to load.

censor.onReady(callback) - Fires when the moderation engine is ready.

censor.onError(callback) - Fires if the moderation engine fails to load.

Design Philosophy

CensorCore avoids modifying the DOM, intercepting events, or altering UI behavior. Instead, it provides a predictable, developer‑controlled moderation function. This ensures transparency, stability, and compatibility across a wide range of applications.

Disclaimer

The CensorCore wordlist is curated solely by Derrick Richard to ensure consistency and quality. Community members cannot directly edit the wordlist. To request a new word or phrase, please submit a request in the Word Request section of the repository's Discussions page.

License

CensorCore is released under the MIT License.

Official Links

Official CensorCore Site
GitHub Repository
Developer's Portfolio Website

Closure

Thank you for taking the time to read this. If you have any questions or feedback, please feel free to leave a comment on this article, or create a discussion on the CensorCore Repository Discussions Page.
I would appreciate every star and every piece of feedback I can get on this project. Thank you.

Top comments (2)

Collapse
 
michele_saladino profile image
Michele Saladino

I saw that you have inserted "kms" in the blocked words. What will the behavior be if I'm talking about kilometers in the page?

Collapse
 
derrickrichard profile image
Derrick Richard

Right now, using “kms” in any context will still trigger the block, even if you’re talking about kilometers. In a future update, I plan to swap the static wordlist.json for a smarter Python based text scanning system. Instead of blocking specific words, it will assess the overall meaning of a message and will only prevent sending if the content is truly harmful or explicit. This should remove false positives like “kms” used in regular, non-harmful contexts.