8 Commits

Author SHA1 Message Date
RainySY
c67b7779ab fix: 修复登录假成功,Cookie 改为每会话注入
根因:linux.do 登录表单启用 hCaptcha 人机验证,自动化浏览器无法通过,
旧自动登录永远不可能成功;而抓取的 _forum_session 是匿名会话本就存在的
cookie,误报「自动登录成功」,导致受限主题一直 404。

修复:
- 移除无效的账号密码自动登录(_auto_login_and_capture)
- Cookie 改为每个 StealthySession 会话都重新注入(旧代码跨请求丢失)
- 登录校验端点改用 /notifications.json(匿名 403 / 登录 200),
  弃用对匿名也返回 404 的 /session/current_user.json
- Cookie 配置支持多格式:完整 Cookie 头、单 name=value、裸值(向后兼容)

linuxdo_username/password 保留仅为兼容,不再生效。
2026-06-16 23:52:59 +08:00
RainySY
136f15e3ec feat: add auto-login to capture session cookie
When linuxdo_username and linuxdo_password are configured, the plugin
automatically logs in via Playwright and captures the _forum_session
cookie from the browser context. No manual cookie copy needed.

Auth priority:
1. Manual linuxdo_session_cookie (if configured)
2. Auto-login via username+password (if configured)
3. Anonymous access (fallback)

Also update README and CHANGELOG with dual-mode auth documentation.
2026-06-16 14:25:23 +08:00
RainySY
70f4f6eb97 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)
2026-06-16 14:16:30 +08:00
RainySY
b64bfeba8c docs: update README with login feature and updated config table
- Add login feature to feature list (🔑 账户登录)
- Add use_api_render, linuxdo_username, linuxdo_password to config table
- Add 🔑 账户登录(可选) section with setup instructions and security note
- Update technology diagram to reflect API render pipeline
2026-06-16 13:33:27 +08:00
RainySY
f99ba02dfb fix: revert screenshot default to full_page=True for complete capture
The viewport-only mode cut off long posts. Keep full page as default
while retaining all other optimizations (networkidle, element hiding,
smart wait).
2026-06-15 22:29:42 +08:00
RainySY
fa5c4e78b5 feat: optimize screenshot rendering quality
- Use networkidle instead of load — waits for Discourse JS rendering
- Wait for .cooked selector — smart content detection with fallback
- Hide fixed/sticky elements via JS injection:
  - .d-header (top navigation bar)
  - .sidebar-wrapper (left sidebar)
  - .topic-navigation-wrapper, .footer-nav
- Scroll to first post content for clean framing
- Default to viewport screenshot (not full_page) — practical preview
- Add screenshot_full_page config option for users who want full thread
- Adjust viewport to 1280×900 (16:9-ish)
2026-06-15 22:22:57 +08:00
RainySY
a13be98c26 fix: resolve code review issues - config integration, thread safety, cleanup
- Remove duplicate @staticmethod decorator on _take_screenshot
- Wire up _conf_schema.json config items to actual code:
  - max_content_length (was hardcoded 400)
  - screenshot_timeout (was hardcoded 30000/20000ms)
- Remove unused StealthyFetcher import and dead code (StealthyFetcher.adaptive=True)
- Fix _stats thread safety with threading.Lock
- Fix metadata.yaml author field (was plugin name, now 'RainySY')
- Sync README: correct screenshot size, remove non-existent screenshot_width config,
  fix asyncio.to_thread() -> run_in_executor()
- Add MIT LICENSE file
- Explicitly declare lxml>=5.0 in requirements.txt
2026-06-15 19:28:45 +08:00
RainySY
5f41aa73ea feat: initial release - linux.do link preview plugin
- Auto-detect linux.do URLs in chat messages
- Bypass Cloudflare Turnstile via Scrapling StealthyFetcher
- Full-page screenshot (1920×1080) with caching
- Text summary extraction (title + content)
- Configurable cache TTL / content length / screenshot timeout
- Stats and cache management commands: /linuxdo_stats, /linuxdo_clean
- Async non-blocking thread pool design
2026-06-15 17:00:58 +08:00