Commit Graph
51 Commits
Author SHA1 Message Date
OLmatter 72adabf070 fix(install): show pip progress in real-time during install
The & powershell -File | Tee-Object pipeline buffered bootstrap output, so
during the ~1min pip install users saw nothing between 'Installing cpu
environment...' and 'Starting backend on 8888' - looked frozen. Run bootstrap
in-process (no child powershell, no pipe) so pip progress streams to console;
use Start-Transcript for the log file instead of Tee pipe (no buffering).
2026-06-23 05:36:52 +08:00
OLmatter 4810ce289b fix(gui): /captcha_direct path still used old [direct] print without timing
The [direct] 识别成功 log line (captcha_server.py line 492) was the one users
actually saw - it had no timing. My earlier [captcha] print landed on the
[CAPTURE] path (auto-capture), a DIFFERENT code path. Replace the [direct]
success/fail logs with the same [captcha] summary including end-to-end + yolo
+ ocr timing. Now both paths print timing consistently.
2026-06-23 04:41:37 +08:00
OLmatter 9af3e1e5a8 fix(gui): print recognition summary with timing in captcha_server CAPTURE path
The [CAPTURE] got result line truncated JSON at 200 chars, cutting off
elapsed_ms - user saw no timing. Replace with a concise [captcha] summary:
  [captcha] 城匙称 -> 称匙城 | conf=1.00 end-to-end=312ms (worker total=285ms yolo=120ms ocr=165ms) | engine=yolo+hybrid_cpu_parallel
This is the code path one-click-start actually runs (scripts/tools/), not
backend/server.py where I added a similar line earlier.
2026-06-23 04:22:33 +08:00
OLmatter 0771cfa86b feat(gui): show active OCR model in captcha_server GUI
Add a '识别模型' row below status showing the resolved model: for hybrid mode
'hybrid | 主 PP-OCRv6_tiny_rec → 兜底 PP-OCRv6_medium_rec', for GPU the gpu
model, otherwise the cpu model. Updated every tick so it reflects config even
if resolved after GUI start.
2026-06-23 04:10:48 +08:00
OLmatter 0a108e9523 fix(ocr): v6 default was only in backend/ - one-click actually runs scripts/tools/
User log showed PP-OCRv5_mobile_rec still loading despite v6 'upgrade'. Root
cause: one-click-start -> start_backend.ps1 -> scripts/tools/start_backend.py
-> captcha_server.py (the EARLY pipeline), NOT backend/server.py (PR#10). The
v6 default I set in backend/ was never reached.

Set v6 defaults in the code path users actually run:
- backend_config.py: cpu_fast_model v5_mobile -> v6_tiny, cpu_fallback_model
  v5_server -> v6_medium, gpu_model v5_server -> v6_tiny (hybrid fast path).
- ppocr_cpu_pool_worker.py: MODEL_NAME v5_server -> v6_tiny (non-hybrid path).
- backend_config.py line 134 gpu probe default also v6_tiny.
2026-06-23 04:08:50 +08:00
OLmatter 9579981d22 feat(install): auto-select PyPI mirror with multi-source fallback
Instead of hardcoding a single mirror (if it's down, install fails), probe a
list of mirrors at install time and pick the first reachable one:
1. Tsinghua  2. Aliyun  3. USTC  4. Tencent  5. pypi.org (official fallback)
HEAD probe with 3s timeout per mirror (~seconds total). Users can still override
via -PipArg. Verified: probe correctly selects Tsinghua when reachable.
2026-06-23 03:50:05 +08:00
OLmatter 866d502cfd fix(install): PowerShell ate -i as param name -> pass pip args as ;-joined string
Real root cause of 100% failure (finally visible via tee log):
'bootstrap_windows.ps1 : Missing an argument for parameter PipArg'
one_click_start Invoke-Bootstrap passed '-PipArg -i -PipArg https://...'
but PowerShell splatting treats the dash-prefixed '-i' as the NEXT parameter
name, not the PipArg value -> bootstrap aborts before pip even runs.

Same class of bug as the argparse one, one layer up. Fix:
- Invoke-Bootstrap: join PipArg into a single ;-delimited string, pass one
  -PipArg value (no dash ambiguity at the PS param layer).
- bootstrap_windows.ps1: PipArg is now [string]; split on ';' to recover the
  array, then emit '--pip-arg=VALUE' to setup_backend as before.
- Verified: bootstrap_windows.ps1 -PipArg '-i;https://...' runs cleanly,
  setup_backend receives --pip-arg=-i --pip-arg=https://... correctly.
2026-06-23 03:38:36 +08:00
OLmatter 6c79d672db diag(install): tee bootstrap output to logs/backend-install.log for diagnosis
Users hitting [FAIL] with no visible pip error - the nested powershell +
setup_backend errors were getting buried. Tee the full bootstrap output to
logs/backend-install.log and tell the user to share that file when reporting.
2026-06-23 03:28:55 +08:00
OLmatter f40eb564ee fix(install): mirror never reached pip - argparse ate -i as a flag
Root cause of 100% install failure: setup_backend.py --pip-arg used action=append,
so '--pip-arg -i' made argparse treat '-i' (a dash-prefixed value) as the next
option and abort with 'error: argument --pip-arg: expected one argument'.
The mirror set by one_click_start.ps1 never reached pip -> mainland users hit
PyPI timeout -> 'Backend environment repair failed'.

Fix:
- bootstrap_windows.ps1: emit '--pip-arg=VALUE' (= form) so dash-prefixed values
  like -i / --index-url are not misparsed as options.
- setup_backend.py: also pass mirror to the 'pip install --upgrade pip setuptools
  wheel' step (line 137 previously had none, would time out before requirements).
- Verified end-to-end: fresh venv, full CPU install via Tsinghua mirror,
  paddleocr-3.7.0 + paddlepaddle-3.3.1 installed, smoke test passed.
2026-06-23 03:21:50 +08:00
OLmatter d06c69f132 fix(ps1): add UTF-8 BOM to all .ps1 to fix PS 5.1 ParserError on CN Windows
PS 5.1 on Chinese Windows reads non-BOM files as the system ANSI codepage
(GBK), so UTF-8 Chinese bytes corrupt parsing and surface as
'Missing expression after comma' at param blocks. Adding EF BB BF BOM forces
PS 5.1 to interpret as UTF-8. Affects one_click_start.ps1 (the .cmd entry),
bootstrap_windows.ps1, start_backend.ps1, setup_backend.ps1,
start-backend-pipeline-gui.ps1, and the release scripts.
2026-06-23 03:07:52 +08:00
OLmatter 7176d7376c fix(install): default pip to Tsinghua mirror to avoid PyPI timeout in CN
Users in mainland China hitting ReadTimeoutError / RemoteDisconnected when
one-click-start.cmd installs backend deps from files.pythonhosted.org.
one_click_start.ps1 -PipArg now defaults to -i https://pypi.tuna.tsinghua.edu.cn/simple;
users can override by passing -PipArg explicitly. Chain already supports it:
one_click_start.ps1 -> bootstrap_windows.ps1 -> setup_backend.py --pip-arg.
2026-06-23 03:00:53 +08:00
OLmatter b9239895e1 fix(release): use python zipfile instead of broken tar -a; include gpu requirements in portable
- build_release_zips.ps1 / build_portable.ps1: Windows bsdtar -a misidentifies
  .zip extension and produces corrupt archives; Compress-Archive fails on long/
  non-ASCII paths. Fall back to python zipfile (no MAX_PATH limit, standard zip).
- build_portable.ps1: add requirements-backend-gpu.txt to Include list. The
  one_click_start.ps1 Assert-RequiredFiles check requires BOTH requirements
  files in every package; portable-cpu was missing gpu one, causing
  '[FAIL] Release package is incomplete' on first run.
2026-06-23 02:48:14 +08:00
OLmatter bb5690292e Merge branch 'pr-25-macos'
# Conflicts:
#	README.md
2026-06-21 05:29:55 +08:00
OLmatter 0c0ff27be2 Fix portable venv rebuild 2026-06-21 02:58:56 +08:00
Kang 3186d5b8de feat(macos): add backend setup and launch support 2026-06-20 14:27:31 +08:00
OLmatter 9c1587e459 docs(launcher): warn about Windows long paths 2026-06-19 01:21:22 +08:00
OLmatter 421c2a7a54 fix(launcher): harden one-click and gui startup 2026-06-19 00:26:40 +08:00
OLmatter 15313a9ab6 Refine rush and captcha timing flow 2026-06-16 04:08:15 +08:00
OLmatterandClaude Opus 4.7 6f00ad245f revert(userscript): 回退到 v8.19 (e07ec9e)
v8.20 / v8.21 / v8.21.x 在用户本地确认主循环失效
(不会自动购买 / 不会自动关弹窗),回退到 PR #17 之前
的 v8.19 黄金时间延长版,这是用户最后确认正常的版本。

高级模式 / ±20% 抖动 / incognito 提示全部撤销(它们是
引入 CFG undefined 死循环的根源,且不再单独发布)。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-15 23:43:30 +08:00
OLmatterandClaude Opus 4.7 03dd2f1e0e fix(userscript): v8.21.3 root-cause captcha loop — CFG undefined in captcha IIFE
真正根因:v8.21 在 captcha IIFE 内的 handleCaptchaDirectInPage 直接引用
CFG.CAPTCHA_CLICK_DELAY,但 captcha IIFE 是独立闭包,没有 CFG。
后端响应成功后走到 click loop 就抛 ReferenceError: CFG is not defined,
catch 块重置 captchaSent=false + lastCaptchaText='' → 50ms tick 死循环。

修复:
- captcha IIFE 顶部通过 GM_getValue('glm_coding_config_v5') 读
  CAPTCHA_CLICK_DELAY / RL_RETRY_DELAY(主 IIFE 写到同一 key),
  预计算 _clickDelay / _rlDelay 常量
- catch 块改为 30s 冷却(window.__glmCaptchaCooldownUntil),
  checkCaptchaPrompt 起手检查冷却直接 return,不再重发同一张图

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-15 23:27:53 +08:00
OLmatterandClaude Opus 4.7 cd64ff6bab fix(userscript): v8.21.2 inline jitter logic, kill captcha-send loop
Root cause: v8.21 added a top-level `function jitterDelay()` helper.
In some Tampermonkey/cache scenarios the helper is undefined inside
the `handleCaptchaDirectInPage` async closure, throwing
`ReferenceError: jitterDelay is not defined`. The catch block then
resets `captchaSent = false` and `lastCaptchaText = ''`, so the
`setInterval(checkCaptchaPrompt, 50)` loop resends the same captcha
to the backend every 50ms ("dead loop sending captcha").

Fix: inline the ±20% jitter math at both call sites
(line 1814 and 1117), drop the helper entirely. Also added
`Number(...) || default` guards so a stale `CFG.CAPTCHA_CLICK_DELAY`
or `CFG.RL_RETRY_DELAY` of NaN/null/undefined falls back to the
DEF value rather than making `setTimeout(NaN)` fire instantly.

Side effect that confirmed the bug: the captcha bg element lost
its layout during the storm, so `rect.width = 0` and
`nx * rect.width = 0`, but `rect.left` was ~-9992 from a stale
frame ref — hence the marker spamming `(-9992, -10029)`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-15 23:12:47 +08:00
OLmatterandClaude Opus 4.7 66a9ea559e feat(backend): pipeline GUI launcher + 精简启动器
新增 backend/gui.py Tk 监控窗口:
- 拉起 backend.server 子进程并接管 stdout
- 顶部状态栏(启动中/运行中、YOLO/OCR worker 数、监听地址)
- 中间识别列表(最近 20 条 prompt/pred_text/confidence/耗时)
- 底部日志框(stdout 实时滚动,高亮 worker ready / 错误)
- 关闭窗口自动 terminate 后端

后端新增 /recent?limit=20 端口(GUI 拉取最近识别结果),
/health 同步返回 n_yolo / n_ocr / port 字段。

精简根目录启动器(7 → 2):
- 删 start-backend.cmd / start-backend-pipeline.cmd /
      install-env.cmd / 启动后端.cmd / 首次安装环境.cmd
- 留 one-click-start.cmd(首次装环境)
- 留 start-backend-pipeline-gui.cmd(日常启动 + GUI)
- start-backend-pipeline.ps1 → start-backend-pipeline-gui.ps1

打包脚本 build_portable.ps1 / build_release_zips.ps1 同步
更新入口列表和错误提示。

补 .gitignore: official_models/(81M OCR 模型权重,不入库)

补 scripts/tools/evaluate_pipeline_compare.py(PR #10 评估
脚本,cherry-pick 时漏了)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-15 22:53:36 +08:00
sunshineandsunshine 6b052da423 PR A: Pipeline Backend, YOLO to OCR multi-process, CPU auto-allocation (#10)
* feat(pipeline): multi-process YOLO→OCR pipeline backend

- server.py: FastAPI gateway, 3-level mp.Queue pipeline, round-robin dispatch
- worker.py: YOLO character detection worker (core-pinned, single-threaded)
- ppocr_worker.py: PP-OCRv5 recognition worker with pre-warm cache
- evaluate.py: select_fixed3 box selection from scripts/tools/

- Smart CPU core allocation: N_YOLO = cores/4, N_OCR = cores/2
- config.json auto-created on first run (_auto + _cores metadata)
- /health endpoint: {status:'starting'|'ok', workers:N, ready_workers:N}
- Worker watchdog: auto-restart crashed OCR workers
- Shutdown cleanup: _shutdown event + try/finally for orphaned processes

- one_click_start.ps1: pipeline dep check (fastapi/uvicorn/psutil) non-blocking
- setup_backend.py: smoke test includes pipeline deps
- requirements-backend-cpu/gpu.txt: +fastapi, uvicorn[standard], psutil

- README: pipeline architecture + auto CPU allocation
- .gitignore: +config.json, server logs

Minimal verification:
  python -m py_compile backend/server.py backend/worker.py backend/ppocr_worker.py backend/evaluate.py  # OK
  python backend/server.py  →  GET /health  →  {'status':'ok','workers':12,'ready_workers':12}

* fix: review feedback - timeout cleanup, watchdog, health, paddleocr

- handle_direct/handle_direct_url: clean pending_requests on TimeoutError
- _worker_watchdog: always check p.is_alive(), remove ready_count bypass
- /health: add alive_workers field (count is_alive)
- start_backend.ps1: include paddleocr in import check

---------

Co-authored-by: sunshine <qt22260@gmail.com>
2026-06-15 20:57:57 +08:00
OLmatterandClaude Opus 4.7 a1397fca40 chore: bump userscript to v8.20 after PR #17 merge
PR #17 was merged as v8.19 (matching the rush mode feature label),
but our v8.19 was already the golden-time extension. Bump to v8.20
to reflect the combined feature set: golden-time 9:30-11:00 + rush
mode + tabEl 1-index fix + findAndClickConfirm payment-button guard.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-15 20:40:44 +08:00
sunshineandsunshine 1b090e4bf6 feat(userscript): rush mode v8.19 (rebase from author v8.18) (#17)
- Configurable via panel: enable toggle + HH:MM:SS target time
- checkPayDialog: __glmRushConfirmed guard protects first payment dialog
- tick(): rush lock cleared only when dialog is gone (!getPayDialog)
- handleCaptchaDirectInPage: wait for target time, set rush lock on both
  before-target and already-past branches
- RUSH_CFG reads from user config, parseInt fixed (Number.isFinite guard)

- everSucceeded && PS.bizId (2 locations): prevent stale success
  from keeping sold-out dialogs open
- findAndClickConfirm: removed .pay-dialog/.el-dialog selectors
  (prevent accidental payment button clicks by captcha confirm)
- tabEl: [n] -> [n-1] for correct 1-index to 0-index mapping

- @connect localhost + @connect 127.0.0.1
- Version 8.18 -> 8.19
- Both copies synced, SHA256 identical, whitespace clean

Co-authored-by: sunshine <qt22260@gmail.com>
2026-06-15 20:40:12 +08:00
智商局局长 5d1e797872 fix: patch find_spec to hide torch from modelscope in paddle GPU worker (#19)
PaddleOCR 通过 modelscope 自动探测并加载 torch,但 torch 与 paddle
在同一进程中初始化 CUDA 会触发 pybind11 类型注册冲突
(_gpuDeviceProperties already registered)。

通过 monkey-patch importlib.util.find_spec,对 modelscope 隐藏 torch
的存在,使其跳过 torch 加载,仅在 paddle 进程中生效。

同时补充 cuda_runtime/bin 到 DLL 搜索路径。
2026-06-15 20:22:04 +08:00
OLmatterandClaude Opus 4.7 e07ec9e181 feat: extend golden time to 11:00 (10:30+ still possible per user feedback)
isGoldenTime() now covers 9:30-11:00 (was 9:30-10:10) so late-morning
restock windows are treated as rush mode: no page refresh, no MAX_RL
cap on 555 retries. Bump userscript to v8.19 and add CHANGELOG entry.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-15 19:33:55 +08:00
OLmatterandClaude Opus 4.7 514d0b330e docs: warn about RPM risk control and default 2 windows
- change openMultipleWindows prompt default from 3 to 2 (max stays 10)
- add prominent RPM warning box in README rush section after GLM upgraded RPM limits
- strengthen language in step 5 and 重要提醒 from "may trigger" to "has caused widespread failure"
- sync root and scripts/userscripts/ copies

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-14 14:00:42 +08:00
OLmatter 08afc38844 fix: allow localhost direct captcha requests 2026-06-13 23:53:31 +08:00
OLmatter 4e5474405c fix: fallback from broken GPU OCR in auto mode 2026-06-13 19:33:37 +08:00
OLmatter a787a48ee0 feat: add MiniMax token plan referral entry 2026-06-13 19:20:53 +08:00
OLmatter 3bed2c842d fix: harden portable packaging and public docs 2026-06-13 11:30:49 +08:00
OLmatter 27629a1839 fix: clean userscript prompt and package cmd launchers 2026-06-13 11:23:40 +08:00
OLmatter 152eeb5eca fix: avoid false backend env repair on Windows 2026-06-12 22:32:22 +08:00
OLmatter f14b4717f4 fix: keep backend python aligned with selected mode 2026-06-11 21:30:39 +08:00
sunshine 095d1947c7 feat(userscript): fetch-first, GM_xmlhttpRequest fallback
4 network functions changed to try fetch() first, fallback to GM_xmlhttpRequest:
- fetchImageDataUrl
- postDirect
- serverRequest
- fetchCaptchaImageDirect

fetch() has no 6-connection limit per domain (unlike GM_xmlhttpRequest),
eliminating the bottleneck when multiple windows/iframes hit localhost:8888.
GM_xmlhttpRequest is kept as fallback for CORS-restricted contexts.

Both userscript copies synced, SHA256 identical, trailing whitespace cleaned.
2026-06-09 23:18:50 +08:00
OLmatter db275068bf fix: repair incomplete backend environment on start 2026-06-06 17:40:45 +08:00
OLmatter 2f8cc1bf0f Improve rush stability and discount entry 2026-05-29 20:16:22 +08:00
OLmatter d4dd03ed6c Simplify release packaging and direct captcha flow 2026-05-27 20:52:57 +08:00
OLmatter 83e3c12afc fix: detect left aligned captcha modal 2026-05-27 13:27:40 +08:00
OLmatter e8ec05387e Keep config endpoint backward compatible 2026-05-26 22:44:54 +08:00
OLmatter 665dab0be1 Fix backend browser capture compatibility 2026-05-26 22:31:25 +08:00
OLmatter 89a7d5706a Add captcha model development journey 2026-05-26 11:04:30 +08:00
OLmatter b5285097be Improve Chinese search keywords 2026-05-26 09:38:05 +08:00
OLmatter 395e9decc4 Expose userscript at repository root 2026-05-26 08:18:22 +08:00
OLmatter 226441d0a2 Fix payment popup auto close default 2026-05-26 08:07:59 +08:00
OLmatter 79470e33c2 Disable auto closing invalid payment popups by default 2026-05-25 19:33:33 +08:00
OLmatter 89f80342fd Hide explicit invite code from public text 2026-05-25 19:27:09 +08:00
OLmatter d1f651afa6 Credit original Greasy Fork userscript author 2026-05-25 19:09:23 +08:00
OLmatter 036a34d007 Use GLM invite code and remove other platform promos 2026-05-25 19:01:02 +08:00