-
Notifications
You must be signed in to change notification settings - Fork 1k
/
jdCookie.js
33 lines (30 loc) · 1.01 KB
/
jdCookie.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
const fs = require('fs')
const dotenv = require('dotenv')
let CookieJDs = []
try {
process.chdir(__dirname)
fs.accessSync('.env', fs.constants.R_OK)
dotenv.config()
} catch (e) {
}
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 {
CookieJDs = [process.env.JD_COOKIE];
}
}
if (JSON.stringify(process.env).indexOf('GITHUB') > -1) {
process.exit(0);
}
CookieJDs = [...new Set(CookieJDs.filter(item => !!item))]
if (!require.main.filename.includes('.ts')) {
console.log(`\n====================共${CookieJDs.length}个京东账号Cookie=========\n`);
console.log(`================== ${new Date().toLocaleString('zh-CN', {timeZone: 'Asia/Shanghai'})} =====================\n`)
}
for (let i = 0; i < CookieJDs.length; i++) {
const index = (i + 1 === 1) ? '' : (i + 1);
exports['CookieJD' + index] = CookieJDs[i].trim();
}