forked from jinyu121/SurgeRule
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Customize_config.html
509 lines (508 loc) · 29.6 KB
/
Customize_config.html
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<title>Surge Customize</title>
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdn.bootcss.com/bootstrap-switch/3.3.2/css/bootstrap3/bootstrap-switch.min.css" rel="stylesheet"/>
<style>
body{
margin-bottom:50px;
}
</style>
</head>
<body>
<div class="jumbotron">
<div class="container">
<h1>Surge 规则定制</h1>
<p>
自定义节点信息按需挑选规则,定制一份适合你自己的 Surge 规则。
</p>
</div>
</div>
<div class="container">
<ul id="main_tab" class="nav nav-tabs nav-justified" role="tablist">
<li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">定制规则</a></li>
<li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">解析定制代码</a></li>
</ul>
<div class="row">
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<div class="col-sm-12">
<form>
<div class="section">
<h1 class="page-header"><span class="glyphicon glyphicon-tasks"></span> 节点信息</h1>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<textarea id="node_info" class="form-control" rows="5"></textarea>
<span class="help-block">填入你的节点信息。包括<code>[Proxy]</code>和<code>[Proxy Group]</code>段。<a href="#" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#node_info_example_model">查看示例</a></span>
</div>
</div>
</div>
</div>
<div class="section">
<h1 class="page-header"><span class="glyphicon glyphicon-list-alt"></span> 规则选取</h1>
<h2>基于域名的规则</h2>
<h3>增强规则</h3>
<div class="row">
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-big_company"/> 大公司</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-bbs" advanced="advanced"/> BBS</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-blog" advanced="advanced"/> 博客</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-cdn"/> 公共CDN</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-design" advanced="advanced"/> 设计狮</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-developer" advanced="advanced"/> 程序猿</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-download" advanced="advanced"/> 下载站</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-education" advanced="advanced"/> 教育</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-government" advanced="advanced"/> 政府机构</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-image" advanced="advanced"/> 图床、图片分享</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-music" advanced="advanced"/> 音乐、播客</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-net_disk" advanced="advanced"/> 网盘、文件分享</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-news"/> 新闻</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-read_and_write" advanced="advanced"/> 阅读与写作</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-shopping" advanced="advanced"/> 购物</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-sns" advanced="advanced"/> 社交网络</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-tools" advanced="advanced"/> 工具</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-url" advanced="advanced"/> 链接服务</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-video" advanced="advanced"/> 视频分享</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-xxx" advanced="advanced"/> XXX</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-enhance-unknow" advanced="advanced"/> 其他</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label class="text-danger"><input type="checkbox" name="domain-enhance-gfwlist" advanced="advanced" data-on-color="danger" data-off-color="success"/> 激进规则</label>
</div>
</div>
</div>
<h3>去广告规则</h3>
<div class="row">
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-adblock-ad_company"/> 广告公司</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-adblock-analysis"/> 统计公司</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-adblock-shopping"/> 购物网站</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-adblock-sns"/> 社交网络</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-adblock-tool"/> 工具网站</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-adblock-video"/> 视频网站</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-adblock-aggressive_qq_qzone" advanced="advanced" data-off-color="success"/> 屏蔽 QQ 空间</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="domain-adblock-aggressive_qq_ipad_aikan" advanced="advanced" data-off-color="success"/> 屏蔽 QQ 爱看</label>
</div>
</div>
</div>
<h2>基于 IP 的规则</h2>
<h3>增强规则</h3>
<div class="row">
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="ip-enhance-telegram" advanced="advanced"/> Telegram</label>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label class="text-danger"><input type="checkbox" name="ip-enhance-gfwlist" advanced="advanced" data-on-color="danger" data-off-color="success"/> 激进规则</label>
</div>
</div>
</div>
<h3>去广告规则</h3>
<div class="row">
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="ip-adblock-china_mobile" advanced="advanced"/> 10086</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="ip-adblock-china_unicom" advanced="advanced"/> 10010</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="ip-adblock-china_telecom" advanced="advanced"/> 10000</label>
</div>
</div>
</div>
<h2>其他规则</h2>
<h3>Hosts</h3>
<div class="row">
<div class="col-sm-3 col-xs-6">
暂无
</div>
</div>
<h3>URL重写</h3>
<div class="row">
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="other-rewrite-qq"/> QQ</label>
</div>
</div>
<div class="col-sm-3 col-xs-6">
<div class="checkbox">
<label><input type="checkbox" name="other-rewrite-jd"/> 京东跳转</label>
</div>
</div>
</div>
</div>
<div class="section">
<h1 class="page-header"><span class="glyphicon glyphicon-wrench"></span> 其他选项</h1>
<h3>规则托管</h3>
<div class="row">
<div class="col-sm-12">
<div class="checkbox">
<label><input type="checkbox" name="config-managed" advanced="advanced" data-on-color="success" data-off-color="success"/> 生成托管的规则 <span class="text-danger">【 托管的规则可以自动更新,但是不可手工编辑 】</span></label>
</div>
</div>
</div>
</div>
<div class="section">
<h1 class="page-header"><span class="glyphicon glyphicon-download-alt"></span> 下载</h1>
<p class="lead">
你好,你的个人版 Surge 规则定制成功。点击下面的按钮下载保持。
</p>
<button id="doit" class="btn btn-primary btn-block btn-lg">下载</button>
<p class="help-block">
生成 Surge 规则后,您可能需要复制整个 URL ,并在 Surge 中选择 <code>Download Configuration from URL</code> 。
</p>
</div>
</form>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="settings">
<div class="col-sm-12">
<div id="config-parse-result-success" class="alert alert-success" role="alert">
<h4><span class="glyphicon glyphicon-ok"></span> 成功</h4>请切换到左边“定制规则”继续定制!
</div>
<div id="config-parse-result-error" class="alert alert-danger" role="alert">
<h4><span class="glyphicon glyphicon-alert"></span> 有错误</h4>此配置代码有错误,放弃吧!
</div>
<form>
<div class="section">
<h1 class="page-header"><span class="glyphicon glyphicon-equalizer"></span> 定制代码</h1>
<p>定制代码是规则文件的第一行<code>#!MANAGED-CONFIG ..........</code></p>
<p>定制代码中记录了上一次定制的各种选项,可以简化您的定制过程。如果您有定制代码,请在下方输入。</p>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<textarea id="customize_code" class="form-control" rows="5"></textarea>
</div>
</div>
</div>
<button id="parseit" class="btn btn-primary btn-block btn-lg">解析定制代码</button>
<h1 class="page-header"><span class="glyphicon glyphicon-console"></span> JSON 文件</h1>
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<textarea id="customize_code_json" class="form-control" rows="10"></textarea>
<span class="help-block">此 JSON 文件是定制代码的明文形式。</span>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- 模态框 -->
<div class="modal fade" id="node_info_example_model" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">节点配置示例</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-6">
<h4>完整配置</h4>
<pre class="pre-scrollable">
[Proxy]
💊 Direct = direct
🌞 1 = custom,1.2.3.4,443,aes-256-cfb,password,https://github.com/jinyu121/SurgeRule/raw/master/helper/SSEncrypt.module, ota=true
🌞 2 = custom,1.2.3.4,443,aes-256-cfb,password,https://github.com/jinyu121/SurgeRule/raw/master/helper/SSEncrypt.module, ota=true
🌚 1 = custom,1.2.3.4,443,aes-256-cfb,password,https://github.com/jinyu121/SurgeRule/raw/master/helper/SSEncrypt.module, ota=true
🌚 2 = custom,1.2.3.4,443,aes-256-cfb,password,https://github.com/jinyu121/SurgeRule/raw/master/helper/SSEncrypt.module, ota=true
[Proxy Group]
🚀 Proxy = select, 💊 Direct, 🌞 Auto, 🌚 Auto, ⚖ Select
🌐 Proxy = select, 💊 Direct, 🚀 Proxy
🇨🇳 Proxy = select, 💊 Direct, 🚀 Proxy
🍎 Proxy = select, 💊 Direct, 🚀 Proxy
🌞 Auto = url-test, 🌞 1, 🌞 2, url = http://www.gstatic.com/generate_204
🌚 Auto = url-test, 🌚 1, 🌚 2, url = http://www.gstatic.com/generate_204
⚖ Select = select, 🌞 1, 🌞 2, 🌚 1, 🌚 2
</pre>
</div>
<div class="col-sm-6">
<h4>精简配置</h4>
<pre class="pre-scrollable">
[Proxy]
💊 Direct = direct
🌞 Line = custom,1.2.3.4,443,aes-256-cfb,password,https://github.com/jinyu121/SurgeRule/raw/master/helper/SSEncrypt.module, ota=true
[Proxy Group]
🚀 Proxy = select, 🌞 Line
🌐 Proxy = select, 🌞 Line
🇨🇳 Proxy = select, 🌞 Line
🍎 Proxy = select, 🌞 Line
</pre>
</div>
</div>
<h4>配置说明</h4>
<div class="row">
<div class="col-sm-12">
<p>
在<code>[Proxy]</code>或<code>[Proxy Group]</code>中,<b>必须</b>保留如下 Proxy 或 Group:
</p>
<ul>
<li>直连规则: <code>💊 Direct = direct</code></li>
<li>一般代理: <code>🚀 Proxy</code></li>
<li>兜底全局代理: <code>🌐 Proxy</code></li>
<li>国内网站访问规则: <code>🇨🇳 Proxy</code></li>
<li>苹果服务专用规则: <code>🍎 Proxy</code></li>
</ul>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
<p class="pull-left hidden-xs">
更详的细配置说明,请参阅官方英文版<a href="https://www.gitbook.com/book/blankwonder/surge-manual" target="_blank">《 Surge 使用手册 》</a>
</p>
</div>
</div>
</div>
</div>
<script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdn.bootcss.com/jquery-json/2.6.0/jquery.json.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap-switch/3.3.2/js/bootstrap-switch.min.js"></script>
<script src="helper/js/base64.min.js"></script>
<script>
$(function(){
// TextArea 多行文本转字符串数组
function textarea_to_array(item){
return $(item).val().split("\n");
}
// TextArea 字符串数组转多行文本
function array_to_textarea(item){
return item.join("\n");
}
// 规则生成和下载
function make_rule(){
cfg={
"config":{
"managed":true,
"node":[],
"category":[
"domain",
"ip",
"other"
]
},
"domain":{
"enhance":[],
"adblock":[]
},
"ip":{
"enhance":[],
"adblock":[]
},
"other": {
"hosts": [],
"rewrite": []
}
}
// 读取节点信息
cfg.config.node=textarea_to_array("#node_info");
// 读取配置信息
cfg.config.category.forEach(function(category){
Object.keys(cfg[category]).forEach(function(rule_set){
obj = $(":checkbox:checked[name ^= "+ category+"-"+rule_set +"]");
obj.each(function(ith){
name = obj[ith].name.replace(category+"-"+rule_set+"-","");
cfg[category][rule_set].push(name);
})
});
});
// 读取其他信息
cfg.config.managed=$(":checkbox[name = 'config-managed']").prop("checked");
// 编码
cfg_b64 = Base64.encode($.toJSON(cfg));
$("#customize_code").val(cfg_b64);
$("#customize_code_json").val(JSON.stringify(cfg, null, 4));
// 下载
open("Customize.php/?conf="+cfg_b64);
return false;
};
// 规则解析
function parse_rule(){
// 读取
cfg_b64 = $("#customize_code").val();
str_conf_pos = cfg_b64.indexOf("?conf=");
if (str_conf_pos != -1){
cfg_b64 = cfg_b64.substring(str_conf_pos + 6);
}
// 解析
try{
// 解码
cfg = $.parseJSON(Base64.decode(cfg_b64));
// 解析节点信息
$("#node_info").val(array_to_textarea(cfg.config.node));
// 解析规则选取
// 初始化:全部不选中
$(":checkbox").bootstrapSwitch("destroy");
$(":checkbox").prop("checked", false);
cfg.config.category.forEach(function(category){
Object.keys(cfg[category]).forEach(function(rule_set){
cfg[category][rule_set].forEach(function(rule_name){
checkbox_name = category+"-"+rule_set +"-"+rule_name;
$(":checkbox[name = '"+checkbox_name+"']").prop("checked", true);
});
});
});
// 其他配置
$(":checkbox[name = 'config-managed']").prop("checked",cfg.config.managed);
// 显示逻辑
$(":checkbox").bootstrapSwitch({size:'mini'});
$("#customize_code_json").val(JSON.stringify(cfg, null, 4));
$("#config-parse-result-success").slideDown().slideUp(1500);
$("#main_tab a[href='#home']").tab('show');
}catch(e){
$("#config-parse-result-error").slideDown().slideUp(2000);
}
return false;
}
// 初始化:全部选中
$(":checkbox").prop("checked", true);
// 初始化:排除激进规则
$(":checkbox[advanced]").prop("checked", false);
$("#config-parse-result-success").hide();
$("#config-parse-result-error").hide();
// 显示
$(":checkbox").bootstrapSwitch({size:'mini'});
// 提交事件
$("#doit").click(make_rule);
// 提交事件
$("#parseit").click(parse_rule);
});
</script>
</body>
</html>