Peng-YM 2022-05-18 13:40:24 +08:00
parent 48d533af83
commit 6bb837f74f
3 changed files with 20 additions and 8 deletions

View File

@ -2131,7 +2131,7 @@ var ProxyUtils = (function () {
1. This function name should be `operator`! 1. This function name should be `operator`!
2. Always declare variables before using them! 2. Always declare variables before using them!
*/ */
function ScriptOperator(script, targetPlatform) { function ScriptOperator(script, targetPlatform, $arguments) {
return { return {
name: "Script Operator", name: "Script Operator",
func: (proxies) => { func: (proxies) => {
@ -2231,14 +2231,14 @@ var ProxyUtils = (function () {
1. This function name should be `func`! 1. This function name should be `func`!
2. Always declare variables before using them! 2. Always declare variables before using them!
*/ */
function ScriptFilter(script) { function ScriptFilter(script, targetPlatform, $arguments) {
return { return {
name: "Script Filter", name: "Script Filter",
func: (proxies) => { func: (proxies) => {
let output = FULL(proxies.length, true); let output = FULL(proxies.length, true);
!(function () { !(function () {
eval(script); eval(script);
output = filter(proxies); output = filter(proxies, targetPlatform);
})(); })();
return output; return output;
}, },
@ -2807,12 +2807,24 @@ var ProxyUtils = (function () {
for (const item of operators) { for (const item of operators) {
// process script // process script
let script; let script;
const $arguments = {};
if (item.type.indexOf("Script") !== -1) { if (item.type.indexOf("Script") !== -1) {
const {mode, content} = item.args; const {mode, content} = item.args;
if (mode === "link") { 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 // if this is remote script, download it
try { try {
script = await $.http.get(content).then((resp) => resp.body); script = await $downloader.download(url);
} catch (err) { } catch (err) {
$.error( $.error(
`Error when downloading remote script: ${item.args.content}.\n Reason: ${err}` `Error when downloading remote script: ${item.args.content}.\n Reason: ${err}`
@ -2836,7 +2848,7 @@ var ProxyUtils = (function () {
); );
let processor; let processor;
if (item.type.indexOf("Script") !== -1) { if (item.type.indexOf("Script") !== -1) {
processor = PROXY_PROCESSORS[item.type](script, targetPlatform); processor = PROXY_PROCESSORS[item.type](script, targetPlatform, $arguments);
} else { } else {
processor = PROXY_PROCESSORS[item.type](item.args); processor = PROXY_PROCESSORS[item.type](item.args);
} }

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
function operator(proxies, targetPlatform) { function operator(proxies, targetPlatform) {
const fingerprint = "你的指纹"; const {fingerprint} = $arguments;
proxies.forEach(proxy => { proxies.forEach(proxy => {
if (targetPlatform === "Surge") { if (targetPlatform === "Surge") {
proxy.tfo = `${proxy.tfo || false}, server-cert-fingerprint-sha256=${fingerprint}`; proxy.tfo = `${proxy.tfo || false}, server-cert-fingerprint-sha256=${fingerprint}`;