{{ message }}
pr-commit-lines-changed - Restore feature#9486
Merged
Merged
Conversation
fregante
commented
May 16, 2026
Comment on lines
+32
to
+33
Member
Author
|
|
||
| async function init(): Promise<void> { | ||
| function repeatItems(count: number, Item: () => React.JSX.Element): React.JSX.Element[] { | ||
| return Array.from({length: count}).map(() => <Item style={{borderRadius: '2px'}}/>); |
Member
Author
There was a problem hiding this comment.
GitHub is using a new style with custom classes. This gets it closer, but the red is not striped like theirs. Oh well
fregante
commented
May 16, 2026
| import {tooltipped} from '../helpers/tooltip.js'; | ||
| import GetCommitChanges from './pr-commit-lines-changed.gql'; | ||
| import observe from '../helpers/selector-observer.js'; | ||
| import {expectToken} from '../github-helpers/github-token.js'; |
Member
Author
There was a problem hiding this comment.
Uh, not sure why the lack of expectToken was not causing the tests to fail before.
Member
Author
There was a problem hiding this comment.
Oh it's because it requires observe too 🤔
refined-github/build/features.test.ts
Line 175 in e589821
Member
Author
There was a problem hiding this comment.
Oh it's because line api.v4 failures within init are already caught. expectToken was required specifically because api.v4 (and therefore their already-existing internal expectToken) was called too late to be caught.
Co-authored-by: Grigory <techuila.sunset@gmail.com>
fregante
commented
May 17, 2026
Comment on lines
+13
to
+26
DCjanus
added a commit
to DCjanus/userscripts
that referenced
this pull request
May 22, 2026
## Why - 在 GitHub PR 文件较多时,左侧文件树缺少每个文件的增删行数,不方便优先定位改动较大的文件。 - 希望像 GitLab MR 一样,在文件树里直接区分文件是否已标记为 Viewed。 ## What - 新增 `GitHubPrFileTreeReviewStats.user.js`,在 GitHub PR Files/Changes 页的文件树中注入每个文件的 `+N -N`。 - 通过当前页面 DOM 读取 diff header 和 Viewed 按钮状态,不调用 GitHub API,避免 rate limit 和额外认证问题。 - 未 Viewed 文件在文件树中加粗,已 Viewed 文件恢复正常字重。 - 在 README 脚本列表中加入新脚本入口。 ## Validation - `node --check scripts/GitHubPrFileTreeReviewStats.user.js` - `git diff --check` - 使用 Chrome 登录态在 `refined-github/refined-github#9486` 的 PR Files 页面确认 DOM 可匹配到文件树、增删行数和 Viewed 状态。
DCjanus
added a commit
to DCjanus/userscripts
that referenced
this pull request
May 22, 2026
## Why - Viewed 按钮保存是异步的,点击后文件树状态需要在不刷新页面的情况下重新同步。 - GitHub PR 的局部刷新可能只更新 diff header 文本或重挂载部分 DOM,文件树里的增删行数也需要跟着更新。 ## What - 改成事件驱动同步:DOM mutation、Viewed 控件事件、GitHub 自身 `fetch` / `XMLHttpRequest` 完成后都会触发同步。 - Viewed 点击时只对当前文件做乐观同步,后续由 DOM/network 事件回读页面真实状态校正。 - 新增 `@run-at document-start`,尽早安装网络完成 hook,覆盖 PR Files 的局部刷新和新 commit 更新。 - 保持 userscript version 不变,不用版本号承载这个 draft PR 的内部迭代。 - 兼容旧版 GitHub file tree 中没有 `file-tree-row` li 的链接结构。 ## Validation - `node --check scripts/GitHubPrFileTreeReviewStats.user.js` - `git diff --check` - 使用本机 Chrome headless 加载 `refined-github/refined-github#9486`,注入脚本后确认 3 个文件统计可显示。 - 模拟 diff header 文本变化后触发页面 fetch 完成信号,文件树统计从原始值更新到 `+2-0`。 --------- Co-authored-by: DCjanus <DCjanus@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



pr-commit-lines-changed: Cannot read properties of undefined (reading 'replaceWith') #9456Test URLs
3d93b78(#6674)Screenshot