# munadil16/yt-ext architecture

> Architecture diagram of the GitHub repository munadil16/yt-ext, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/munadil16/yt-ext
- Repository: https://github.com/munadil16/yt-ext

## Overview

##### Project type and purpose
- This is a lightweight Chrome browser extension (“yt-ext”) whose sole purpose is to let users change YouTube’s playback speed up to 10×.
- Key indicators: presence of manifest.json, background.js, content.js, popup.html, and instructions about “load unpacked” and “open YouTube” in the README.

##### File structure
- manifest.json – declares extension metadata, permissions (e.g., activeTab, scripting), background and content scripts, popup UI.
- background.js – long-lived event listeners; typically routes messages between the popup and content script or manages state if needed.
- content.js – injected into YouTube pages; directly interacts with the page’s DOM (e.g., finds the <video> element and adjusts playbackRate).
- .gitignore, README.md – ancillary files, not part of runtime.

##### README for additional insights
- No larger architecture described—functionality is straightforward.

a. Main components:
1. Chrome Browser Extension Host
2. manifest.json (configuration)
3. Popup UI (popup.html + script.js + styles.css)
4. background.js (optional router, event hub)
5. content.js (injected script on YouTube pages)
6. YouTube Webpage (video player API)
7. User (triggering UI)
b. Relationships & interactions:
- Popup script captures speed selection → sends chrome.runtime.sendMessage to background or directly to content script.
- background.js (if used) receives message → relays to content.js via chrome.tabs.sendMessage.
- content.js (already injected in the YouTube tab) receives the message → locates video element → sets video.playbackRate to the new value.
c. Architectural patterns & principles:
- Event-driven, message-passing architecture.
- Single responsibility: UI code lives in popup, page manipulation in content, routing in background.
d. Key technologies & frameworks:
- Manifest V3 (or V2 depending on version)
- Chrome Extension APIs: chrome.runtime, chrome.tabs, chrome.scripting
- Vanilla JS, HTML, CSS

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and External
    User["User"]:::user
    YouTube["YouTube Webpage"]:::external

    %% Chrome Extension Host Container
    subgraph "Chrome Extension Host"
        Config["manifest.json"]:::config
        subgraph "Popup UI"
            PopupHTML["popup.html"]:::ui
            ScriptJS["script.js"]:::ui
            Styles["styles.css"]:::ui
        end
        Background["background.js"]:::router
        Content["content.js"]:::content
        Icons["icons/"]:::assets
    end

    %% Relationships
    User -->|click icon| PopupHTML
    PopupHTML -->|loads| ScriptJS
    ScriptJS -->|"chrome.runtime.sendMessage"| Background
    Background -->|"chrome.tabs.sendMessage"| Content
    Content -->|"video.playbackRate= value"| YouTube
    Config -->|configures| PopupHTML
    Config -->|configures| Background
    Config -->|configures| Content
    Config -->|includes assets| Icons

    %% Click Events
    click Config "https://github.com/munadil16/yt-ext/blob/main/manifest.json"
    click PopupHTML "https://github.com/munadil16/yt-ext/blob/main/popup.html"
    click ScriptJS "https://github.com/munadil16/yt-ext/blob/main/script.js"
    click Styles "https://github.com/munadil16/yt-ext/blob/main/styles.css"
    click Background "https://github.com/munadil16/yt-ext/blob/main/background.js"
    click Content "https://github.com/munadil16/yt-ext/blob/main/content.js"
    click Icons "https://github.com/munadil16/yt-ext/tree/main/icons/"

    %% Styles
    classDef user fill:#f9f,stroke:#333,stroke-width:1px
    classDef external fill:#eee,stroke:#999,stroke-width:1px
    classDef config fill:#ffd700,stroke:#b8860b,stroke-width:1px
    classDef ui fill:#87cefa,stroke:#4682b4,stroke-width:1px
    classDef router fill:#98fb98,stroke:#2e8b57,stroke-width:1px
    classDef content fill:#ffb6c1,stroke:#c71585,stroke-width:1px
    classDef assets fill:#d3d3d3,stroke:#696969,stroke-width:1px
```
