xBlockOrigin follows a feature-based architecture with clear separation of concerns. This guide explains the project structure and key directories.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/chefnaphtha/xBlockOrigin/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The project is organized as a monorepo with the extension code inpackages/extension/:
Source directory structure
Thepackages/extension/src/ directory contains all source code, organized by feature:
Api directory
Handles all communication with X.com’s GraphQL API:All API responses are validated using Valibot schemas to ensure type safety at runtime.
Background directory
Contains the background service worker (Chrome) or background page (Firefox):index.ts- Main background script entry point- Handles extension lifecycle events
- Manages communication between content scripts and popup
Content directory
Content scripts that run on X.com pages:| File | Purpose |
|---|---|
index.ts | Main content script entry point |
orchestrator.ts | Coordinates user processing and muting logic |
postHider.ts | Applies blur overlay to posts from muted users |
hiddenPostNotice.ts | UI components for unhiding posts |
timelineScanner.ts | Scans timeline for user profiles |
searchScanner.ts | Scans search results |
statusScanner.ts | Scans post detail pages |
replyScanner.ts | Scans notifications and replies |
profileScanner.ts | Scans user profile pages |
extractors.ts | Extract user data from DOM elements |
flagInjector.ts | Inject country flags next to usernames |
unmuteHandler.ts | Handle unmute and whitelist actions |
Each scanner targets specific X.com page types and uses MutationObserver to detect dynamically loaded content.
Popup directory
Preact-based UI components for the extension popup:Main components
App.tsx- Root application componentindex.tsx- Entry point that renders the apphooks.ts- Custom Preact hooks
Feature sections
BlacklistManager.tsx/BlacklistSection.tsx- Country blacklist managementWhitelistManager.tsx/WhitelistSection.tsx- User whitelist managementMutedUsersSection.tsx/MutedUsersTable.tsx- Display muted usersSettings.tsx- Extension settingsStats.tsx- Muting statisticsExportButton.tsx- CSV export functionalityDebugPanel.tsx- Developer debugging tools
Subcomponents
Static assets
popup.html- HTML shell for the popupthemes.css- Theme styles (light/dark/dim)theme-loader.js- Detect and apply theme on load
Storage directory
Data persistence layer using Chrome storage APIs:Uses
chrome.storage.sync for settings (syncs across devices) and chrome.storage.local for user data.Utils directory
Shared utility modules:| File | Purpose |
|---|---|
cache.ts | Persistent cache with TTL (24h for countries, 5min for following status) |
rateLimit.ts | API request queue for sequential processing |
rateLimitState.ts | Request queue state management |
csvExporter.ts | Export muted users to CSV format |
countryFlags.ts | Country name to flag emoji mapping |
themeDetector.ts | Detect X.com theme (light/dark/dim) |
unmuteService.ts | Bulk unmute operations |
Manifest files
Two manifest versions for cross-browser compatibility:manifest.v3.json (Chrome/Edge)
- Uses Manifest V3 specification
- Service worker instead of background page
- Required for Chrome Web Store
manifest.v2.json (Firefox)
- Uses Manifest V2 specification
- Persistent background page
- Required for Firefox Add-ons (V3 not fully supported)
Build output
Thedist/ directory is generated during builds and contains browser-ready extensions:
Naming conventions
The codebase follows these conventions:- PascalCase - Directories and React/Preact components (
Popup/,App.tsx) - camelCase - Utility files and functions (
cache.ts,orchestrator.ts) - No semicolons - Biome configuration enforces no semicolons
- Tab indentation - 4-space tabs configured in Biome
- Lowercase comments - Comments use lowercase for consistency
Architecture principles
The project follows functional programming principles:Key principles
- Feature-based organization - Related code stays together
- Functional over OOP - Pure functions and modules preferred
- No barrel exports - Import directly from source files
- Files under 200 lines - Split large files into focused modules
- Runtime validation - Use Valibot for type safety at runtime
- Never use
anyoras- Maintain strict type safety