Skip to content

Conversation

@cyfung1031
Copy link
Collaborator

手动合并避免合并错误

CodFrm and others added 7 commits December 19, 2025 10:03
* 处理GM xhr的问题

* 补上单元测试

* 恢复之前的单元测试

* 增加 readyState 判断 修复 responseText 问题

* 删除调试日志

* `${Date.now}` -> `${Date.now()}`

* 修复fetch模式下,触发 readyState==1的问题

* fetch行为与TM保持一致

* 调整测试

* 修改错误的单元测试

* GMXhr 代码修正

* 中文

* 中文

* parseType 代码改善

* 调整代码

* 加入 allowResponse 特殊处理:readyState 达至 4 之前,排除 response, responseText, responseXML

* `res.readyState === 4` -> `res.readyState === 4 || reqDone`

* Update gm_xhr.ts

* 调整代码

* typescript 调整

* 增加逻辑控制保护

* typescript 调整

* 处理共用

* 整理代码

* 修复错误

---------

Co-authored-by: cyfung1031 <44498510+cyfung1031@users.noreply.github.com>
* 处理 只显示提示,不显示感叹号 的问题

* 优化弹出窗口的userscripts提示

* 该错误为预期内情况,无需记录 debug 日志

* 通过测试

* 删除日志

* 通过测试

* default isUserScriptsAvailableState to null

* 要求用户重启扩展/浏览器,会重置badge状态的

---------

Co-authored-by: cyfung1031 <44498510+cyfung1031@users.noreply.github.com>
* responseHeaders: `TM兼容: 使用 \r\n 及不包含空白`

Co-Authored-By: wangyizhi <yz@ggnb.top>

* 中文

* 代码调整

* added streamReader error

* 代码调整

* 代码调整

* 加注释

* nativeResponseHeadersTreatment -> normalizeResponseHeaders

* Update bg_gm_xhr.ts

* update

* 代码调整

* 代码调整

* 单元测试

* 修改 normalizeResponseHeaders 实现

---------

Co-Authored-By: wangyizhi <yz@ggnb.top>
* fix 1087

* 修改为30秒

---------

Co-authored-by: 王一之 <yz@ggnb.top>
* 更新 example/tests/gm_xhr_test.js

* Update gm_xhr_test.js

---------

Co-authored-by: 王一之 <yz@ggnb.top>
@CodFrm
Copy link
Member

CodFrm commented Dec 19, 2025

这是怎么手动合并的?怎么还有eslint错误

@CodFrm
Copy link
Member

CodFrm commented Dec 19, 2025

不能直接提main->release/v1.3的PR吗?

image

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

这是一次从 main 分支手动合并至 v1.3 分支的 PR,主要目的是避免自动合并可能导致的错误。此次合并包含多个重要的 bug 修复和功能改进。

主要变更:

  • 修复了 GM_xmlhttpRequest 的 responseHeaders 格式问题,使其符合 TamperMonkey 的实现规范
  • 修复了多处 Date.now 缺少括号的 bug
  • 改进了类型定义,增加了更精确的类型注解
  • 增强了 Popup 组件的国际化支持和状态管理
  • 添加了对 chrome.action.getBadgeText 的 mock 支持

Reviewed changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/runtime/gm_api.test.ts 为 GM_xmlhttpRequest 测试添加了 responseHeaders 格式验证,确保使用 \r\n 分隔且无尾随空白
tests/pages/popup/App.test.tsx 添加了 chrome.action.getBadgeText 的 mock 实现以支持测试
tests/mocks/blob.ts 更新了 Blob.stream() 的返回类型以匹配 TypeScript 的最新类型定义
src/types/scriptcat.d.ts 优化了 GM_xmlhttpRequest 响应类型定义,增加了 undefined 类型支持和更精确的泛型参数
src/types/main.d.ts 添加了 ValueOf 工具类型用于提取对象值的联合类型
src/template/scriptcat.d.tpl 同步更新类型定义模板文件
src/pkg/utils/xhr/fetch_xhr.ts 添加了 TamperMonkey 兼容性注释,更新了 ReadableStream 类型参数,增加了错误处理
src/pkg/utils/xhr/bg_gm_xhr.ts 修复了 Date.now 缺少括号的 bug,集成了 normalizeResponseHeaders 函数,移除了无用代码
src/pkg/utils/utils.ts 新增 normalizeResponseHeaders 函数用于标准化 HTTP 响应头格式
src/pkg/utils/utils.test.ts 为 normalizeResponseHeaders 添加了全面的测试用例
src/pkg/utils/cron.ts 修复了 cron 表达式解析逻辑,改进了 "once" 关键字的处理和时间格式输出
src/app/service/service_worker/runtime.ts 添加了可选链操作符以安全处理 chrome.userScripts API 可能不存在的情况
src/app/service/service_worker/index.ts 为批量更新页面添加了 autoclose 参数以改善用户体验
src/app/service/service_worker/gm_api/gm_xhr.ts 优化了 responseHeaders 的构建逻辑以符合 TamperMonkey 规范
src/app/service/content/gm_api/gm_xhr.ts 重构了响应处理逻辑,使用命名常量替代魔法数字,修复了 Date.now bug,改进了 TamperMonkey 兼容性
src/pages/components/layout/PopupLayout.tsx 添加了 ConfigProvider 以支持 Arco Design 组件的国际化
src/pages/components/PopupWarnings/index.tsx 改进了 UserScripts API 可用性检测,通过 badge 状态判断是否需要重启扩展
packages/chrome-extension-mock/index.ts 导入并注册了 Action mock 类
packages/chrome-extension-mock/action.ts 新增 Action mock 类实现 getBadgeText 方法
example/tests/gm_xhr_test.js 更新了测试脚本版本,添加了针对 bug #1078#1080 的测试用例和 responseHeaders 格式测试

Comment on lines 398 to 415
expect(formatBytes(1536, 1)).toBe("1.5 KB");

Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此行末尾有多余的空白字符。建议删除以保持代码整洁。

Suggested change
expect(formatBytes(1536, 1)).toBe("1.5 KB");
expect(formatBytes(1536, 1")).toBe("1.5 KB");

Copilot uses AI. Check for mistakes.
@CodFrm
Copy link
Member

CodFrm commented Dec 19, 2025

image

这个合并方式很有问题,正确的应该是从 main 分支重新开一个分支出来,然后在这个新的分支上解决冲突,我再使用 merge commit 的方式合并,现在这样这些提交都重复了一次

@cyfung1031
Copy link
Collaborator Author

不能直接提main->release/v1.3的PR吗?

image

v1.3 跟 main 差异大,两边共通 utils 不一样,无法直接 auto merge

之前你 auto merge 了我也是再提交了一个PR修正合并错误

@cyfung1031
Copy link
Collaborator Author

image 这个合并方式很有问题,正确的应该是从 main 分支重新开一个分支出来,然后在这个新的分支上解决冲突,我再使用 merge commit 的方式合并,现在这样这些提交都重复了一次

好吧,你看看怎么处理。我先关一下

@cyfung1031 cyfung1031 closed this Dec 19, 2025
@CodFrm
Copy link
Member

CodFrm commented Dec 19, 2025

不能直接提main->release/v1.3的PR吗?
image

v1.3 跟 main 差异大,两边共通 utils 不一样,无法直接 auto merge

之前你 auto merge 了我也是再提交了一个PR修正合并错误

之前也不算 auto merge,应该是我一些冲突解决得不对

@CodFrm
Copy link
Member

CodFrm commented Dec 19, 2025

100397e

@cyfung1031 cyfung1031 deleted the pr-v1.3-merge003 branch December 21, 2025 09:42
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.

2 participants