Update resource-parser.js

This commit is contained in:
Shawn
2020-12-30 09:34:15 +08:00
parent 2ad15cf3c1
commit 753e5ec6f3

View File

@@ -1,5 +1,5 @@
/**
☑️ 资源解析器 ©𝐒𝐡𝐚𝐰𝐧 ⟦2020-12-28 21:59⟧
☑️ 资源解析器 ©𝐒𝐡𝐚𝐰𝐧 ⟦2020-12-29 22:59⟧
----------------------------------------------------------
🛠 发现 𝐁𝐔𝐆 请反馈: @Shawn_KOP_bot
⛳️ 关注 🆃🅶 相关频道: https://t.me/QuanX_API
@@ -64,7 +64,7 @@
⦿ 通知参数 𝗻𝘁𝗳=0/1, 用于 关闭/打开 资源解析器的提示通知
𝗿𝗲𝘄𝗿𝗶𝘁𝗲/𝗳𝗶𝗹𝘁𝗲𝗿 默认“开启”通知提示, 以防规则误删除
𝘀𝗲𝗿𝘃𝗲𝗿 资源解析则默认”关闭“通知提示
⦿ 类型参数 type=domain-set/rule/module/list
⦿ 类型参数 𝐭𝐲𝐩𝐞=𝐝𝐨𝐦𝐚𝐢𝐧-𝐬𝐞𝐭/𝐫𝐮𝐥𝐞/𝐦𝐨𝐝𝐮𝐥𝐞/𝐥𝐢𝐬𝐭/𝐧𝐨𝐝𝐞𝐬
❖ 当解析器未能正确识别类型时, 可尝试使用此参数强制指定
----------------------------------------------------------
*/
@@ -93,9 +93,9 @@ content0 = content0.indexOf("DOCTYPE html") != -1 && link0.indexOf("github.com")
//正常使用部分,調試註釋此部分
var para = (link0.indexOf("http") != -1 && link0.indexOf("://") != -1) ? link0 : link0 + content0.split("\n")[0];
var para = /^(http|https)\:\/\//.test(link0) ? link0 : content0.split("\n")[0];
var para1 = para.slice(para.indexOf("#") + 1) //防止参数中其它位置也存在"#"
var mark0 = para.indexOf("#") != -1 ? true : false;
var mark0 = para.indexOf("#") != -1 ? true : false; //是否有參數需要解析
var Pinfo = mark0 && para1.indexOf("info=") != -1 ? para1.split("info=")[1].split("&")[0] : 0;
var ntf_flow = 0;
//常用量
@@ -148,7 +148,8 @@ let [flow, exptime, errornode, total] = "";
var typeU = para1.indexOf("type=") != -1 ? para1.split("type=")[1].split("&")[0] : "";
//$notify(type0,"hh")
var type0=""
//flag=1,2,3分别为 server、rewrite、rule 类型
@@ -341,27 +342,33 @@ function Type_Check(subs) {
} else if (ClashK.some(NodeCheck) || typeU == "clash"){ // Clash 类型节点转换
type = "Clash";
content0 = Clash2QX(subs)
} else if ((subi.indexOf("hostname=") != -1 || RewriteK.some(RewriteCheck) || subi.indexOf("pattern=") != -1) && subs.indexOf("[Proxy]") == -1 && subs.indexOf("[server_local]") == -1 && para1.indexOf("dst=filter")==-1 && subi.indexOf("securehostname") == -1 && typeU != "module") {
} else if ((subi.indexOf("hostname=") != -1 || RewriteK.some(RewriteCheck) || subi.indexOf("pattern=") != -1) && !/\[(Proxy|filter_local)\]/.test(subs) && para1.indexOf("dst=filter")==-1 && subi.indexOf("securehostname") == -1 && typeU != "module" && typeU != "nodes") {
type = "rewrite" //Quantumult X 类型 rewrite/ Surge Script/
} else if ( ((ModuleK.some(RewriteCheck) || para1.indexOf("dst=rewrite") != -1) && (para1.indexOf("dst=filter") == -1) && subs.indexOf("[Proxy]") == -1) || typeU == "module") { // Surge 类型 module /rule-set(含url-regex) 类型
} else if ( (((ModuleK.some(RewriteCheck) || para1.indexOf("dst=rewrite") != -1) && (para1.indexOf("dst=filter") == -1) && subs.indexOf("[Proxy]") == -1) || typeU == "module") && typeU != "nodes") { // Surge 类型 module /rule-set(含url-regex) 类型
type = "sgmodule"
} else if ((RuleK.some(RuleCheck) && subs.indexOf(html) == -1 && subs.indexOf("[Proxy]") == -1 && subs.indexOf("[server_local]") == -1) || typeU == "rule" ||para1.indexOf("dst=filter")!=-1) {
} else if (((RuleK.some(RuleCheck) && subs.indexOf(html) == -1 && !/\[(Proxy|server_local)\]/.test(subs)) || typeU == "rule" || para1.indexOf("dst=filter")!=-1) && typeU != "nodes") {
type = "Rule";
} else if ((DomainK.some(RuleCheck) || typeU == "domain-set") && subs.indexOf("[Proxy]") == -1 ) {
} else if ((DomainK.some(RuleCheck) || typeU == "domain-set") && subs.indexOf("[Proxy]") == -1 && typeU != "nodes") {
type = "Rule";
content0 = Domain2Rule(content0) // 转换 domain-set
} else if (subsn.length >= 1 && SubK2.some(NodeCheck) && subs.indexOf("[Proxy]") == -1 && subs.indexOf("[filter_local]") == -1) { //未b64加密的多行URI 组合订阅
} else if (subsn.length >= 1 && SubK2.some(NodeCheck) && !/\[(Proxy|filter_local)\]/.test(subs)) { //未b64加密的多行URI 组合订阅
type = "Subs"
} else if (SubK.some(NodeCheck)) { //b64加密的订阅类型
type = "Subs-B64Encode"
} else if ((subi.indexOf("tag=") != -1 && QuanXK.some(NodeCheck) && subs.indexOf("[Proxy]") == -1 && subs.indexOf("[filter_local]") == -1) || typeU =="list") {
} else if ((subi.indexOf("tag=") != -1 && QuanXK.some(NodeCheck) && !/\[(Proxy|filter_local)\]/.test(subs)) || typeU =="list") {
type = "Subs" // QuanX list
} else if (subs.indexOf("[Proxy]") != -1) {
type = "Surge"; // Surge Profiles
} else if ((SurgeK.some(NodeCheck) && subs.indexOf("[Proxy]") == -1 && subs.indexOf("[filter_local]") == -1) || typeU == "list") {
} else if ((SurgeK.some(NodeCheck) && !/\[(Proxy|filter_local)\]/.test(subs)) || typeU == "list") {
type = "Subs" // Surge proxy list
} else if (subs.indexOf("[server_local]") != -1) {
type = "QuanX" // QuanX Profile
} else if(typeU == "nodes") {
type = "Subs-B64Encode"
}
// 用于通知判断类型debug
if(typeU == "X"){
$notify(type,"",content0)
}
return type
}
@@ -369,10 +376,8 @@ function Type_Check(subs) {
// 检查节点名字(重复以及空名)等QuanX 不允许的情形
function TagCheck_QX(content) {
var Olist = content
var Nlist = []
var nmlist = []
var nulllist = []; //记录空名字节点
var duplist = []; //记录重名节点
var [Nlist, nmlist] = [ [], [] ]
var [nulllist,duplist] = [ [], [] ]; //记录空名字节点&重名节点
var no = 0;
for (var i = 0; i < Olist.length; i++) {
var item = Olist[i] ? Olist[i] : ""