jd_scripts/jdCookie.js

35 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-11-10 09:29:58 +08:00
/*
此文件为Node.js专用其他用户请忽略
*/
//此处填写京东账号cookie。
let CookieJDs = [
2020-11-10 10:01:30 +08:00
'',//账号一ck,例:pt_key=XXX;pt_pin=XXX;
'',//账号二ck,例:pt_key=XXX;pt_pin=XXX;如有更多,依次类推
2020-11-10 09:29:58 +08:00
]
2021-01-16 17:10:19 +08:00
// 判断环境变量里面是否有京东ck
2020-11-10 09:29:58 +08:00
if (process.env.JD_COOKIE) {
if (process.env.JD_COOKIE.indexOf('&') > -1) {
CookieJDs = process.env.JD_COOKIE.split('&');
} else if (process.env.JD_COOKIE.indexOf('\n') > -1) {
CookieJDs = process.env.JD_COOKIE.split('\n');
} else {
2020-11-19 16:06:05 +08:00
CookieJDs = [process.env.JD_COOKIE];
2020-11-10 09:29:58 +08:00
}
}
2021-01-16 17:10:19 +08:00
if (JSON.stringify(process.env).indexOf('GITHUB')>-1) {
console.log(`请勿使用github action运行此脚本,无论你是从你自己的私库还是其他哪里拉取的源代码,都会导致我被封号\n`);
!(async () => {
await require('./sendNotify').sendNotify('提醒', `请勿使用github action、滥用github资源会封我仓库以及账号`)
await process.exit(0);
})()
}
2021-02-28 17:34:24 +08:00
CookieJDs = [...new Set(CookieJDs.filter(item => !!item))]
2021-03-16 16:05:01 +08:00
console.log(`\n====================共${CookieJDs.length}个京东账号Cookie=========\n`);
2021-01-04 17:22:19 +08:00
console.log(`==================脚本执行- 北京时间(UTC+8)${new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString()}=====================\n`)
2021-03-12 11:50:06 +08:00
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {};
2020-11-10 09:29:58 +08:00
for (let i = 0; i < CookieJDs.length; i++) {
2021-03-16 16:05:01 +08:00
if (!CookieJDs[i].match(/pt_pin=(.+?);/) || !CookieJDs[i].match(/pt_key=(.+?);/)) console.log(`\n提示:京东cookie 【${CookieJDs[i]}】填写不规范,可能会影响部分脚本正常使用。正确格式为: pt_key=xxx;pt_pin=xxx;(分号;不可少)\n`);
2020-11-10 09:29:58 +08:00
const index = (i + 1 === 1) ? '' : (i + 1);
2021-01-05 09:20:26 +08:00
exports['CookieJD' + index] = CookieJDs[i].trim();
2020-11-10 09:29:58 +08:00
}