1
0
mirror of https://github.com/6dylan6/jdpro.git synced 2026-05-02 02:36:40 +08:00
This commit is contained in:
dylan
2023-09-26 23:58:18 +08:00
parent 94cd789c68
commit 2761a3da36
+20 -6
View File
@@ -6,7 +6,7 @@ let CookieJDs = [
'',//账号一ck,例:pt_key=XXX;pt_pin=XXX;
'',//账号二ck,例:pt_key=XXX;pt_pin=XXX;如有更多,依次类推
]
let IP='';
let IP = '';
// 判断环境变量里面是否有京东ck
if (process.env.JD_COOKIE) {
if (process.env.JD_COOKIE.indexOf('&') > -1) {
@@ -17,7 +17,7 @@ if (process.env.JD_COOKIE) {
CookieJDs = [process.env.JD_COOKIE];
}
}
if (JSON.stringify(process.env).indexOf('GITHUB')>-1) {
if (JSON.stringify(process.env).indexOf('GITHUB') > -1) {
console.log(`请勿使用github action运行此脚本,无论你是从你自己的私库还是其他哪里拉取的源代码,都会导致我被封号\n`);
!(async () => {
await require('./sendNotify').sendNotify('提醒', `请勿使用github action、滥用github资源会封我仓库以及账号`)
@@ -32,9 +32,9 @@ if (JSON.stringify(process.env).indexOf('GITHUB')>-1) {
// } catch (e) { }
//})()
CookieJDs = [...new Set(CookieJDs.filter(item => !!item))]
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {};
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { };
console.log(`\n====================共${CookieJDs.length}个京东账号Cookie=================\n`);
console.log(`============脚本执行时间:${formatdate(new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000))}=============\n`)
console.log(`============脚本执行时间:${formatdate(new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000))}=============\n`)
console.log('>>>>>>>>>>>>>>6Dylan6 提示:任务正常运行中>>>>>>>>>>>>>>>\n')
for (let i = 0; i < CookieJDs.length; i++) {
if (!CookieJDs[i].match(/pt_pin=(.+?);/) || !CookieJDs[i].match(/pt_key=(.+?);/)) console.log(`\n提示:京东cookie 【${CookieJDs[i]}】填写不规范,可能会影响部分脚本正常使用。正确格式为: pt_key=xxx;pt_pin=xxx;(分号;不可少)\n`);
@@ -42,8 +42,22 @@ for (let i = 0; i < CookieJDs.length; i++) {
const index = (i + 1 === 1) ? '' : (i + 1);
exports['CookieJD' + index] = CookieJDs[i].trim();
}
let permit = process.env.PERMIT_JS ? process.env.PERMIT_JS.split('&') : '';
if (process.env.DP_POOL) {
if (permit && permit.filter(x => process.mainModule.filename.includes(x)).length != 0) {
try {
require("global-agent/bootstrap");
global.GLOBAL_AGENT.HTTP_PROXY = process.env.DP_POOL;
console.log(`\n---------------使用代理池模式---------------\n`);
} catch {
throw new Error(`请安装global-agent依赖,才能启用代理!`);
}
} else {
}
}
function getIP() {
const https = require('https');
return new Promise((resolve, reject) => {
@@ -62,7 +76,7 @@ function getIP() {
let tmp = '';
res.on('error', reject);
res.on('data', d => tmp += d);
res.on('end',() => resolve(tmp));
res.on('end', () => resolve(tmp));
});
req.on('error', reject);
@@ -82,7 +96,7 @@ function SetShareCodesEnv(nameChinese = "", nameConfig = "", envName = "") {
// rawCodeConfig = ini.parse(fs.readFileSync(shareCodeLogPath, 'utf-8'))
// 使用env模块
require('dotenv').config({path: shareCodeLogPath})
require('dotenv').config({ path: shareCodeLogPath })
rawCodeConfig = process.env
}