# the1812/bilibili-evolved architecture

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

- Interactive diagram: https://gitdiagram.com/the1812/bilibili-evolved
- Repository: https://github.com/the1812/bilibili-evolved

## Overview

Bilibili Evolved is a browser userscript that enhances Bilibili with optional, user-installed components. The principal workflow is: a user opens Bilibili, the script initializes, loads enabled components and plugins according to settings, and those features adapt the page. The repository also includes feature families for feeds, live, styling, touch, utilities, and video, plus a development hot-reload path. Edges are limited to relationships visible in the README or supplied source/index references; unsampled feature internals are represented by their directories.

Main entry points: [`src/components/component.ts`](https://github.com/the1812/bilibili-evolved/blob/master/src/components/component.ts) (Component loading), [`src/plugins/plugin.ts`](https://github.com/the1812/bilibili-evolved/blob/master/src/plugins/plugin.ts) (Plugin loading), [`src/core/style.ts`](https://github.com/the1812/bilibili-evolved/blob/master/src/core/style.ts) (Style runtime), [`src/client/init.ts`](https://github.com/the1812/bilibili-evolved/blob/master/src/client/init.ts) (Client initialization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Userscript runtime"]
  node_init["Client initialization<br/>[init.ts]"]
  node_component["Component loading<br/>[component.ts]"]
  node_settings[("Settings<br/>[index.ts]")]
  node_plugins["Plugin loading<br/>[plugin.ts]"]
  node_plugin_data["Plugin data<br/>[data.ts]"]
  node_plugin_hooks["Plugin hooks<br/>[hook.ts]"]
  node_lifecycle["Lifecycle<br/>[life-cycle.ts]"]
  node_core_apis["Core APIs<br/>[core-apis.ts]"]
  node_style["Style runtime<br/>[style.ts]"]
  node_ajax["AJAX<br/>[ajax.ts]"]
  node_observer["DOM observer<br/>[observer.ts]"]
  node_spin_query["DOM queries<br/>[spin-query.ts]"]
  node_utils["Core utilities<br/>[index.ts]"]
end

subgraph group_features["Page features"]
  node_feeds["Feed enhancements"]
  node_live["Live enhancements"]
  node_style_features["Style features"]
  node_touch["Touch features"]
  node_utilities["Utility features"]
  node_video["Video features"]
end

subgraph group_dev["Development client"]
  node_dev_client["Dev hot reload<br/>[client.ts]"]
  node_dev_server["Dev server<br/>[server.ts]"]
  node_registry_watcher["Registry watcher"]
  node_websocket["WebSocket server"]
end

node_user(("Bilibili user"))
node_bilibili["Bilibili page"]

node_user -->|"opens"| node_bilibili
node_bilibili -.->|"runs script"| node_init
node_init -->|"loads"| node_component
node_init -->|"uses"| node_lifecycle
node_component -->|"reads"| node_settings
node_component -->|"waits for"| node_lifecycle
node_component -->|"loads"| node_plugins
node_plugins -->|"reads"| node_settings
node_plugins -->|"uses"| node_plugin_data
node_plugins -->|"uses"| node_plugin_hooks
node_style -->|"reads"| node_settings
node_style -->|"uses"| node_plugin_hooks
node_component -->|"loads styles"| node_style
node_dev_client -->|"fetches code"| node_ajax
node_dev_client -->|"refreshes styles"| node_style
node_dev_server -->|"starts"| node_registry_watcher
node_dev_server -->|"starts"| node_websocket
node_registry_watcher -->|"notifies"| node_websocket
node_spin_query -->|"watches mutations"| node_observer
node_observer -->|"uses"| node_utils
node_video -.->|"enhances video pages"| node_bilibili
node_feeds -.->|"enhances feeds"| node_bilibili
node_live -.->|"enhances live pages"| node_bilibili
node_style_features -.->|"changes appearance"| node_bilibili
node_touch -.->|"adds touch controls"| node_bilibili
node_utilities -.->|"adds utilities"| node_bilibili

click node_init "https://github.com/the1812/bilibili-evolved/blob/master/src/client/init.ts"
click node_component "https://github.com/the1812/bilibili-evolved/blob/master/src/components/component.ts"
click node_settings "https://github.com/the1812/bilibili-evolved/blob/master/src/core/settings/index.ts"
click node_plugins "https://github.com/the1812/bilibili-evolved/blob/master/src/plugins/plugin.ts"
click node_plugin_data "https://github.com/the1812/bilibili-evolved/blob/master/src/plugins/data.ts"
click node_plugin_hooks "https://github.com/the1812/bilibili-evolved/blob/master/src/plugins/hook.ts"
click node_lifecycle "https://github.com/the1812/bilibili-evolved/blob/master/src/core/life-cycle.ts"
click node_core_apis "https://github.com/the1812/bilibili-evolved/blob/master/src/core/core-apis.ts"
click node_style "https://github.com/the1812/bilibili-evolved/blob/master/src/core/style.ts"
click node_ajax "https://github.com/the1812/bilibili-evolved/blob/master/src/core/ajax.ts"
click node_observer "https://github.com/the1812/bilibili-evolved/blob/master/src/core/observer.ts"
click node_spin_query "https://github.com/the1812/bilibili-evolved/blob/master/src/core/spin-query.ts"
click node_utils "https://github.com/the1812/bilibili-evolved/blob/master/src/core/utils/index.ts"
click node_feeds "https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/feeds"
click node_live "https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/live"
click node_style_features "https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/style"
click node_touch "https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/touch"
click node_utilities "https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/utils"
click node_video "https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/video"
click node_dev_client "https://github.com/the1812/bilibili-evolved/blob/master/registry/lib/components/utils/dev-client/client.ts"
click node_dev_server "https://github.com/the1812/bilibili-evolved/blob/master/dev-tools/dev-server/server.ts"
click node_registry_watcher "https://github.com/the1812/bilibili-evolved/blob/master/dev-tools/dev-server/registry-watcher.ts"
click node_websocket "https://github.com/the1812/bilibili-evolved/blob/master/dev-tools/dev-server/web-socket-server.ts"

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_init,node_component,node_settings,node_plugins,node_plugin_data,node_plugin_hooks,node_lifecycle,node_core_apis,node_style,node_ajax,node_observer,node_spin_query,node_utils,node_user toneBlue
class node_feeds,node_live,node_style_features,node_touch,node_utilities,node_video toneAmber
class node_dev_client,node_dev_server,node_registry_watcher,node_websocket toneMint
class node_bilibili toneIndigo
```

## Components

### Userscript runtime

- [Client initialization](https://github.com/the1812/bilibili-evolved/blob/master/src/client/init.ts): `src/client/init.ts`
- [Component loading](https://github.com/the1812/bilibili-evolved/blob/master/src/components/component.ts): `src/components/component.ts`
- [Settings](https://github.com/the1812/bilibili-evolved/blob/master/src/core/settings/index.ts): `src/core/settings/index.ts`
- [Plugin loading](https://github.com/the1812/bilibili-evolved/blob/master/src/plugins/plugin.ts): `src/plugins/plugin.ts`
- [Plugin data](https://github.com/the1812/bilibili-evolved/blob/master/src/plugins/data.ts): `src/plugins/data.ts`
- [Plugin hooks](https://github.com/the1812/bilibili-evolved/blob/master/src/plugins/hook.ts): `src/plugins/hook.ts`
- [Lifecycle](https://github.com/the1812/bilibili-evolved/blob/master/src/core/life-cycle.ts): `src/core/life-cycle.ts`
- [Core APIs](https://github.com/the1812/bilibili-evolved/blob/master/src/core/core-apis.ts): `src/core/core-apis.ts`
- [Style runtime](https://github.com/the1812/bilibili-evolved/blob/master/src/core/style.ts): `src/core/style.ts`
- [AJAX](https://github.com/the1812/bilibili-evolved/blob/master/src/core/ajax.ts): `src/core/ajax.ts`
- [DOM observer](https://github.com/the1812/bilibili-evolved/blob/master/src/core/observer.ts): `src/core/observer.ts`
- [DOM queries](https://github.com/the1812/bilibili-evolved/blob/master/src/core/spin-query.ts): `src/core/spin-query.ts`
- [Core utilities](https://github.com/the1812/bilibili-evolved/blob/master/src/core/utils/index.ts): `src/core/utils/index.ts`

### Page features

- [Feed enhancements](https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/feeds): `registry/lib/components/feeds`
- [Live enhancements](https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/live): `registry/lib/components/live`
- [Style features](https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/style): `registry/lib/components/style`
- [Touch features](https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/touch): `registry/lib/components/touch`
- [Utility features](https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/utils): `registry/lib/components/utils`
- [Video features](https://github.com/the1812/bilibili-evolved/tree/master/registry/lib/components/video): `registry/lib/components/video`

### Development client

- [Dev hot reload](https://github.com/the1812/bilibili-evolved/blob/master/registry/lib/components/utils/dev-client/client.ts): `registry/lib/components/utils/dev-client/client.ts`
- [Dev server](https://github.com/the1812/bilibili-evolved/blob/master/dev-tools/dev-server/server.ts): `dev-tools/dev-server/server.ts`
- [Registry watcher](https://github.com/the1812/bilibili-evolved/blob/master/dev-tools/dev-server/registry-watcher.ts): `dev-tools/dev-server/registry-watcher.ts`
- [WebSocket server](https://github.com/the1812/bilibili-evolved/blob/master/dev-tools/dev-server/web-socket-server.ts): `dev-tools/dev-server/web-socket-server.ts`

### Other components

- **Bilibili user**
- **Bilibili page**

## Connections

- Bilibili user → Bilibili page: opens (evidence: `README.md`)
- Bilibili page → Client initialization: runs script (evidence: `README.md`)
- Client initialization → Component loading: loads (evidence: `src/client/init.ts`)
- Client initialization → Lifecycle: uses (evidence: `src/client/init.ts`)
- Component loading → Settings: reads (evidence: `src/components/component.ts`)
- Component loading → Lifecycle: waits for (evidence: `src/components/component.ts`)
- Component loading → Plugin loading: loads (evidence: `src/components/component.ts`)
- Plugin loading → Settings: reads (evidence: `src/plugins/plugin.ts`)
- Plugin loading → Plugin data: uses (evidence: `src/plugins/plugin.ts`)
- Plugin loading → Plugin hooks: uses (evidence: `src/plugins/plugin.ts`)
- Style runtime → Settings: reads (evidence: `src/core/style.ts`)
- Style runtime → Plugin hooks: uses (evidence: `src/core/style.ts`)
- Component loading → Style runtime: loads styles (evidence: `src/components/component.ts`)
- Dev hot reload → AJAX: fetches code (evidence: `registry/lib/components/utils/dev-client/client.ts`)
- Dev hot reload → Style runtime: refreshes styles (evidence: `registry/lib/components/utils/dev-client/client.ts`)
- Dev server → Registry watcher: starts (evidence: `dev-tools/dev-server/server.ts`)
- Dev server → WebSocket server: starts (evidence: `dev-tools/dev-server/server.ts`)
- Registry watcher → WebSocket server: notifies (evidence: `dev-tools/dev-server/registry-watcher.ts`)
- DOM queries → DOM observer: watches mutations (evidence: `src/core/spin-query.ts`)
- DOM observer → Core utilities: uses (evidence: `src/core/observer.ts`)
- Video features → Bilibili page: enhances video pages (evidence: `README.md`)
- Feed enhancements → Bilibili page: enhances feeds (evidence: `README.md`)
- Live enhancements → Bilibili page: enhances live pages (evidence: `README.md`)
- Style features → Bilibili page: changes appearance (evidence: `README.md`)
- Touch features → Bilibili page: adds touch controls (evidence: `README.md`)
- Utility features → Bilibili page: adds utilities (evidence: `README.md`)
