mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-12-03 09:45:54 +00:00
feat: 脚本操作可通过 context.process 按 customName 控制后续操作(前端 >= 2.17.16)
This commit is contained in:
4 files changed
+241
-1
No files matched your search
@@ -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: "${
|
||||
|
||||
Reference in new issue
Block a user