How sandipwane/custom-font-plus works
Main Components
• Manifest & Configuration: The manifest.json (along with files like google9eb51814538804eb.html and privacy-policy.md) defines the extension’s permissions, entry points, and metadata.
• Content Script: The content.js file is the core piece that runs in the context of webpages, enforcing the custom fonts and handling the fallback system.
• Popup Interface: popup.html and popup.js (supported by styles.css) build the UI that users interact with to configure the extension (setting primary and fallback fonts).
Relationships and Data Flow
• The manifest.json links the popup (user interface) and the content script. It specifies where content.js should be injected (i.e., on which webpages) and registers the popup.
• User interactions occur in the popup interface (popup.html and popup.js). When a user selects fonts and saves the settings, these selections are stored (likely through the browser's extension storage) and used to control the behavior of the content script.
Important Architectural Patterns and Design Principles
• Separation of Concerns: Different parts of the extension are dedicated to specific roles; the popup handles configuration, and the content script manages web page modifications.
• Modularity: Each file has a distinct purpose (UI, script injection, configuration, assets), making the extension maintainable.
• Reusability and Declarative Configuration: The manifest serves as the declarative configuration file that ties together the various components.
Technologies, Frameworks, or Libraries
• Chrome Extension APIs: Used within content.js and popup.js to interact with the browser.
• Standard HTML/CSS/JavaScript: For building the user interface in popup.html and managing styles in styles.css.
• Content Script interacting directly with “webpage” representations, indicating that it’s the element modifying the site’s font styling.