# aashu-kattel/uner architecture

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

- Interactive diagram: https://gitdiagram.com/aashu-kattel/uner
- Repository: https://github.com/aashu-kattel/uner

## Overview

##### Main Components
- Manifest (manifest.json) – Declares permissions, content-script injection, and the popup UI.
- Popup UI (popup.html + popup.js) – Provides the toggle control and writes the enabled/disabled state to Chrome Storage Sync.
- Content Script (content.js) – Injected into every matching webpage; reads the toggle state, cleans existing links, and observes dynamic DOM changes.
- Chrome Storage Sync – Persists the toggle state across sessions and shares it between popup and content script.
- Host Webpage – Any webpage containing `` tags whose URLs need cleaning.

##### Relationships and Data Flows
- popup.js reads/writes the “enabled” flag in Chrome Storage Sync.
- popup.js sends a message or invokes chrome.tabs.reload() when toggled off.
- content.js checks the “enabled” flag on load; if true, it:
– Scans all `` tags, strips tracking parameters (utm_*, gclid, fbclid, etc.).
– Installs a MutationObserver to monitor newly added nodes and cleans their links.
- When the toggle is switched off, popup.js triggers a page reload; content.js sees “enabled = false” and does not clean.

##### Architectural Patterns
- Event-driven: popup UI events and DOM MutationObserver events.
- Separation of concerns: UI logic in popup, link-cleaning logic in content script.
- Message/state synchronization via Chrome Storage Sync (no persistent background script needed).

##### Technologies and APIs to Call Out
- Chrome Extensions APIs: chrome.storage.sync, chrome.tabs.reload, chrome.runtime.sendMessage/onMessage (if used)
- Web APIs: MutationObserver, DOM traversal (querySelectorAll)
- Standard HTML/CSS/JS for popup UI

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Chrome Extension Components
    subgraph "Chrome Extension"
        Manifest["Manifest<br/>manifest.json"]:::manifest
        PopupHTML["Popup UI (HTML)<br/>popup.html"]:::popup
        PopupJS["Popup UI (JS)<br/>popup.js"]:::popup
        Storage["Chrome Storage Sync"]:::storage
    end

    %% Host Webpage Components
    subgraph "Host Webpage"
        Webpage["Browser Tab / Webpage DOM"]:::webpage
        Content["Content Script<br/>content.js"]:::content
    end

    %% User Interaction
    User["User"]:::external
    User -->|"click toggle icon"| PopupHTML
    PopupHTML -->|"loads script"| PopupJS
    PopupJS -->|"chrome.storage.sync get/set 'enabled'"| Storage
    PopupJS -->|"chrome.tabs.reload"| Webpage

    %% Content Script Injection and Operations
    Manifest -->|"inject content script"| Content
    Content -->|"chrome.storage.sync get 'enabled'"| Storage
    Content -->|"strip parameters + observe mutations"| Webpage

    %% Click Events
    click Manifest "https://github.com/aashu-kattel/uner/blob/main/manifest.json"
    click PopupHTML "https://github.com/aashu-kattel/uner/blob/main/popup.html"
    click PopupJS "https://github.com/aashu-kattel/uner/blob/main/popup.js"
    click Content "https://github.com/aashu-kattel/uner/blob/main/content.js"

    %% Styles
    classDef popup fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef storage fill:#FFA500,stroke:#000,stroke-width:1px
    classDef content fill:#90EE90,stroke:#000,stroke-width:1px
    classDef webpage fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef manifest fill:#FFD1DC,stroke:#000,stroke-width:1px
    classDef external fill:#FFFFFF,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
```
