FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Script-Hub/Rewrite-Parser.js at main · samuel56u/Script-Hub · GitHub
Script-Hub/Rewrite-Parser.js at main · samuel56u/Script-Hub · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
samuel56u
/
Script-Hub
Public
forked from
Script-Hub-Org/Script-Hub
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Script-Hub
/
Rewrite-Parser.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
1891 lines (1679 loc) · 69.6 KB
Breadcrumbs
Script-Hub
/
Rewrite-Parser.js
Copy path
File metadata and controls
1891 lines (1679 loc) · 69.6 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************
支持将 QX重写 Surge模块 Loon插件 解析至Surge Shadowrocket Loon Stash
远程重写支持多链接输入,链接间用😂连接 可以 重写 模块 插件 混合传入
说明
原脚本作者@小白脸 脚本修改@chengkongyiban
感谢@xream 提供的replace-Header.js
echo-response.js
感谢@mieqq 提供的replace-body.js
插件图标用的 @Keikinn 的 StickerOnScreen项目 以及 @Toperlock 的图标库项目,感谢
项目地址:
https://github.com/Script-Hub-Org/Script-Hub
***************************/
const
script_start
=
Date
.
now
(
)
const
JS_NAME
=
'Script Hub: 重写转换'
const
$
=
new
Env
(
JS_NAME
)
let
arg
if
(
typeof
$argument
!=
'undefined'
)
{
arg
=
Object
.
fromEntries
(
$argument
.
split
(
'&'
)
.
map
(
item
=>
item
.
split
(
'='
)
)
)
}
else
{
arg
=
{
}
}
// 超时设置 与 script-converter.js 相同
const
HTTP_TIMEOUT
=
(
$
.
getval
(
'Parser_http_timeout'
)
??
20
)
*
1000
const
url
=
$request
.
url
const
req
=
url
.
split
(
/
f
i
l
e
\/
_
s
t
a
r
t
_
\/
/
)
[
1
]
.
split
(
/
\/
_
e
n
d
_
\/
/
)
[
0
]
const
reqArr
=
req
.
match
(
'%F0%9F%98%82'
)
?
req
.
split
(
'%F0%9F%98%82'
)
:
[
req
]
//$.log("原始链接:" + req);
const
urlArg
=
url
.
split
(
/
\/
_
e
n
d
_
\/
/
)
[
1
]
//获取参数
const
queryObject
=
parseQueryString
(
urlArg
)
//$.log("参数:" + $.toStr(queryObject));
//目标app
const
targetApp
=
queryObject
.
target
const
app
=
targetApp
.
split
(
'-'
)
[
0
]
const
isSurgeiOS
=
targetApp
==
'surge-module'
const
isStashiOS
=
targetApp
==
'stash-stoverride'
const
isLooniOS
=
targetApp
==
'loon-plugin'
const
isShadowrocket
=
targetApp
==
'shadowrocket-module'
const
evJsori
=
queryObject
.
evalScriptori
const
evJsmodi
=
queryObject
.
evalScriptmodi
const
evUrlori
=
queryObject
.
evalUrlori
const
evUrlmodi
=
queryObject
.
evalUrlmodi
let
noNtf
=
queryObject
.
noNtf
?
istrue
(
queryObject
.
noNtf
)
:
false
//默认开启通知
let
localsetNtf
=
$
.
lodash_get
(
arg
,
'Notify'
)
||
$
.
getval
(
'ScriptHub通知'
)
||
''
noNtf
=
localsetNtf
==
'开启通知'
?
false
:
localsetNtf
==
'关闭通知'
?
true
:
noNtf
let
openMsgHtml
=
istrue
(
queryObject
.
openMsgHtml
)
noNtf
=
openMsgHtml
?
true
:
noNtf
let
nName
=
queryObject
.
n
!=
undefined
?
getArgArr
(
queryObject
.
n
)
:
null
//名字简介
let
category
=
queryObject
.
category
??
null
let
icon
=
queryObject
.
icon
??
null
let
Pin0
=
queryObject
.
y
!=
undefined
?
getArgArr
(
queryObject
.
y
)
:
null
//保留
let
Pout0
=
queryObject
.
x
!=
undefined
?
getArgArr
(
queryObject
.
x
)
:
null
//排除
let
hnAdd
=
queryObject
.
hnadd
!=
undefined
?
queryObject
.
hnadd
.
split
(
/
\s
*
,
\s
*
/
)
:
null
//加
let
hnDel
=
queryObject
.
hndel
!=
undefined
?
queryObject
.
hndel
.
split
(
/
\s
*
,
\s
*
/
)
:
null
//减
let
hnRegDel
=
queryObject
.
hnregdel
!=
undefined
?
new
RegExp
(
queryObject
.
hnregdel
)
:
null
//正则删除hostname
let
synMitm
=
istrue
(
queryObject
.
synMitm
)
//将force与mitm同步
let
delNoteSc
=
istrue
(
queryObject
.
del
)
let
nCron
=
queryObject
.
cron
!=
undefined
?
getArgArr
(
queryObject
.
cron
)
:
null
//替换cron目标
let
ncronexp
=
queryObject
.
cronexp
!=
undefined
?
queryObject
.
cronexp
.
replace
(
/
\.
/
g
,
' '
)
.
split
(
'+'
)
:
null
//新cronexp
let
nArgTarget
=
queryObject
.
arg
!=
undefined
?
getArgArr
(
queryObject
.
arg
)
:
null
//arg目标
let
nArg
=
queryObject
.
argv
!=
undefined
?
getArgArr
(
queryObject
.
argv
)
:
null
//arg参数
let
nTilesTarget
=
queryObject
.
tiles
!=
undefined
?
getArgArr
(
queryObject
.
tiles
)
:
null
let
ntilescolor
=
queryObject
.
tcolor
!=
undefined
?
getArgArr
(
queryObject
.
tcolor
)
:
null
let
nPolicy
=
queryObject
.
policy
!=
undefined
?
queryObject
.
policy
:
null
let
njsnametarget
=
queryObject
.
njsnametarget
!=
undefined
?
getArgArr
(
queryObject
.
njsnametarget
)
:
null
//修改脚本名目标
let
njsname
=
queryObject
.
njsname
!=
undefined
?
getArgArr
(
queryObject
.
njsname
)
:
null
//修改脚本名
let
timeoutt
=
queryObject
.
timeoutt
!=
undefined
?
getArgArr
(
queryObject
.
timeoutt
)
:
null
//修改超时目标
let
timeoutv
=
queryObject
.
timeoutv
!=
undefined
?
getArgArr
(
queryObject
.
timeoutv
)
:
null
//修改超时的值
let
enginet
=
queryObject
.
enginet
!=
undefined
?
getArgArr
(
queryObject
.
enginet
)
:
null
//修改引擎目标
let
enginev
=
queryObject
.
enginev
!=
undefined
?
getArgArr
(
queryObject
.
enginev
)
:
null
//修改引擎的值
let
jsConverter
=
queryObject
.
jsc
!=
undefined
?
getArgArr
(
queryObject
.
jsc
)
:
null
//脚本转换1
let
jsConverter2
=
queryObject
.
jsc2
!=
undefined
?
getArgArr
(
queryObject
.
jsc2
)
:
null
//脚本转换2
let
compatibilityOnly
=
istrue
(
queryObject
.
compatibilityOnly
)
//兼容转换
let
keepHeader
=
istrue
(
queryObject
.
keepHeader
)
//保留mock header
let
jsDelivr
=
istrue
(
queryObject
.
jsDelivr
)
//开启jsDelivr
let
localText
=
queryObject
.
localtext
!=
undefined
?
'\n'
+
queryObject
.
localtext
:
''
//纯文本输入
let
ipNoResolve
=
istrue
(
queryObject
.
nore
)
//ip规则不解析域名
let
sni
=
queryObject
.
sni
!=
undefined
?
getArgArr
(
queryObject
.
sni
)
:
null
//sni嗅探
let
sufkeepHeader
=
keepHeader
==
true
?
'&keepHeader=true'
:
''
//用于保留header的后缀
let
sufjsDelivr
=
jsDelivr
==
true
?
'&jsDelivr=true'
:
''
//用于开启jsDeliver的后缀
//用于自定义发送请求的请求头
const
reqHeaders
=
{
headers
:
{
}
}
if
(
queryObject
.
headers
)
{
decodeURIComponent
(
queryObject
.
headers
)
.
split
(
/
\r
?
\n
/
)
.
map
(
i
=>
{
if
(
/
.
+
:
.
+
/
.
test
(
i
)
)
{
const
[
_
,
key
,
value
]
=
i
.
match
(
/
^
(
.
*
?
)
:
(
.
*
)
$
/
)
if
(
key
?.
length
>
0
&&
value
?.
length
>
0
)
{
reqHeaders
.
headers
[
key
]
=
value
}
}
}
)
}
//插件图标区域
const
iconStatus
=
$
.
getval
(
'启用插件随机图标'
)
??
'启用'
const
iconReplace
=
$
.
getval
(
'替换原始插件图标'
)
??
'禁用'
const
iconLibrary1
=
$
.
getval
(
'插件随机图标合集'
)
??
'Doraemon(100P)'
const
iconLibrary2
=
iconLibrary1
.
split
(
'('
)
[
0
]
const
iconFormat
=
/
g
i
f
/
i
.
test
(
iconLibrary2
)
?
'.gif'
:
'.png'
//统一前置声明变量
let
name
,
desc
,
randomicon
,
body
,
jscStatus
,
jsc2Status
,
jsPre
,
jsSuf
,
mark
,
noteK
,
ruletype
,
rulenore
,
rulesni
,
rulePandV
,
rulepolicy
,
rulevalue
,
modistatus
,
hostdomain
,
hostvalue
,
panelname
,
title
,
content
,
style
,
scriptname
,
jsurl
,
jsname
,
img
,
jsfrom
,
jstype
,
eventname
,
size
,
proto
,
engine
,
jsptn
,
jsarg
,
rebody
,
wakesys
,
cronexp
,
ability
,
updatetime
,
timeout
,
tilesicon
,
tilescolor
,
urlInNum
,
noteK2
,
noteK4
,
noteKn4
,
noteKn6
,
noteKn8
,
rwtype
,
rwptn
,
rwvalue
,
ori
,
MITM
,
force
,
result
let
Rewrite
=
isLooniOS
?
'[Rewrite]'
:
'[URL Rewrite]'
//随机插件图标
if
(
(
isStashiOS
||
isLooniOS
)
&&
iconStatus
==
'启用'
)
{
const
stickerStartNum
=
1001
const
stickerSum
=
iconLibrary1
.
split
(
'('
)
[
1
]
.
split
(
'P'
)
[
0
]
let
randomStickerNum
=
parseInt
(
stickerStartNum
+
Math
.
random
(
)
*
stickerSum
)
.
toString
(
)
randomicon
=
'https://github.com/Toperlock/Quantumult/raw/main/icon/'
+
iconLibrary2
+
'/'
+
iconLibrary2
+
'-'
+
randomStickerNum
+
iconFormat
}
//通知名区域
let
rewriteName
=
req
.
substring
(
req
.
lastIndexOf
(
'/'
)
+
1
)
.
split
(
'.'
)
[
0
]
let
resFile
=
urlArg
.
split
(
'?'
)
[
0
]
let
resFileName
=
resFile
.
substring
(
0
,
resFile
.
lastIndexOf
(
'.'
)
)
let
notifyName
if
(
nName
!=
null
&&
nName
[
0
]
!=
''
)
{
notifyName
=
nName
[
0
]
}
else
{
notifyName
=
resFileName
}
//修改名字和简介
if
(
nName
===
null
)
{
name
=
rewriteName
desc
=
name
}
else
{
name
=
nName
[
0
]
!=
''
?
nName
[
0
]
:
rewriteName
desc
=
nName
[
1
]
!=
undefined
?
nName
[
1
]
:
name
}
let
modInfoObj
=
{
name
:
name
,
desc
:
desc
,
author
:
''
,
icon
:
randomicon
,
category
:
''
,
}
//信息中转站
let
bodyBox
=
[
]
//存储待转换的内容
let
otherRule
=
[
]
//不支持的规则&脚本
let
notBuildInPolicy
=
[
]
//不是内置策略的规则
let
inBox
=
[
]
//被释放的重写或规则
let
outBox
=
[
]
//被排除的重写或规则
let
modInfoBox
=
[
]
//模块简介等信息
let
modInputBox
=
[
]
//loon插件的可交互按钮
let
hostBox
=
[
]
//host
let
ruleBox
=
[
]
//规则
let
rwBox
=
[
]
//重写
let
rwhdBox
=
[
]
//HeaderRewrite
let
panelBox
=
[
]
//Panel信息
let
jsBox
=
[
]
//脚本
let
mockBox
=
[
]
//MapLocal或echo-response
let
hnBox
=
[
]
//MITM主机名
let
fheBox
=
[
]
//force-http-engine
let
skipBox
=
[
]
//skip-ip
let
realBox
=
[
]
//real-ip
let
hndelBox
=
[
]
//正则剔除的主机名
let
sgArg
=
[
]
//surge模块参数
let
hnaddMethod
=
'%APPEND%'
let
fheaddMethod
=
'%APPEND%'
let
skipaddMethod
=
'%APPEND%'
let
realaddMethod
=
'%APPEND%'
//待输出
let
modInfo
=
[
]
//模块简介
let
httpFrame
=
''
//Stash的http:父框架
let
tiles
=
[
]
//磁贴覆写
let
General
=
[
]
let
Panel
=
[
]
let
host
=
[
]
let
rules
=
[
]
let
URLRewrite
=
[
]
let
HeaderRewrite
=
[
]
let
MapLocal
=
[
]
let
script
=
[
]
let
cron
=
[
]
let
providers
=
[
]
hnBox
=
hnAdd
!=
null
?
hnAdd
:
[
]
const
jsRegex
=
/
\s
*
[
=
,
]
\s
*
(?:
s
c
r
i
p
t
-
p
a
t
h
|
p
a
t
t
e
r
n
|
t
i
m
e
o
u
t
|
a
r
g
u
m
e
n
t
|
s
c
r
i
p
t
-
u
p
d
a
t
e
-
i
n
t
e
r
v
a
l
|
r
e
q
u
i
r
e
s
-
b
o
d
y
|
m
a
x
-
s
i
z
e
|
a
b
i
l
i
t
y
|
b
i
n
a
r
y
-
b
o
d
y
-
m
o
d
e
|
c
r
o
n
e
x
p
r
?
|
w
a
k
e
-
s
y
s
t
e
m
|
e
n
a
b
l
e
d
?
|
e
n
g
i
n
e
|
t
a
g
|
t
y
p
e
|
i
m
g
-
u
r
l
|
d
e
b
u
g
|
e
v
e
n
t
-
n
a
m
e
|
d
e
s
c
)
\s
*
=
\s
*
/
const
panelRegex
=
/
\s
*
[
=
,
]
\s
*
(?:
t
i
t
l
e
|
c
o
n
t
e
n
t
|
s
t
y
l
e
|
s
c
r
i
p
t
-
n
a
m
e
|
u
p
d
a
t
e
-
i
n
t
e
r
v
a
l
)
\s
*
=
\s
*
/
const
policyRegex
=
/
^
(
d
i
r
e
c
t
|
r
e
j
e
c
t
-
?
(
i
m
g
|
v
i
d
e
o
|
d
i
c
t
|
a
r
r
a
y
|
d
r
o
p
|
2
0
0
|
t
i
n
y
g
i
f
)
?
(
-
n
o
-
d
r
o
p
)
?
|
\{
\{
\{
[
^
,
]
+
\}
\}
\}
)
$
/
i
const
mockRegex
=
/
\s
+
(?:
d
a
t
a
-
t
y
p
e
|
s
t
a
t
u
s
-
c
o
d
e
|
h
e
a
d
e
r
|
d
a
t
a
)
\s
*
=
/
//查询js binarymode相关
let
binaryInfo
=
$
.
getval
(
'Parser_binary_info'
)
if
(
binaryInfo
!=
null
&&
binaryInfo
.
length
>
0
)
{
binaryInfo
=
$
.
toObj
(
binaryInfo
)
}
else
{
binaryInfo
=
[
]
}
!
(
async
(
)
=>
{
if
(
evUrlori
)
{
evUrlori
=
(
await
$
.
http
.
get
(
evUrlori
)
)
.
body
}
if
(
evUrlmodi
)
{
evUrlmodi
=
(
await
$
.
http
.
get
(
evUrlmodi
)
)
.
body
}
if
(
req
==
'http://local.text'
)
{
body
=
localText
}
else
{
for
(
let
i
=
0
;
i
<
reqArr
.
length
;
i
++
)
{
let
res
=
await
http
(
reqArr
[
i
]
,
reqHeaders
)
let
reStatus
=
res
.
status
body
=
reStatus
==
200
?
res
.
body
:
reStatus
==
404
?
'#!error=404: Not Found'
:
''
reStatus
==
404
&&
$
.
msg
(
JS_NAME
,
'来源链接已失效'
,
'404: Not Found ---> '
+
reqArr
[
i
]
,
''
)
if
(
body
.
match
(
/
^
(?:
\s
)
*
\/
\*
[
\s
\S
]
*
?
(?:
\r
|
\n
)
\s
*
\*
+
\/
/
)
)
{
body
=
body
.
match
(
/
^
(?:
\n
|
\r
)
*
\/
\*
(
[
\s
\S
]
*
?
)
(?:
\r
|
\n
)
\s
*
\*
+
\/
/
)
[
1
]
bodyBox
.
push
(
body
)
}
else
{
bodyBox
.
push
(
body
)
}
}
//for
body
=
bodyBox
.
join
(
'\n\n'
)
+
localText
}
eval
(
evJsori
)
eval
(
evUrlori
)
body
=
body
.
match
(
/
[
^
\r
\n
]
+
/
g
)
for
await
(
let
[
y
,
x
]
of
body
.
entries
(
)
)
{
//简单处理方便后续操作
x
=
x
.
trim
(
)
.
replace
(
/
^
(
#
|
;
|
\/
\/
)
\s
*
/
,
'#'
)
.
replace
(
/
\s
+
[
^
\s
]
+
\s
+
u
r
l
-
a
n
d
-
h
e
a
d
e
r
\s
+
/
,
' url '
)
.
replace
(
/
(
^
[
^
#
]
.
+
)
\x20
+
\/
\/
.
+
/
,
'$1'
)
.
replace
(
/
^
#
!
P
R
O
F
I
L
E
-
V
E
R
S
I
O
N
-
R
E
Q
U
I
R
E
D
\s
+
[
0
-
9
]
+
\s
+
/
i
,
''
)
.
replace
(
/
^
(
#
)
?
h
o
s
t
(
-
s
u
f
f
i
x
|
-
k
e
y
w
o
r
d
|
-
w
i
l
d
c
a
r
d
)
?
\s
*
,
\s
*
/
i
,
'$1DOMAIN$2,'
)
.
replace
(
/
^
(
#
)
?
i
p
6
-
c
i
d
r
\s
*
,
\s
*
/
i
,
'$1IP-CIDR6,'
)
//去掉注释
if
(
Pin0
!=
null
)
{
for
(
let
i
=
0
;
i
<
Pin0
.
length
;
i
++
)
{
const
elem
=
Pin0
[
i
]
.
trim
(
)
if
(
x
.
indexOf
(
elem
)
!=
-
1
&&
/
^
#
/
.
test
(
x
)
)
{
x
=
x
.
replace
(
/
^
#
/
,
''
)
inBox
.
push
(
x
)
break
}
}
//循环结束
}
//去掉注释结束
//增加注释
if
(
Pout0
!=
null
)
{
for
(
let
i
=
0
;
i
<
Pout0
.
length
;
i
++
)
{
const
elem
=
Pout0
[
i
]
.
trim
(
)
if
(
x
.
indexOf
(
elem
)
!=
-
1
&&
!
/
^
(
h
o
s
t
n
a
m
e
|
f
o
r
c
e
-
h
t
t
p
-
e
n
g
i
n
e
-
h
o
s
t
s
|
s
k
i
p
-
p
r
o
x
y
|
a
l
w
a
y
s
-
r
e
a
l
-
i
p
|
r
e
a
l
-
i
p
)
\s
*
=
/
.
test
(
x
)
&&
!
/
^
#
/
.
test
(
x
)
)
{
x
=
'#'
+
x
outBox
.
push
(
x
)
break
}
}
//循环结束
}
//增加注释结束
//剔除被注释的重写
if
(
delNoteSc
==
true
&&
/
^
#
/
.
test
(
x
)
&&
!
/
^
#
!
/
.
test
(
x
)
)
{
x
=
''
}
//sni嗅探
if
(
sni
!=
null
)
{
for
(
let
i
=
0
;
i
<
sni
.
length
;
i
++
)
{
const
elem
=
sni
[
i
]
.
trim
(
)
if
(
x
.
indexOf
(
elem
)
!=
-
1
&&
/
^
(
D
O
M
A
I
N
|
R
U
L
E
-
S
E
T
)
/
i
.
test
(
x
)
&&
!
/
,
\s
*
e
x
t
e
n
d
e
d
-
m
a
t
c
h
i
n
g
/
i
.
test
(
x
)
)
{
x
=
x
+
',extended-matching'
break
}
}
//循环结束
}
//启用sni嗅探结束
//ip规则不解析域名
if
(
ipNoResolve
==
true
)
{
if
(
/
^
(?:
i
p
-
[
c
a
]
|
R
U
L
E
-
S
E
T
)
/
i
.
test
(
x
)
&&
!
/
,
\s
*
n
o
-
r
e
s
o
l
v
e
/
.
test
(
x
)
)
{
x
=
x
+
',no-resolve'
}
}
//增加ip规则不解析域名结束
if
(
jsConverter
!=
null
)
{
jscStatus
=
isJsCon
(
x
,
jsConverter
)
}
if
(
jsConverter2
!=
null
)
{
jsc2Status
=
isJsCon
(
x
,
jsConverter2
)
}
if
(
jsc2Status
==
true
)
{
jscStatus
=
false
}
jsPre
=
''
jsSuf
=
''
if
(
jscStatus
==
true
||
jsc2Status
==
true
)
{
jsPre
=
'http://script.hub/convert/_start_/'
}
if
(
jscStatus
==
true
)
{
jsSuf
=
`/_end_/_yuliu_.js?type=_js_from_-script&target=
${
app
}
-script`
}
else
if
(
jsc2Status
==
true
)
{
jsSuf
=
`/_end_/_yuliu_.js?type=_js_from_-script&target=
${
app
}
-script&wrap_response=true`
}
if
(
compatibilityOnly
==
true
&&
(
jscStatus
==
true
||
jsc2Status
==
true
)
)
{
jsSuf
=
jsSuf
+
'&compatibilityOnly=true'
}
//模块信息
if
(
/
^
#
!
.
+
?
=
\s
*
$
/
.
test
(
x
)
)
{
}
else
if
(
isLooniOS
&&
/
^
#
!
(?:
s
e
l
e
c
t
|
i
n
p
u
t
)
\s
*
=
\s
*
.
+
/
.
test
(
x
)
)
{
getInputInfo
(
x
,
modInputBox
)
}
else
if
(
/
^
#
!
.
+
?
=
.
+
/
.
test
(
x
)
&&
!
/
^
#
!
(?:
s
e
l
e
c
t
|
i
n
p
u
t
)
\s
*
=
\s
*
.
+
/
.
test
(
x
)
)
{
getModInfo
(
x
)
}
//#!arguments参数
if
(
!
isSurgeiOS
&&
/
^
#
!
a
r
g
u
m
e
n
t
s
\s
*
=
\s
*
.
+
/
.
test
(
x
)
)
{
parseArguments
(
x
)
}
//hostname
if
(
/
^
h
o
s
t
n
a
m
e
\s
*
=
.
+
/
.
test
(
x
)
)
hnaddMethod
=
getHn
(
x
,
hnBox
,
hnaddMethod
)
if
(
/
^
f
o
r
c
e
-
h
t
t
p
-
e
n
g
i
n
e
-
h
o
s
t
s
\s
*
=
.
+
/
.
test
(
x
)
)
fheaddMethod
=
getHn
(
x
,
fheBox
,
fheaddMethod
)
if
(
/
^
s
k
i
p
-
p
r
o
x
y
\s
*
=
.
+
/
.
test
(
x
)
)
skipaddMethod
=
getHn
(
x
,
skipBox
,
skipaddMethod
)
if
(
/
^
(?:
a
l
w
a
y
s
-
)
?
r
e
a
l
-
i
p
\s
*
=
.
+
/
.
test
(
x
)
)
realaddMethod
=
getHn
(
x
,
realBox
,
realaddMethod
)
//reject 解析
if
(
/
.
+
r
e
j
e
c
t
(?:
-
\w
+
)
?
$
/
i
.
test
(
x
)
&&
!
/
^
#
?
(
D
O
M
A
I
N
.
*
?
\s
*
,
|
I
P
-
C
I
D
R
6
?
\s
*
,
|
I
P
-
A
S
N
\s
*
,
|
O
R
\s
*
,
|
A
N
D
\s
*
,
|
N
O
T
\s
*
,
|
U
S
E
R
-
A
G
E
N
T
\s
*
,
|
U
R
L
-
R
E
G
E
X
\s
*
,
|
R
U
L
E
-
S
E
T
\s
*
,
|
D
E
?
S
T
-
P
O
R
T
\s
*
,
|
P
R
O
T
O
C
O
L
\s
*
,
)
/
i
.
test
(
x
)
&&
!
/
^
#
!
/
.
test
(
x
)
)
{
mark
=
getMark
(
y
,
body
)
rw_reject
(
x
,
mark
)
}
//重定向 解析
if
(
/
(?:
\s
(?:
3
0
2
|
3
0
7
|
h
e
a
d
e
r
)
(?:
$
|
\s
)
|
u
r
l
\s
+
3
0
(?:
2
|
7
)
\s
)
/
.
test
(
x
)
)
{
mark
=
getMark
(
y
,
body
)
rw_redirect
(
x
,
mark
)
}
//header rewrite 解析
if
(
/
\s
h
e
a
d
e
r
-
(?:
d
e
l
|
a
d
d
|
r
e
p
l
a
c
e
|
r
e
p
l
a
c
e
-
r
e
g
e
x
)
\s
/
.
test
(
x
)
)
{
mark
=
getMark
(
y
,
body
)
noteK
=
isNoteK
(
x
)
x
=
x
.
replace
(
/
^
#
/
,
''
)
rwhdBox
.
push
(
{
mark
,
noteK
,
x
}
)
}
//(request|response)-(header|body) 解析
if
(
/
\s
u
r
l
\s
+
(?:
r
e
q
u
e
s
t
|
r
e
s
p
o
n
s
e
)
-
(?:
h
e
a
d
e
r
|
b
o
d
y
)
\s
/
i
.
test
(
x
)
)
{
mark
=
getMark
(
y
,
body
)
getQxReInfo
(
x
,
y
,
mark
)
}
//rule解析
if
(
/
^
#
?
(?:
d
o
m
a
i
n
(?:
-
s
u
f
f
i
x
|
-
k
e
y
w
o
r
d
|
-
w
i
l
d
c
a
r
d
|
-
s
e
t
)
?
|
i
p
-
c
i
d
r
6
?
|
i
p
-
a
s
n
|
r
u
l
e
-
s
e
t
|
u
s
e
r
-
a
g
e
n
t
|
u
r
l
-
r
e
g
e
x
|
(
d
e
?
s
t
|
i
n
|
s
r
c
)
-
p
o
r
t
|
a
n
d
|
n
o
t
|
o
r
|
p
r
o
t
o
c
o
l
)
\s
*
,
.
+
/
i
.
test
(
x
)
)
{
mark
=
getMark
(
y
,
body
)
noteK
=
isNoteK
(
x
)
ruletype
=
x
.
split
(
/
\s
*
,
\s
*
/
)
[
0
]
.
replace
(
/
^
#
/
,
''
)
rulenore
=
/
,
\s
*
n
o
-
r
e
s
o
l
v
e
/
.
test
(
x
)
?
',no-resolve'
:
''
rulesni
=
/
,
\s
*
e
x
t
e
n
d
e
d
-
m
a
t
c
h
i
n
g
/
.
test
(
x
)
?
',extended-matching'
:
''
rulePandV
=
x
.
replace
(
/
^
#
/
,
''
)
.
replace
(
ruletype
,
''
)
.
replace
(
/
\s
*
,
\s
*
n
o
-
r
e
s
o
l
v
e
/
,
''
)
.
replace
(
/
\s
*
,
\s
*
e
x
t
e
n
d
e
d
-
m
a
t
c
h
i
n
g
/
,
''
)
.
replace
(
/
^
\s
*
,
\s
*
/
,
''
)
rulepolicy
=
getPolicy
(
rulePandV
)
rulevalue
=
rulePandV
.
replace
(
rulepolicy
,
''
)
.
replace
(
/
\s
*
,
\s
*
$
/
,
''
)
.
replace
(
/
"
/
g
,
''
)
if
(
nPolicy
!=
null
&&
!
policyRegex
.
test
(
rulepolicy
)
)
{
rulepolicy
=
nPolicy
modistatus
=
'yes'
}
else
{
modistatus
=
'no'
}
ruleBox
.
push
(
{
mark
,
noteK
,
ruletype
,
rulevalue
,
rulepolicy
,
rulenore
,
rulesni
,
ori
:
x
,
modistatus
}
)
}
//rule解析结束
//host解析
if
(
/
^
#
?
(?:
\*
|
l
o
c
a
l
h
o
s
t
|
[
-
*
?
0
-
9
a
-
z
]
+
\.
[
-
*
.
?
0
-
9
a
-
z
]
+
)
\s
*
=
\s
*
(?:
s
e
v
e
r
\s
*
:
\s
*
|
s
c
r
i
p
t
\s
*
:
\s
*
)
?
[
\s
0
-
9
a
-
z
:
/
,
.
]
+
$
/
g
.
test
(
x
)
)
{
noteK
=
isNoteK
(
x
)
mark
=
getMark
(
y
,
body
)
hostdomain
=
x
.
split
(
/
\s
*
=
\s
*
/
)
[
0
]
hostvalue
=
x
.
split
(
/
\s
*
=
\s
*
/
)
[
1
]
hostBox
.
push
(
{
mark
,
noteK
,
hostdomain
,
hostvalue
,
ori
:
x
}
)
}
//Panel信息
if
(
/
[
=
,
]
\s
*
s
c
r
i
p
t
-
n
a
m
e
\s
*
=
.
+
/
.
test
(
x
)
)
{
mark
=
getMark
(
y
,
body
)
noteK
=
isNoteK
(
x
)
panelname
=
x
.
split
(
/
\s
*
=
/
)
[
0
]
.
replace
(
/
^
#
/
,
''
)
title
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
t
i
t
l
e
\s
*
=
\s
*
/
)
content
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
c
o
n
t
e
n
t
\s
*
=
\s
*
/
)
style
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
s
t
y
l
e
\s
*
=
\s
*
/
)
scriptname
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
s
c
r
i
p
t
-
n
a
m
e
\s
*
=
\s
*
/
)
updatetime
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
u
p
d
a
t
e
-
i
n
t
e
r
v
a
l
\s
*
=
\s
*
/
)
panelBox
.
push
(
{
mark
,
noteK
,
panelname
,
title
,
content
,
style
,
scriptname
,
updatetime
,
ori
:
x
,
num
:
y
,
}
)
}
//Panel信息解析结束
//脚本解析
if
(
/
s
c
r
i
p
t
-
p
a
t
h
\s
*
=
.
+
/
.
test
(
x
)
)
{
mark
=
getMark
(
y
,
body
)
noteK
=
isNoteK
(
x
)
jsurl
=
getJsInfo
(
x
,
/
s
c
r
i
p
t
-
p
a
t
h
\s
*
=
\s
*
/
)
jsname
=
/
[
=
,
]
\s
*
t
y
p
e
\s
*
=
\s
*
/
.
test
(
x
)
?
x
.
split
(
/
\s
*
=
/
)
[
0
]
.
replace
(
/
^
#
/
,
''
)
:
/
,
\s
*
t
a
g
\s
*
=
\s
*
/
.
test
(
x
)
?
getJsInfo
(
x
,
/
,
\s
*
t
a
g
\s
*
=
\s
*
/
)
:
jsurl
.
substring
(
jsurl
.
lastIndexOf
(
'/'
)
+
1
,
jsurl
.
lastIndexOf
(
'.'
)
)
img
=
getJsInfo
(
x
,
/
[
,
\s
]
\s
*
i
m
g
-
u
r
l
\s
*
=
\s
*
/
)
jsfrom
=
'surge'
jsurl
=
toJsc
(
jsurl
,
jscStatus
,
jsc2Status
,
jsfrom
)
jstype
=
/
[
=
,
]
\s
*
t
y
p
e
\s
*
=
\s
*
/
.
test
(
x
)
?
getJsInfo
(
x
,
/
[
=
,
]
\s
*
t
y
p
e
\s
*
=
\s
*
/
)
:
x
.
split
(
/
\s
+
/
)
[
0
]
.
replace
(
/
^
#
/
,
''
)
eventname
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
e
v
e
n
t
-
n
a
m
e
\s
*
=
\s
*
/
)
size
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
m
a
x
-
s
i
z
e
\s
*
=
\s
*
/
)
proto
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
b
i
n
a
r
y
-
b
o
d
y
-
m
o
d
e
\s
*
=
\s
*
/
)
jsptn
=
/
[
=
,
]
\s
*
p
a
t
t
e
r
n
\s
*
=
\s
*
/
.
test
(
x
)
?
getJsInfo
(
x
,
/
[
=
,
]
\s
*
p
a
t
t
e
r
n
\s
*
=
\s
*
/
)
.
replace
(
/
"
/
g
,
''
)
:
x
.
split
(
/
\s
+
/
)
[
1
]
jsptn
=
/
c
r
o
n
|
e
v
e
n
t
|
n
e
t
w
o
r
k
-
c
h
a
n
g
e
d
|
g
e
n
e
r
i
c
|
d
n
s
|
r
u
l
e
/
i
.
test
(
jstype
)
?
''
:
jsptn
jsarg
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
a
r
g
u
m
e
n
t
\s
*
=
\s
*
/
)
rebody
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
r
e
q
u
i
r
e
s
-
b
o
d
y
\s
*
=
\s
*
/
)
wakesys
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
w
a
k
e
-
s
y
s
t
e
m
\s
*
=
\s
*
/
)
cronexp
=
/
c
r
o
n
e
x
p
r
?
\s
*
=
\s
*
/
.
test
(
x
)
?
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
c
r
o
n
e
x
p
r
?
\s
*
=
\s
*
/
)
:
/
c
r
o
n
\s
+
"
/
.
test
(
x
)
?
x
.
split
(
'"'
)
[
1
]
:
''
ability
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
a
b
i
l
i
t
y
\s
*
=
\s
*
/
)
engine
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
e
n
g
i
n
e
\s
*
=
\s
*
/
)
updatetime
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
s
c
r
i
p
t
-
u
p
d
a
t
e
-
i
n
t
e
r
v
a
l
\s
*
=
\s
*
/
)
timeout
=
getJsInfo
(
x
,
/
[
=
,
\s
]
\s
*
t
i
m
e
o
u
t
\s
*
=
\s
*
/
)
tilesicon
=
jstype
==
'generic'
&&
/
i
c
o
n
=
/
.
test
(
x
)
?
x
.
split
(
'icon='
)
[
1
]
.
split
(
'&'
)
[
0
]
:
''
tilescolor
=
jstype
==
'generic'
&&
/
i
c
o
n
-
c
o
l
o
r
=
/
.
test
(
x
)
?
x
.
split
(
'icon-color='
)
[
1
]
.
split
(
'&'
)
[
0
]
:
''
if
(
nCron
!=
null
&&
jstype
!=
'cron'
)
{
for
(
let
i
=
0
;
i
<
nCron
.
length
;
i
++
)
{
let
elem
=
nCron
[
i
]
.
trim
(
)
if
(
x
.
indexOf
(
elem
)
!=
-
1
)
{
let
jsname
=
jsurl
.
substring
(
jsurl
.
lastIndexOf
(
'/'
)
+
1
,
jsurl
.
lastIndexOf
(
'.'
)
)
+
'-cron'
jsBox
.
push
(
{
mark
,
noteK
,
jsname
,
img
,
jstype
:
'cron'
,
jsptn
:
''
,
jsurl
,
updatetime
,
wakesys
:
'1'
,
timeout
:
'120'
,
ori
:
x
,
num
:
y
,
}
)
}
}
//for
}
jsBox
.
push
(
{
mark
,
noteK
,
jsname
,
img
,
jstype
,
jsptn
,
jsurl
,
rebody
,
proto
,
size
,
ability
,
updatetime
,
timeout
,
jsarg
,
cronexp
,
wakesys
,
tilesicon
,
tilescolor
,
eventname
,
engine
,
ori
:
x
,
num
:
y
,
}
)
}
//脚本解析结束
//qx脚本解析
if
(
/
\s
u
r
l
\s
+
s
c
r
i
p
t
-
/
.
test
(
x
)
)
{
x
=
x
.
replace
(
/
\s
{
2
,
}
/
g
,
' '
)
mark
=
getMark
(
y
,
body
)
noteK
=
isNoteK
(
x
)
jstype
=
x
.
match
(
' url script-response'
)
?
'http-response'
:
'http-request'
urlInNum
=
x
.
split
(
/
\s
/
)
.
indexOf
(
'url'
)
jsptn
=
x
.
split
(
/
\s
/
)
[
urlInNum
-
1
]
.
replace
(
/
^
#
/
,
''
)
jsurl
=
x
.
split
(
/
\s
/
)
[
urlInNum
+
2
]
jsfrom
=
'qx'
jsname
=
jsurl
.
substring
(
jsurl
.
lastIndexOf
(
'/'
)
+
1
,
jsurl
.
lastIndexOf
(
'.'
)
)
jsarg
=
''
proto
=
await
isBinaryMode
(
jsurl
,
jsname
)
jsurl
=
toJsc
(
jsurl
,
jscStatus
,
jsc2Status
,
jsfrom
)
rebody
=
/
\s
s
c
r
i
p
t
[
^
\s
]
*
(
-
b
o
d
y
|
-
a
n
a
l
y
z
e
)
/
.
test
(
x
)
?
'true'
:
''
size
=
rebody
==
'true'
?
'-1'
:
''
if
(
nCron
!=
null
)
{
for
(
let
i
=
0
;
i
<
nCron
.
length
;
i
++
)
{
let
elem
=
nCron
[
i
]
.
trim
(
)
if
(
x
.
indexOf
(
elem
)
!=
-
1
)
{
let
jsname
=
jsurl
.
substring
(
jsurl
.
lastIndexOf
(
'/'
)
+
1
,
jsurl
.
lastIndexOf
(
'.'
)
)
+
'-cron'
jsBox
.
push
(
{
mark
,
noteK
,
jsname
,
jstype
:
'cron'
,
jsptn
:
''
,
jsurl
,
wakesys
:
'1'
,
timeout
:
'120'
,
ori
:
x
,
num
:
y
,
}
)
}
}
//for
}
jsBox
.
push
(
{
mark
,
noteK
,
jsname
,
jstype
,
jsptn
,
jsurl
,
rebody
,
proto
,
size
,
timeout
:
'60'
,
ori
:
x
,
num
:
y
,
}
)
}
//qx脚本解析结束
//qx cron脚本解析
if
(
/
^
(?
!
^
(?:
#
!
a
r
g
u
m
e
n
t
s
-
d
e
s
c
\s
*
=
|
#
!
d
e
s
c
\s
*
=
)
)
[
^
\s
]
+
\s
+
[
^
u
\s
]
+
\s
+
[
^
\s
]
+
\s
+
[
^
\s
]
+
\s
+
[
^
\s
]
+
\s
+
(
[
^
\s
]
+
\s
+
)
?
(
h
t
t
p
s
?
|
f
t
p
|
f
i
l
e
)
:
\/
\/
/
.
test
(
x
)
)
{
mark
=
getMark
(
y
,
body
)
noteK
=
isNoteK
(
x
)
cronexp
=
x
.
replace
(
/
\s
{
2
,
}
/
g
,
' '
)
.
split
(
/
\s
(
h
t
t
p
s
?
|
f
t
p
|
f
i
l
e
)
/
)
[
0
]
.
replace
(
/
^
#
/
,
''
)
jsurl
=
x
.
replace
(
/
^
#
/
,
''
)
.
replace
(
/
\x20
{
2
,
}
/
g
,
' '
)
.
replace
(
cronexp
,
''
)
.
split
(
/
\s
*
,
\s
*
/
)
[
0
]
.
trim
(
)
jsname
=
/
,
\s
*
t
a
g
\s
*
=
/
.
test
(
x
)
?
getJsInfo
(
x
,
/
[
,
\s
]
\s
*
t
a
g
\s
*
=
\s
*
/
,
jsRegex
)
:
jsurl
.
substring
(
jsurl
.
lastIndexOf
(
'/'
)
+
1
,
jsurl
.
lastIndexOf
(
'.'
)
)
img
=
getJsInfo
(
x
,
/
[
,
\s
]
\s
*
i
m
g
-
u
r
l
\s
*
=
\s
*
/
,
jsRegex
)
jsfrom
=
'qx'
jsurl
=
toJsc
(
jsurl
,
jscStatus
,
jsc2Status
,
jsfrom
)
jsBox
.
push
(
{
mark
,
noteK
,
jsname
,
img
,
jstype
:
'cron'
,
jsptn
:
''
,
cronexp
,
jsurl
,
wakesys
:
'1'
,
timeout
:
'120'
,
ori
:
x
,
num
:
y
,
}
)
}
//qx cron 脚本解析结束
//mock 解析
if
(
/
u
r
l
\s
+
e
c
h
o
-
r
e
s
p
o
n
s
e
\s
|
\s
d
a
t
a
\s
*
=
\s
*
"
|
\s
d
a
t
a
-
t
y
p
e
\s
*
=
/
.
test
(
x
)
)
{
mark
=
getMark
(
y
,
body
)
getMockInfo
(
x
,
mark
,
y
)
}
}
//for await循环结束
//去重
let
obj
=
{
}
inBox
=
[
...
new
Set
(
inBox
)
]
outBox
=
[
...
new
Set
(
outBox
)
]
hnBox
=
[
...
new
Set
(
hnBox
)
]
fheBox
=
[
...
new
Set
(
fheBox
)
]
skipBox
=
[
...
new
Set
(
skipBox
)
]
realBox
=
[
...
new
Set
(
realBox
)
]
ruleBox
=
[
...
new
Set
(
ruleBox
)
]
modInputBox
=
modInputBox
.
reduce
(
(
curr
,
next
)
=>
{
/*判断对象中是否已经有该属性 没有的话 push 到 curr数组*/
obj
[
next
.
a
+
next
.
b
]
?
''
:
(
obj
[
next
.
a
+
next
.
b
]
=
curr
.
push
(
next
)
)
return
curr
}
,
[
]
)
hostBox
=
hostBox
.
reduce
(
(
curr
,
next
)
=>
{
/*判断对象中是否已经有该属性 没有的话 push 到 curr数组*/
obj
[
next
.
hostdomain
]
?
''
:
(
obj
[
next
.
hostdomain
]
=
curr
.
push
(
next
)
)
return
curr
}
,
[
]
)
rwBox
=
rwBox
.
reduce
(
(
curr
,
next
)
=>
{
/*判断对象中是否已经有该属性 没有的话 push 到 curr数组*/
obj
[
next
.
rwptn
]
?
''
:
(
obj
[
next
.
rwptn
]
=
curr
.
push
(
next
)
)
return
curr
}
,
[
]
)
panelBox
=
panelBox
.
reduce
(
(
curr
,
next
)
=>
{
/*判断对象中是否已经有该属性 没有的话 push 到 curr数组*/
obj
[
next
.
scriptname
]
?
''
:
(
obj
[
next
.
scriptname
]
=
curr
.
push
(
next
)
)
return
curr
}
,
[
]
)
jsBox
=
jsBox
.
reduce
(
(
curr
,
next
)
=>
{
/*判断对象中是否已经有该属性 没有的话 push 到 curr数组*/
obj
[
next
.
jstype
+
next
.
jsptn
+
next
.
jsurl
+
next
.
jsarg
]
?
''
:
(
obj
[
next
.
jstype
+
next
.
jsptn
+
next
.
jsurl
+
next
.
jsarg
]
=
curr
.
push
(
next
)
)
return
curr
}
,
[
]
)
mockBox
=
mockBox
.
reduce
(
(
curr
,
next
)
=>
{
/*判断对象中是否已经有该属性 没有的话 push 到 curr数组*/
obj
[
next
.
mockptn
]
?
''
:
(
obj
[
next
.
mockptn
]
=
curr
.
push
(
next
)
)
return
curr
}
,
[
]
)
//去重结束
//$.log($.toStr(hnBox))
inBox
=
(
inBox
[
0
]
||
''
)
&&
`已根据关键词保留以下内容:\n
${
inBox
.
join
(
'\n\n'
)
}
`
outBox
=
(
outBox
[
0
]
||
''
)
&&
`已根据关键词排除以下内容:\n
${
outBox
.
join
(
'\n'
)
}
`
shNotify
(
inBox
)
shNotify
(
outBox
)
//mitm删除主机名
if
(
hnDel
!=
null
&&
hnBox
.
length
>
0
)
hnBox
=
hnBox
.
filter
(
item
=>
hnDel
.
indexOf
(
item
)
==
-
1
)
//mitm正则删除主机名
if
(
hnRegDel
!=
null
)
{
hndelBox
=
hnBox
.
filter
(
item
=>
hnRegDel
.
test
(
item
)
)
hnBox
=
hnBox
.
filter
(
item
=>
!
hnRegDel
.
test
(
item
)
)
}
hndelBox
.
length
>
0
&&
noNtf
==
false
&&
$
.
msg
(
JS_NAME
,
notifyName
+
' 已根据正则剔除主机名'
,
`
${
hndelBox
}
`
)
hnBox
=
pieceHn
(
hnBox
)
fheBox
=
pieceHn
(
fheBox
)
skipBox
=
pieceHn
(
skipBox
)
realBox
=
pieceHn
(
realBox
)
if
(
synMitm
)
fheBox
=
hnBox
//模块信息输出
switch
(
targetApp
)
{
case
'surge-module'
:
case
'shadowrocket-module'
:
case
'loon-plugin'
:
case
'stash-stoverride'
:
modInfoObj
[
'name'
]
=
nName
==
null
?
modInfoObj
[
'name'
]
:
name
modInfoObj
[
'desc'
]
=
nName
==
null
?
modInfoObj
[
'desc'
]
:
desc
modInfoObj
[
'category'
]
=
category
==
null
?
modInfoObj
[
'category'
]
:
category
if
(
icon
==
null
)
{
modInfoObj
[
'icon'
]
=
iconReplace
==
'禁用'
?
modInfoObj
[
'icon'
]
:
randomicon
}
else
{
modInfoObj
[
'icon'
]
=
/
\/
/
.
test
(
icon
)
?
icon
:
await
getIcon
(
icon
)
}
for
(
let
key
in
modInfoObj
)
{
if
(
modInfoObj
[
key
]
)
{
let
info
=
!
isStashiOS
?
'#!'
+
key
+
'='
+
modInfoObj
[
key
]
:
key
+
': |-\n '
+
modInfoObj
[
key
]
modInfo
.
push
(
info
)
}
}
for
(
let
i
=
0
;
i
<
modInputBox
.
length
;
i
++
)
{
let
info
=
'#!'
+
modInputBox
[
i
]
.
a
+
modInputBox
[
i
]
.
b
modInfo
.
push
(
info
)
}
//for
break
}
//模块信息输出结束
//rule输出 switch不适合
for
(
let
i
=
0
;
i
<
ruleBox
.
length
;
i
++
)
{
noteK
=
ruleBox
[
i
]
.
noteK
?
'#'
:
''
mark
=
ruleBox
[
i
]
.
mark
?
ruleBox
[
i
]
.
mark
:
''
if
(
noteK
!=
'#'
&&
isStashiOS
)
{
noteKn8
=
'\n '
noteKn6
=
'\n '
noteKn4
=
'\n '
noteK4
=
' '
noteK2
=
' '
}
else
{
noteKn8
=
'\n# '
noteKn6
=
'\n# '
noteKn4
=
'\n# '
noteK4
=
'# '
noteK2
=
'# '
}
ruletype
=
ruleBox
[
i
]
.
ruletype
.
toUpperCase
(
)
rulevalue
=
ruleBox
[
i
]
.
rulevalue
?
ruleBox
[
i
]
.
rulevalue
:
''
rulepolicy
=
ruleBox
[
i
]
.
rulepolicy
?
ruleBox
[
i
]
.
rulepolicy
:
''
rulepolicy
=
policyRegex
.
test
(
rulepolicy
)
&&
!
/
\{
\{
\{
[
^
,
]
+
\}
\}
\}
/
.
test
(
rulepolicy
)
?
rulepolicy
.
toUpperCase
(
)
:
rulepolicy
rulenore
=
ruleBox
[
i
]
.
rulenore
?
ruleBox
[
i
]
.
rulenore
:
''
rulesni
=
ruleBox
[
i
]
.
rulesni
?
ruleBox
[
i
]
.
rulesni
:
''
rulesni
=
isLooniOS
||
isStashiOS
?
''
:
rulesni
modistatus
=
ruleBox
[
i
]
.
modistatus
ori
=
ruleBox
[
i
]
.
ori
if
(
/
d
e
?
s
t
-
p
o
r
t
/
i
.
test
(
ruletype
)
)
{
ruletype
=
isSurgeiOS
||
isLooniOS
?
'DEST-PORT'
:
'DST-PORT'
}
if
(
/
r
e
j
e
c
t
-
v
i
d
e
o
/
i
.
test
(
rulepolicy
)
&&
!
isLooniOS
)
{
rulepolicy
=
'REJECT-TINYGIF'
}
if
(
/
r
e
j
e
c
t
-
t
i
n
y
g
i
f
/
i
.
test
(
rulepolicy
)
&&
isLooniOS
)
{
rulepolicy
=
'REJECT-IMG'
}
if
(
/
r
e
j
e
c
t
-
(?:
d
i
c
t
|
a
r
r
a
y
|
i
m
g
)
/
i
.
test
(
rulepolicy
)
&&
isSurgeiOS
)
{
rulepolicy
=
'REJECT-TINYGIF'
}
if
(
/
r
e
j
e
c
t
-
/
i
.
test
(
rulepolicy
)
&&
!
/
u
r
l
-
r
e
g
e
x
/
i
.
test
(
ruletype
)
&&
isStashiOS
)
{
rulepolicy
=
'REJECT'
}
if
(
/
r
e
j
e
c
t
-
[
^
-
]
+
-
n
o
-
d
r
o
p
/
i
.
test
(
rulepolicy
)
&&
!
isLooniOS
)
{
rulepolicy
=
rulepolicy
.
replace
(
/
-
n
o
-
d
r
o
p
/
i
,
''
)
}
if
(
rulepolicy
==
''
)
{
notBuildInPolicy
.
push
(
ori
)
}
else
if
(
/
^
p
r
o
x
y
$
/
i
.
test
(
rulepolicy
)
&&
modistatus
==
'no'
&&
(
isSurgeiOS
||
isStashiOS
)
)
{
notBuildInPolicy
.
push
(
ori
)
}
else
if
(
!
policyRegex
.
test
(
rulepolicy
)
&&
!
/
^
p
r
o
x
y
$
/
i
.
test
(
rulepolicy
)
&&
modistatus
==
'no'
)
{
notBuildInPolicy
.
push
(
ori
)
}
else
if
(
/
^
i
n
-
p
o
r
t
|
d
o
m
a
i
n
-
w
i
l
d
c
a
r
d
$
/
i
.
test
(
ruletype
)
&&
isSurgeiOS
)
{
rules
.
push
(
mark
+
noteK
+
ruletype
+
','
+
rulevalue
+
','
+
rulepolicy
+
rulenore
+
rulesni
)
}
else
if
(
/
^
p
r
o
t
o
c
o
l
$
/
i
.
test
(
ruletype
)
&&
(
isLooniOS
||
isSurgeiOS
)
)
{
rules
.
push
(
mark
+
noteK
+
ruletype
+
','
+
rulevalue
+
','
+
rulepolicy
+
rulenore
)
}
else
if
(
/
^
(?:
d
o
m
a
i
n
-
s
e
t
|
r
u
l
e
-
s
e
t
)
$
/
i
.
test
(
ruletype
)
&&
(
isSurgeiOS
||
isShadowrocket
)
)
{
rules
.
push
(
mark
+
noteK
+
ruletype
+
','
+
rulevalue
+
','
+
rulepolicy
+
rulenore
+
rulesni
)
}
else
if
(
/
^
(?:
d
o
m
a
i
n
(
-
s
u
f
f
i
x
|
-
k
e
y
w
o
r
d
)
?
|
i
p
(
-
a
s
n
|
-
c
i
d
r
6
?
)
|
u
s
e
r
-
a
g
e
n
t
|
u
r
l
-
r
e
g
e
x
|
d
e
?
s
t
-
p
o
r
t
|
a
n
d
|
o
r
|
n
o
t
)
$
/
i
.
test
(
ruletype
)
&&
!
isStashiOS
)
{
rulevalue
=
/
,
/
.
test
(
rulevalue
)
&&
!
/
[
(
)
]
/
.
test
(
rulevalue
)
?
'"'
+
rulevalue
+
'"'
:
rulevalue
rules
.
push
(
mark
+
noteK
+
ruletype
+
','
+
rulevalue
+
','
+
rulepolicy
+
rulenore
+
rulesni
)
}
else
if
(
/
(?:
^
d
o
m
a
i
n
$
|
d
o
m
a
i
n
-
s
u
f
f
i
x
|
d
o
m
a
i
n
-
k
e
y
w
o
r
d
|
i
p
-
|
d
e
?
s
t
-
p
o
r
t
)
/
i
.
test
(
ruletype
)
&&
isStashiOS
)
{
rules
.
push
(
mark
+
noteK2
+
'- '
+
ruletype
+
','
+
rulevalue
+
','
+
rulepolicy
+
rulenore
)
}
else
if
(
/
s
r
c
-
p
o
r
t
/
i
.
test
(
ruletype
)
&&
(
isSurgeiOS
||
isLooniOS
)
)
{
rules
.
push
(
mark
+
noteK
+
ruletype
+
','
+
rulevalue
+
','
+
rulepolicy
)
}
else
if
(
/
u
r
l
-
r
e
g
e
x
/
i
.
test
(
ruletype
)
&&
isStashiOS
&&
/
r
e
j
e
c
t
/
i
.
test
(
rulepolicy
)
)
{
let
Urx2Reject
if
(
/
D
I
C
T
/
i
.
test
(
rulepolicy
)
)
{
Urx2Reject
=
'-dict'
}
else
if
(
/
A
R
R
A
Y
/
i
.
test
(
rulepolicy
)
)
{
Urx2Reject
=
'-array'
}
else
if
(
/
D
R
O
P
|
v
i
d
e
o
/
i
.
test
(
rulepolicy
)
)
{
Urx2Reject
=
'-200'
}
else
if
(
/
I
M
G
$
|
T
I
N
Y
G
I
F
$
/
i
.
test
(
rulepolicy
)
)
{
Urx2Reject
=
'-img'
}
else
if
(
/
R
E
J
E
C
T
$
/
i
.
test
(
rulepolicy
)
)
{
Urx2Reject
=
''
}
URLRewrite
.
push
(
mark
+
noteK4
+
'- >-'
+
noteKn6
+
rulevalue
+
' - reject'
+
Urx2Reject
)
}
else
{
otherRule
.
push
(
ori
)
}
}
//for rule输出结束
//reject redirect输出
for
(
let
i
=
0
;
i
<
rwBox
.
length
;
i
++
)
{
noteK
=
rwBox
[
i
]
.
noteK
?
'#'
:
''
mark
=
rwBox
[
i
]
.
mark
?
rwBox
[
i
]
.
mark
:
''
rwtype
=
rwBox
[
i
]
.
rwtype
rwptn
=
rwBox
[
i
]
.
rwptn
rwvalue
=
rwBox
[
i
]
.
rwvalue
switch
(
targetApp
)
{
case
'loon-plugin'
:
case
'shadowrocket-module'
:
rwtype
=
isShadowrocket
&&
/
-
v
i
d
e
o
/
.
test
(
rwtype
)
?
'reject-img'
:
isLooniOS
&&
/
-
t
i
n
y
g
i
f
/
.
test
(
rwtype
)
?
'reject-img'
:
rwtype
URLRewrite
.
push
(
mark
+
noteK
+
rwptn
+
' '
+
rwvalue
+
' '
+
rwtype
)
break
case
'stash-stoverride'
:
if
(
noteK
!=
'#'
)
{
noteKn8
=
'\n '
noteKn6
=
'\n '
noteKn4
=
'\n '
noteK4
=
' '
noteK2
=
' '
}
else
{
noteKn8
=
'\n# '
noteKn6
=
'\n# '
noteKn4
=
'\n# '
noteK4
=
'# '
noteK2
=
'# '
}
URLRewrite
.
push
(
mark
+
noteK4
+
'- >-'
+
noteKn6
+
rwptn
+
' '
+
rwvalue
+
' '
+
rwtype
.
replace
(
/
-
v
i
d
e
o
|
-
t
i
n
y
g
i
f
/
,
'-img'
)
)
break
case
'surge-module'
:
if
(
/
(?:
r
e
j
e
c
t
|
3
0
2
|
3
0
7
|
h
e
a
d
e
r
)
$
/
.
test
(
rwtype
)
)
URLRewrite
.
push
(
mark
+
noteK
+
rwptn
+
' '
+
rwvalue
+
' '
+
rwtype
)
if
(
/
r
e
j
e
c
t
-
d
i
c
t
/
.
test
(
rwtype
)
)
MapLocal
.
push
(
mark
+
noteK
+
rwptn
+
' data-type=text data="{}" status-code=200'
)
if
(
/
r
e
j
e
c
t
-
a
r
r
a
y
/
.
test
(
rwtype
)
)
MapLocal
.
push
(
mark
+
noteK
+
rwptn
+
' data-type=text data="[]" status-code=200'
)
if
(
/
r
e
j
e
c
t
-
2
0
0
/
.
test
(
rwtype
)
)
MapLocal
.
push
(
mark
+
noteK
+
rwptn
+
' data-type=text data=" " status-code=200'
)
if
(
/
r
e
j
e
c
t
-
(?:
i
m
g
|
t
i
n
y
g
i
f
|
v
i
d
e
o
)
/
.
test
(
rwtype
)
)
MapLocal
.
push
(
mark
+
noteK
+
rwptn
+
' data-type=tiny-gif status-code=200'
)
break
}
//switch
}
//reject redirect输出for
//headerRewrite输出
for
(
let
i
=
0
;
i
<
rwhdBox
.
length
;
i
++
)
{
noteK
=
rwhdBox
[
i
]
.
noteK
?
'#'
:
''
mark
=
rwhdBox
[
i
]
.
mark
?
rwhdBox
[
i
]
.
mark
:
''
x
=
rwhdBox
[
i
]
.
x
switch
(
targetApp
)
{
case
'surge-module'
:
HeaderRewrite
.
push
(
mark
+
noteK
+
x
)
break
case
'loon-plugin'
:
x
=
x
.
replace
(
/
^
h
t
t
p
-
(
r
e
q
u
e
s
t
|
r
e
s
p
o
n
s
e
)
\s
+
/
,
''
)
URLRewrite
.
push
(
mark
+
noteK
+
x
)
break
case
'stash-stoverride'
:
if
(
noteK
!=
'#'
)
{
noteKn8
=
'\n '
noteKn6
=
'\n '
noteKn4
=
'\n '
noteK4
=
' '
noteK2
=
' '
}
else
{
noteKn8
=
'\n# '
noteKn6
=
'\n# '
noteKn4
=
'\n# '
noteK4
=
'# '
noteK2
=
'# '
}
let
hdtype
=
/
^
h
t
t
p
-
r
e
s
p
o
n
s
e
\s
/
.
test
(
x
)
?
' response-'
:
' request-'
x
=
x
.
replace
(
/
^
h
t
t
p
-
(?:
r
e
q
u
e
s
t
|
r
e
s
p
o
n
s
e
)
\s
+
/
,
''
)
.
replace
(
/
\s
+
h
e
a
d
e
r
-
/
,
hdtype
)
HeaderRewrite
.
push
(
mark
+
`
${
noteK4
}
- >-
${
noteKn6
}
`
+
x
)
break
case
'shadowrocket-module'
:
otherRule
.
push
(
noteK
+
x
)
break
}
//headerRewrite输出结束
}
//for
//host输出
for
(
let
i
=
0
;
i
<
hostBox
.
length
;
i
++
)
{
noteK
=
hostBox
[
i
]
.
noteK
?
'#'
:
''
mark
=
hostBox
[
i
]
.
mark
?
hostBox
[
i
]
.
mark
:
''
hostdomain
=
hostBox
[
i
]
.
hostdomain
View remainder of file in raw view
Footer
© 2026 GitHub, Inc.
Footer navigation
Terms
Privacy
Security
Status
Community
Docs
Contact
You can’t perform that action at this time.
Back
|
FazBrowse Home
|
New Git URL