YouTube Bot Comments Filter

建立於 5 天前
更新於 1 天前
Hides or blurs bot comments on YouTube (nickname pattern detection) with settings in the account menu. Multilingual UI.
#filter
#youtube
#comments
#YouTube
#评论增强
#内容过滤
資料統計
總安裝量
13
近 24 小時
+0
使用者評分
-
YouTube机器人评论过滤工具,通过昵称模式检测隐藏或模糊可疑评论

YouTube Bot Comments Filter

CI Install userscript License: MIT Version A userscript for YouTube that detects spam bot comments by nickname pattern and hides or blurs them. Settings live in the YouTube account (avatar) menu — open Bot filter and choose hide or blur. Compatible with Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat, and other managers that support the // ==UserScript== metadata block.

Quick install

  1. Install a userscript manager (Tampermonkey or Violentmonkey recommended).
  2. Click the install link below — your manager should open an installation prompt. Install URL:
https://raw.githubusercontent.com/NemoKing1210/youtube-bot-comments-filter/main/youtube-bot-comments-filter.user.js

Install

Install from URL (dashboard)

Manager Path
Tampermonkey Dashboard → UtilitiesInstall from URL
Violentmonkey Dashboard → +Install from URL
Greasemonkey Add-on menu → New User Script → paste the raw URL
ScriptCat Install the extension and use the GitHub raw URL
Paste the install URL above.

Manual install

  1. Open the built youtube-bot-comments-filter.user.js in this repository (or run npm run build after cloning).
  2. Copy the entire file contents.
  3. In your userscript manager, create a new script and paste the code.
  4. Save and enable the script.

Updates

The script includes @updateURL and @downloadURL metadata pointing to the raw GitHub file. Supported managers check for updates automatically. To release a new version:

  1. Bump version in package.json.
  2. Run npm run build (regenerates root youtube-bot-comments-filter.user.js / .meta.js).
  3. Add an entry to CHANGELOG.md.
  4. Push to main (or create a GitHub Release).

Features

  • Bot detection by nickname — weighted rule engine scores commenter display names (e.g. @SAWS.PW__TyT_Ha_CauT_05)
  • Hide mode — bot comment body is replaced by a localized placeholder notice
  • Blur mode — bot comments stay in place but are blurred and dimmed; hover to reveal
  • Account-menu settings — entry in the avatar menu with hide/blur options and a toggle for the bot % badge
  • Confidence badge — estimated bot probability when above 50% (amber / orange / red); can be turned off in settings
  • Persistent preference — selected mode is saved between sessions
  • YouTube-like styling — uses YouTube CSS variables for light/dark theme compatibility
  • 10 UI languages — English, Russian, Spanish, French, German, Portuguese, Chinese, Japanese, Arabic, Hindi (detected from browser locale)

Supported pages

Site URL pattern
YouTube https://www.youtube.com/*
Works on watch pages, Shorts with comments, and any YouTube view that renders the standard comments section (ytd-comment-view-model / ytd-comment-renderer).

Display modes

Mode Behavior
Hide (default) Comment body is replaced by a short notice; layout stays stable
Blur Bot comments appear blurred, grayscale, and semi-transparent; full content shows on hover
Open your avatar menu → Bot filter → choose a mode. The subtitle under the menu entry shows the current mode.

How it works

YouTube page loads
       │
       ▼
MutationObserver + periodic rescan (SPA-safe)
       │
       ▼
Ensure account-menu settings entry when the avatar menu opens
       │
       ▼
For each new comment (ytd-comment-view-model / ytd-comment-renderer)
       │
       ▼
Read author display name (#author-text)
       │
       ▼
Run BotDetector rules → sum weights
       │
       ├── score < threshold ──► leave comment unchanged
       │
       └── score ≥ threshold ──► apply hide notice or blur

Bot detection

Detection is based on the commenter's display name, not comment text. Each rule has a name, weight, and test(name) function. The total score is the sum of matched rule weights. If the total is ≥ 4 (default threshold), the comment is flagged as a bot. Built-in signals include:

Signal Weight Example
Domain-like prefix with spam TLD 3 @SAWS.PW__..., @TLES.TOP-...
Separator right after TLD 2 .PW__, .TOP-
Transliterated spam keywords 3 tyt_ha, na_caut, smotri, 4ki_na
Many underscores 1 three or more _ in the name
Leetspeak digit in word 1 Sy4ki, CauT0
ALLCAPS prefix with dot 1 @SAWS.PW
Exact match list 100 SAWS.PW, TLES.TOP
Spam TLDs checked: PW, TOP, XYZ, ONLINE, SITE, CLUB, WIN, CC, ICU, VIP, and others commonly abused in bot nicknames.
To extend detection, edit EXACT_MATCHES / SPAM_TLDS in src/constants.js or push new objects into RULES in src/detection/bot-detector.js.

Dynamic content

YouTube loads comments asynchronously (infinite scroll, replies, navigation without full reload). A MutationObserver on document.documentElement schedules debounced passes via requestAnimationFrame. A 2-second safety interval catches any missed mutations.

Repository layout

youtube-bot-comments-filter/
├── src/                                      # Source (edit here)
│   ├── main.js
│   ├── constants.js
│   ├── settings.js
│   ├── i18n/
│   ├── detection/
│   ├── styles/
│   └── features/
├── scripts/                                  # Build helpers
├── youtube-bot-comments-filter.user.js       # Built installable userscript
├── youtube-bot-comments-filter.meta.js       # Built metadata-only mirror
├── package.json
├── vite.config.js
├── README.md
├── CHANGELOG.md
└── LICENSE
File Purpose
src/ Editable source modules
youtube-bot-comments-filter.user.js Built script served at @downloadURL / @updateURL
youtube-bot-comments-filter.meta.js Lightweight metadata mirror for update checks
vite.config.js Userscript metadata + Vite / monkey config

Script metadata

Key // ==UserScript== fields (generated from vite.config.js + package.json):

Field Value
@namespace https://github.com/NemoKing1210/youtube-bot-comments-filter
@version From package.json
@updateURL / @downloadURL Raw GitHub URL of youtube-bot-comments-filter.user.js
@homepageURL This repository
@supportURL GitHub Issues
@license MIT
@grant GM_getValue, GM_setValue
@match https://www.youtube.com/*
Localized @name and @description tags are provided for en, ru, es, fr, de, pt-BR, zh-CN, ja, ar, and hi.

Required permissions

Grant Purpose
GM_getValue / GM_setValue Persist hide/blur mode preference between sessions
GM_addStyle Inject filter / menu CSS (auto-granted by the Vite build)
No network requests are made. The script only reads the DOM and applies CSS classes.

Development

Requires Node.js 20+ (npm).

npm install
npm run dev      # Vite serve — open/install the generated "dev:" userscript
npm run build    # Production → dist/ + copy to repo root
npm run ci       # Same checks as GitHub Actions (build + verify artifacts)

Edit files under src/ (entry: src/main.js). Userscript metadata (@match, localized names, …) lives in vite.config.js. Version is package.json → header @version and in-script SCRIPT_VERSION. After changes that should ship, run npm run build and commit the regenerated root .user.js / .meta.js. Pull requests run CI, which fails if those files are out of date.

Local workflow notes

  • npm run dev: vite-plugin-monkey serves an installable userscript (name prefixed with dev:). Install it once in Tampermonkey, Violentmonkey, or ScriptCat; HMR applies while the server runs.
  • Built file: after npm run build, you can also install the root youtube-bot-comments-filter.user.js (Violentmonkey Track local file still works on that artifact).
  • Do not commit localhost @updateURL / @downloadURL values.

Configuration

Constant Default Location Description
STORAGE_KEY_MODE ytbf_mode src/constants.js Storage key for display mode
DEFAULT_MODE hide src/constants.js Initial mode when no preference is saved
STORAGE_KEY_SHOW_SCORE ytbf_show_score src/constants.js Storage key for bot % badge visibility
DEFAULT_SHOW_SCORE false src/constants.js Show confidence badges by default
THRESHOLD 4 src/constants.js Minimum bot score to flag a comment
EXACT_MATCHES SAWS.PW, … src/constants.js Substrings that instantly flag a nickname
SAFETY_RESCAN_MS 2000 src/constants.js Fallback timer if a mutation is missed

Disclaimer

This project is not affiliated with Google or YouTube. Bot detection is heuristic — some legitimate usernames may be flagged, and some bots may slip through. Use it as a convenience filter, not a guarantee of comment quality.

License

MIT — Copyright (c) 2026 NemoKing

腳本詳情
適用網站
授權協議MIT
權限與存取
使用能力
儲存空間