commit f8bce257b9eb53eb159960a3f768f12f6572da9e Author: chickliu Date: Sun Aug 31 13:07:06 2025 +0800 添加 tx.js diff --git a/tx.js b/tx.js new file mode 100644 index 0000000..8c1e1d5 --- /dev/null +++ b/tx.js @@ -0,0 +1,55 @@ +// ==Rewrite== +// @name 修改 /withdraw/apply 请求体 +// @version 1.0.0 +// @description 在 /withdraw/apply 的请求体末尾添加 &verify_type=1 +// @author YourName +// @match *://*/* +// @run-at request-body +// ==/Rewrite== + +if (typeof $request !== 'undefined' && $request.body) { + // 检查请求的 URL 是否包含目标路径 + if ($request.url.indexOf('/withdraw/apply') !== -1) { + // 获取当前的请求体 + let body = $request.body; + + // 检查请求体是否已经包含 verify_type,避免重复添加 + if (body.indexOf('verify_type=') === -1) { + // 在请求体末尾添加 &verify_type=1 + // 注意:需要根据原始请求体的格式来处理拼接符号(& 或 ?) + let newBody; + if (body.length > 0) { + // 如果原请求体不为空,且最后一位不是&,则添加&,否则直接添加 + if (body.endsWith('&')) { + newBody = body + 'verify_type=1'; + } else if (body.indexOf('?') !== -1 && body.endsWith('?')) { + // 如果请求体是URL编码形式且以?结尾,这种情况较少见,通常GET参数在URL中,POST请求体多是表单编码或JSON + newBody = body + 'verify_type=1'; + } else { + // 最常见的情况,原请求体不为空,且没有以&结尾,则添加&后拼接 + newBody = body + '&verify_type=1'; + } + } else { + // 如果原请求体为空,则直接添加 + newBody = 'verify_type=1'; + } + + // 打印日志,便于调试 + console.log(`Original Body: ${body}`); + console.log(`Modified Body: ${newBody}`); + + // 完成重写,返回修改后的请求体 + $done({ body: newBody }); + } else { + // 如果已经存在 verify_type,则不进行任何修改 + console.log('verify_type already exists in request body. No modification needed.'); + $done({}); + } + } else { + // 如果不是目标 URL,直接放行 + $done({}); + } +} else { + // 如果没有请求体,直接放行 + $done({}); +} \ No newline at end of file