Peng-YM committed 2022-05-18 13:41:12 +08:00
1 parent 25cb0e7a69
commit 2d4f589eb0
3 files changed
+20 -8

No files matched your search

+17 -5
View File
@@ -2131,7 +2131,7 @@ var ProxyUtils = (function () {
1. This function name should be `operator`!
2. Always declare variables before using them!
*/
function ScriptOperator(script, targetPlatform) {
function ScriptOperator(script, targetPlatform, $arguments) {
return {
name: "Script Operator",
func: (proxies) => {
@@ -2231,14 +2231,14 @@ var ProxyUtils = (function () {
1. This function name should be `func`!
2. Always declare variables before using them!
*/
function ScriptFilter(script) {
function ScriptFilter(script, targetPlatform, $arguments) {
return {
name: "Script Filter",
func: (proxies) => {
let output = FULL(proxies.length, true);
!(function () {
eval(script);
output = filter(proxies);
output = filter(proxies, targetPlatform);
})();
return output;
},
@@ -2807,12 +2807,24 @@ var ProxyUtils = (function () {
for (const item of operators) {
// process script
let script;
const $arguments = {};
if (item.type.indexOf("Script") !== -1) {
const {mode, content} = item.args;
if (mode === "link") {
const url = content;
// extract link arguments
const rawArgs = url.split('#');
if (rawArgs.length > 1) {
for (const pair of rawArgs[1].split("&")) {
const key = pair.split('=')[0];
const value = (pair.split('=')[1] || true);
$arguments[key] = value;
}
}
// if this is remote script, download it
try {
script = await $.http.get(content).then((resp) => resp.body);
script = await $downloader.download(url);
} catch (err) {
$.error(
`Error when downloading remote script: ${item.args.content}.\n Reason: ${err}`
@@ -2836,7 +2848,7 @@ var ProxyUtils = (function () {
);
let processor;
if (item.type.indexOf("Script") !== -1) {
processor = PROXY_PROCESSORS[item.type](script, targetPlatform);
processor = PROXY_PROCESSORS[item.type](script, targetPlatform, $arguments);
} else {
processor = PROXY_PROCESSORS[item.type](item.args);
}
+2 -2
View File
@@ -1,2 +1,2 @@
// UPDATED AT: 2022年 5月18日 星期三 11时05分30秒 CST
const $=API("sub-store"),Base64=new Base64Code,$downloader=new ResourceDownloader;function service(){console.log("\n┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅\n 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 © 𝑷𝒆𝒏𝒈-𝒀𝑴\n┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅\n");const e=express(),t="settings",n="subs",r="collections",s="rules",o="builtin",i="artifacts",a="Auto Generated Sub-Store Backup",c="Sub-Store",l="Sub-Store Artifacts Repository";async function p(e){const{gistToken:n}=$.read(t);return n?new Gist({token:n,key:l}).upload(e):Promise.reject("未设置Gist Token!")}async function u(e){const{headers:t}=await $.http.get({url:e,headers:{"User-Agent":"Quantumult/1.0.13 (iPhone10,3; iOS 14.0)"}});return t[Object.keys(t).filter(e=>/SUBSCRIPTION-USERINFO/i.test(e))[0]]}function f(e){const t=Object.keys(e);let n="";for(let r of t)if(/USER-AGENT/i.test(r)){n=e[r];break}return-1!==n.indexOf("Quantumult%20X")?"QX":-1!==n.indexOf("Surge")?"Surge":-1!==n.indexOf("Decar")||-1!==n.indexOf("Loon")?"Loon":-1!==n.indexOf("Stash")||-1!==n.indexOf("Shadowrocket")?"Clash":null}async function d({type:e,item:t,platform:r,noProcessor:s}={platform:"JSON",noProcessor:!1}){if("subscription"===e){const e=t,n=await $downloader.download(e.url,e.ua);let o=ProxyUtils.parse(n);s||(o=await ProxyUtils.process(o,e.process||[],r));const i={};return o.forEach(e=>{i[e.name]&&$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』","⚠️ 订阅包含重复节点!","请仔细检测配置!",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"})}),ProxyUtils.produce(o,r)}if("collection"===e){const e=$.read(n),o=t,i=o.subscriptions;let a=[],c=0;if(await Promise.all(i.map(async t=>{const n=e[t];try{$.info(`正在处理子订阅:${n.name}...`);const e=await $downloader.download(n.url,n.ua);let t=ProxyUtils.parse(e);s||(t=await ProxyUtils.process(t,n.process||[],r)),a=a.concat(t),c++,$.info(`✅ 子订阅:${n.name}加载成功,进度--${100*(c/i.length).toFixed(1)}% `)}catch(e){c++,$.error(`❌ 处理组合订阅中的子订阅: ${n.name}时出现错误:${e},该订阅已被跳过!进度--${100*(c/i.length).toFixed(1)}%`)}})),s||(a=await ProxyUtils.process(a,o.process||[],r)),0===a.length)throw new Error("组合订阅中不含有效节点!");const l={};return a.forEach(e=>{l[e.name]&&$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』","⚠️ 订阅包含重复节点!","请仔细检测配置!",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"})}),ProxyUtils.produce(a,r)}if("rule"===e){const e=t;let n=[];for(let t=0;t<e.urls.length;t++){const r=e.urls[t];$.info(`正在处理URL:${r},进度--${100*((t+1)/e.urls.length).toFixed(1)}% `);try{const{body:e}=await $downloader.download(r),t=RuleUtils.parse(e);n=n.concat(t)}catch(e){$.error(`处理分流订阅中的URL: ${r}时出现错误:${e}! 该订阅已被跳过。`)}}return n=await RuleUtils.process(n,[{type:"Remove Duplicate Filter"}]),RuleUtils.produce(n,r)}}$.read(n)||$.write({},n),$.read(r)||$.write({},r),$.read(t)||$.write({},t),$.read(s)||$.write({},s),$.read(i)||$.write({},i),$.write({rules:getBuiltInRules()},o),e.get("/download/collection/:name",async function(e,t){const{name:s}=e.params,{raw:o}=e.query||"false",i=e.query.target||f(e.headers)||"JSON",a=$.read(r)[s];$.info(`正在下载组合订阅:${s}`);const c=$.read(n),l=a.subscriptions;if(l.length>0){const e=c[l[0]],n=await u(e.url);n&&t.set("subscription-userinfo",n)}if(a)try{const e=await d({type:"collection",item:a,platform:i,noProcessor:o});"JSON"===i?t.set("Content-Type","application/json;charset=utf-8").send(e):t.send(e)}catch(e){$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』 下载组合订阅失败",`❌ 下载组合订阅错误:${s}!`,`🤔 原因:${e}`),t.status(500).json({status:"failed",message:e})}else $.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』 下载组合订阅失败",`❌ 未找到组合订阅:${s}!`),t.status(404).json({status:"failed"})}),e.get("/download/:name",async function(e,t){const{name:r}=e.params,{cache:s}=e.query,{raw:o}=e.query||"false",i=e.query.target||f(e.headers)||"JSON";$.info(`正在下载订阅:${r}`);const a=$.read(n)[r];if(a)try{const e=await d({type:"subscription",item:a,platform:i,noProcessor:o}),n=await u(a.url);n&&t.set("subscription-userinfo",n),"JSON"===i?t.set("Content-Type","application/json;charset=utf-8").send(e):t.send(e)}catch(e){$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』 下载订阅失败",`❌ 无法下载订阅:${r}!`,`🤔 原因:${JSON.stringify(e)}`),$.error(JSON.stringify(e)),t.status(500).json({status:"failed",message:e})}else $Line truncated
// UPDATED AT: 2022年 5月18日 星期三 13时38分56秒 CST
const $=API("sub-store"),Base64=new Base64Code,$downloader=new ResourceDownloader;function service(){console.log("\n┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅\n 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 © 𝑷𝒆𝒏𝒈-𝒀𝑴\n┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅\n");const e=express(),t="settings",n="subs",r="collections",s="rules",o="builtin",i="artifacts",a="Auto Generated Sub-Store Backup",c="Sub-Store",l="Sub-Store Artifacts Repository";async function p(e){const{gistToken:n}=$.read(t);return n?new Gist({token:n,key:l}).upload(e):Promise.reject("未设置Gist Token!")}async function u(e){const{headers:t}=await $.http.get({url:e,headers:{"User-Agent":"Quantumult/1.0.13 (iPhone10,3; iOS 14.0)"}});return t[Object.keys(t).filter(e=>/SUBSCRIPTION-USERINFO/i.test(e))[0]]}function f(e){const t=Object.keys(e);let n="";for(let r of t)if(/USER-AGENT/i.test(r)){n=e[r];break}return-1!==n.indexOf("Quantumult%20X")?"QX":-1!==n.indexOf("Surge")?"Surge":-1!==n.indexOf("Decar")||-1!==n.indexOf("Loon")?"Loon":-1!==n.indexOf("Stash")||-1!==n.indexOf("Shadowrocket")?"Clash":null}async function d({type:e,item:t,platform:r,noProcessor:s}={platform:"JSON",noProcessor:!1}){if("subscription"===e){const e=t,n=await $downloader.download(e.url,e.ua);let o=ProxyUtils.parse(n);s||(o=await ProxyUtils.process(o,e.process||[],r));const i={};return o.forEach(e=>{i[e.name]&&$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』","⚠️ 订阅包含重复节点!","请仔细检测配置!",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"})}),ProxyUtils.produce(o,r)}if("collection"===e){const e=$.read(n),o=t,i=o.subscriptions;let a=[],c=0;if(await Promise.all(i.map(async t=>{const n=e[t];try{$.info(`正在处理子订阅:${n.name}...`);const e=await $downloader.download(n.url,n.ua);let t=ProxyUtils.parse(e);s||(t=await ProxyUtils.process(t,n.process||[],r)),a=a.concat(t),c++,$.info(`✅ 子订阅:${n.name}加载成功,进度--${100*(c/i.length).toFixed(1)}% `)}catch(e){c++,$.error(`❌ 处理组合订阅中的子订阅: ${n.name}时出现错误:${e},该订阅已被跳过!进度--${100*(c/i.length).toFixed(1)}%`)}})),s||(a=await ProxyUtils.process(a,o.process||[],r)),0===a.length)throw new Error("组合订阅中不含有效节点!");const l={};return a.forEach(e=>{l[e.name]&&$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』","⚠️ 订阅包含重复节点!","请仔细检测配置!",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"})}),ProxyUtils.produce(a,r)}if("rule"===e){const e=t;let n=[];for(let t=0;t<e.urls.length;t++){const r=e.urls[t];$.info(`正在处理URL:${r},进度--${100*((t+1)/e.urls.length).toFixed(1)}% `);try{const{body:e}=await $downloader.download(r),t=RuleUtils.parse(e);n=n.concat(t)}catch(e){$.error(`处理分流订阅中的URL: ${r}时出现错误:${e}! 该订阅已被跳过。`)}}return n=await RuleUtils.process(n,[{type:"Remove Duplicate Filter"}]),RuleUtils.produce(n,r)}}$.read(n)||$.write({},n),$.read(r)||$.write({},r),$.read(t)||$.write({},t),$.read(s)||$.write({},s),$.read(i)||$.write({},i),$.write({rules:getBuiltInRules()},o),e.get("/download/collection/:name",async function(e,t){const{name:s}=e.params,{raw:o}=e.query||"false",i=e.query.target||f(e.headers)||"JSON",a=$.read(r)[s];$.info(`正在下载组合订阅:${s}`);const c=$.read(n),l=a.subscriptions;if(l.length>0){const e=c[l[0]],n=await u(e.url);n&&t.set("subscription-userinfo",n)}if(a)try{const e=await d({type:"collection",item:a,platform:i,noProcessor:o});"JSON"===i?t.set("Content-Type","application/json;charset=utf-8").send(e):t.send(e)}catch(e){$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』 下载组合订阅失败",`❌ 下载组合订阅错误:${s}!`,`🤔 原因:${e}`),t.status(500).json({status:"failed",message:e})}else $.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』 下载组合订阅失败",`❌ 未找到组合订阅:${s}!`),t.status(404).json({status:"failed"})}),e.get("/download/:name",async function(e,t){const{name:r}=e.params,{cache:s}=e.query,{raw:o}=e.query||"false",i=e.query.target||f(e.headers)||"JSON";$.info(`正在下载订阅:${r}`);const a=$.read(n)[r];if(a)try{const e=await d({type:"subscription",item:a,platform:i,noProcessor:o}),n=await u(a.url);n&&t.set("subscription-userinfo",n),"JSON"===i?t.set("Content-Type","application/json;charset=utf-8").send(e):t.send(e)}catch(e){$.notify("🌍 『 𝑺𝒖𝒃-𝑺𝒕𝒐𝒓𝒆 』 下载订阅失败",`❌ 无法下载订阅:${r}!`,`🤔 原因:${JSON.stringify(e)}`),$.error(JSON.stringify(e)),t.status(500).json({status:"failed",message:e})}else $Line truncated
+1 -1
View File
@@ -1,5 +1,5 @@
function operator(proxies, targetPlatform) {
const fingerprint = "你的指纹";
const {fingerprint} = $arguments;
proxies.forEach(proxy => {
if (targetPlatform === "Surge") {
proxy.tfo = `${proxy.tfo || false}, server-cert-fingerprint-sha256=${fingerprint}`;