Transform your Arabic AI conversations with intelligent RTL formatting
Features • Installation • How It Works • Privacy • Contributing
Arabic text in Claude.ai appears left-aligned and broken, making conversations difficult to read. Code blocks get corrupted when mixed with Arabic text, and manual text direction fixes are tedious and time-consuming.
QalamRTL is a lightweight Chrome extension that automatically detects Arabic content and applies proper RTL (Right-To-Left) formatting while intelligently preserving code blocks, JSON, and English text in their correct LTR direction.
- Intelligent threshold-based analysis — Only applies RTL when Arabic is dominant (30%+ ratio, 10+ characters)
- Per-paragraph processing — Each text block evaluated independently
- False positive prevention — Won't trigger on single Arabic words in English sentences
- Streaming response support — Works seamlessly as AI types character-by-character
- Preserves all programming languages — Python, JavaScript, JSON, SQL, etc.
- Inline code safety — Keeps
code snippetsreadable within Arabic text - Syntax integrity — Zero formatting corruption or character reversal
- Multi-level nesting — Handles code blocks inside lists, blockquotes, and tables
- Real-time processing — Applies formatting instantly during AI streaming
- Debounced mutations — Optimized observer pattern prevents layout thrashing
- Zero configuration — Works out-of-the-box, no settings required
- Toggle control — Enable/disable per tab with one click
- 100% local processing — Everything runs in your browser
- Zero data collection — No analytics, tracking, or telemetry
- Minimal permissions — Only
storage(for toggle state) - No external requests — Completely offline after installation
- Open source — Fully auditable codebase
🚧 Coming Soon — Extension is pending review
-
Clone the repository
git clone https://github.com/fathighanem/QalamRTL.git cd QalamRTL -
Verify assets
- Ensure
assets/containsicon16.png,icon32.png,icon48.png,icon128.png - All icon files are already included ✅
- Ensure
-
Load in Chrome
- Open
chrome://extensions/ - Enable Developer mode (top-right toggle)
- Click Load unpacked
- Select the
QalamRTLfolder
- Open
-
Verify installation
- QalamRTL icon should appear in your extensions toolbar
- Visit Claude.ai
- Extension auto-activates on the supported site
📖 Detailed setup: See INSTALLATION.md
- Navigate to Claude.ai
- Type your message in Arabic (or mixed Arabic/English)
- Send — QalamRTL automatically formats the response
- Read properly aligned, beautifully formatted Arabic text
Click the QalamRTL icon in your toolbar to:
- ✅ Enable (مُفعَّل) — Active RTL formatting
- ⭕ Disable (معطَّل) — Pause formatting for current tab
✅ Pure Arabic conversations
✅ Mixed Arabic/English technical documentation
✅ Code tutorials with Arabic explanations
✅ Arabic comments in programming examples
✅ Multilingual AI-assisted learning┌─────────────────────────────────────────────────┐
│ Browser Content Script │
├─────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌──────────────────────┐ │
│ │ Constants │ │ Arabic Detector │ │
│ │ Config │ │ - Unicode ranges │ │
│ └─────────────┘ │ - Ratio threshold │ │
│ └──────────────────────┘ │
│ ┌──────────────────────────────────────────┐ │
│ │ Code Block Guard │ │
│ │ Protects: pre, code, JSON, inline code │ │
│ └──────────────────────────────────────────┘ │
│ ┌──────────────────────────────────────────┐ │
│ │ RTL Applicator │ │
│ │ Applies .qrtl-block class to elements │ │
│ └──────────────────────────────────────────┘ │
│ ┌──────────────────────────────────────────┐ │
│ │ MutationObserver + Debouncing │ │
│ │ Watches DOM changes, handles streaming │ │
│ └──────────────────────────────────────────┘ │
│ ┌──────────────────────────────────────────┐ │
│ │ Claude.ai Site Adapter │ │
│ │ Platform-specific selectors & init │ │
│ └──────────────────────────────────────────┘ │
└─────────────────────────────────────────────────┘
- Detection — Page load triggers Claude adapter
- Observation — MutationObserver watches for new messages
- Analysis — Each text block scanned for Arabic Unicode ranges
- Protection — Code blocks locked to LTR before RTL application
- Application — CSS class applied to qualifying elements
- Streaming — Debounced re-processing during AI response typing
- Manifest V3 — Latest Chrome Extension standard
- Vanilla JavaScript — Zero dependencies, <50KB total size
- CSS-based styling — No inline styles, clean DOM manipulation
- Adaptive selectors — Failover mechanisms for DOM structure changes
- Memory efficient — Cleanup on disable, no memory leaks
📘 Deep dive: See ARCHITECTURE.md
Edit src/constants.js to adjust behavior:
const QRTL_CONSTANTS = {
// Arabic Detection
ARABIC_RATIO_THRESHOLD: 0.30, // 30% Arabic content required
ARABIC_MIN_CHAR_COUNT: 10, // Minimum 10 Arabic characters
// Performance
STREAMING_DEBOUNCE_MS: 400, // Streaming response delay
OBSERVER_DEBOUNCE_MS: 100, // DOM mutation debounce
// Polling (for SPA container detection)
CONTAINER_POLL_INTERVAL_MS: 300, // Poll every 300ms
CONTAINER_POLL_MAX_RETRIES: 60 // Max 18 seconds wait
};Modify css/rtl-fixes.css to adjust visual styling:
.qrtl-block {
direction: rtl !important;
unicode-bidi: embed !important;
text-align: right !important;
}# Open Chrome DevTools on Claude.ai and paste:
# 1. Check if messages are found
document.querySelectorAll('[data-testid="assistant-message"]').length
# 2. Verify RTL processing
document.querySelectorAll('.qrtl-block').length
# 3. Check processed markers
document.querySelectorAll('[data-qrtl-processed]').length
# 4. Inspect console logs
# Look for: [QalamRTL] messages in console# Run unit tests (Node.js)
cd tests
node unit-runner.js
# Expected: 25/25 passing- ✅ Pure Arabic text (100% ratio)
- ✅ Pure English text (0% ratio)
- ✅ Mixed content (50/50 split)
- ✅ Code blocks with Arabic comments
- ✅ Inline code preservation
- ✅ JSON structure integrity
- ✅ Streaming response handling
- ✅ Edge cases (URLs, math, tables)
📋 Test plan: See tests/MANUAL-QA.md
Check browser console:
// Open DevTools (F12) and run:
console.log(window.QRTLClaudeAdapter);
// Should return an object, not undefinedVerify installation:
- Go to
chrome://extensions/ - QalamRTL should be enabled with no errors
- Check that you're on
claude.ai
Force reload:
- Refresh the page (
Ctrl+RorCmd+R) - Hard refresh (
Ctrl+Shift+RorCmd+Shift+R) - Reload extension from
chrome://extensions/
Claude.ai updates their DOM frequently. If formatting stops working:
-
Check adapter file for
[VERIFY-ON-UPDATE]comments:src/adapters/claude.js
-
Inspect current selectors:
// In DevTools console: document.querySelectorAll('[data-testid="assistant-message"]').length // Claude
-
Update selectors if needed and reload extension
📖 Debugging guide: See docs/DEBUGGING.md
QalamRTL is 100% privacy-first:
| Aspect | Guarantee |
|---|---|
| Analytics | ❌ None — no tracking pixels, no telemetry |
| Network Requests | ❌ None — completely offline |
| Data Storage | ✅ Only toggle state (local) |
| Permissions | ✅ storage only (for toggle) |
| Code Auditing | ✅ Fully open source |
{
"permissions": ["storage"], // Save toggle state
"host_permissions": [ // Apply CSS/JS only on:
"https://claude.ai/*"
]
}No access to:
- ❌ Browsing history
- ❌ Other tabs or websites
- ❌ Clipboard
- ❌ Downloads
- ❌ Geolocation
- ✅ No
eval()or dynamic code execution - ✅ No external CDN dependencies
- ✅ Content Security Policy compliant
- ✅ Minimal DOM manipulation scope
- ✅ No third-party libraries
Contributions are welcome! Here's how to help:
- 🌐 Platform support — Gemini, Perplexity, Poe, etc.
- 🧪 Test coverage — Expand unit tests for edge cases
- 🎨 UI enhancements — Settings page, custom themes
- 🌍 Localization — Interface translations (Arabic, English, etc.)
- 📱 Firefox support — WebExtension port
# 1. Fork and clone
git clone https://github.com/fathighanem/QalamRTL.git
cd QalamRTL
# 2. Load in Chrome (Developer Mode)
# chrome://extensions/ → Load unpacked
# 3. Make changes
# Edit files in src/, css/, popup/
# 4. Test
node tests/unit-runner.js
# 5. Submit PR
git checkout -b feature/your-feature
git commit -am "Add your feature"
git push origin feature/your-feature- ✅ Use
'use strict';in all modules - ✅ IIFE pattern:
(function(window) {...})(window); - ✅ JSDoc comments for all functions
- ✅ Consistent 2-space indentation
- ✅ Descriptive variable names
| Document | Description |
|---|---|
| REQUIREMENTS.md | Complete functional & non-functional requirements |
| ARCHITECTURE.md | Technical architecture & design decisions |
| INSTALLATION.md | Detailed installation guide |
| tests/MANUAL-QA.md | Manual testing checklist (38 items) |
| docs/DEBUGGING.md | Troubleshooting guide with console commands |
| docs/SELECTOR-MAINTENANCE.md | How to update DOM selectors |
This project is licensed under the MIT License — see LICENSE for details.
Copyright (c) 2026 QalamRTL Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
...
- Built for Arabic-speaking developers, researchers, and students worldwide
- Inspired by the need for proper RTL support in modern AI interfaces
- Thanks to the open-source community for Chrome Extension standards
- Repository: github.com/fathighanem/QalamRTL
- Issues: Report a bug
- Chrome Web Store: (Coming Soon)