# jumpingcodes/url-hider architecture

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

- Interactive diagram: https://gitdiagram.com/jumpingcodes/url-hider
- Repository: https://github.com/jumpingcodes/url-hider

## Overview

##### Project type and purpose
- URL-Hider is a Chrome browser extension whose purpose is to let users add URLs to a “hidden list,” automatically hide those URLs when those pages load, and allow the user to copy back the original URL on demand.

##### File structure
- manifest.json: describes extension metadata, permissions (tabs, storage), and entry points (background and popup).
- background.js: runs in the background context, listens for tab events, applies the hiding logic, and mediates storage.
- popup.html / popup.js / styles.css: the user‐facing popup UI where you add URLs to hide and copy them back.
- jsconfig.json: configures module resolution for any JS tooling.
- README.md: usage instructions.

##### README for additional insights
- No external services or servers—all logic runs client-side.
- Data persistence is implicit (Chrome Storage API).
- No content scripts—the background script directly uses the Chrome Tabs API to detect when a hidden URL is loaded.

##### Main components and their relationships
a. Components:
- Manifest (configuration)
- Popup UI (popup.html, popup.js, styles.css)
- Background Script (background.js)
- Chrome Runtime & Tabs APIs (built-in browser services)
- Storage (chrome.storage.local)
b. Interactions:
2. popup.js reads/writes hidden-URL list via chrome.storage.local.
3. background.js subscribes to chrome.tabs.onUpdated or chrome.tabs.onActivated events.
5. When the user clicks “copy original URL,” popup.js retrieves it (from a temporary in-memory map or storage) and writes it to the clipboard.
c. Architectural patterns:
- Event-driven messaging between popup UI and background script via Chrome runtime messaging or direct storage API.
- Clear separation: UI logic in popup, core logic in background, data layer in storage.
d. Key technologies:
- Chrome Extension Manifest v3 (or v2 if older)
- Chrome Storage API (chrome.storage.local)
- Chrome Tabs and Runtime APIs
- Vanilla JS for UI & background logic

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Configuration
    Manifest["manifest.json"]:::config
    JSConfig["jsconfig.json"]:::config
    README["README.md"]:::config

    %% UI Layer
    subgraph "Popup UI" 
        direction TB
        PopupHTML["popup.html"]:::ui
        PopupJS["popup.js"]:::ui
        Styles["styles.css"]:::ui
    end

    %% Background Layer
    Background["background.js"]:::logic

    %% Browser APIs
    subgraph "Browser APIs" 
        direction TB
        Storage["chrome.storage.local"]:::storage
        TabsAPI["chrome.tabs API"]:::api
        RuntimeAPI["chrome.runtime API"]:::api
    end

    %% Permissions & Entry Points
    Manifest -->|"entry: popup.html"| PopupHTML
    Manifest -->|"entry: background.js"| Background
    Manifest -->|"permissions: storage, tabs"| Storage
    Manifest -->|"permissions: tabs"| TabsAPI

    %% UI Interactions
    PopupJS -->|"read/write hidden list"| Storage
    PopupJS -->|"send copy request"| Background

    %% Background Interactions
    Background -->|"fetch hidden list"| Storage
    Background -->|"subscribe onUpdated/onActivated"| TabsAPI
    Background -->|"hide URL via update"| TabsAPI

    %% Legend grouping for config files
    Manifest --- JSConfig
    Manifest --- README

    %% Click Events
    click Manifest "https://github.com/jumpingcodes/url-hider/blob/main/manifest.json"
    click PopupHTML "https://github.com/jumpingcodes/url-hider/blob/main/popup.html"
    click PopupJS "https://github.com/jumpingcodes/url-hider/blob/main/popup.js"
    click Styles "https://github.com/jumpingcodes/url-hider/blob/main/styles.css"
    click Background "https://github.com/jumpingcodes/url-hider/blob/main/background.js"
    click JSConfig "https://github.com/jumpingcodes/url-hider/blob/main/jsconfig.json"
    click README "https://github.com/jumpingcodes/url-hider/blob/main/README.md"

    %% Styles
    classDef config fill:#f9f,stroke:#333,stroke-width:1px
    classDef ui fill:#bbf,stroke:#333,stroke-width:1px
    classDef logic fill:#bfb,stroke:#333,stroke-width:1px
    classDef api fill:#ddd,stroke:#333,stroke-width:1px
    classDef storage fill:#ffa,stroke:#333,stroke-width:1px
```
