Skip to content

Commit

Permalink
finished docs and updated dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
eric2788 committed Mar 9, 2024
1 parent 1df8270 commit d891d00
Show file tree
Hide file tree
Showing 11 changed files with 650 additions and 148 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ tests/
目录如下:
```
docs/
├── adapters.md # 适配器的模块
├── background.md # 后台脚本的模块
├── database.md # 数据库的结构定义
├── features.md # 新增功能模块
├── pages.md # 新增扩展页面
└── settings.md # 新增设定区块
Expand Down
21 changes: 21 additions & 0 deletions docs/adapters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 适配器

用于连接或转换不同的B站WS数据源以供内容脚本使用。

## 适配器列表

目前只有 `WebSocket``Dom` 两种适配器。

WebSocket 是目前最常用的适配器,它直接挂钩网页上的 WebSocket 客户端,以获取B站WS数据。

Dom 适配器则是通过解析网页上的DOM元素,以获取特定数据。

WebSocket 相比Dom适配器更加稳定和更加泛用。但万一 WebSocket 无法使用,Dom 适配器则是一个备选方案。

如果你需要新增一个适配器,你需要留意以下内容:

- 你需要用到 [`utils/messaging.ts`](/src/utils/messaging.ts) 中的 `sendBLiveMessage` 方法,以发送数据到内容脚本。

- 新增方式可以在 `adapters/` 目录下创建文件,然后在 `adapters/index.ts` 中进行注册。

- 基于目前以WS为主的情况,你需要发送以 WS 结构为準的数据。
Loading

0 comments on commit d891d00

Please sign in to comment.