# Qingtian Bridge — 2026-08-25 调试详情

## 1. 项目

**Qingtian Bridge 0.1.0**

用途：连接 ChatGPT 与 Qingtian Web 的每日记录系统。

## 2. 已确认环境

Chrome 扩展为 Unpacked Extension。

扩展名称：

```text
Qingtian Bridge
```

扩展 ID：

```text
hhdnhocgepodjfkdjfminhihnjdebklh
```

扩展目录：

```text
C:\QingtianBridge
```

Chrome Extensions 页面显示扩展为 On。

## 3. Manifest

Manifest 使用：

```text
manifest_version: 3
```

权限包括：

```text
activeTab
storage
tabs
```

Host permissions：

```text
https://chatgpt.com/*
https://iiei-server.tail37e617.ts.net/*
```

Background：

```text
background.js
```

ChatGPT content script：

```text
content.js
```

Qingtian Web content script：

```text
qingtian.js
```

## 4. ChatGPT 测试

Chrome DevTools Console 可以看到：

```text
[Qingtian Bridge] content.js LOADED
```

因此 `content.js` 并非完全没有加载。

## 5. Qingtian Web 测试

点击读取 ChatGPT 内容后出现：

```text
桥接失败：

ChatGPT 页面没有加载 Qingtian content.js。

Could not establish connection. Receiving end does not exist.
```

另一次测试直接出现：

```text
桥接失败：

Could not establish connection. Receiving end does not exist.
```

## 6. Chrome Extension Errors

Chrome Extensions → Qingtian Bridge → Errors 中记录：

```text
[Qingtian Bridge] Error:
Could not establish connection. Receiving end does not exist.
```

Stack Trace 指向：

```text
qingtian.js:63
```

## 7. 当前判断

现在应该重点检查 **message receiver 和消息路由**。

目标链路应为：

```text
Qingtian Web
    ↓
qingtian.js
    ↓
background.js / service worker
    ↓
ChatGPT tab
    ↓
content.js
```

需要确认：

1. `background.js` service worker 是否正在运行。
2. `background.js` 是否注册 `chrome.runtime.onMessage.addListener(...)`。
3. `qingtian.js` 是否直接发送给不存在的 receiver。
4. `content.js` 是否注册 message listener。
5. `tabs.sendMessage()` 使用的 tab ID 是否正确。
6. ChatGPT tab 是否已经加载 `content.js`。
7. ChatGPT 页面刷新后 content script 是否重新加载。
8. Manifest 的 `content_scripts.matches` 是否覆盖实际 ChatGPT URL。

## 8. 明天调试顺序

### A. Service worker

打开：

```text
chrome://extensions
```

进入 Qingtian Bridge：

```text
Inspect views → service worker
```

确认 `background.js` 正常运行。

### B. ChatGPT content.js

确认 Console：

```text
[Qingtian Bridge] content.js LOADED
```

并确认 message listener 已注册。

### C. qingtian.js

检查发送消息的代码和发送目标。

### D. background.js

建议使用 background 作为唯一中转层：

```text
Qingtian → background → ChatGPT content.js
```

### E. 最终测试

验证：

```text
ChatGPT
  ↓
content.js
  ↓
background.js
  ↓
qingtian.js
  ↓
Qingtian Web
```

最终目标是让 ChatGPT 对话内容能够正常写入 Qingtian 的 Daily Markdown 和 Detail Markdown。

## 9. 核心错误

```text
Receiving end does not exist
```

含义：发送消息时，Chrome 找不到对应的 message receiver。

所以下一阶段应优先检查 **消息接收端和消息路由**，而不是继续修改页面 UI。
