feat: 脚本操作可通过 context.process 按 customName 控制后续操作(前端 >= 2.17.16)

This commit is contained in:
xream committed 2026-05-24 23:59:48 +08:00
1 parent 6682ab865a
commit baccae7c7f
4 files changed
+241 -1

No files matched your search

+31
View File
@@ -109,6 +109,21 @@ function parse(raw) {
});
}
function shouldSkipByContext(item, context) {
const control = context.process;
if (!control || typeof control !== 'object') return false;
const { type, customNames } = control;
if (!Array.isArray(customNames)) return false;
const matched =
item.customName != null && customNames.includes(item.customName);
if (type === 'disable') return matched;
if (type === 'enable') return !matched;
return false;
}
async function processFn(
proxies,
operators = [],
@@ -128,6 +143,14 @@ async function processFn(
);
continue;
}
if (shouldSkipByContext(item, context)) {
$.info(
`Skipping context-controlled operator: "${
item.type
}" with customName "${item.customName || ''}"`,
);
continue;
}
if (item.disabled) {
$.log(
`Skipping disabled operator: "${
@@ -184,6 +207,14 @@ async function processResponseFn(
let output = normalizeResponse(response);
for (const item of operators) {
if (!isResponseTransformerType(item.type)) continue;
if (shouldSkipByContext(item, context)) {
$.info(
`Skipping context-controlled response transformer: "${
item.type
}" with customName "${item.customName || ''}"`,
);
continue;
}
if (item.disabled) {
$.log(
`Skipping disabled response transformer: "${