How fahadyousafmahar/chromeurdu works
1. Project purpose
- Chrome extension whose core job is to make Urdu text render with Nastaleeq fonts on websites.
- The main architectural concern is not a backend or data service, but browser-side DOM/style injection.
2. Extension shell
- manifest.json is the central wiring file for the Chrome Extension: it defines permissions, content scripts, assets, and any UI entry points.
- This repo appears to be a pure client-side extension with no server component.
3. Injection layer
- src/inject/inject.js is the main runtime script that likely runs inside web pages as a content script.
- Its role is to detect page context and attach the extension’s styling or UI into the current tab.
4. Global styling for injected pages
- src/inject/inject.css provides the base CSS used by the injected page-level experience.
- This is likely the shared styling applied regardless of the target site.
5. Site-specific adaptations
- src/inject/google.css, src/inject/twitter.css, and src/inject/whatsapp.css indicate special handling for specific sites.
- Architecturally, this suggests a per-domain override model: common behavior plus tailored CSS fixes for major websites with different layouts and font rendering quirks.
6. Embedded app/UI surface
- src/inject/app/index.html plus the js, css, and img subfolders form a small front-end app bundled into the extension.
- This is likely the extension’s popup or injected control panel, used to toggle behavior or expose settings/help.
7. App behavior scripts
- src/inject/app/js/index.js and src/inject/app/js/popup.js separate general UI logic from popup-specific behavior.
- That separation implies two layers: a reusable app shell and a popup/controller entry point.
8. Localization
- _locales/en/messages.json shows the extension uses Chrome’s built-in i18n mechanism.
- This means user-facing labels/messages are externalized, enabling future translation support without changing the code structure.
9. Static assets
- icons/ contains extension icons used by Chrome in the toolbar, store listing, or installed-extension UI.
- src/inject/app/img/ contains images used by the embedded UI.
10. Main data flow
- Chrome loads the extension from manifest.json.
- On matching pages, inject.js runs in the page context and applies the relevant CSS.
- For specific domains, the extension swaps in or adds the site-specific CSS file.
- The extension UI provides user interaction, likely without needing any persistent backend state.
11. Boundaries
- The key boundary is between the browser page DOM and the extension’s injected assets.
- Another boundary is between shared styling and site-specific styling, which is important for understanding maintainability and troubleshooting rendering issues.
12. Operational model
- This is a lightweight extension architecture: no API calls, no database, no build-time service dependencies visible in the tree.
- The “system” is essentially Chrome + extension manifest + injected scripts/styles + localized UI assets.
13. What an architecture diagram should emphasize
- Chrome browser as the host environment.
- manifest.json as the orchestration point.
- Content script / injected layer as the main execution path.
- Shared CSS plus per-site CSS branches.
- Optional extension UI/popup assets.
- Localization and icons as supporting resources.
Main entry points: manifest.json Manifest · inject.js Inject script · index.html App shell · index.js App logic
Components 14
Host Environment
Chrome executes the extension and injects assets into page contexts.
- Chrome · Host environment that loads the extension and provides page DOM access.
Extension Core
Manifest wiring plus the main content-script injection path.
- Manifest · Central configuration for permissions, content scripts, and extension entry points.
manifest.json - Inject script · Runs in page context to apply the Urdu Nastaleeq rendering behavior.
src/inject/inject.js - Base CSS · Common styles used by the injected page-level experience.
src/inject/inject.css - Google fixes · Domain-specific styling adjustments for Google pages.
src/inject/google.css - Twitter fixes · Domain-specific styling adjustments for Twitter pages.
src/inject/twitter.css - WhatsApp fixes · Domain-specific styling adjustments for WhatsApp pages.
src/inject/whatsapp.css
Extension UI
Bundled in-extension interface and popup logic.
- App shell · Bundled extension UI surface for controls or popup content.
src/inject/app/index.html - App logic · Reusable JavaScript for the embedded extension app.
src/inject/app/js/index.js - Popup logic · Popup-specific behavior for the extension UI.
src/inject/app/js/popup.js - App styles · Styles for the embedded extension app UI.
src/inject/app/css/index.css
Support Assets
Localized messages and icon/image resources.
- English strings · Chrome i18n messages used for extension labels and text.
_locales/en/messages.json - Icons · Toolbar and extension UI icons.
icons - UI images · Images used by the embedded app UI.
src/inject/app/img
Connections 19
- Chrome → Manifest: loads · Chrome reads the manifest to install and run the extension.
- Manifest → Inject script: registers · Manifest declares the page injection runtime.
- Manifest → Base CSS: includes · Manifest makes the shared injected styles available.
- Manifest → Google fixes: includes · Manifest provides site-specific styling for Google pages.
- Manifest → Twitter fixes: includes · Manifest provides site-specific styling for Twitter pages.
- Manifest → WhatsApp fixes: includes · Manifest provides site-specific styling for WhatsApp pages.
- Manifest → App shell: exposes · Manifest wires the bundled UI surface into the extension.
- Manifest → English strings: localizes · Manifest points Chrome to the message catalog.
- Manifest → Icons: references · Manifest uses extension icons for browser surfaces.
- Inject script → Base CSS: applies · Runtime injection uses the shared base styling.
- Inject script → Google fixes: switches to · Adds site-specific CSS when the active domain needs Google fixes.
- Inject script → Twitter fixes: switches to · Adds site-specific CSS when the active domain needs Twitter fixes.
- Inject script → WhatsApp fixes: switches to · Adds site-specific CSS when the active domain needs WhatsApp fixes.
- Inject script → App shell: mounts · Can attach the extension UI into the page or extension surface.
- App shell → App logic: drives · The shell loads the reusable UI logic.
- App shell → Popup logic: drives · The shell loads popup-specific behavior.
- App shell → App styles: styles · The shell is styled by the bundled UI stylesheet.
- App shell → UI images: uses · The UI shell consumes bundled image assets.
- App logic → Popup logic: shares code · Popup behavior builds on the common app logic.