@@ -5,7 +5,13 @@ import Logger from "@App/app/logger/logger";
55import LoggerCore from "@App/app/logger/core" ;
66import { cacheInstance } from "@App/app/cache" ;
77import { CACHE_KEY_SCRIPT_INFO } from "@App/app/cache_key" ;
8- import { checkSilenceUpdate , InfoNotification , openInCurrentTab , randomMessageFlag } from "@App/pkg/utils/utils" ;
8+ import {
9+ checkSilenceUpdate ,
10+ getBrowserType ,
11+ InfoNotification ,
12+ openInCurrentTab ,
13+ randomMessageFlag ,
14+ } from "@App/pkg/utils/utils" ;
915import { ltever } from "@App/pkg/utils/semver" ;
1016import type { Script , SCRIPT_RUN_STATUS , ScriptDAO , ScriptRunResource } from "@App/app/repo/scripts" ;
1117import { SCRIPT_STATUS_DISABLE , SCRIPT_STATUS_ENABLE , ScriptCodeDAO } from "@App/app/repo/scripts" ;
@@ -112,7 +118,23 @@ export class ScriptService {
112118 types : [ "main_frame" ] ,
113119 }
114120 ) ;
115- // 获取i18n
121+ // 兼容 chrome 内核 < 128 处理
122+ const condition : chrome . declarativeNetRequest . RuleCondition = {
123+ regexFilter : "^([^#]+?)\\.user(\\.bg|\\.sub)?\\.js((\\?).*|$)" ,
124+ resourceTypes : [ chrome . declarativeNetRequest . ResourceType . MAIN_FRAME ] ,
125+ requestMethods : [ "get" as chrome . declarativeNetRequest . RequestMethod ] ,
126+ } ;
127+ const browserType = getBrowserType ( ) ;
128+ if ( browserType . chrome && browserType . chromeVersion >= 128 ) {
129+ condition . excludedResponseHeaders = [
130+ {
131+ header : "Content-Type" ,
132+ values : [ "text/html" ] ,
133+ } ,
134+ ] ;
135+ } else {
136+ condition . excludedRequestDomains = [ "github.com" ] ;
137+ }
116138 // 重定向到脚本安装页
117139 chrome . declarativeNetRequest . updateDynamicRules (
118140 {
@@ -127,17 +149,7 @@ export class ScriptService {
127149 regexSubstitution : `${ DocumentationSite } ${ localePath } /docs/script_installation/#url=\\0` ,
128150 } ,
129151 } ,
130- condition : {
131- regexFilter : "^([^#]+?)\\.user(\\.bg|\\.sub)?\\.js((\\?).*|$)" ,
132- resourceTypes : [ chrome . declarativeNetRequest . ResourceType . MAIN_FRAME ] ,
133- requestMethods : [ "get" as chrome . declarativeNetRequest . RequestMethod ] ,
134- excludedResponseHeaders : [
135- {
136- header : "Content-Type" ,
137- values : [ "text/html" ] ,
138- } ,
139- ] ,
140- } ,
152+ condition : condition ,
141153 } ,
142154 ] ,
143155 } ,
0 commit comments