Skip to content

WordCensor: 3 censor modes (Grawlix / Replace / Alternative) and tidier UI#276

Merged
niksedk merged 1 commit into
mainfrom
feature/word-censor-modes
May 24, 2026
Merged

WordCensor: 3 censor modes (Grawlix / Replace / Alternative) and tidier UI#276
niksedk merged 1 commit into
mainfrom
feature/word-censor-modes

Conversation

@niksedk

@niksedk niksedk commented May 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Engine refactored to take a CensorOptions { Mode, Replacement, ColorRed } object.
  • Three modes:
    • Grawlix — existing behaviour: mask first ~50% with #@!?$%&.
    • Replace with text — replace the whole match with a user-editable string (default [censored]).
    • Random alternative word — swap with another word from the bad-word list itself. Rough case pattern is preserved (FUCK → DAMN, Fuck → Damn).
  • UI gets a 'How should offensive words be replaced?' card with the 3 modes as radio buttons, the replacement text box inline with its radio, and the highlight-in-red checkbox tucked into the same card. Window grew to 780x640.
  • Settings now persists mode + replacement + colorRed (was just colorRed); older settings still load with sensible defaults for missing fields.

Test plan

  • Run on a subtitle containing offensive words; verify all 3 modes produce visibly different output in the preview.
  • Toggle modes — preview updates immediately, line selection (include/exclude) is preserved across re-builds.
  • Edit the replacement string with Replace mode active — preview re-renders on each keystroke.
  • Toggle 'Highlight in red' — replacements wrap in <font color="#ff0000">…</font>.
  • Close & reopen the plugin — last-used mode + replacement string + colour flag are restored.
  • Verify Alternative mode doesn't loop forever even on a bad-word list of size 1 (degenerate case returns the original).

🤖 Generated with Claude Code

…er UI

The engine now takes a CensorOptions object with a Mode enum:
- Grawlix (existing): mask the first ~50% of each match with random
  #@!?$%& characters.
- Replacement: replace the whole match with a user-supplied string,
  default '[censored]'. The string is editable in the window.
- Alternative: swap the match with another random entry from the bad-word
  list itself, with rough case-pattern preservation (FUCK → DAMN,
  Fuck → Damn, fuck → damn). Retries a few times to avoid picking the
  same word back.

UI changes:
- New 'How should offensive words be replaced?' card with the 3 modes as
  radio buttons; the replacement text box sits inline with its radio.
- Highlight-in-red checkbox moved into the same card.
- Window grew a bit (780x640) to fit the mode picker comfortably; section
  spacing tidied.

Settings now persist mode + replacement + colorRed (was just colorRed).
Old settings still load — only the missing fields fall back to defaults.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@niksedk niksedk merged commit 145f392 into main May 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant