# atsukii01/shortloopplus architecture

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

- Interactive diagram: https://gitdiagram.com/atsukii01/shortloopplus
- Repository: https://github.com/atsukii01/shortloopplus

## Overview

##### Project type and purpose
- This is a browser extension (Chrome MV2 compatible) called ShortLoop+.
- Purpose: automatically scroll YouTube Shorts to the next video when one ends.
- It’s a front-end-only tool: no server or database, just content scripts and UI.

##### File structure
- manifest.json: declares extension metadata, permissions, content scripts.
- content_youtube.js: content script injected into YouTube pages.
- README.md/SECURITY.md/LICENSE: documentation and legal.
- No background/page scripts aside from content_youtube.js and popup.html.

##### README for additional insights
- Supports Chrome, Brave, Edge, Firefox via MV2.
- User flow: install → click “Shorts” button in popup → content script activates → page auto-scrolls.
- No mention of messaging but typical MV2 patterns suggest popup UI will message content script.

a. Components
- Browser (host environment)
- Extension manifest (configuration)
- Popup UI (popup.html)
- Content Script (content_youtube.js)
- YouTube Shorts web page (YouTube DOM & player)
- Browser Extension APIs (chrome.runtime, chrome.tabs)
b. Relationships & data flows
1. Browser loads manifest.json
2. manifest.json injects content_youtube.js into matching YouTube pages
4. Popup UI sends a message (chrome.runtime.sendMessage or chrome.tabs.sendMessage)
to content script to “activate auto-scroll.”
5. Content script listens for video “ended” events on the YouTube player DOM
6. On end, content script calls DOM scroll functions (e.g., window.scrollBy)
to move to the next Short
c. Architectural patterns
- MV2 extension model: manifest → content scripts + UI popup.
- Event-driven: extension responds to browser and DOM events.
- Single-page integration: no back end, all logic runs in page context.
d. Key technologies
- WebExtension APIs (chrome.* / browser.*)
- JavaScript content script for DOM manipulation
- HTML/CSS for popup UI
- manifest.json schema (permissions, host permissions, content_scripts)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Extension Layer"
        Manifest["Manifest.json"]:::extension
        Popup["Popup UI (popup.html)"]:::extension
        ContentScript["Content Script (content_youtube.js)"]:::extension
    end

    subgraph "Browser / Host Environment"
        Browser["Browser"]:::external
        APIs["Extension APIs (chrome.runtime, chrome.tabs)"]:::api
        YouTube["YouTube Shorts Page"]:::external
    end

    subgraph "Documentation"
        README["README.md"]:::docs
        SECURITY["SECURITY.md"]:::docs
        LICENSE["LICENSE.md"]:::docs
    end

    Browser -->|"loads"| Manifest
    Manifest -.->|"injects content script"| ContentScript
    Browser -->|"renders popup"| Popup
    Popup -->|"sends message"| ContentScript
    ContentScript -->|"listens for video ended"| YouTube
    ContentScript -->|"calls scroll action"| YouTube
    ContentScript -->|"uses APIs"| APIs
    Popup -->|"uses APIs"| APIs

    click Manifest "https://github.com/atsukii01/shortloopplus/blob/main/manifest.json"
    click Popup "https://github.com/atsukii01/shortloopplus/blob/main/popup.html"
    click ContentScript "https://github.com/atsukii01/shortloopplus/blob/main/content_youtube.js"
    click README "https://github.com/atsukii01/shortloopplus/blob/main/README.md"
    click SECURITY "https://github.com/atsukii01/shortloopplus/blob/main/SECURITY.md"
    click LICENSE "https://github.com/atsukii01/shortloopplus/blob/main/LICENSE.md"

    classDef extension fill:#D0E6FF,stroke:#0366d6,color:#000
    classDef external fill:#FFD8A8,stroke:#FF7F00,color:#000
    classDef api fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef docs fill:#F0F0F0,stroke:#999999,color:#000
```
