Repository navigation
Conversation
@exclude-match 按 @match 的 match pattern 规则解析为 MATCH_EXCLUDE,进入原生注册的 excludeMatches、early-start/unwrap 的页内检查、Popup 原始规则与站点排除判断; 解析失败的取值直接丢弃,不退化成 @exclude 的 glob/正则,并在兼容性检查中报为不生效。 页面加载缓存键纳入 exclude-match,并更新 CompiledResourceNamespace 让旧的编译规则重建; VM 备份的 excludeMatch/origExcludeMatch 改为独立映射到 selfMetadata["exclude-match"]。
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.
Checklist / 检查清单
背景
@exclude-match之前在脚本猫里不生效:extractUrlPatterns只认@match/@include/@exclude,命中@exclude-match的网址脚本照样执行。本次改动
@exclude-match按@match的同一套 match pattern 规则解析(包括 TM 兼容写法:省略 scheme、端口、http*、*),生成MATCH_EXCLUDE规则。解析失败的取值直接丢弃,不会像@exclude那样退化成 glob/正则。@exclude行为不变。excludeMatches)、early-start 与 unwrap 的页内检查、Popup 原始规则(originalMetadata/originalUrlPatterns),以及 Popup「不在此站点执行」的判断(excludeFromMatch)。作者已用@exclude-match排除的网址不会再被重复写入排除。exclude-match,同时更新CompiledResourceNamespace。否则升级前已安装的带@exclude-match的脚本,重启后会继续复用不含排除的旧编译规则。exclude-match加入已消费指令;解析不出规则的取值和@match一样报为不生效(安装页/编辑器共用)。excludeMatch/origExcludeMatch改为独立映射到selfMetadata["exclude-match"]。原来它们被并入exclude,而且origExcludeMatch=false会连作者的@exclude一起替换。现在作者的@exclude-match已真正生效,不独立映射的话,用户在 VM 里关掉的作者规则导入后会复活。已知限制
synchronize.ts的 TM 格式orig_excludes、External Accessscripts.metadata.get的excludes都还不展示/导出exclude-match(@exclude在安装页同样没有展示)。这几处只是展示或导出,不影响执行结果;External Access 的字段需要与 sctl 仓 protocol 同步修改,留作后续。@exclude-match,与作者@exclude的现有行为一致。建议审查重点
url_matcher.ts中@exclude-match复用@match的归一化逻辑:省略 scheme 的www.a.com/*会补成*://www.a.com/*。这里按「与 @match 同义」处理,不算扩大匹配范围。origExcludeMatch语义的变化(self_metadata.ts)。关联
close #1714
验证
excludeMatches、early-start 规则、缓存键、excludeFromMatch、VM 导入映射、兼容性表。pnpm exec vitest run --no-coverage src/pkg src/app/service/service_worker src/app/service/content src/pages/install src/pages/import src/pages/popup:2119 passed / 25 failed。失败的都在未改动的文件(popup preload/usePopupData、PermissionCard 移动端、synchronize、openUpdatePageByUUID、BackgroundPrompt);逐个文件单独运行全部通过(popup 67/67、script.test 90/90、synchronize 86/86、PermissionCard 31/31、BackgroundPrompt 5/5)。pnpm run test:ci在本机不可用作信号:未改动的origin/main基线同样失败 80 个文件 / 138 个用例(机器负载约 9–17,isolate:false共享 worker 的 mock 串扰),每次失败的集合也不同。请以 CI 结果为准。src/pages/install/compat.test.ts新增用例。合法的@exclude-match不产生标记;*admin*这类解析不出规则的取值在「其他声明」里连同取值和行号标出,不混进运行网站行。该用例在 main 的兼容性表上会失败。pnpm run typecheck、prettier --check、改动文件eslint均通过(pre-commit hook 同样通过)。pnpm run build+e2e/session.mjs无头会话,本地http://127.0.0.1:18714):普通 / early-start + 正则@include/@unwrap三个脚本都带@exclude-match http://127.0.0.1/admin/*。chrome.userScripts.getScripts()中三者的excludeMatches都是["http://127.0.0.1/admin/*"];/home/上三者都执行,/admin/上都不执行(看 dataset 与 console 输出)。未在浏览器里验证「升级后重启复用旧编译规则」这一路径,它依赖CompiledResourceNamespace更新后启动时的清理重建。