refactor: replace Playwright form login with cookie injection

linux.do doesn't provide user-level API keys, and the Playwright form
login approach was fragile (depends on SPA rendering, CSRF handling,
selector stability). Replace with a simpler cookie injection approach:

- User copies _forum_session cookie from browser DevTools
- Plugin injects it into StealthySession's browser context
- Validates via /session/current_user.json
- Falls back to anonymous if cookie is invalid/expired

Config changes:
- Add linuxdo_session_cookie (string, optional)
- Remove linuxdo_username and linuxdo_password (no longer needed)
This commit is contained in:
RainySY
2026-06-16 14:16:30 +08:00
parent b64bfeba8c
commit 70f4f6eb97
4 changed files with 71 additions and 105 deletions

View File

@@ -29,16 +29,10 @@
"default": true,
"hint": "启用后用 Discourse JSON API 拉数据+自定义 HTML 模板渲染(推荐,完整、干净、不受页面截断/懒加载影响);关闭则走传统页面截图方案。"
},
"linuxdo_username": {
"description": "LinuxDo 用户名(可选)",
"linuxdo_session_cookie": {
"description": "LinuxDo 会话 Cookie(可选)",
"type": "string",
"default": "",
"hint": "配置后插件将自动登录,可访问受限分类、私信预览等非公开内容。留空则保持匿名访问。"
},
"linuxdo_password": {
"description": "LinuxDo 密码(可选,敏感)",
"type": "string",
"default": "",
"hint": "⚠️ 密码以明文存储于配置文件请确保文件权限600或使用专用低权限账户。重启后凭据需重新输入。"
"hint": "从浏览器 DevTools 复制 _forum_session cookie 值。登录 linux.do → F12 → Application → Cookies → linux.do → _forum_session → 复制 Value。留空则保持匿名访问。"
}
}