forked from ihaoljy/Rewrite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BodyOk.js
51 lines (44 loc) · 1.34 KB
/
BodyOk.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
BodyOk 4.1.9
间歇性断食追踪
[rewrite_local]
^https:\/\/api\.apphud\.com\/v1\/(subscriptions|customers)$ url script-response-body https://raw.githubusercontent.com/Yu9191/Rewrite/main/BodyOk.js
[mitm]
hostname = api.apphud.com
*/
var body = $response.body;
var url = $request.url;
function baby(obj) {
return {
"id": "fcdaaeee-0ba3-4394-baf5-393ce711f018",
"group_id": "0fd127e0",
"unit": "year",
"autorenew_enabled": false,
"expires_at": "2099-09-09T11:05:44.000Z",
"in_retry_billing": false,
"introductory_activated": true,
"cancelled_at": null,
"platform": "ios",
"product_id": "ok.annual.sub",
"retries_count": 0,
"started_at": "2023-12-18T11:05:45.000Z",
"local": false,
"next_check_at": "2023-12-25T11:12:44.000Z",
"kind": "autorenewable",
"units_count": 1,
"environment": "production",
"status": "trial"
};
}
var obj = JSON.parse(body);
if (url.includes('/subscriptions')) {
if (obj.data.hasOwnProperty('subscriptions')) {
obj.data.subscriptions = [baby(obj)];
}
} else if (url.includes('/customers')) {
if (obj.data.results.hasOwnProperty('subscriptions')) {
obj.data.results.subscriptions = [baby(obj)];
}
}
body = JSON.stringify(obj);
$done({ body, url });