Skip to content

专注模式:换视频和读取失败的判断抽成函数并补表格测试 - #434

Merged
PathGao merged 1 commit into
mainfrom
refactor/clip-change-rules
Oct 27, 2026
Merged

PathGao merged 1 commit into
mainfrom
refactor/clip-change-rules

Conversation

@PathGao

@PathGao PathGao commented Oct 27, 2026

Copy link
Copy Markdown
Owner

改了什么

content.js 里换视频之后怎么办的几个判断夹在 await、DOM 和 chrome 调用中间,这一块改动最多(近 60 个提交)。抽成不碰 DOM 的函数,content.selftest.js 逐行覆盖:

  • isOtherClip:换了视频,或 cid 已知时换了分 P。
  • clipChangeAction:专注模式开着重读,带 mdg_reader 进专注模式,否则不动。
  • readFailureAction:旧的读取失败忽略;视频信息读到了、不是限流时降级成无字幕;其余报错。
  • clipFields / clipPage:视频信息怎么合并;pageIndex / pageCount 的限幅和 buildSidepanelContext 共用。

等待和世代号的代码不动,行为不变。

验证

  • node scripts/selftest.mjs:39 个通过。去掉 cid 未知的保护或 !alive,测试失败。
  • Chrome(ego),B站 BV164411b7dx(112 P):专注模式开着时页内换分 P,保持打开、重读、标题保留;0.15 秒内连换两次,停在对的分 P,无报错;专注模式关着时页内换分 P,侧边栏拿到 P2 / 112;无字幕视频(BV1RJHV6pECP)保留标题和作者、分 P 1 / 1。扩展无报错。
  • 没测到:专注模式关着时页内跳到带 mdg_reader 的地址。

isOtherClip、clipChangeAction、readFailureAction、clipFields / clipPage 不碰 DOM,content.selftest.js 逐行覆盖;等待和世代号的代码不动,行为不变。
@PathGao
PathGao merged commit 899c983 into main Oct 27, 2026
2 checks passed
@PathGao
PathGao deleted the refactor/clip-change-rules branch October 27, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant