# sysrqmagician/extraneous architecture

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

- Interactive diagram: https://gitdiagram.com/sysrqmagician/extraneous
- Repository: https://github.com/sysrqmagician/extraneous

## Overview

##### Main Components
- Browser Extension Core – The project leverages a WebExtension manifest (manifest.json) that defines the extension’s identity and behavior.
- Background Script – Located in src/background.ts, this component handles extension lifecycle events, communication, and central logic.
- Content Script – Found in src/content.ts, it interacts directly with the web page content rendered by Invidious.
- Popup UI – In the popup folder (popup/popup.html), this UI component provides a user interface for configuration or notifications.
- Feature Modules – In the src/modules directory, several scripts (like additionalLinks.ts, deArrow.ts, hideSlop.ts, watched.ts) add specific functionalities.
- Configuration & Initialization – Files like src/config_popup.ts might manage custom settings or interactions from the popup.
- Build & Development Tools – Files such as build.ts, cog.toml, and workflow configurations in .github/workflows indicate automated build, linting, testing, or deployment pipelines.
- Deno Environment – The project uses Deno (as seen by deno.jsonc and deno.lock) to run and manage TypeScript code outside of traditional Node environments.

##### Relationships and Interactions
- The manifest.json acts as the entry point, linking various script components (background, content, UI).
- The Background script governs overall extension behavior and communicates with both content scripts and the popup UI.
- Content scripts embedded into web pages perform modifications (applying features like DeArrow or video hiding) by interacting with DOM elements.
- The Popup UI provides a front-end which sends user commands or settings to the background component.
- Feature modules operate as independent components under the background or content scripts, encapsulating their respective functionalities. They may also interact with one another if their features interlink (e.g., caching data or sharing configuration settings).

##### Architectural Patterns and Technologies
- Modularity: Functionalities are broken into discrete modules under src/modules.
- Separation of Concerns: The design separates the UI layer (popup), central logic (background), and web content manipulation (content scripts).
- Messaging/Communication: Expect a clear message-based API for communication between the popup, background, and content scripts.
- Build & Automation: The CI/CD integration (via .github/workflows), Deno runtime, and build scripts (build.ts, Justfile) align with modern JavaScript/TypeScript project practices.

## Diagram (Mermaid)

```mermaid
flowchart TD
    M("Browser Extension Core (manifest.json)"):::core

    subgraph "Runtime Components"
        direction TB
        BG("Background Script (src/background.ts)"):::runtime
        CS("Content Script (src/content.ts)"):::runtime
        PU("Popup UI (popup/popup.html)"):::runtime
    end

    subgraph "Feature Modules"
        direction TB
        AL("Additional Links (src/modules/additionalLinks.ts)"):::module
        DA("DeArrow (src/modules/deArrow.ts)"):::module
        HS("HideSlop (src/modules/hideSlop.ts)"):::module
        WT("Watched (src/modules/watched.ts)"):::module
    end

    C("Configuration & Initialization (src/config_popup.ts)"):::core

    subgraph "Build & Development Tools"
        direction TB
        B1("build.ts"):::build
        B2("cog.toml"):::build
        B3("deno.jsonc"):::build
        B4("deno.lock"):::build
        B5(".github/workflows/deno.yml"):::build
        B6("Justfile"):::build
    end

    %% Interactions between components
    M -->|"loads"| BG
    M -->|"loads"| CS
    M -->|"loads"| PU

    PU -->|"sends_commands"| BG
    BG -->|"communicates_with"| CS

    CS -->|"injects_features"| AL
    CS -->|"injects_features"| DA
    CS -->|"injects_features"| HS
    CS -->|"injects_features"| WT

    PU -->|"configures"| C
    BG -->|"reads_config"| C
    C -->|"updates"| BG

    %% Build tools triggering builds/deployments
    B1 -->|"triggers_build"| M
    B2 -->|"triggers_build"| M
    B3 -->|"triggers_build"| M
    B4 -->|"triggers_build"| M
    B5 -->|"triggers_build"| M
    B6 -->|"triggers_build"| M

    %% Click Events
    click M "https://github.com/sysrqmagician/extraneous/blob/main/manifest.json"
    click BG "https://github.com/sysrqmagician/extraneous/blob/main/src/background.ts"
    click CS "https://github.com/sysrqmagician/extraneous/blob/main/src/content.ts"
    click PU "https://github.com/sysrqmagician/extraneous/blob/main/popup/popup.html"
    click AL "https://github.com/sysrqmagician/extraneous/blob/main/src/modules/additionalLinks.ts"
    click DA "https://github.com/sysrqmagician/extraneous/blob/main/src/modules/deArrow.ts"
    click HS "https://github.com/sysrqmagician/extraneous/blob/main/src/modules/hideSlop.ts"
    click WT "https://github.com/sysrqmagician/extraneous/blob/main/src/modules/watched.ts"
    click C "https://github.com/sysrqmagician/extraneous/blob/main/src/config_popup.ts"
    click B1 "https://github.com/sysrqmagician/extraneous/blob/main/build.ts"
    click B2 "https://github.com/sysrqmagician/extraneous/blob/main/cog.toml"
    click B3 "https://github.com/sysrqmagician/extraneous/blob/main/deno.jsonc"
    click B4 "https://github.com/sysrqmagician/extraneous/blob/main/deno.lock"
    click B5 "https://github.com/sysrqmagician/extraneous/blob/main/.github/workflows/deno.yml"
    click B6 "https://github.com/sysrqmagician/extraneous/tree/main/Justfile"

    %% Styles
    classDef core fill:#ffdead,stroke:#333,stroke-width:2px;
    classDef runtime fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef module fill:#d1e7dd,stroke:#333,stroke-width:2px;
    classDef build fill:#f8d7da,stroke:#333,stroke-width:2px;
```
