mirror of
https://github.com/KOP-XIAO/QuantumultX.git
synced 2026-01-25 13:05:10 +00:00
Update switch-check-google.js
This commit is contained in:
@@ -4,15 +4,33 @@ For Quantumult-X 598+ ONLY!!
|
|||||||
|
|
||||||
[task_local]
|
[task_local]
|
||||||
|
|
||||||
|
// UI 入口切换版本
|
||||||
event-interaction https://raw.githubusercontent.com/KOP-XIAO/QuantumultX/master/Scripts/switch-check-google.js, tag=Google Sifter, img-url=https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Google_Search.png, enabled=true
|
event-interaction https://raw.githubusercontent.com/KOP-XIAO/QuantumultX/master/Scripts/switch-check-google.js, tag=Google Sifter, img-url=https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Google_Search.png, enabled=true
|
||||||
|
|
||||||
|
// Cron 定时切换版本
|
||||||
|
0 8 * * * https://raw.githubusercontent.com/KOP-XIAO/QuantumultX/master/Scripts/switch-check-google.js, tag=Google Sifter, img-url=https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Google_Search.png, enabled=true
|
||||||
|
|
||||||
|
|
||||||
ps. 简单粗暴的 UI-Interaction 版本。无数据持久化、粗暴延迟等待。完美主义建议使用 Helge大佬的boxjs版本 https://t.me/QuanXNews/193
|
ps. 简单粗暴的 UI-Interaction 版本。无数据持久化、粗暴延迟等待。完美主义建议使用 Helge大佬的boxjs版本 https://t.me/QuanXNews/193
|
||||||
|
|
||||||
@XIAO_KOP
|
@XIAO_KOP
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
var policy = $environment.params
|
//var policy = $environment.params
|
||||||
|
var cronsign = $environment.executeType == 0 || $environment.executeType == "0" || $environment.executeType == "-1"? "Y" : "N"
|
||||||
|
var policy = $environment.executeType == 0 || $environment.executeType == "0" || $environment.executeType == "-1"? GetPolicy($environment.sourcePath) : $environment.params
|
||||||
|
console.log(JSON.stringify($environment))
|
||||||
|
console.log("策略组:"+policy)
|
||||||
|
|
||||||
|
function GetPolicy(cnt) {
|
||||||
|
if (cnt && cnt.indexOf("#policy=") !=-1) {
|
||||||
|
return decodeURIComponent(cnt.split("#policy=")[1].trim())
|
||||||
|
}else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const message = {
|
const message = {
|
||||||
action: "get_customized_policy",
|
action: "get_customized_policy",
|
||||||
content: policy
|
content: policy
|
||||||
@@ -33,15 +51,15 @@ $configuration.sendMessage(message).then(resolve => {
|
|||||||
}
|
}
|
||||||
if (resolve.ret) {
|
if (resolve.ret) {
|
||||||
//console.log(JSON.stringify(resolve.ret))
|
//console.log(JSON.stringify(resolve.ret))
|
||||||
output=JSON.stringify(resolve.ret[message.content])? JSON.parse(JSON.stringify(resolve.ret[message.content]["candidates"])) : [$environment.params]
|
output=JSON.stringify(resolve.ret[message.content])? JSON.parse(JSON.stringify(resolve.ret[message.content]["candidates"])) : [policy]
|
||||||
pflag = JSON.stringify(resolve.ret[message.content])? pflag:0
|
pflag = JSON.stringify(resolve.ret[message.content])? pflag:0
|
||||||
console.log("Google 送中检测 检测")
|
console.log("Google 送中检测 检测")
|
||||||
console.log("节点or策略组:"+pflag)
|
console.log("节点or策略组:"+pflag)
|
||||||
|
|
||||||
if (pflag==1) {
|
if (pflag==1) {
|
||||||
console.log("节点数量:"+resolve.ret[$environment.params]["candidates"].length)
|
console.log("节点数量:"+resolve.ret[policy]["candidates"].length)
|
||||||
|
|
||||||
if(resolve.ret[$environment.params]["candidates"].length==0) {
|
if(resolve.ret[policy]["candidates"].length==0) {
|
||||||
$done({"title":"Google 送中检测","htmlMessage":`<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b>😭 无有效节点</b>`});
|
$done({"title":"Google 送中检测","htmlMessage":`<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b>😭 无有效节点</b>`});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,12 +102,12 @@ function Check() {
|
|||||||
if (OKList[0] && pflag==1) { //有支持节点、且为策略组才操作
|
if (OKList[0] && pflag==1) { //有支持节点、且为策略组才操作
|
||||||
ReOrder(OKList)
|
ReOrder(OKList)
|
||||||
} else if (!OKList[0]){ //不支持
|
} else if (!OKList[0]){ //不支持
|
||||||
content =pflag==0 ? `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b>😭 该节点已被 Google 送中 </b><br><br>👇<br><br><font color=#FF5733>-------------------------<br><b>⟦ `+$environment.params+` ⟧ </b><br>-------------------------</font>`: `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin">` + "<br>❌ <b>⟦ "+$environment.params+ " ⟧ </b>⚠️ 切换失败<br><br><b>该策略组内未找到未被 Google 送中</b> 的节点" + "<br><br><font color=#FF5733>-----------------------------<br><b>检测详情请查看JS脚本记录</b><br>-----------------------------</font>"+`</p>`
|
content =pflag==0 ? `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b>😭 该节点已被 Google 送中 </b><br><br>👇<br><br><font color=#FF5733>-------------------------<br><b>⟦ `+policy+` ⟧ </b><br>-------------------------</font>`: `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin">` + "<br>❌ <b>⟦ "+policy+ " ⟧ </b>⚠️ 切换失败<br><br><b>该策略组内未找到未被 Google 送中</b> 的节点" + "<br><br><font color=#FF5733>-----------------------------<br><b>检测详情请查看JS脚本记录</b><br>-----------------------------</font>"+`</p>`
|
||||||
//为节点且检测超时/出错
|
//为节点且检测超时/出错
|
||||||
content = pflag==0 && Len(NoList)==0 ? content = `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b>⚠️ 该节点 Google 送中检测失败 </b><br><br>👇<br><br><font color=#FF5733>-------------------------<br><b>⟦ `+$environment.params+` ⟧ </b><br>-------------------------</font>`: content
|
content = pflag==0 && Len(NoList)==0 ? content = `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b>⚠️ 该节点 Google 送中检测失败 </b><br><br>👇<br><br><font color=#FF5733>-------------------------<br><b>⟦ `+policy+` ⟧ </b><br>-------------------------</font>`: content
|
||||||
$done({"title":"Google 送中检测&切换", "htmlMessage": content})
|
$done({"title":"Google 送中检测&切换", "htmlMessage": content})
|
||||||
} else if (OKList[0]){ //支持, 但为节点
|
} else if (OKList[0]){ //支持, 但为节点
|
||||||
content = `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b> 🎉 该节点未被 Google 送中 </b><br><br>👇<br><br><font color=#FF5733>-------------------------<br><b>⟦ `+$environment.params+` ⟧ </b><br>-------------------------</font>`
|
content = `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b> 🎉 该节点未被 Google 送中 </b><br><br>👇<br><br><font color=#FF5733>-------------------------<br><b>⟦ `+policy+` ⟧ </b><br>-------------------------</font>`
|
||||||
$done({"title":"Google 送中检测&切换", "htmlMessage": content})
|
$done({"title":"Google 送中检测&切换", "htmlMessage": content})
|
||||||
}
|
}
|
||||||
}, relay)
|
}, relay)
|
||||||
@@ -136,13 +154,14 @@ function ReOrder(cnt) {
|
|||||||
$configuration.sendMessage(mes1).then(resolve => {
|
$configuration.sendMessage(mes1).then(resolve => {
|
||||||
if (resolve.error) {
|
if (resolve.error) {
|
||||||
console.log(resolve.error);
|
console.log(resolve.error);
|
||||||
content =pflag==0 && array[0]? `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b> 🎉 该节点未被 Google 送中 </b><br><br>👇<br><br><font color=#FF5733>-------------------------<br><b>⟦ `+$environment.params+` ⟧ </b><br>-------------------------</font>` : `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b>😭 该节点已被 Google 送中 </b><br><br>👇<br><br><font color=#FF5733>-------------------------<br><b>⟦ `+$environment.params+` ⟧ </b><br>-------------------------</font>`
|
content =pflag==0 && array[0]? `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b> 🎉 该节点未被 Google 送中 </b><br><br>👇<br><br><font color=#FF5733>-------------------------<br><b>⟦ `+policy+` ⟧ </b><br>-------------------------</font>` : `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin"><br><b>😭 该节点已被 Google 送中 </b><br><br>👇<br><br><font color=#FF5733>-------------------------<br><b>⟦ `+policy+` ⟧ </b><br>-------------------------</font>`
|
||||||
content = pflag!=0 && !array[0]? `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin">` + "<br>❌ <b>⟦ "+$environment.params+ " ⟧ </b>⚠️ 切换失败<br><br><b>该策略组内未找到未被 Google 送中</b> 的节点" + "<br><br><font color=#FF5733>-----------------------------<br><b>检测详情请查看JS脚本记录</b><br>-----------------------------</font>"+`</p>` : content
|
content = pflag!=0 && !array[0]? `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin">` + "<br>❌ <b>⟦ "+policy+ " ⟧ </b>⚠️ 切换失败<br><br><b>该策略组内未找到未被 Google 送中</b> 的节点" + "<br><br><font color=#FF5733>-----------------------------<br><b>检测详情请查看JS脚本记录</b><br>-----------------------------</font>"+`</p>` : content
|
||||||
$done({"title":"Google 送中检测&切换", "htmlMessage": content})
|
$done({"title":"Google 送中检测&切换", "htmlMessage": content})
|
||||||
}
|
}
|
||||||
if (resolve.ret) {
|
if (resolve.ret) {
|
||||||
console.log("已经切换至未被 <b>Google 送中</b> 的路线中延迟最优节点 ➟ "+array[0])
|
console.log("已经切换至未被 <b>Google 送中</b> 的路线中延迟最优节点 ➟ "+array[0])
|
||||||
content = `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin">` + "<br><b>⟦ "+$environment.params+ " ⟧ </b>已切换至未被<b>Google</b> 送中延迟最优路线<br><br> 👇<br><br> ⟦ "+array[0]+ " ⟧" + "<br><br><font color=#16A085>"+Ping+"</font><br><font color=#FF5733>-----------------------------<br><b>检测详情请查看JS脚本记录</b><br>-----------------------------</font>"+`</p>`
|
if (cronsign == "Y") { $notify("🐸 Google 定时送中检测&切换", "🎉 已切换至未被送中的最优延迟线路👇", array[0] +"\n 👉 "+Ping)}
|
||||||
|
content = `<p style="text-align: center; font-family: -apple-system; font-size: large; font-weight: thin">` + "<br><b>⟦ "+policy+ " ⟧ </b>已切换至未被<b>Google</b> 送中延迟最优路线<br><br> 👇<br><br> ⟦ "+array[0]+ " ⟧" + "<br><br><font color=#16A085>"+Ping+"</font><br><font color=#FF5733>-----------------------------<br><b>检测详情请查看JS脚本记录</b><br>-----------------------------</font>"+`</p>`
|
||||||
$done({"title":"Google 送中检测&切换", "htmlMessage": content })
|
$done({"title":"Google 送中检测&切换", "htmlMessage": content })
|
||||||
}
|
}
|
||||||
}, reject => {
|
}, reject => {
|
||||||
|
|||||||
Reference in New Issue
Block a user