How jordwest/news-feed-eradicator works
Project Type & Purpose
• Recognize that this is a browser extension developed as a WebExtension (compatible with both Chrome and Firefox).
• Its primary function is to remove the Facebook news feed (and possibly similar content from other websites) and replace it with a custom quote display.
• It uses a modular architecture with clearly defined functional areas to manage background processing, UI components, site-specific logic, messaging, and options configuration.
Main Components
a. WebExtension Shell:
• Manifest Files (src/manifest.json, src/manifest-chrome.json): These define what scripts run, permissions, and other configuration details.
• Build & Packaging: While not a runtime component, note the Makefile and build/dist folders (for production and development flows).
b. Background Component:
• Background Scripts: Represent the background page and service worker (src/background/service-worker.ts) that manage extension-wide tasks.
• Background Store: There is a dedicated state management area (src/background/store) implementing a Redux-like pattern with actions, reducers, effects, and selectors.
c. UI & Components:
• Components Directory (src/components): Contains various UI modules (alert, info-panel, quote-display, quote-editor, etc.) for rendering content or notifications.
• Options Screen: (src/options) where users can configure the extension’s behavior via options.html, options.css, and options.ts.
• Content Script Elements: Although not explicitly under a “content” folder, the injection of UI (via src/lib/inject-ui.ts) and interception logic (src/intercept.ts) plays a key role in modifying the page.
d. Site-Specific Logic:
• Sites Directory (src/sites): Contains modules targeting specific sites (Facebook variations, Hacker News, LinkedIn, Twitter, etc.) with tailored functions to remove news feeds and possibly adjust styles (notice “*.str.css” files).
e. Shared Libraries & Utilities:
• Lib Directory (src/lib): Aggregates helper functions (e.g., generate-id, handle-error, parse-csv, route-change) that provide core functionalities.
• Messaging: (src/messaging) which defines types and possibly utility functions for inter-module communication between the background and content scripts.
Relationships & Interactions
• The Manifest defines which background scripts and option pages are loaded.
• The background service worker (and its state management system) initiates and orchestrates actions, listening to events (both browser events and messages) and maintaining state.
• The UI components are injected into web pages using functions (inject-ui) triggered either by the background or content scripts.
• Site-specific modules are consulted to determine how to interact (e.g., remove or adjust DOM elements) for each supported website.
• Communication is facilitated by a messaging system connecting content scripts, background scripts, and option pages (using types defined in src/messaging/types.ts).
Architectural Patterns & Key Technologies
• Modular Structure: Clear separation of concerns between background processing, UI rendering, state management, site-specific logic, and utilities.
• Redux-like State Management: With actions, reducers, selectors, and effects found in multiple “store” folders (both in src/store and src/background/store).
• Service Worker: Serving as the background script providing persistent processing even when no UI is visible.
• Build Tools: Using TypeScript (tsconfig.json), Rollup (rollup.config.js), and a Makefile to manage builds and development workflow.
• WebExtension Standards: The overall design conforms to modern browser extension APIs as dictated by the manifest files.
Detailing and Labeling
• Clearly label every component with its file/directory name or a descriptive name (e.g., “Service Worker & Background Store”, “UI – Quote Display Module”, “Site Modules (Facebook, Twitter, …)”).
• Notes or legends if required to explain symbols, especially the Redux-like component flow (actions → effects → reducer → state updates).