How mhd101/quick-rename works
Project Type and Purpose
• This is a Chrome browser extension called Quick-Rename that intercepts file downloads and gives users the option to rename files before saving. It consists of a manifest file for configuration, a background script to handle download events, and a popup UI for user interaction.
File Structure Analysis
• manifest.json: Declares extension metadata, permissions (e.g., “downloads”), and entry points (background and popup).
• background.js: Runs in the background context, listens for download events, invokes rename logic or skips.
• popup.html / popup.js / style.css: Defines the extension’s popup window UI—HTML layout, styling, and client-side logic to send user choices to the background script.
• README.md: Explains installation, usage, and contribution guidelines.
Key Insights from the README
• Purpose: Rename or skip renaming files at download time.
• No external infrastructure or servers—entirely client-side within the browser.
• Relies on Chrome’s Downloads API and message passing between popup and background contexts.
a. Main Components
• Manifest (central config)
• Background Script (event handler)
• Popup UI (HTML/CSS/JS)
• Chrome Downloads API (external service)
• Optional: Browser Storage API (if storing preferences)
b. Relationships and Interactions
• The browser loads manifest.json → registers background.js and popup.
• popup.js sends a message to background.js with the user’s rename choice.
• background.js intercepts chrome.downloads.onDeterminingFilename → applies rename or passes through.
• background.js invokes chrome.downloads.download with modified filename.
c. Architectural Patterns
• Event-driven architecture: background.js responds to download events.
• Message-passing: popup.js ↔ background.js via chrome.runtime.sendMessage/ onMessage.
d. Technologies and Frameworks
• JavaScript (ES6)
• Chrome Extension APIs (manifest v2 or v3)
• HTML5/CSS3 for popup UI