mirror of
https://github.com/KOP-XIAO/QuantumultX.git
synced 2026-01-25 17:15:09 +00:00
type check improve
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
☑️ 资源解析器 ©𝐒𝐡𝐚𝐰𝐧 ⟦2021-10-22 21:35⟧
|
☑️ 资源解析器 ©𝐒𝐡𝐚𝐰𝐧 ⟦2021-11-01 11:15⟧
|
||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
🛠 发现 𝐁𝐔𝐆 请反馈: @ShawnKOP_bot
|
🛠 发现 𝐁𝐔𝐆 请反馈: @ShawnKOP_bot
|
||||||
⛳️ 关注 🆃🅶 相关频道: https://t.me/QuanX_API
|
⛳️ 关注 🆃🅶 相关频道: https://t.me/QuanX_API
|
||||||
@@ -123,7 +123,7 @@ const rwrite_link = { "open-url": link1, "media-url": "https://shrtm.nu/x3o2" }
|
|||||||
const rwhost_link = { "open-url": link1, "media-url": "https://shrtm.nu/0n5J" } // hostname filter link
|
const rwhost_link = { "open-url": link1, "media-url": "https://shrtm.nu/0n5J" } // hostname filter link
|
||||||
const rule_link = { "open-url": link1, "media-url": "https://shrtm.nu/cpHD" } // rule filter link
|
const rule_link = { "open-url": link1, "media-url": "https://shrtm.nu/cpHD" } // rule filter link
|
||||||
const nan_link = { "open-url": link1, "media-url": qxpng } // nan error link
|
const nan_link = { "open-url": link1, "media-url": qxpng } // nan error link
|
||||||
const bug_link = { "open-url": "https://t.me/Shawn_KOP_bot", "media-url": "https://shrtm.nu/obcB" } // bug link
|
const bug_link = { "open-url": "https://t.me/ShawnKOP_bot", "media-url": "https://shrtm.nu/obcB" } // bug link
|
||||||
const sub_link = { "open-url": link1, "media-url": "https://shrtm.nu/ebAr" } // server link
|
const sub_link = { "open-url": link1, "media-url": "https://shrtm.nu/ebAr" } // server link
|
||||||
|
|
||||||
|
|
||||||
@@ -172,7 +172,9 @@ var Pdel = mark0 && para1.indexOf("del=") != -1 ? para1.split("del=")[1].split("
|
|||||||
var typeU = para1.indexOf("type=") != -1 ? para1.split("type=")[1].split("&")[0] : "";
|
var typeU = para1.indexOf("type=") != -1 ? para1.split("type=")[1].split("&")[0] : "";
|
||||||
var Pfcr = para1.indexOf("fcr=") != -1 ? para1.split("fcr=")[1].split("&")[0] : ""; // force-cellular 参数
|
var Pfcr = para1.indexOf("fcr=") != -1 ? para1.split("fcr=")[1].split("&")[0] : ""; // force-cellular 参数
|
||||||
|
|
||||||
var typeQ = $resource.type //返回 field 类型参数
|
var typeQ = $resource.type? $resource.type:"unsupported" //返回 field 类型参数
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//花漾字 pattern
|
//花漾字 pattern
|
||||||
var pat=[]
|
var pat=[]
|
||||||
@@ -205,7 +207,8 @@ var flag = 1
|
|||||||
|
|
||||||
function Parser() {
|
function Parser() {
|
||||||
type0 = Type_Check(content0); // 类型判断
|
type0 = Type_Check(content0); // 类型判断
|
||||||
if (type0 != "web"){
|
//$notify(type0)
|
||||||
|
if (type0 != "web" && type0 != "wrong-field"){
|
||||||
try {
|
try {
|
||||||
//$notify(type0,"hh")
|
//$notify(type0,"hh")
|
||||||
if (Pdbg){
|
if (Pdbg){
|
||||||
@@ -216,6 +219,10 @@ function Parser() {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
$notify("❌ 解析出现错误", "⚠️ 请点击发送链接反馈", err, bug_link);
|
$notify("❌ 解析出现错误", "⚠️ 请点击发送链接反馈", err, bug_link);
|
||||||
}
|
}
|
||||||
|
} else if (type0 == "wrong-field"){
|
||||||
|
//$notify(type0+"ss")
|
||||||
|
$notify("❌ 解析类型与目标类型"+" 「"+typeQ+" 」不符", "⚠️ 请自行检查链接内容,或点击通知反馈", $resource.link, bug_link)
|
||||||
|
total=""
|
||||||
} else {
|
} else {
|
||||||
total=""
|
total=""
|
||||||
}
|
}
|
||||||
@@ -344,6 +351,7 @@ function ResourceParse() {
|
|||||||
total = content0
|
total = content0
|
||||||
$done({ content: content0 })
|
$done({ content: content0 })
|
||||||
}
|
}
|
||||||
|
if (Pcnt == 1 && flag !=1) {$notify("解析后最终返回内容" , "总数量: " +total.split("\n").length, total)}
|
||||||
return total
|
return total
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -421,36 +429,36 @@ function Type_Check(subs) {
|
|||||||
$notify("‼️ 该链接返回网页内容,无有效订阅"+ " ➟ " + "⟦" + subtag + "⟧", "⁉️ 点通知跳转以确认链接是否失效\n"+link0, subs, nan_link);
|
$notify("‼️ 该链接返回网页内容,无有效订阅"+ " ➟ " + "⟦" + subtag + "⟧", "⁉️ 点通知跳转以确认链接是否失效\n"+link0, subs, nan_link);
|
||||||
type = "web";
|
type = "web";
|
||||||
} else if (typeU == "nodes" ) {
|
} else if (typeU == "nodes" ) {
|
||||||
type = "Subs-B64Encode"
|
type = (typeQ == "unsupported" || typeQ =="server")? "Subs-B64Encode":"wrong-field"
|
||||||
} else if (ClashK.some(NodeCheck) || typeU == "clash"){ // Clash 类型节点转换
|
} else if (ClashK.some(NodeCheck) || typeU == "clash"){ // Clash 类型节点转换
|
||||||
type = "Clash";
|
type = (typeQ == "unsupported" || typeQ =="server")? "Clash":"wrong-field";
|
||||||
content0 = Clash2QX(subs)
|
content0 = Clash2QX(subs)
|
||||||
} else if ((/^hostname\s*\=|pattern\=/.test(subi) || RewriteK.some(RewriteCheck)) && !/\[(Proxy|filter_local)\]/.test(subs) && para1.indexOf("dst=filter")==-1 && subi.indexOf("securehostname") == -1 && !/module|nodes|rule/.test(typeU) ) {
|
} else if ((/^hostname\s*\=|pattern\=/.test(subi) || RewriteK.some(RewriteCheck)) && !/\[(Proxy|filter_local)\]/.test(subs) && para1.indexOf("dst=filter")==-1 && subi.indexOf("securehostname") == -1 && !/module|nodes|rule/.test(typeU) ) {
|
||||||
type = "rewrite" //Quantumult X 类型 rewrite/ Surge Script/
|
type = (typeQ == "unsupported" || typeQ =="rewrite")? "rewrite":"wrong-field" //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") && typeU != "nodes" && typeU != "rule") { // 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" && typeU != "rule" && typeQ !="filter") { // Surge 类型 module /rule-set(含url-regex) 类型
|
||||||
type = "sgmodule"
|
type = (typeQ == "unsupported" || typeQ =="rewrite")? "sgmodule" : "wrong-field"
|
||||||
} else if (((RuleK.some(RuleCheck) && subs.indexOf(html) == -1 && !/\[(Proxy|server_local)\]/.test(subs)) || typeU == "rule" || para1.indexOf("dst=filter")!=-1) && typeU != "nodes") {
|
} 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";
|
type = (typeQ == "unsupported" || typeQ =="filter")? "Rule":"wrong-field";
|
||||||
} else if ((DomainK.some(RuleCheck) || typeU == "domain-set") && subs.indexOf("[Proxy]") == -1 && typeU != "nodes") {
|
} else if ((DomainK.some(RuleCheck) || typeU == "domain-set") && subs.indexOf("[Proxy]") == -1 && typeU != "nodes") {
|
||||||
type = "Rule";
|
type = (typeQ == "unsupported" || typeQ =="filter")? "Rule":"wrong-field";
|
||||||
content0 = Domain2Rule(content0) // 转换 domain-set
|
content0 = Domain2Rule(content0) // 转换 domain-set
|
||||||
} else if (subsn.length >= 1 && SubK2.some(NodeCheck) && !/\[(Proxy|filter_local)\]/.test(subs)) { //未b64加密的多行URI 组合订阅
|
} else if (subsn.length >= 1 && SubK2.some(NodeCheck) && !/\[(Proxy|filter_local)\]/.test(subs)) { //未b64加密的多行URI 组合订阅
|
||||||
type = "Subs"
|
type = (typeQ == "unsupported" || typeQ =="server"||typeQ =="uri") ? "Subs":"wrong-field"
|
||||||
} else if (SubK.some(NodeCheck)) { //b64加密的订阅类型
|
} else if (SubK.some(NodeCheck)) { //b64加密的订阅类型
|
||||||
type = "Subs-B64Encode"
|
type = (typeQ == "unsupported" || typeQ =="server")? "Subs-B64Encode":"wrong-field"
|
||||||
} else if ((subi.indexOf("tag=") != -1 && QuanXK.some(NodeCheck) && !/\[(Proxy|filter_local)\]/.test(subs)) || typeU =="list") {
|
} else if ((subi.indexOf("tag=") != -1 && QuanXK.some(NodeCheck) && !/\[(Proxy|filter_local)\]/.test(subs)) || typeU =="list") {
|
||||||
type = "Subs" // QuanX list
|
type = (typeQ == "unsupported" || typeQ =="server")? "Subs":"wrong-field" // QuanX list
|
||||||
} else if (subs.indexOf("[Proxy]") != -1) {
|
} else if (subs.indexOf("[Proxy]") != -1) {
|
||||||
type = "Surge"; // Surge Profiles
|
type = (typeQ == "unsupported" || typeQ =="server")? "Surge":"wrong-field"; // Surge Profiles
|
||||||
content0 = Surge2QX(content0).join("\n");
|
content0 = Surge2QX(content0).join("\n");
|
||||||
} else if ((SurgeK.some(NodeCheck) && !/\[(Proxy|filter_local)\]/.test(subs)) || typeU == "list") {
|
} else if ((SurgeK.some(NodeCheck) && !/\[(Proxy|filter_local)\]/.test(subs)) || typeU == "list") {
|
||||||
type = "Subs" // Surge proxy list
|
type = (typeQ == "unsupported" || typeQ =="server")? "Subs":"wrong-field" // Surge proxy list
|
||||||
} else if (subs.indexOf("[server_local]") != -1) {
|
} else if (subs.indexOf("[server_local]") != -1) {
|
||||||
//type = "QuanX" // QuanX Profile
|
//type = "QuanX" // QuanX Profile
|
||||||
type = "Subs"
|
type = (typeQ == "unsupported" || typeQ =="server")? "Subs":"wrong-field"
|
||||||
} else if (content0.indexOf("server") !=-1 && content0.indexOf("server_port") !=-1) { //SIP008
|
} else if (content0.indexOf("server") !=-1 && content0.indexOf("server_port") !=-1) { //SIP008
|
||||||
//type = "QuanX"
|
//type = "QuanX"
|
||||||
type = "Subs"
|
type = (typeQ == "unsupported" || typeQ =="server")? "Subs":"wrong-field"
|
||||||
content0 = SIP2QuanX(content0)
|
content0 = SIP2QuanX(content0)
|
||||||
}
|
}
|
||||||
// 用于通知判断类型,debug
|
// 用于通知判断类型,debug
|
||||||
@@ -930,7 +938,7 @@ function Rule_Handle(subs, Pout, Pin) {
|
|||||||
const exclude = (item) => cc.indexOf(item) != -1; // 删除项
|
const exclude = (item) => cc.indexOf(item) != -1; // 删除项
|
||||||
const RuleCheck = (item) => cc.toLowerCase().indexOf(item) != -1; //无视注释行
|
const RuleCheck = (item) => cc.toLowerCase().indexOf(item) != -1; //无视注释行
|
||||||
if (Tout.some(exclude) && !RuleK.some(RuleCheck) && RuleK2.some(RuleCheck)) {
|
if (Tout.some(exclude) && !RuleK.some(RuleCheck) && RuleK2.some(RuleCheck)) {
|
||||||
dlist.push("-" + Rule_Policy(cc))
|
dlist.push("-" + Rule_Policy(cc)) // 注释掉条目
|
||||||
} else if (!RuleK.some(RuleCheck) && cc) { //if Pout.some, 不操作注释项
|
} else if (!RuleK.some(RuleCheck) && cc) { //if Pout.some, 不操作注释项
|
||||||
dd = Rule_Policy(cc);
|
dd = Rule_Policy(cc);
|
||||||
if (Tin != "" && Tin != null) {
|
if (Tin != "" && Tin != null) {
|
||||||
@@ -1032,14 +1040,15 @@ function rule_list_handle(cnt) {
|
|||||||
if(cnt.indexOf("::")!=-1 && cnt.indexOf("/")!=-1) { // ip-v6?
|
if(cnt.indexOf("::")!=-1 && cnt.indexOf("/")!=-1) { // ip-v6?
|
||||||
cnt = "ip6-cidr, " + cnt
|
cnt = "ip6-cidr, " + cnt
|
||||||
cnt = Ppolicy == "Shawn" ? cnt+", Shawn" : cnt+", "+Ppolicy
|
cnt = Ppolicy == "Shawn" ? cnt+", Shawn" : cnt+", "+Ppolicy
|
||||||
} else if (cnt.split("/").length == 2) {//ip-cid
|
} else if (cnt.split("/").length == 2) {//ip-cidr
|
||||||
cnt = "ip-cidr, " + cnt
|
cnt = "ip-cidr, " + cnt
|
||||||
cnt = Ppolicy == "Shawn" ? cnt+", Shawn" : cnt+", "+Ppolicy
|
cnt = Ppolicy == "Shawn" ? cnt+", Shawn" : cnt+", "+Ppolicy
|
||||||
} else if (cnt) { //host - suffix
|
} else if (cnt.indexOf("payload:")==-1) { //host - suffix
|
||||||
cnt = "host-suffix, " + cnt
|
cnt = "host-suffix, " + cnt
|
||||||
cnt = Ppolicy == "Shawn" ? cnt+", Shawn" : cnt+", "+Ppolicy
|
cnt = Ppolicy == "Shawn" ? cnt+", Shawn" : cnt+", "+Ppolicy
|
||||||
}
|
}
|
||||||
return cnt}
|
return cnt
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Domain-Set
|
// Domain-Set
|
||||||
|
|||||||
Reference in New Issue
Block a user