# darkhoundz/forced-browser architecture

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

- Interactive diagram: https://gitdiagram.com/darkhoundz/forced-browser
- Repository: https://github.com/darkhoundz/forced-browser

## Overview

Forced browser is a drop-in JavaScript script for captive-portal login or index pages. On page load it detects in-app browsers and presents an accessible prompt to open the current URL in a regular browser. The prompt supports platform-specific browser launch attempts, copying the URL (including a fallback), and dismissing the notice. The repository contains only one runtime file; the sampled excerpts do not show all detection-to-prompt wiring, so the graph avoids asserting uncertain internal calls.

Main entry points: [`forced_browser.js`](https://github.com/darkhoundz/forced-browser/blob/master/forced_browser.js) (Forced browser script)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_portal_user(("Portal visitor"))
node_script["Forced browser script<br/>[forced_browser.js]"]
node_detection["Webview detection<br/>[forced_browser.js]"]
node_prompt["Browser prompt<br/>[forced_browser.js]"]
node_launch["Browser launch<br/>[forced_browser.js]"]
node_copy["Link copying<br/>[forced_browser.js]"]
node_web_runtime["Browser runtime"]
node_regular_browser["Regular browser"]

node_portal_user -->|"loads portal page"| node_web_runtime
node_web_runtime -->|"runs on load"| node_script
node_script -->|"detects webview"| node_detection
node_prompt -->|"creates dialog"| node_web_runtime
node_launch -->|"opens URL"| node_regular_browser
node_copy -->|"copies URL"| node_web_runtime
node_portal_user -->|"chooses action"| node_prompt

click node_script "https://github.com/darkhoundz/forced-browser/blob/master/forced_browser.js"
click node_detection "https://github.com/darkhoundz/forced-browser/blob/master/forced_browser.js"
click node_prompt "https://github.com/darkhoundz/forced-browser/blob/master/forced_browser.js"
click node_launch "https://github.com/darkhoundz/forced-browser/blob/master/forced_browser.js"
click node_copy "https://github.com/darkhoundz/forced-browser/blob/master/forced_browser.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_portal_user toneIndigo
class node_script,node_detection,node_prompt,node_launch,node_web_runtime,node_regular_browser toneBlue
class node_copy toneTeal
```

## Components

### Other components

- **Portal visitor**
- [Forced browser script](https://github.com/darkhoundz/forced-browser/blob/master/forced_browser.js): `forced_browser.js`
- [Webview detection](https://github.com/darkhoundz/forced-browser/blob/master/forced_browser.js): `forced_browser.js`
- [Browser prompt](https://github.com/darkhoundz/forced-browser/blob/master/forced_browser.js): `forced_browser.js`
- [Browser launch](https://github.com/darkhoundz/forced-browser/blob/master/forced_browser.js): `forced_browser.js`
- [Link copying](https://github.com/darkhoundz/forced-browser/blob/master/forced_browser.js): `forced_browser.js`
- **Browser runtime**
- **Regular browser**

## Connections

- Portal visitor → Browser runtime: loads portal page
- Browser runtime → Forced browser script: runs on load
- Forced browser script → Webview detection: detects webview
- Browser prompt → Browser runtime: creates dialog
- Browser launch → Regular browser: opens URL
- Link copying → Browser runtime: copies URL
- Portal visitor → Browser prompt: chooses action
