Files
ObsidianHome/小鱼/闲鱼消息通知/README.md
T

70 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 闲鱼卖家消息通知(Edge + 调试端口轮询)
在不改网页、不装扩展的前提下,用你**自己的登录态**盯着 seller.goofish.com 的未读红点,一旦有新消息就:
本地 Windows 弹窗 + 提示音,并(可选)转发到飞书 / 企业微信 / 钉钉 / Bark(iPhone)/ Server酱。
## 原理
`launch-edge.bat` 用**独立 profile** 启动 Edge 并打开调试端口(9333)。`watch.js` 通过 CDP 每 5 秒读一次页面 DOM 里的未读徽标,数值变大就通知。
独立 profile 是必需的:Edge 136+ 在默认 profile 上会忽略调试端口。
## 三步上手
1. **双击 `launch-edge.bat`** → 在弹出的 Edge 窗口里扫码登录闲鱼,进入**消息页**,保持标签页开着。
(窗口顶部会有一条"正在受自动化软件控制"的提示,正常。)
2. **双击 `probe.bat`** → 生成 `probe-result.json`,把结果发给助手校准未读元素的选择器。
3. **双击 `start-watch.bat`** 测试;确认能弹窗后,改用 `start-watch-hidden.vbs` 后台常驻。
## 通知配置
- 只想要本地弹窗/声音:默认即可。
- 想推到手机/群里:编辑 `config.json` 的 `webhooks` 数组,加一条即可,支持:
| type | url 说明 |
|---|---|
| `feishu` | 飞书群 → 添加自定义机器人,复制 webhook 地址 |
| `wecom` | 企业微信群机器人地址 |
| `dingtalk` | 钉钉自定义机器人地址 |
| `bark` | `https://api.day.app/你的KEY`(iPhone 锁屏推送,推荐) |
| `serverchan` | `https://sctapi.ftqq.com/你的KEY.send` |
| `custom` | 任意 URL,可选 `method`/`headers`/`body`,body 里可用 `{{title}}` `{{text}}` |
示例:
```json
"webhooks": [
{ "type": "feishu", "url": "https://open.feishu.cn/open-apis/bot/v2/hook/xxxx" },
{ "type": "bark", "url": "https://api.day.app/你的KEY" }
]
```
配好后先跑一次测试:`node watch.js --test`
## 其他配置项
| 键 | 说明 |
|---|---|
| `pollSeconds` | 轮询间隔,默认 5 秒 |
| `badgeFilter.requireRed` | 只认红色徽标,减少误报 |
| `badgeFilter.includePathRegex` | 只监视路径匹配的元素,例如 `"im-nav|message"` |
| `notifyOnDecrease` | 已读后消息数变少时也提醒(默认关) |
| `quietHours` | `{"from":"23:00","to":"08:00"}`,静默时段不打扰 |
| `heartbeatMinutes` | 每隔 N 分钟写一条心跳日志,确认还活着 |
## 注意事项
- **这个 Edge 窗口的登录态独立**,和你日常用的 Edge 互不影响;闲鱼的登录过期后需要重新扫码。
- 别把 `edge-profile` 目录删了,删了就得重新登录。
- 页面大改版时红点结构会变,届时重跑 `probe.bat` 重新校准。
- 关机自启:把 `start-watch-hidden.vbs` 的快捷方式丢进 `shell:startup`。
- 日志:`watch.log`,超过 2MB 自动转成 `watch.log.old`。
## 文件
- `launch-edge.ps1` / `launch-edge.bat`:启动带调试端口的 Edge
- `probe.js` / `probe.bat`:摸清页面未读元素结构
- `watch.js`:监听主程序
- `cdp.js`:极简 CDP 客户端(零依赖,用 Node 22 内置 WebSocket)
- `notify.js` + `toast.ps1`:Toast 弹窗、提示音、webhook 转发
- `config.json`:配置