@@ -5,7 +5,13 @@ import Logger from "@App/app/logger/logger";
55import LoggerCore from "@App/app/logger/core" ;
66import Cache from "@App/app/cache" ;
77import CacheKey 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" ;
@@ -107,7 +113,23 @@ export class ScriptService {
107113 types : [ "main_frame" ] ,
108114 }
109115 ) ;
110- // 获取i18n
116+ // 兼容 chrome 内核 < 128 处理
117+ const condition : chrome . declarativeNetRequest . RuleCondition = {
118+ regexFilter : "^([^#]+?)\\.user(\\.bg|\\.sub)?\\.js((\\?).*|$)" ,
119+ resourceTypes : [ chrome . declarativeNetRequest . ResourceType . MAIN_FRAME ] ,
120+ requestMethods : [ "get" as chrome . declarativeNetRequest . RequestMethod ] ,
121+ } ;
122+ const browserType = getBrowserType ( ) ;
123+ if ( browserType . chrome && browserType . chromeVersion >= 128 ) {
124+ condition . excludedResponseHeaders = [
125+ {
126+ header : "Content-Type" ,
127+ values : [ "text/html" ] ,
128+ } ,
129+ ] ;
130+ } else {
131+ condition . excludedRequestDomains = [ "github.com" ] ;
132+ }
111133 // 重定向到脚本安装页
112134 chrome . declarativeNetRequest . updateDynamicRules (
113135 {
@@ -122,17 +144,7 @@ export class ScriptService {
122144 regexSubstitution : `https://docs.scriptcat.org${ localePath } /docs/script_installation/#url=\\0` ,
123145 } ,
124146 } ,
125- condition : {
126- regexFilter : "^([^#]+?)\\.user(\\.bg|\\.sub)?\\.js((\\?).*|$)" ,
127- resourceTypes : [ chrome . declarativeNetRequest . ResourceType . MAIN_FRAME ] ,
128- requestMethods : [ "get" as chrome . declarativeNetRequest . RequestMethod ] ,
129- excludedResponseHeaders : [
130- {
131- header : "Content-Type" ,
132- values : [ "text/html" ] ,
133- } ,
134- ] ,
135- } ,
147+ condition : condition ,
136148 } ,
137149 ] ,
138150 } ,
0 commit comments