forked from ihaoljy/Rewrite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTopluntan.js
65 lines (49 loc) · 2.09 KB
/
Topluntan.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
52
53
54
55
56
57
58
59
60
61
62
63
/*
Top论坛
课程全解锁
仅测试Surge
[rewrite_local]
https://super.toppps.com/app-api/v1/toppps/(live/getLiveSpaceDetailsV2|products) url script-response-body https://raw.githubusercontent.com/Yu9191/Rewrite/main/Topluntan.js
[mitm]
hostname = super.toppps.com
*/
const response_body = $response.body;
const url = $request.url;
let body = response_body;
if (url.includes("https://super.toppps.com/app-api/v1/toppps/live/getLiveSpaceDetailsV2")) {
// 空中课堂定制课程
body = body.replace(/"tryRights":\s*false/g, '"tryRights": true')
.replace(/"leftTryTime":\s*\d+/g, '"leftTryTime": 9000000')
.replace(/"pdfRights":\s*false/g, '"pdfRights": true');
const pdfUrlMatch = body.match(/"pdfList":\s*\["([^"]+)"/);
if (pdfUrlMatch && pdfUrlMatch.length > 1) {
const pdfListEncoded = pdfUrlMatch[1];
const pdfListDecoded = decodeURIComponent(pdfListEncoded);
// 发送通知
notifyPDFLink(pdfListDecoded);
}
} else if (url.includes("https://super.toppps.com/app-api/v1/toppps/products")) {
// 空中课堂普通课程
const pdfUrlMatch = body.match(/"pdfUrl":\s*"([^"]+)"/);
if (pdfUrlMatch && pdfUrlMatch.length > 1) {
const pdfUrlEncoded = pdfUrlMatch[1];
const pdfUrlDecoded = decodeURIComponent(pdfUrlEncoded);
// 发送通知
notifyPDFLink(pdfUrlDecoded);
}
body = body.replace(/"pdfFree":\s*\d+/g, '"pdfFree": 1')
.replace(/"videoFree":\s*\d+/g, '"videoFree": 1')
.replace(/"videoDownload":\s*\d+/g, '"videoDownload": 1')
.replace(/"audioFree":\s*\d+/g, '"audioFree": 1')
.replace(/"videoFileSize":\s*\d+/g, '"videoFileSize": 1');
}
$done({ body });
function notifyPDFLink(link) {
if ('undefined' !== typeof $task) {
// 在 Quantumult X 环境下使用 $notify() 函数进行通知
$notify("PDF 下载链接", "", link);
} else {
// 在 Surge 环境下使用 $notification.post() 函数进行通知
$notification.post("PDF 下载链接", "", link);
}
}