@@ -47,6 +47,7 @@ import { CompiledResourceDAO } from "@App/app/repo/resource";
4747import { initRegularUpdateCheck } from "./regular_updatecheck" ;
4848import { parseSkillScriptMetadata } from "@App/pkg/utils/skill_script" ;
4949import { TempStorageDAO , TempStorageItemType } from "@App/app/repo/tempStorage" ;
50+ import { EnableAgent } from "@App/app/const" ;
5051
5152export type TCheckScriptUpdateOption = Partial <
5253 { checkType : "user" ; noUpdateCheck ?: number } | ( { checkType : "system" } & Record < string , any > )
@@ -98,8 +99,11 @@ export class ScriptService {
9899 }
99100 // 处理url, 实现安装脚本
100101 let targetUrl : string ;
101- // 判断是否为 file:///*/*.user.js 或 file:///*/*.skill.js
102- if ( req . url . startsWith ( "file://" ) && ( req . url . endsWith ( ".user.js" ) || req . url . endsWith ( ".skill.js" ) ) ) {
102+ // 判断是否为 file:///*/*.user.js 或 file:///*/*.skill.js(skill 仅 agent 启用时)
103+ if (
104+ req . url . startsWith ( "file://" ) &&
105+ ( req . url . endsWith ( ".user.js" ) || ( EnableAgent && req . url . endsWith ( ".skill.js" ) ) )
106+ ) {
103107 targetUrl = req . url ;
104108 } else {
105109 const reqUrl = new URL ( req . url ) ;
@@ -166,8 +170,13 @@ export class ScriptService {
166170 { schemes : [ "http" , "https" ] , hostEquals : "docs.scriptcat.org" , pathPrefix : "/en/docs/script_installation/" } ,
167171 { schemes : [ "http" , "https" ] , hostEquals : "www.tampermonkey.net" , pathPrefix : "/script_installation.php" } ,
168172 { schemes : [ "file" ] , pathSuffix : ".user.js" } ,
169- { schemes : [ "file" ] , pathSuffix : ".skill.js" } ,
170- { schemes : [ "file" ] , pathSuffix : ".cat.md" } ,
173+ // Skill 安装入口仅在 agent 启用时拦截(正式版屏蔽)
174+ ...( EnableAgent
175+ ? [
176+ { schemes : [ "file" ] , pathSuffix : ".skill.js" } ,
177+ { schemes : [ "file" ] , pathSuffix : ".cat.md" } ,
178+ ]
179+ : [ ] ) ,
171180 ] ,
172181 }
173182 ) ;
@@ -252,21 +261,26 @@ export class ScriptService {
252261 isUrlFilterCaseSensitive : false ,
253262 requestDomains : [ "bitbucket.org" ] , // Chrome 101+
254263 } ,
255- // SkillScript (.skill.js) 安装检测
256- {
257- regexFilter : "^([^?#]+?\\.skill\\.js)" ,
258- resourceTypes : [ chrome . declarativeNetRequest . ResourceType . MAIN_FRAME ] ,
259- requestMethods : [ "get" as chrome . declarativeNetRequest . RequestMethod ] ,
260- isUrlFilterCaseSensitive : false ,
261- excludedRequestDomains : [ "github.com" , "gitlab.com" , "gitea.com" , "bitbucket.org" ] ,
262- } ,
263- // Skill 包 (.cat.md) 安装检测
264- {
265- regexFilter : "^([^?#]+?\\.cat\\.md)" ,
266- resourceTypes : [ chrome . declarativeNetRequest . ResourceType . MAIN_FRAME ] ,
267- requestMethods : [ "get" as chrome . declarativeNetRequest . RequestMethod ] ,
268- isUrlFilterCaseSensitive : false ,
269- } ,
264+ // Skill 安装入口仅在 agent 启用时拦截(正式版屏蔽)
265+ ...( EnableAgent
266+ ? [
267+ // SkillScript (.skill.js) 安装检测
268+ {
269+ regexFilter : "^([^?#]+?\\.skill\\.js)" ,
270+ resourceTypes : [ chrome . declarativeNetRequest . ResourceType . MAIN_FRAME ] ,
271+ requestMethods : [ "get" as chrome . declarativeNetRequest . RequestMethod ] ,
272+ isUrlFilterCaseSensitive : false ,
273+ excludedRequestDomains : [ "github.com" , "gitlab.com" , "gitea.com" , "bitbucket.org" ] ,
274+ } ,
275+ // Skill 包 (.cat.md) 安装检测
276+ {
277+ regexFilter : "^([^?#]+?\\.cat\\.md)" ,
278+ resourceTypes : [ chrome . declarativeNetRequest . ResourceType . MAIN_FRAME ] ,
279+ requestMethods : [ "get" as chrome . declarativeNetRequest . RequestMethod ] ,
280+ isUrlFilterCaseSensitive : false ,
281+ } ,
282+ ]
283+ : [ ] ) ,
270284 ] ;
271285 const installPageURL = chrome . runtime . getURL ( "src/install.html" ) ;
272286 const rules = conditions . map ( ( condition , idx ) => {
@@ -948,8 +962,8 @@ export class ScriptService {
948962 logger ?. error ( "prepare script failed" , Logger . E ( e ) ) ;
949963 }
950964 }
951- // 检测是否为 SkillScript
952- const skillScriptMeta = parseSkillScriptMetadata ( code ) ;
965+ // 检测是否为 SkillScript(仅 agent 启用时,正式版不识别 skill 安装)
966+ const skillScriptMeta = EnableAgent ? parseSkillScriptMetadata ( code ) : null ;
953967 if ( skillScriptMeta ) {
954968 const si = await createTempCodeEntry ( false , uuid , code , url , upsertBy , { } as SCMetadata , options ) ;
955969 si [ 1 ] . skillScript = true ;
0 commit comments