forked from CenBoMin/JDTASK_V2P
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JDTaskV2P.cookie.js
67 lines (58 loc) · 3.12 KB
/
JDTaskV2P.cookie.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
64
65
66
67
// @grant require
// @grant nodejs
/*
此文件为Node.js &elecV2P专用。其他用户请忽略
使用V2P函数$store处理进度cookie,并存储一个cookie值作为V2P执行的环境变量JD_COOKIE
CookiesJDV2P值成功保存→script/Shell/JDCookies.txt,文件用于py脚本
*/
const fs = require('fs')
///////////////////////////////
let CookiesJD = $store.get('CookiesJD', 'array')
let CookieJD = $store.get('CookieJD', 'string')
let CookieJD2 = $store.get('CookieJD2', 'string')
let CookiesJDV2P = $store.get('CookiesJDV2P', 'string')
let CookiesJDCARV2P = $store.get('CookiesJDCARV2P', 'string')
/////////////////////////////// 定时更新执行任务的cookie值:CookiesJDV2P
if (CookiesJD && CookieJD && CookieJD2) {
const CookiesJDList = CookiesJD.map(item => item.cookie)
CookiesJDList.unshift(CookieJD2);
CookiesJDList.unshift(CookieJD);
const cookieV2P1 = CookiesJDList.join("&");
$store.put(cookieV2P1, 'CookiesJDV2P', 'string') ? console.log("🌟 CookiesJDV2P转换成功!请到store/cookie 常量储存管理查看") : console.log("CookiesJDV2P转换失败!❌");
}else if (CookiesJD) {
const CookiesJDList = CookiesJD.map(item => item.cookie)
const cookieV2P1 = CookiesJDList.join("&");
$store.put(cookieV2P1, 'CookiesJDV2P', 'string') ? console.log("🌟 CookiesJDV2P转换成功!请到store/cookie 常量储存管理查看") : console.log("CookiesJDV2P转换失败!❌");
} else {
if (CookieJD2) {
const CookiesJDList = new Array();
CookiesJDList.unshift(CookieJD2);
CookiesJDList.unshift(CookieJD);
const cookieV2P2 = CookiesJDList.join("&");
$store.put(cookieV2P2, 'CookiesJDV2P', 'string') ? console.log("🌟 CookiesJDV2P转换成功!请到store/cookie 常量储存管理查看") : console.log("CookiesJDV2P转换失败!❌");
} else {
$store.put(CookieJD, 'CookiesJDV2P', 'string') ? console.log("🌟 CookiesJDV2P转换成功!请到store/cookie 常量储存管理查看") : console.log("CookiesJDV2P转换失败!❌");
}
}
/////////////////////////////// Python脚本:JDCookies.txt文件生成
if (CookiesJDV2P) {
const content = CookiesJDV2P.split("&").join("\n");
fs.writeFile('/usr/local/app/script/Shell/JDCookies.txt', content, err => {
if (err) {
console.error(err)
return
}else {
console.log("🌟 Python脚本cookie值已经格式化!已保存到script/Shell/JDCookies.txt");
}
//文件写入成功。
})
/////////////////////////////// 助力任务的环境变量:PtPinJDV2P_PY &PtPinJDV2P
const ptpinList = new Array();
const CookiesJDV2PList = CookiesJDV2P.split("&");
for (let i = 0; i < CookiesJDV2PList.length; i++) {
ptpinList.push(CookiesJDV2PList[i].split(";")[1].replace(/pt_pin=/,""))
}
const ptpinsValue = ptpinList.join("&");
$store.put(ptpinsValue, 'PtPinJDV2P', 'string') ? console.log("🌟 PtPinJDV2P转换成功!请到store/cookie 常量储存管理查看") : console.log("PtPinJDV2P转换失败!❌");
$store.put(ptpinList, 'PtPinJDV2P_PY', 'string') ? console.log("🌟 PtPinJDV2P_PY转换成功!请到store/cookie 常量储存管理查看") : console.log("PtPinJDV2P_PY转换失败!❌");
}