MCPcopy Index your code
hub / github.com/Moli-X/Resources / ResourceParse

Function ResourceParse

Script/Parser.js:281–414  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

279
280
281function ResourceParse() {
282 //预处理,分流/重写等处理完成
283 if (type0 == "Subs-B64Encode") { // subs2QX 负责所有节点的转换
284 if (Pdbg) {$notify("original content", "node-b64", content0)}
285 total = Subs2QX(Base64.decode(content0), Pudp0, Ptfo0, Pcert0, PTls13);
286 } else if (type0 == "Subs") {
287 //$notify("subs","",content0+Pudp0+Ptfo0+Pcert0+PTls13)
288 total = Subs2QX(content0, Pudp0, Ptfo0, Pcert0, PTls13);
289 } else if (type0 == "QuanX" || type0 == "Clash" || type0 == "Surge") {
290 total = Subs2QX(isQuanX(content0).join("\n"), Pudp0, Ptfo0, Pcert0, PTls13);
291 } else if (type0 == "sgmodule") { // surge module 模块/含 url-regex 的 rule-set
292 //2023-03-06 考虑模块重写与quanx类型重写的混搭
293 flag = 2
294 //total = SGMD2QX(content0) // 转换
295 total = Rewrite_Filter(isQuanXRewrite(content0.split("\n")), Pin0, Pout0,Preg,Pregout);//Rewrite_Filter(total, Pin0, Pout0,Preg,Pregout); // 筛选过滤
296 if (Preplace) { total = ReplaceReg(total, Preplace) }
297 total = total.filter( (ele,pos)=>total.indexOf(ele) == pos); //重写重复检查
298 if (Pcdn) {total = CDN(total)
299 } else { total = total.join("\n")}
300 } else if (type0 == "rewrite") { // rewrite 类型
301 flag = 2;
302 total = Rewrite_Filter(isQuanXRewrite(content0.split("\n")), Pin0, Pout0,Preg,Pregout);
303 if (Preplace) { total = ReplaceReg(total, Preplace) }
304 // rewrite重复检测
305 total = total.filter( (ele,pos)=>total.indexOf(ele) == pos);
306 if (Pcdn) {total = CDN(total)
307 } else {total = total.join("\n")}
308 } else if (type0 == "Rule") { // rule 类型, 已处理完毕
309 flag = 3;
310 total = Rule_Handle(content0.split("\n").map(item=>item.trim()).filter(Boolean), Pout0, Pin0).filter(Boolean);
311 if (Preg && total.length!=0) { // 正则筛选规则 filter
312 total = total.map(Regex).filter(Boolean)
313 RegCheck(total, "分流引用", "regex", Preg)
314 }
315 if (Pregout && total.length!=0) { // 正则删除规则 filter
316 total = total.map(RegexOut).filter(Boolean)
317 RegCheck(total, "分流引用", "regout", Pregout)
318 }
319 if (Preplace) { total = ReplaceReg(total, Preplace) }
320 if (Ppolicyset) {total = policy_sets(total, Ppolicyset)}
321 // filter 重复检测
322 total = total.length<100? total.filter( (ele,pos)=>total.indexOf(ele) == pos) : total
323 total = total.join("\n")
324 } else if (content0.trim() == "") {
325 $notify("‼️ 引用" + "⟦" + subtag + "⟧" + " 返回內容为空", "⁉️ 点通知跳转以确认链接是否失效", para.split("#")[0], nan_link);
326 flag = 0;
327 } else if (type0 == "sub-http") {
328 let url = VCheck(String(Base64.decode(content0.split("sub://")[1].split("#")[0])+", opt-parser=true, tag="+(new Date()).getTime()))
329 RLink = RLink.replace("sremoteposition",url).replace("fremoteposition","").replace("rremoteposition","")
330 let ADDres0 = ADDres.replace("url-encoded-json",encodeURIComponent(RLink))
331 openlink = {"open-url": ADDres0}
332 $notify("⚠️ 该链接为节点订阅, 请点击此通知跳转添加", url, ADDres0,openlink)
333 flag = -1
334 total = ""
335 } else if (type0 == "unknown") {
336 ParseUnknown(content0)
337 flag = -1;
338 } else if (type0 == "profile") {

Callers 1

ParserFunction · 0.85

Calls 15

Subs2QXFunction · 0.85
isQuanXFunction · 0.85
Rewrite_FilterFunction · 0.85
isQuanXRewriteFunction · 0.85
ReplaceRegFunction · 0.85
CDNFunction · 0.85
Rule_HandleFunction · 0.85
RegCheckFunction · 0.85
policy_setsFunction · 0.85
VCheckFunction · 0.85
ParseUnknownFunction · 0.85
Profile_HandleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…