@@ -267,6 +267,7 @@ let hn2name = 'hostname'
267267
268268//待输出
269269let modInfo = [ ] //模块简介
270+ let loonArg = [ ] //[Argument]
270271let httpFrame = '' //Stash的http:父框架
271272let tiles = [ ] //磁贴覆写
272273let General = [ ]
@@ -516,12 +517,12 @@ if (binaryInfo != null && binaryInfo.length > 0) {
516517 if ( / ^ # ! .+ ?= \s * $ / . test ( x ) ) {
517518 } else if ( isLooniOS && / ^ # ! (?: s e l e c t | i n p u t ) \s * = \s * .+ / . test ( x ) ) {
518519 getInputInfo ( x , modInputBox )
519- } else if ( / ^ # ! .+ ?= .+ / . test ( x ) && ! / ^ # ! (?: s e l e c t | i n p u t ) \s * = \s * .+ / . test ( x ) ) {
520+ } else if ( / ^ # ! .+ ?= .+ / . test ( x ) && ! / ^ # ! (?: s e l e c t | i n p u t | a r g u m e n t s ) \s * = \s * .+ / . test ( x ) ) {
520521 getModInfo ( x )
521522 }
522523
523524 //#!arguments参数
524- if ( / ^ # ! a r g u m e n t s \s * = \s * .+ / . test ( x ) ) {
525+ if ( / ^ # ! a r g u m e n t s \s * = \s * .+ / . test ( x ) || / = \s * i n p u t | s e l e c t | s w i t c h / . test ( x ) ) {
525526 parseArguments ( x )
526527 }
527528
@@ -810,6 +811,8 @@ if (binaryInfo != null && binaryInfo.length > 0) {
810811 ? getJsInfo ( x , / [ = , \s ] \s * c r o n e x p r ? \s * = \s * / )
811812 : / c r o n \s + " / . test ( x )
812813 ? x . split ( '"' ) [ 1 ]
814+ : / c r o n \s + [ ^ \s ] + ?\s + /
815+ ? x . split ( / \s / ) [ 1 ]
813816 : ''
814817 ability = getJsInfo ( x , / [ = , \s ] \s * a b i l i t y \s * = \s * / )
815818 engine = getJsInfo ( x , / [ = , \s ] \s * e n g i n e \s * = \s * / )
@@ -1051,6 +1054,17 @@ if (binaryInfo != null && binaryInfo.length > 0) {
10511054 realBox = pieceHn ( realBox )
10521055 if ( synMitm ) fheBox = hnBox
10531056
1057+ if ( isSurgeiOS && sgArg . length > 0 ) {
1058+ let sgargArr = [ ]
1059+ for ( let i = 0 ; i < sgArg . length ; i ++ ) {
1060+ let key = sgArg [ i ] . key
1061+ let value = sgArg [ i ] . value . split ( ',' ) [ 0 ] . trim ( )
1062+ let a = key + ':' + value
1063+ sgargArr . push ( a )
1064+ }
1065+ modInfoObj [ 'arguments' ] = ( sgargArr [ 0 ] || '' ) && `${ sgargArr . join ( ',' ) } `
1066+ }
1067+
10541068 //模块信息输出
10551069 switch ( targetApp ) {
10561070 case 'surge-module' :
@@ -1090,6 +1104,18 @@ if (binaryInfo != null && binaryInfo.length > 0) {
10901104 break
10911105 } //模块信息输出结束
10921106
1107+ //[Argument]输出
1108+ if ( isLooniOS && sgArg . length > 0 ) {
1109+ for ( let i = 0 ; i < sgArg . length ; i ++ ) {
1110+ let key = sgArg [ i ] . key
1111+ let type = sgArg [ i ] . type
1112+ let value = sgArg [ i ] . value
1113+ if ( type == 'switch' ) value = / ^ t r u e / . test ( value ) ? 'true,false' : 'false,true'
1114+ let tag = sgArg [ i ] . tag
1115+ loonArg . push ( key + '=' + type + ',' + value + ',' + tag )
1116+ }
1117+ }
1118+
10931119 //rule输出 switch不适合
10941120 for ( let i = 0 ; i < ruleBox . length ; i ++ ) {
10951121 noteK = ruleBox [ i ] . noteK ? '#' : ''
@@ -1658,6 +1684,8 @@ if (binaryInfo != null && binaryInfo.length > 0) {
16581684 case 'loon-plugin' :
16591685 modInfo = ( modInfo [ 0 ] || '' ) && `${ modInfo . join ( '\n' ) } `
16601686
1687+ loonArg = ( loonArg [ 0 ] || '' ) && `[Argument]\n${ loonArg . join ( '\n' ) } `
1688+
16611689 rules = ( rules [ 0 ] || '' ) && `[Rule]\n${ rules . join ( '\n' ) } `
16621690
16631691 Panel = ( Panel [ 0 ] || '' ) && `[Panel]\n${ Panel . join ( '\n\n' ) } `
@@ -1696,6 +1724,8 @@ if (binaryInfo != null && binaryInfo.length > 0) {
16961724
16971725 body = `${ modInfo }
16981726
1727+ ${ loonArg }
1728+
16991729${ General }
17001730
17011731${ rules }
@@ -1797,12 +1827,21 @@ ${providers}
17971827 break
17981828 } //输出内容结束
17991829 body = body . replace ( / \n { 2 , } / g, '\n\n' )
1800- if ( ! isSurgeiOS && sgArg . length > 0 ) {
1830+ if ( ! isSurgeiOS && ! isLooniOS && sgArg . length > 0 ) {
18011831 for ( let i = 0 ; i < sgArg . length ; i ++ ) {
18021832 let e = '{{{' + sgArg [ i ] . key + '}}}'
18031833 let r = sgArg [ i ] . value
18041834 body = body . replaceAll ( e , r )
18051835 } //for
1836+ } else if ( isSurgeiOS ) {
1837+ body = body . replaceAll ( '{{{' , '{' ) . replaceAll ( '}}}' , '}' )
1838+ for ( let i = 0 ; i < sgArg . length ; i ++ ) {
1839+ let e = '{' + sgArg [ i ] . key + '}'
1840+ let r = '{{{' + sgArg [ i ] . key + '}}}'
1841+ body = body . replaceAll ( e , r )
1842+ } //for
1843+ } else if ( isLooniOS ) {
1844+ body = body . replaceAll ( '{{{' , '{' ) . replaceAll ( '}}}' , '}' )
18061845 }
18071846
18081847 eval ( evJsmodi )
@@ -2273,19 +2312,38 @@ function getPolicy(str) {
22732312}
22742313
22752314function parseArguments ( str ) {
2315+ if ( / # ! a r g u m e n t s / . test ( str ) ) {
22762316 const queryString = str . split ( / # ! a r g u m e n t s \s * = \s * / ) [ 1 ] //获取查询字符串部分
22772317 const regex = / ( [ ^ : , ] + ) : ( \s * " .+ ?" | [ ^ , ] * ) / g //匹配键值对的正则表达式
22782318 let match
22792319
22802320 while ( ( match = regex . exec ( queryString ) ) ) {
22812321 const key = match [ 1 ] . trim ( ) . replace ( / ^ " ( .+ ) " $ / , '$1' ) //去除头尾空白符和引号
22822322 const value = match [ 2 ] . trim ( ) . replace ( / ^ " ( .+ ) " $ / , '$1' ) //去除头尾空白符和引号
2283- sgArg . push ( { key, value } ) //将键值对添加到对象中
2323+ const type = / ^ ( t r u e | f a l s e ) $ / . test ( value ) ? 'switch' : 'input'
2324+ const tag = `tag=${ key } , desc=${ key } `
2325+
2326+ sgArg . push ( { key, value, type, tag } ) //将键值对添加到对象中
2327+
22842328 if ( value == "hostname" ) {
22852329 hn2 = true
2286- hn2name = '{{{' + key + '}}}'
2330+ hn2name = key
22872331 }
22882332 }
2333+ } else {
2334+ const regex = / ( ^ .* ?) \s * = \s * ( .* ?) \s * , ( .* ?) , \s * ( [ ^ , ] * \s * = .+ ) / //获取信息
2335+ const key = str . match ( regex ) [ 1 ]
2336+ const type = str . match ( regex ) [ 2 ]
2337+ const value = str . match ( regex ) [ 3 ]
2338+ const tag = str . match ( regex ) [ 4 ]
2339+
2340+ sgArg . push ( { key, value, type, tag } )
2341+
2342+ if ( value == "hostname" ) {
2343+ hn2 = true
2344+ hn2name = key
2345+ }
2346+ }
22892347}
22902348
22912349function parseQueryString ( url ) {
0 commit comments