How emirkabal/better-instagram-videos works
Project Type and Purpose
• This is a browser extension intended to enhance video controls on Instagram (playback, volume, autoskip, and download options).
• The project is built with modern web technologies and uses a tool like Plasmo for extension framework management.
• The extension supports multiple locales, as seen in the assets/_locales directory.
File Structure
• Top-Level Directories:
– .github: Contains workflows and CI/CD scripts (e.g., submit.yml) that show how the project is integrated with GitHub actions.
– src: The heart of the project where the application logic is maintained.
• Within src:
– components: Contains reusable UI components (Buttons, ProgressBars, Controller, etc.) that constitute the extension’s interface.
▪ The Controller subfolder organises various UI controls (Download, Volume, Autoskip, etc.) with associated styles.
– modules: Houses specific functionality related to the Instagram integration (modules/instagram with Home, Reels, Stories, etc.) and possibly overarching injection logic (Injector.tsx and IntervalInjector.tsx).
– utils and contents: Provide helper functions and core logic (like main.ts) to coordinate the extension’s operations.
• Other Files:
– plasmo.md implies the use of the Plasmo framework, which is common in building browser extensions.
– package.json, pnpm-lock.yaml, tsconfig.json define the overall development and build environment for the project.
Diagramming the Architecture
a. Main Components:
• UI Components:
• Popup UI: Represented by the code in src/popup.
• Controller and Other UI Components: Group all interactive components under src/components/Controller and other components.
• Application Modules:
• Instagram-specific Modules: Show src/modules/instagram, which contains specialized components (e.g., Home, Reels, Stories) that hook into Instagram’s video content.
• Utility Modules: Represent the Injector and IntervalInjector under src/modules that might interface with the DOM or run periodic tasks.
• Assets and Localization:
• Use assets folder to represent localization support (multiple languages) and static images.
• Build/Deployment & Configuration:
• Mention the build process triggered by pnpm scripts (“pnpm run build”), with integration points from GitHub workflows (.github/workflows) and Plasmo configurations.
b. Relationships and Interactions:
• Data Flow:
• Start from the browser’s extension loader, which loads the built artifact from the dist directory.
• Once loaded, the popup and content scripts (e.g., controllers on Instagram pages) interact with the user.
• The components (Buttons, Progress Bars, etc.) in the Controller send and receive data (such as playback state, volume, etc.).
• Modules (especially under modules/instagram) are responsible for interfacing directly with Instagram’s pages, injecting additional controls via the Injector components.
• Communication:
• How the popup UI can dispatch events that change the state in the controller components, possibly through background scripts or direct injection.
c. Architectural Patterns & Design Principles:
• Separation of Concerns: Clearly illustrate the distinction between concerns: UI / presentation (components), business logic (modules, injector), and localization/assets.
• Use of a Framework (Plasmo): Mark any integration points where the Plasmo framework’s abstractions might affect loading or context (e.g., content script injection, lazy-loading of modules).
d. Relevant Technologies/Frameworks:
• React or a similar framework (inferred from the use of .tsx files).
• Plasmo framework for browser extension scaffolding.
• CSS styling for UI components.
• pnpm for package and dependency management.
Instructing the Principal Software Engineer
• Clear Labels:
• Visual Differentiation:
• Detail the Roles:
• How the Injector components are responsible for interfacing with Instagram’s DOM and enabling custom behavior.
• How the assets and localization support integrate with the UI to offer multi-language capability.
• Overall Layout:
Final Thought: