How dai-mywk/ad-blocker-extension works
Main Components
• Manifest (manifest.json): Acts as the configuration file for the extension and defines metadata, permissions, and the required scripts.
• Background Script (background.js): Contains the logic for setting up and enforcing block rules using Chrome’s declarativeNetRequest API.
• Popup Page (popup.html): Provides a simple user interface for the extension (if any additional interaction, though basic as per current file structure).
Relationships and Interactions
• The Manifest is the entry point and configuration hub; it registers the background script and the popup page.
• The Background Script is autonomously run by the Chrome runtime, and it interacts with the declarativeNetRequest API to enforce the blocking rules.
• The declarativeNetRequest API (an external Chrome API) is used by the background script to carry out the actual ad blocking.
Important Architectural Patterns and Principles
• Modularity: Each file has a clear purpose — configuration (manifest.json), background processing (background.js), and user interface (popup.html).
• Separation of Concerns: The extension separates configuration, functionality, and presentation. The declarativeNetRequest API usage is handled solely within the background script, while the popup handles UI concerns.
• Event-Driven Operation: The background script likely responds to events (like network requests) and applies rules accordingly.
Relevant Technologies and Frameworks
• Chrome Extension API: Specifically, the declarativeNetRequest API.
• JavaScript/HTML/CSS: Standard technologies used to implement the background logic and popup interface.