From 109186c68762c512b02c525af48bbecba9a6d84c Mon Sep 17 00:00:00 2001 From: Shawn <45581750+KOP-XIAO@users.noreply.github.com> Date: Fri, 12 Nov 2021 16:29:01 +0800 Subject: [PATCH] update --- Scripts/UI-Action.json | 1 + Scripts/switch-check-google.js | 149 +++++++++++++++++++++++++++++++++ Scripts/switch-check-nf.js | 2 +- Scripts/switch-check-ytb.js | 2 +- 4 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 Scripts/switch-check-google.js diff --git a/Scripts/UI-Action.json b/Scripts/UI-Action.json index 4db192b..7d61709 100644 --- a/Scripts/UI-Action.json +++ b/Scripts/UI-Action.json @@ -10,5 +10,6 @@ "event-interaction https://raw.githubusercontent.com/KOP-XIAO/QuantumultX/master/Scripts/switch-check-ytb.js, tag=YouTube 切换, img-url=https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/YouTube_Letter.png, enabled=true", "event-interaction https://raw.githubusercontent.com/KOP-XIAO/QuantumultX/master/Scripts/switch-check-nf.js, tag=Netflix 切换, img-url=https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Netflix_Letter.png, enabled=true", "event-interaction https://raw.githubusercontent.com/KOP-XIAO/QuantumultX/master/Scripts/switch-check-disneyplus.js, tag=Disneyᐩ 切换, img-url=https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Disney.png, enabled=true", + "event-interaction https://raw.githubusercontent.com/KOP-XIAO/QuantumultX/master/Scripts/switch-check-google.js, tag=Google 切换, img-url=https://raw.githubusercontent.com/Koolson/Qure/master/IconSet/Color/Google.png, enabled=true", ] } \ No newline at end of file diff --git a/Scripts/switch-check-google.js b/Scripts/switch-check-google.js new file mode 100644 index 0000000..2a5bdb6 --- /dev/null +++ b/Scripts/switch-check-google.js @@ -0,0 +1,149 @@ +/*** + +For Quantumult-X 598+ ONLY!! + +[task_local] + +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 + +ps. 简单粗暴的 UI-Interaction 版本。无数据持久化、粗暴延迟等待。完美主义建议使用 Helge大佬的boxjs版本 https://t.me/QuanXNews/193 + +@XIAO_KOP + +**/ + +var policy = $environment.params +const message = { + action: "get_customized_policy", + content: policy + +}; + +var output=[] +var OKList=["送中节点 ➟ "] +var NoList=["未送中节点 ➟ "] +var ErrorList=["检测出错节点 ➟ "] +var pflag=1 //是否是策略,或者简单节点 + +$configuration.sendMessage(message).then(resolve => { + if (resolve.error) { + console.log(resolve.error); + $done() + } + if (resolve.ret) { + //$notify(JSON.stringify(resolve.ret)) + output=JSON.stringify(resolve.ret[message.content])? JSON.parse(JSON.stringify(resolve.ret[message.content]["candidates"])) : [$environment.params] + pflag = JSON.stringify(resolve.ret[message.content])? pflag:0 + console.log("Google 送中检测 检测") + console.log("节点or策略组:"+pflag) + //$notify(typeof(output),output) + Check() + //$done({"title":"策略内容","message":output}) + } + //$done();| +}, reject => { + // Normally will never happen. + $done(); +}); + +function Check() { + var relay = 2000; + for ( var i=0;i < output.length;i++) { + testGoogle(output[i]) + } + if (output.length<=5) { + relay = 2000 + } else if (output.length<10) { + relay =4000 + } else if (output.length<15) { + relay =6000 + } else if (output.length<20) { + relay =8000 + } else { + relay =10000 + } + console.log(output.length+":"+relay) + setTimeout(() => { + console.log(OKList) + console.log(NoList) + console.log(ErrorList) + const dict = { [policy] : OKList[1]}; + if(OKList[1]) { + console.log("选定未被送中节点:"+OKList[1]) + } + const mes1 = { + action: "set_policy_state", + content: dict + }; + $configuration.sendMessage(mes1).then(resolve => { + if (resolve.error) { + console.log(resolve.error); + content =pflag==0 && OKList[1]? `
🎉 该节点未被 Google 送中
👇
-------------------------
⟦ `+$environment.params+` ⟧
-------------------------` : `
😭 该节点已被 Google 送中
👇
-------------------------
⟦ `+$environment.params+` ⟧
-------------------------`
+ content = pflag!=0 && !OKList[1]? `
` + "
❌ ⟦ "+$environment.params+ " ⟧ ⚠️ 切换失败
该策略组内未找到未被 Google 送中 的节点" + "
-----------------------------
检测详情请查看JS脚本记录
-----------------------------"+`
` + "
⟦ "+$environment.params+ " ⟧ 已切换至未被Google 送中的路线
👇
⟦ "+OKList[1]+ " ⟧" + "
-----------------------------
检测详情请查看JS脚本记录
-----------------------------"+`