添加 tx.js
This commit is contained in:
commit
f8bce257b9
55
tx.js
Normal file
55
tx.js
Normal file
@ -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({});
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user