browser_ai_comments
Browser AI Comments adds AI-powered helpers directly to Drupal’s comment system, using capabilities available in modern Chrome browsers. It lets site visitors translate comments (while writing or while reading) and helps moderators and communities by warning commenters about potentially toxic language before they post.
Features
-
In-comment translation
- Translate the current comment while writing.
- Translate a published comment while viewing.
- Uses Chrome’s experimental Web AI APIs:
LanguageDetectorandTranslator.
-
Toxicity / harmful language warnings while typing
- Detects potentially toxic or hateful language as users type.
- Runs client-side using Transformers.js in a Web Worker (keeps the UI responsive).
- Uses the
Xenova/toxic-bertmodel for classification.
-
Optional submit protection
- Can disable the comment submit button when toxic content is detected (configurable).
Post-Installation
After enabling the module, configure it from the admin UI and then use it in any place Drupal comments are available.
- Go to
Admin > Configuration > Content authoring > Browser AI Comments. - Select which toxicity labels should be flagged and set a threshold value.
- Customize the warning message shown to commenters.
- Optionally enable the setting to disable the submit button while toxic content is detected.
What you’ll see after setup:
- On comment forms: toxicity warnings can appear live while typing.
- On comment display pages: a Translate action is available for published comments (browser support required).
Additional Requirements
- Drupal 11
- Google Chrome Dev/Canary with experimental Web AI features enabled
- Secure context: HTTPS or
localhost - Network access (first run): required to download the toxicity model the first time it runs
Notes: Translation relies on Chrome Web AI APIs (Translator, LanguageDetector). Toxicity detection does not require window.ai.
Recommended modules/libraries
- Transformers.js (used for toxicity detection in a Web Worker)
Xenova/toxic-bertmodel (used for toxicity classification)
If your site uses advanced moderation workflows, pairing with Drupal’s moderation tools (core/workflow setups) can complement the warnings, but this module primarily focuses on front-end assistance at comment time.
Similar projects
This module is different from typical server-side translation or moderation modules because it runs AI features in the browser (client-side) using Chrome’s experimental Web AI APIs and an in-browser toxicity model. That means:
- No server-side translation service is required for the translation feature (but browser support is required).
- Toxicity detection runs locally in the user’s browser via a Worker, instead of needing a remote API.
How it works
- Translation uses the
LanguageDetectorandTranslatorAPIs as shown in the Chrome Web AI playground. - Toxicity detection runs Transformers.js inside a Web Worker using the
Xenova/toxic-bertmodel (inspired by toxic review demos).
Chrome setup
- Enable AI-related flags in
chrome://flags(flag names change frequently). - Restart Chrome and allow any required model downloads.
- Confirm the APIs exist in DevTools:
TranslatorandLanguageDetector.
Usage
- Enable the module.
- Open a comment form or view a published comment.
- Use the Translate button or review toxicity warnings while typing.