forked from ddgksf2013/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai-test
More file actions
44 lines (37 loc) · 1.24 KB
/
ai-test
File metadata and controls
44 lines (37 loc) · 1.24 KB
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
const SUBSCRIPTION_CONFIG = {
'reader': ['vip2','com.valo.reader.vip2.year'],
'PureLibro': ['Pro'],
'MOZE': ['premium'],
'MoneyThings': ['Premium'],
'totowallet': ['all', 'com.ziheng.totowallet.yearly'],
'One4Wall': ['lifetime', 'lifetime_key'],
'Ledger': ['Pro', 'com.lifetime.pro'],
'Cookie': ['allaccess','app.ft.Bookkeeping.lifetime'],
'Percento': ['premium']
};
const DEFAULT_SUBSCRIPTION = {
id: 'default_sub',
status: 'active',
};
const userAgent = $request.useragent;
let responseObject;
try {
responseObject = JSON.parse($response.body);
} catch (error) {
console.error('Failed to parse response body:', error);
$response.status = 500;
$response.body = 'Error parsing response body';
return;
}
function getSubscriptionInfo(appName) {
return SUBSCRIPTION_CONFIG[appName] || DEFAULT_SUBSCRIPTION;
}
const matchedApp = Object.keys(SUBSCRIPTION_CONFIG).find(app => userAgent.includes(app));
if (matchedApp) {
const subscriptionId = getSubscriptionInfo(matchedApp);
responseObject.subscription_id = subscriptionId.id; // 根据responseObject的结构设置
} else {
console.warn('No matching application found in user agent.');
}
$response.status = 200;
$response.body = JSON.stringify(responseObject);