# yahianshi/puretube architecture

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

- Interactive diagram: https://gitdiagram.com/yahianshi/puretube
- Repository: https://github.com/yahianshi/puretube

## Overview

PureTube is a Chromium extension that optimizes YouTube playback and presentation. A viewer watches YouTube while the content script applies SponsorBlock skips, silence acceleration, volume gain, and CSS-based debloating; saved-time metrics are persisted and shown in the popup. Users configure features in the popup, which stores preferences and sends live updates to the active tab. The README documents the combined audio graph and SPA lifecycle; sampled excerpts show settings, messaging, API fetching, and statistics. Some internal wiring is not excerpted, so unsupported links are omitted.

Main entry points: [`content.js`](https://github.com/yahianshi/puretube/blob/main/content.js) (Content engine), [`popup.js`](https://github.com/yahianshi/puretube/blob/main/popup.js) (Popup controller), [`popup.html`](https://github.com/yahianshi/puretube/blob/main/popup.html) (Popup controls), [`debloat.css`](https://github.com/yahianshi/puretube/blob/main/debloat.css) (CSS debloater)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Popup interface"]
  node_popup_ui["Popup controls<br/>[popup.html]"]
  node_popup_controller["Popup controller<br/>[popup.js]"]
  node_popup_styles["Popup styling<br/>[popup.css]"]
end

subgraph group_playback["Playback engine"]
  node_content_engine["Content engine<br/>[content.js]"]
  node_segment_handler["Segment skip and undo<br/>[content.js]"]
  node_silence_engine["Silence skipper<br/>[content.js]"]
  node_audio_pipeline["Audio gain pipeline<br/>[content.js]"]
end

subgraph group_presentation["YouTube presentation"]
  node_segment_display["Highlights and toast<br/>[content.js]"]
  node_debloater["CSS debloater<br/>[debloat.css]"]
end

subgraph group_persistence["Settings and analytics"]
  node_settings_store[("Sync settings")]
  node_stats_manager["Time-saved tracker<br/>[content.js]"]
  node_stats_store[("Local stats")]
end

node_viewer(("Viewer"))
node_youtube["YouTube player"]
node_sponsor_api["SponsorBlock API"]

node_viewer -->|"watches"| node_youtube
node_viewer -->|"configures"| node_popup_ui
node_popup_ui -->|"controls"| node_popup_controller
node_popup_controller -->|"writes settings"| node_settings_store
node_content_engine -->|"reads settings"| node_settings_store
node_popup_controller -->|"sends updates"| node_content_engine
node_youtube -->|"provides playback"| node_content_engine
node_content_engine -->|"fetches segments"| node_sponsor_api
node_content_engine -->|"dispatches skips"| node_segment_handler
node_segment_handler -->|"seeks video"| node_youtube
node_segment_handler -->|"shows skip UI"| node_segment_display
node_content_engine -->|"runs detection"| node_silence_engine
node_silence_engine -->|"uses analysis"| node_audio_pipeline
node_audio_pipeline -->|"amplifies audio"| node_youtube
node_content_engine -->|"sets root attributes"| node_debloater
node_content_engine -->|"tracks playback"| node_stats_manager
node_stats_manager -->|"persists metrics"| node_stats_store
node_popup_controller -->|"loads metrics"| node_stats_store
node_popup_controller -->|"requests stats"| node_content_engine

click node_popup_ui "https://github.com/yahianshi/puretube/blob/main/popup.html"
click node_popup_controller "https://github.com/yahianshi/puretube/blob/main/popup.js"
click node_content_engine "https://github.com/yahianshi/puretube/blob/main/content.js"
click node_segment_handler "https://github.com/yahianshi/puretube/blob/main/content.js"
click node_segment_display "https://github.com/yahianshi/puretube/blob/main/content.js"
click node_silence_engine "https://github.com/yahianshi/puretube/blob/main/content.js"
click node_audio_pipeline "https://github.com/yahianshi/puretube/blob/main/content.js"
click node_debloater "https://github.com/yahianshi/puretube/blob/main/debloat.css"
click node_stats_manager "https://github.com/yahianshi/puretube/blob/main/content.js"
click node_popup_styles "https://github.com/yahianshi/puretube/blob/main/popup.css"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_popup_ui,node_popup_controller,node_popup_styles,node_viewer toneBlue
class node_content_engine,node_segment_handler,node_silence_engine,node_audio_pipeline toneAmber
class node_segment_display,node_debloater,node_sponsor_api toneMint
class node_settings_store,node_stats_manager,node_stats_store toneRose
class node_youtube toneIndigo
```

## Components

### Popup interface

- [Popup controls](https://github.com/yahianshi/puretube/blob/main/popup.html): `popup.html`
- [Popup controller](https://github.com/yahianshi/puretube/blob/main/popup.js): `popup.js`
- [Popup styling](https://github.com/yahianshi/puretube/blob/main/popup.css): `popup.css`

### Playback engine

- [Content engine](https://github.com/yahianshi/puretube/blob/main/content.js): `content.js`
- [Segment skip and undo](https://github.com/yahianshi/puretube/blob/main/content.js): `content.js`
- [Silence skipper](https://github.com/yahianshi/puretube/blob/main/content.js): `content.js`
- [Audio gain pipeline](https://github.com/yahianshi/puretube/blob/main/content.js): `content.js`

### YouTube presentation

- [Highlights and toast](https://github.com/yahianshi/puretube/blob/main/content.js): `content.js`
- [CSS debloater](https://github.com/yahianshi/puretube/blob/main/debloat.css): `debloat.css`

### Settings and analytics

- **Sync settings**
- [Time-saved tracker](https://github.com/yahianshi/puretube/blob/main/content.js): `content.js`
- **Local stats**

### Other components

- **Viewer**
- **YouTube player**
- **SponsorBlock API**

## Connections

- Viewer → YouTube player: watches (evidence: `README.md`)
- Viewer → Popup controls: configures (evidence: `README.md`)
- Popup controls → Popup controller: controls (evidence: `popup.js`)
- Popup controller → Sync settings: writes settings (evidence: `popup.js`)
- Content engine → Sync settings: reads settings (evidence: `content.js`)
- Popup controller → Content engine: sends updates (evidence: `popup.js`)
- YouTube player → Content engine: provides playback (evidence: `README.md`)
- Content engine → SponsorBlock API: fetches segments (evidence: `content.js`)
- Content engine → Segment skip and undo: dispatches skips (evidence: `README.md`)
- Segment skip and undo → YouTube player: seeks video (evidence: `README.md`)
- Segment skip and undo → Highlights and toast: shows skip UI (evidence: `content.js`)
- Content engine → Silence skipper: runs detection (evidence: `content.js`)
- Silence skipper → Audio gain pipeline: uses analysis (evidence: `README.md`)
- Audio gain pipeline → YouTube player: amplifies audio (evidence: `README.md`)
- Content engine → CSS debloater: sets root attributes (evidence: `README.md`)
- Content engine → Time-saved tracker: tracks playback (evidence: `content.js`)
- Time-saved tracker → Local stats: persists metrics (evidence: `content.js`)
- Popup controller → Local stats: loads metrics (evidence: `popup.js`)
- Popup controller → Content engine: requests stats (evidence: `popup.js`)
