# 27sayan/web-defender architecture

> Architecture diagram of the GitHub repository 27sayan/web-defender, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/27sayan/web-defender
- Repository: https://github.com/27sayan/web-defender

## Overview

This repository contains browser-extension security scanners for phishing, DOM-based XSS, and clickjacking, including an integrated extension and separate scanner variants. In the integrated workflow, page scripts inspect the current page and report findings to a background script; the popup requests and displays the stored status, while the background can inject an overall warning into the active tab. Separate extensions have their own reporting behavior. The README is empty, so capabilities and relationships here are based on the shown source; unsampled manifests and evaluation artifacts are not mapped.

Main entry points: [`main/background.js`](https://github.com/27sayan/web-defender/blob/master/main/background.js) (Status Background), [`main/phishingDetection.js`](https://github.com/27sayan/web-defender/blob/master/main/phishingDetection.js) (Phishing Checks), [`main/xssDetection.js`](https://github.com/27sayan/web-defender/blob/master/main/xssDetection.js) (DOM XSS Checks), [`main/clickDetection.js`](https://github.com/27sayan/web-defender/blob/master/main/clickDetection.js) (Clickjacking Checks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integrated["Integrated Scanner"]
  node_main_phish["Phishing Checks"]
  node_main_xss["DOM XSS Checks<br/>[xssDetection.js]"]
  node_main_click["Clickjacking Checks<br/>[clickDetection.js]"]
  node_main_bg["Status Background<br/>[background.js]"]
  node_main_popup["Results Popup<br/>[popup.js]"]
end

subgraph group_standalone_click["Clickjacking Extension"]
  node_click_page["Page Checks<br/>[content.js]"]
  node_click_bg["Clickjacking Background<br/>[background.js]"]
end

subgraph group_standalone_phish["Phishing Extension"]
  node_phish_page["Phishing Checks<br/>[content.js]"]
  node_phish_bg["Phishing Background<br/>[background.js]"]
  node_phish_ui["Phishing Result UI<br/>[content.js]"]
end

subgraph group_standalone_xss["XSS Extension"]
  node_xss_page["DOM XSS Scanner<br/>[content.js]"]
end

node_page(("Visited Page"))

node_page -->|"supplies URL and DOM"| node_main_phish
node_page -->|"supplies page state"| node_main_xss
node_page -->|"supplies page state"| node_main_click
node_main_phish -->|"sends finding"| node_main_bg
node_main_xss -->|"sends finding"| node_main_bg
node_main_click -->|"sends finding"| node_main_bg
node_main_popup -->|"requests statuses"| node_main_bg
node_main_bg -->|"returns statuses"| node_main_popup
node_main_bg -->|"injects summary"| node_page
node_page -->|"supplies URL and DOM"| node_click_page
node_click_page -->|"sends finding"| node_click_bg
node_click_bg -->|"injects result"| node_page
node_page -->|"supplies URL and DOM"| node_phish_page
node_phish_page -->|"sends prediction"| node_phish_bg
node_phish_bg -->|"forwards prediction"| node_phish_ui
node_page -->|"hosts result UI"| node_phish_ui
node_page -->|"supplies URL and DOM"| node_xss_page

click node_main_phish "https://github.com/27sayan/web-defender/blob/master/main/phishingDetection.js"
click node_main_xss "https://github.com/27sayan/web-defender/blob/master/main/xssDetection.js"
click node_main_click "https://github.com/27sayan/web-defender/blob/master/main/clickDetection.js"
click node_main_bg "https://github.com/27sayan/web-defender/blob/master/main/background.js"
click node_main_popup "https://github.com/27sayan/web-defender/blob/master/main/popup.js"
click node_click_page "https://github.com/27sayan/web-defender/blob/master/Clickjacking/content.js"
click node_click_bg "https://github.com/27sayan/web-defender/blob/master/Clickjacking/background.js"
click node_phish_page "https://github.com/27sayan/web-defender/blob/master/Phishing/Extension/content.js"
click node_phish_bg "https://github.com/27sayan/web-defender/blob/master/Phishing/Extension/background.js"
click node_phish_ui "https://github.com/27sayan/web-defender/blob/master/Phishing/Extension/content.js"
click node_xss_page "https://github.com/27sayan/web-defender/blob/master/XSS/content.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_main_phish,node_main_xss,node_main_click,node_main_bg,node_main_popup toneBlue
class node_click_page,node_click_bg toneAmber
class node_phish_page,node_phish_bg,node_phish_ui toneMint
class node_xss_page toneRose
class node_page toneIndigo
```

## Components

### Integrated Scanner

- [Phishing Checks](https://github.com/27sayan/web-defender/blob/master/main/phishingDetection.js): `main/phishingDetection.js`
- [DOM XSS Checks](https://github.com/27sayan/web-defender/blob/master/main/xssDetection.js): `main/xssDetection.js`
- [Clickjacking Checks](https://github.com/27sayan/web-defender/blob/master/main/clickDetection.js): `main/clickDetection.js`
- [Status Background](https://github.com/27sayan/web-defender/blob/master/main/background.js): `main/background.js`
- [Results Popup](https://github.com/27sayan/web-defender/blob/master/main/popup.js): `main/popup.js`

### Clickjacking Extension

- [Page Checks](https://github.com/27sayan/web-defender/blob/master/Clickjacking/content.js): `Clickjacking/content.js`
- [Clickjacking Background](https://github.com/27sayan/web-defender/blob/master/Clickjacking/background.js): `Clickjacking/background.js`

### Phishing Extension

- [Phishing Checks](https://github.com/27sayan/web-defender/blob/master/Phishing/Extension/content.js): `Phishing/Extension/content.js`
- [Phishing Background](https://github.com/27sayan/web-defender/blob/master/Phishing/Extension/background.js): `Phishing/Extension/background.js`
- [Phishing Result UI](https://github.com/27sayan/web-defender/blob/master/Phishing/Extension/content.js): `Phishing/Extension/content.js`

### XSS Extension

- [DOM XSS Scanner](https://github.com/27sayan/web-defender/blob/master/XSS/content.js): `XSS/content.js`

### Other components

- **Visited Page**

## Connections

- Visited Page → Phishing Checks: supplies URL and DOM (evidence: `main/phishingDetection.js`)
- Visited Page → DOM XSS Checks: supplies page state (evidence: `main/xssDetection.js`)
- Visited Page → Clickjacking Checks: supplies page state (evidence: `main/clickDetection.js`)
- Phishing Checks → Status Background: sends finding (evidence: `main/phishingDetection.js`)
- DOM XSS Checks → Status Background: sends finding (evidence: `main/xssDetection.js`)
- Clickjacking Checks → Status Background: sends finding (evidence: `main/clickDetection.js`)
- Results Popup → Status Background: requests statuses (evidence: `main/popup.js`)
- Status Background → Results Popup: returns statuses (evidence: `main/background.js`)
- Status Background → Visited Page: injects summary (evidence: `main/background.js`)
- Visited Page → Page Checks: supplies URL and DOM (evidence: `Clickjacking/content.js`)
- Page Checks → Clickjacking Background: sends finding (evidence: `Clickjacking/content.js`)
- Clickjacking Background → Visited Page: injects result (evidence: `Clickjacking/background.js`)
- Visited Page → Phishing Checks: supplies URL and DOM (evidence: `Phishing/Extension/content.js`)
- Phishing Checks → Phishing Background: sends prediction (evidence: `Phishing/Extension/content.js`)
- Phishing Background → Phishing Result UI: forwards prediction (evidence: `Phishing/Extension/background.js`)
- Visited Page → Phishing Result UI: hosts result UI (evidence: `Phishing/Extension/content.js`)
- Visited Page → DOM XSS Scanner: supplies URL and DOM (evidence: `XSS/content.js`)
