-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShare.sgmodule
28 lines (24 loc) · 1.14 KB
/
Share.sgmodule
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[Module]
name = Modify Response Data
description = Modify the response data for a specific URL.
[Script]
modify-response.js = <inline script>
function onRequest(request, response) {
const url = new URL(request.url);
// 匹配请求 URL
if (url.pathname === "/activecode/bind" && request.method === "POST") {
// 修改响应内容
response.statusCode = 200;
const responseData = {"code":0,"data":{"code":"夹总身体健康","activated":true,"orderId":"","activeCount":0,"timestamp":4765132800000,"s_expire":false}};
response.setHeader("Content-Type", "application/json");
response.setHeader("Content-Length", Buffer.byteLength(JSON.stringify(responseData)));
response.end(JSON.stringify(responseData));
$done(response);
} else {
$done({});
}
}
</inline>
[Rule]
DOMAIN-SUFFIX,api.yuhengye.com,SCRIPT-SET=modify-response.js
URL-REGEX,^http:\/\/api\.yuhengye\.com\/activecode\/bind$,FINAL,HTTP-RESPONSE ^HTTP\/\d+\.\d+ 200$ STATUS 200 BODY .* MODIFY-RESPONSE "{\"code\":0,\"data\":{\"code\":\"夹总身体健康\",\"activated\":true,\"orderId\":\"\",\"activeCount\":0,\"timestamp\":4765132800000,\"s_expire\":false}}"