# ysdemiryilmaz/ysd_url_blocker architecture

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

- Interactive diagram: https://gitdiagram.com/ysdemiryilmaz/ysd_url_blocker
- Repository: https://github.com/ysdemiryilmaz/ysd_url_blocker

## Overview

YSD URL Blocker is a Chrome extension for inspecting page links and preventing unwanted navigations. The popup retrieves links from the active tab, lets users create site-scoped URL or domain rules, and stores rule and pause settings; content and page-context guards intercept clicks and script-opened windows, while the service worker enforces network and strict-mode blocking. The shared rule model supplies matching and scope logic. README evidence is minimal; the popup styling and HTML are not mapped as runtime components.

Main entry points: [`content.js`](https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/content.js) (Page link guard), [`background.js`](https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/background.js) (Background enforcement), [`popup.js`](https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/popup.js) (Popup and rules), [`inject.js`](https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/inject.js) (Scripted-window guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Popup controls"]
  node_popup["Popup and rules<br/>[popup.js]"]
end

subgraph group_blocking["Navigation blocking"]
  node_content["Page link guard<br/>[content.js]"]
  node_mainworld["Scripted-window guard<br/>[inject.js]"]
  node_worker["Background enforcement<br/>[background.js]"]
end

subgraph group_shared["Shared rules"]
  node_rules["Rule matching<br/>[rules.js]"]
  node_i18n["Interface language<br/>[i18n.js]"]
end

node_user(("User"))
node_page["Active webpage"]
node_storage[("Chrome extension storage")]

node_user -->|"manages rules"| node_popup
node_popup -->|"queries links"| node_page
node_page -->|"provides links"| node_content
node_popup -->|"reads and writes"| node_storage
node_worker -->|"reads settings"| node_storage
node_worker -->|"syncs rule changes"| node_storage
node_content -->|"reads rules"| node_storage
node_content -->|"requests pause state"| node_worker
node_worker -->|"broadcasts pause"| node_content
node_content -->|"sends rules"| node_mainworld
node_mainworld -->|"requests rules"| node_content
node_content -->|"cancels blocked clicks"| node_page
node_mainworld -->|"guards scripted opens"| node_page
node_worker -->|"blocks navigations"| node_page
node_worker -->|"updates session rules"| node_worker
node_content -->|"reports blocked links"| node_worker
node_mainworld -->|"reports blocked opens"| node_content
node_popup -->|"uses matching"| node_rules
node_content -->|"filters and matches"| node_rules
node_worker -->|"matches navigations"| node_rules
node_popup -->|"loads language"| node_i18n
node_content -->|"loads language"| node_i18n

click node_popup "https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/popup.js"
click node_content "https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/content.js"
click node_mainworld "https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/inject.js"
click node_worker "https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/background.js"
click node_rules "https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/rules.js"
click node_i18n "https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/i18n.js"

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,node_user toneBlue
class node_content,node_mainworld,node_worker,node_storage toneAmber
class node_rules,node_i18n toneMint
class node_page toneIndigo
```

## Components

### Popup controls

- [Popup and rules](https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/popup.js): `popup.js`

### Navigation blocking

- [Page link guard](https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/content.js): `content.js`
- [Scripted-window guard](https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/inject.js): `inject.js`
- [Background enforcement](https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/background.js): `background.js`

### Shared rules

- [Rule matching](https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/rules.js): `rules.js`
- [Interface language](https://github.com/ysdemiryilmaz/ysd_url_blocker/blob/main/i18n.js): `i18n.js`

### Other components

- **User**
- **Active webpage**
- **Chrome extension storage**

## Connections

- User → Popup and rules: manages rules (evidence: `popup.js`)
- Popup and rules → Active webpage: queries links (evidence: `popup.js`)
- Active webpage → Page link guard: provides links (evidence: `content.js`)
- Popup and rules → Chrome extension storage: reads and writes (evidence: `popup.js`)
- Background enforcement → Chrome extension storage: reads settings (evidence: `background.js`)
- Background enforcement → Chrome extension storage: syncs rule changes (evidence: `background.js`)
- Page link guard → Chrome extension storage: reads rules (evidence: `content.js`)
- Page link guard → Background enforcement: requests pause state (evidence: `content.js`)
- Background enforcement → Page link guard: broadcasts pause (evidence: `background.js`)
- Page link guard → Scripted-window guard: sends rules (evidence: `content.js`)
- Scripted-window guard → Page link guard: requests rules (evidence: `inject.js`)
- Page link guard → Active webpage: cancels blocked clicks (evidence: `content.js`)
- Scripted-window guard → Active webpage: guards scripted opens (evidence: `inject.js`)
- Background enforcement → Active webpage: blocks navigations (evidence: `background.js`)
- Background enforcement → Background enforcement: updates session rules (evidence: `background.js`)
- Page link guard → Background enforcement: reports blocked links (evidence: `content.js`)
- Scripted-window guard → Page link guard: reports blocked opens (evidence: `inject.js`)
- Popup and rules → Rule matching: uses matching (evidence: `popup.js`)
- Page link guard → Rule matching: filters and matches (evidence: `content.js`)
- Background enforcement → Rule matching: matches navigations (evidence: `background.js`)
- Popup and rules → Interface language: loads language (evidence: `popup.js`)
- Page link guard → Interface language: loads language (evidence: `content.js`)
