@@ -203,7 +203,7 @@ var _subscriptionResponseCache = {
203
203
importFromString = function(str,subscribeUrl){
204
204
if(!str){ return; }
205
205
str = ..string.trim(str);
206
-
206
+
207
207
var jsonData;
208
208
if(..string.match(str,"%\[\]") || (
209
209
..string.match(str,"%\{\}") && !..string.match(str,"%\{\}.+%\{\}")
@@ -371,8 +371,8 @@ importFromString = function(str,subscribeUrl){
371
371
if(..string.match(str,"^\s*[\w=+/-_]+\s*$")){
372
372
str = ..crypt.decodeBin(str);
373
373
if(!str) return;
374
- }
375
-
374
+ }
375
+
376
376
var outbounds = ..table.array();
377
377
for(line in ..string.lines(str) ){
378
378
if(#outbounds>=1500){
@@ -1200,10 +1200,117 @@ var currentActiveOutbound = ..globalActiveOutbound;
1200
1200
..publish("uiCommand.print","已自动刷新" + count + "个订阅服务器。")
1201
1201
} )
1202
1202
1203
+ /*importFromClash = function(str,node){
1204
+ if(node){
1205
+ var start = false;var strTemp="";
1206
+ var levelTable = ..table.array();var levelATable = ..table.array();
1207
+ var levelLast = 0;var levelALast = 0;
1208
+ for(line in ..string.lines(str) ){
1209
+ //删除注释字段和空白行
1210
+ line = ..string.splitEx(line,'\#')[1];
1211
+ if( line===null || ..string.match(line,"^\s*$") ){continue;}
1212
+ //确定proxies范围
1213
+ if(..string.match(line,"^\a")){
1214
+ if(..string.startWith(line,"proxies")){start = true;continue;}
1215
+ else {if(start){break;}continue;}
1216
+ }
1217
+
1218
+ if(start){
1219
+ if( ..string.match(line,"^\s*\-\s*%\{\}\s*$") ){strTemp += line+'\n';}
1220
+ elseif( !..string.match(line,"^\s*\-\s*%\{\}\s*$") ){
1221
+ var numNow = #(..string.match(line,"^(\s*)\a"));//键缩进量
1222
+ var numANow = #(..string.match(line,"^(\s*)\-"));//数组缩进量
1223
+ //确定数组缩进等级
1224
+ var levelA;
1225
+ for(index,num in levelATable){if(num = numANow){levelA=index;break;}}
1226
+ if(!levelA && numANow){
1227
+ ..table.push(levelATable,numANow);
1228
+ levelA=..table.count(levelATable);
1229
+ }
1230
+ elseif(!levelA && !numANow){levelA=0}
1231
+
1232
+ if( levelA>1 ){
1233
+ line = ..string.replace(line,"^\s*(-)",'');
1234
+ numNow = #(..string.match(line,"^(\s*)\a"));
1235
+ }
1236
+ elseif( levelA==1 ){
1237
+ var temp = '\n-{';
1238
+ if(levelLast){for(i=1;levelLast;1){temp = '}'+temp;}}
1239
+ line = ..string.replace(line,"^\s*-\s*",temp);
1240
+ }
1241
+
1242
+ if( ..string.match(line,"^\}*\n\-\{\s*\a") ){strTemp += line+","}//-name:1
1243
+ elseif( ..string.match(line,"^\}\n\-\{\s*$") ){strTemp += line}//-
1244
+
1245
+ levelALast = levelA;
1246
+ //确定键缩进等级
1247
+ var level;
1248
+ for(index,num in levelTable){if(num=numNow){level=index;break;}}
1249
+ if(!level && numNow){..table.push(levelTable,numNow);level=..table.count(levelTable);}
1250
+ elseif(!level && !numNow){level=0}
1251
+
1252
+ if( ..string.match(line,"^\s*\a[^\s\:]*(\:)\s*$") ){//name:
1253
+ line = ..string.trim(line);
1254
+ if( levelLast>0 && level>levelLast ){strTemp += line+"{"}
1255
+ elseif( level==levelLast ){strTemp += ","+line+"{"}
1256
+ elseif( level<levelLast ){strTemp += "}"+line+"{"}
1257
+ }
1258
+ elseif( ..string.match(line,"^\s*\a[^\:]*\:?\s*[^\s]*\s*$") ){//name:1
1259
+ line = ..string.trim(line);
1260
+ if( levelLast==0 || level>levelLast ){strTemp += line}
1261
+ elseif( levelLast>0 && level<levelLast){strTemp += "},"+line}
1262
+ elseif( level==levelLast ){strTemp += ","+line}
1263
+ }
1264
+
1265
+ levelLast = level;
1266
+ }
1267
+ }
1268
+ }
1269
+ var match1 = ..table.count(..string.matches(strTemp,"\{"));
1270
+ var match2 = ..table.count(..string.matches(strTemp,"\}"));
1271
+ for(i=1;match1-match2;1){strTemp += "}"}
1272
+
1273
+ if( #(..string.trim(strTemp)) ){str = ..string.trim(strTemp)}
1274
+ }
1275
+ else {
1276
+ var urlmap = ..table.array();
1277
+ var start = false;var levelTable = ..table.array();
1278
+ for(line in ..string.lines(str) ){
1279
+ //删除注释字段和空白行
1280
+ line = ..string.splitEx(line,'\#')[1];
1281
+ if( line===null || ..string.match(line,"^\s*$") ){continue;}
1282
+ //确定proxies范围
1283
+ if(..string.match(line,"^\a")){
1284
+ if(..string.startWith(line,"proxy-providers")){start = true;continue;}
1285
+ else {if(start){break;}continue;}
1286
+ }
1287
+
1288
+ if(start){
1289
+ var numNow = #(..string.match(line,"^(\s*)[^\s]"));//键缩进量
1290
+ var level;
1291
+ for(index,num in levelTable){if(num=numNow){level=index;break;}}
1292
+ if(!level && numNow){..table.push(levelTable,numNow);level=..table.count(levelTable);}
1293
+ elseif(!level && !numNow){level=0}
1294
+
1295
+ if(level==2){
1296
+ var url = ..string.match(line,"^\s*url\:\s*(http.*)");
1297
+ url = url ? ..string.trim(url,'"\'\s\t\r\n ');
1298
+ if(..inet.url.is(url)){..table.push(urlmap,url)}
1299
+ }
1300
+ }
1301
+ }
1302
+
1303
+ if(#urlmap){
1304
+ return urlmap;
1305
+ }
1306
+ }
1307
+ }*/
1308
+
1203
1309
/**intellisense(xray.outbounds)
1204
1310
exportSharedLinks(.(outbounds) = 导出分享链接
1205
1311
importFromString(.(str,subscribeUrl) = 导入分享链接
1206
1312
importFromClipboard() = 自剪贴板导入分享链接
1207
1313
autoUpdateSubscription() = 自动并静默更新订阅源
1208
1314
updateSubscription() = 更新或自剪贴板导入订阅源\n可选在参数中用一个表自定义要更新的订阅地址,\n参数表中键为url,值为true
1315
+ importFromClash(.(str,node) = 从clash文件导入节点或订阅
1209
1316
end intellisense**/
0 commit comments