How david20571015/pixiv-downloader works
Main Components
• Extension Entry Points – The project clearly separates its functionality into different “entrypoints”:
• Background Script (src/entrypoints/background/index.ts): This handles persistent/background tasks, such as managing downloads and possibly coordinating with other scripts.
• Content Script (src/entrypoints/content/DownloadButton.vue and src/entrypoints/content/index.ts): Injected into Pixiv pages, this script is responsible for adding a “Download” button and handling UI interactions on the site.
• Options Page (src/entrypoints/options/OptionsPage.vue, constant.ts, index.html, main.ts): This is the configuration UI built using Vue 3 and Vuetify, allowing users to customize filename templates, choose image sizes, and set up conflict handling modes.
Supporting Utilities and Assets
• Utils (src/utils/downloader.ts and src/utils/options-store.ts): These utility modules contain core functionalities such as download logic (e.g., handling image sizes, conflict resolution) and managing the options/settings storage for the extension.
Interactions and Relationships
• Data Flow:
• The Content Script on a Pixiv illustration page “listens” for user actions (click on the Download button) and communicates with the Background Script to initiate downloads.
• The Background Script, upon receiving signals, leverages the downloader utility to process image data and the options store to load user preferences.
• The Options Page provides a user interface for configuring various settings. Changes here should persist (and be consumed by the downloader) via the options-store utility.
• External Services:
• The extension supports a proxy (https://pixiv.cat/) to bypass hotlink protection. This should be represented as an external dependency the Background Script or downloader invokes when necessary.
• Content Script (UI on Pixiv pages)
• Background Script (Core logic and download management)
• Options Page (Settings UI built with Vue 3 + Vuetify)
• Utility Modules (Downloader and Options Store)
• External Proxy Service (pixiv.cat)
• External systems (Pixiv website, Proxy service) might have a third distinct style or border.
Detailed Steps for the Principal Software Engineer
○ Content Script – Displaying the “Download” button on Pixiv pages.
○ Background Script – Managing background operations and data processes.
○ Options Page – Providing a settings UI for customization.
○ External Services – Pixiv website (where illustrations reside) and Proxy Service (pixiv.cat).
○ User interactions triggering content script actions.
○ Content Script forwarding download requests to Background Script.
○ Background Script invoking utilities (Downloader and Options Store) for handling image downloads and user-defined settings.
○ Background Script contacting the external proxy and Pixiv service as needed.
• Use annotations or callouts to indicate important technologies (e.g., Vue 3 & Vuetify for the Options Page, TypeScript for the core scripts).
– Emphasize directional flows and interactions between scripts and external services.
– Tailor the details so that the division of responsibilities (content, background, options, utils) is immediately apparent.