mirror of
https://github.com/shufflewzc/faker2.git
synced 2025-04-23 10:58:44 +08:00
update
This commit is contained in:
parent
75bc0a670f
commit
d1fbd0d555
688
jd_try.js
688
jd_try.js
@ -1,14 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* 京东试用, 只是一个DEMO
|
* 京东试用, 只是一个DEMO
|
||||||
|
|
||||||
0 18 * * * jd_try.js
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
const qs = require('qs');
|
const qs = require('qs');
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const common = require('./utils/Rebels_jdCommon')
|
const common = require('./utils/Rebels_jdCommon')
|
||||||
const {H5st} = require("./utils/h5st4.4.0_lite");
|
|
||||||
const {SmashUtils} = require("./utils/smashUtils");
|
const {SmashUtils} = require("./utils/smashUtils");
|
||||||
|
const {setBaseCookie} = require("./utils/baseCookie");
|
||||||
|
|
||||||
const $ = new Env("京东试用");
|
const $ = new Env("京东试用");
|
||||||
const URL = "https://api.m.jd.com/client.action";
|
const URL = "https://api.m.jd.com/client.action";
|
||||||
let trialActivityIdList = [];
|
let trialActivityIdList = [];
|
||||||
@ -33,7 +31,7 @@ let args_xh = {
|
|||||||
/*
|
/*
|
||||||
* 控制一次最多跑几个号,默认10个
|
* 控制一次最多跑几个号,默认10个
|
||||||
*/
|
*/
|
||||||
try_num: process.env.JD_TRY_NUM * 1 || 10, /*
|
try_num: process.env.JD_TRY_NUM * 1 || 10000, /*
|
||||||
* 控制是否输出当前环境变量设置,默认为false
|
* 控制是否输出当前环境变量设置,默认为false
|
||||||
* 环境变量名称:XH_TRY_ENV
|
* 环境变量名称:XH_TRY_ENV
|
||||||
*/
|
*/
|
||||||
@ -136,9 +134,7 @@ let args_xh = {
|
|||||||
$.log("\n第一次运行请务必运行一次【依赖安装(jd_indeps.sh)】脚本\n避免出现一些奇怪的问题,遇到问题请先看脚本内注释\n频道:https://t.me/zhouya47\n");
|
$.log("\n第一次运行请务必运行一次【依赖安装(jd_indeps.sh)】脚本\n避免出现一些奇怪的问题,遇到问题请先看脚本内注释\n频道:https://t.me/zhouya47\n");
|
||||||
await requireConfig();
|
await requireConfig();
|
||||||
if (!$.cookiesArr[0]) {
|
if (!$.cookiesArr[0]) {
|
||||||
$.msg($.name, "【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取", "https://bean.m.jd.com/", {
|
console.log($.name, "【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取", "https://bean.m.jd.com/");
|
||||||
"open-url": "https://bean.m.jd.com/",
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
args_xh.tabId = args_xh.tabId.sort(() => 0.5 - Math.random());
|
args_xh.tabId = args_xh.tabId.sort(() => 0.5 - Math.random());
|
||||||
@ -148,59 +144,22 @@ let args_xh = {
|
|||||||
$.UserName = decodeURIComponent($.cookie.match(/pt_pin=(.+?);/) && $.cookie.match(/pt_pin=(.+?);/)[1]);
|
$.UserName = decodeURIComponent($.cookie.match(/pt_pin=(.+?);/) && $.cookie.match(/pt_pin=(.+?);/)[1]);
|
||||||
$.index = i + 1;
|
$.index = i + 1;
|
||||||
$.isLogin = true;
|
$.isLogin = true;
|
||||||
$.nickName = "";
|
|
||||||
$.userAgent = common.genUA($.UserName);
|
$.userAgent = common.genUA($.UserName);
|
||||||
// await totalBean();
|
console.log(`\n开始【京东账号${$.index}】${$.UserName}\n`);
|
||||||
console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`);
|
await try_rafflecount();
|
||||||
$.except = false;
|
$.except = false;
|
||||||
if (args_xh.except.includes($.UserName)) {
|
if (args_xh.except.includes($.UserName)) {
|
||||||
console.log(`跳过账号:${$.nickName || $.UserName}`);
|
console.log(`跳过账号:${$.UserName}`);
|
||||||
$.except = true;
|
$.except = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$.isLogin) {
|
if (!$.isLogin) {
|
||||||
$.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {
|
console.log($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.UserName}`);
|
||||||
"open-url": "https://bean.m.jd.com/bean/signIndex.action",
|
|
||||||
});
|
|
||||||
await $.notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`);
|
await $.notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$.ParamsSignLite = new H5st("https://prodev.m.jd.com/mall/active/3C751WNneAUaZ8Lw8xYN7cbSE8gm/index.html?ids=501730512%2C501676150&navh=49&stath=37&tttparams=wUQ86eyJhZGRyZXNzSWQiOjAsImRMYXQiOjAsImRMbmciOjAsImdMYXQiOiIzOS45NDQwOTMiLCJnTG5nIjoiMTE2LjQ4MjI3NiIsImdwc19hcmVhIjoiMF8wXzBfMCIsImxhdCI6MCwibG5nIjowLCJtb2RlbCI6IlJlZG1pIE5vdGUgMTJUIFBybyIsInBvc0xhdCI6IjM5Ljk0NDA5MyIsInBvc0xuZyI6IjExNi40ODIyNzYiLCJwcnN0YXRlIjoiMCIsInVlbXBzIjoiMC0wLTAiLCJ1bl9hcmVhIjoiMV83Ml81NTY3NF8wIn50%3D&preventPV=1&forceCurrentView=1",
|
|
||||||
$.cookie,
|
|
||||||
$.userAgent, {
|
|
||||||
debug: false,
|
|
||||||
appId: "35fa0",
|
|
||||||
});
|
|
||||||
$.smashUtils = new SmashUtils(
|
|
||||||
'https://prodev.m.jd.com/mall/active/3mpGVQDhvLsMvKfZZumWPQyWt83L/index.html?activityId=501742184&sku=10097544183544',
|
|
||||||
$.cookie,
|
|
||||||
$.userAgent
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
$.smashUtils["getLocalData"]();
|
|
||||||
$.smashUtils["getAppOs"]();
|
|
||||||
$.smashUtils.getBlog();
|
|
||||||
$.smashUtils["getFpv"]();
|
|
||||||
await $.smashUtils.getInfo();
|
|
||||||
$.smashUtils.setjoyyaCookie("init");
|
|
||||||
$.smashUtils.getJrInfo();
|
|
||||||
} catch (e) {
|
|
||||||
$.smashUtils.getInterfaceData({
|
|
||||||
funcName: "other",
|
|
||||||
real_msg: "initial",
|
|
||||||
error_msg: e && e.message
|
|
||||||
})
|
|
||||||
}
|
|
||||||
await $.smashUtils.initial({
|
|
||||||
appId: "50170_", debug: !1, preRequest: !0, onSign: function (e) {
|
|
||||||
e.code, e.message, e.data
|
|
||||||
}, onRequestTokenRemotely: function (e) {
|
|
||||||
e.code, e.message
|
|
||||||
}, onRequestToken: function (e) {
|
|
||||||
e.code, e.message
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
await initSmashUtils();
|
||||||
|
|
||||||
$.totalTry = 0;
|
$.totalTry = 0;
|
||||||
$.totalSuccess = 0;
|
$.totalSuccess = 0;
|
||||||
@ -254,16 +213,14 @@ let args_xh = {
|
|||||||
await showMsg();
|
await showMsg();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($.isNode()) {
|
if ($.index % args_xh.sendNum === 0) {
|
||||||
if ($.index % args_xh.sendNum === 0) {
|
$.sentNum++;
|
||||||
$.sentNum++;
|
console.log(`正在进行第 ${$.sentNum} 次发送通知,发送数量:${args_xh.sendNum}`);
|
||||||
console.log(`正在进行第 ${$.sentNum} 次发送通知,发送数量:${args_xh.sendNum}`);
|
await $.notify.sendNotify(`${$.name}`, `${notifyMsg}`);
|
||||||
await $.notify.sendNotify(`${$.name}`, `${notifyMsg}`);
|
notifyMsg = "";
|
||||||
notifyMsg = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($.isNode() && $.except === false) {
|
if ($.except === false) {
|
||||||
if ($.cookiesArr.length - $.sentNum * args_xh.sendNum < args_xh.sendNum && notifyMsg.length != 0) {
|
if ($.cookiesArr.length - $.sentNum * args_xh.sendNum < args_xh.sendNum && notifyMsg.length != 0) {
|
||||||
console.log(`正在进行最后一次发送通知,发送数量:${$.cookiesArr.length - $.sentNum * args_xh.sendNum}`);
|
console.log(`正在进行最后一次发送通知,发送数量:${$.cookiesArr.length - $.sentNum * args_xh.sendNum}`);
|
||||||
await $.notify.sendNotify(`${$.name}`, `${notifyMsg}`);
|
await $.notify.sendNotify(`${$.name}`, `${notifyMsg}`);
|
||||||
@ -278,24 +235,17 @@ let args_xh = {
|
|||||||
|
|
||||||
function requireConfig() {
|
function requireConfig() {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
$.notify = $.isNode() ? require("./sendNotify") : {
|
$.notify = require("./sendNotify");
|
||||||
sendNotify: async () => {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
//获取 Cookies
|
//获取 Cookies
|
||||||
$.cookiesArr = [];
|
$.cookiesArr = [];
|
||||||
if ($.isNode()) {
|
//Node.js用户请在jdCookie.js处填写京东ck;
|
||||||
//Node.js用户请在jdCookie.js处填写京东ck;
|
const jdCookieNode = require("./jdCookie.js");
|
||||||
const jdCookieNode = require("./jdCookie.js");
|
Object.keys(jdCookieNode).forEach((item) => {
|
||||||
Object.keys(jdCookieNode).forEach((item) => {
|
if (jdCookieNode[item]) $.cookiesArr.push(jdCookieNode[item]);
|
||||||
if (jdCookieNode[item]) $.cookiesArr.push(jdCookieNode[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 = () => {
|
};
|
||||||
};
|
|
||||||
} else {
|
|
||||||
//IOS等用户直接用NobyDa的jd $.cookie
|
|
||||||
$.cookiesArr = [$.getdata("CookieJD"), $.getdata("CookieJD2"), ...jsonParse($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item);
|
|
||||||
}
|
|
||||||
for (let keyWord of $.innerKeyWords) args_xh.titleFilters.push(keyWord);
|
for (let keyWord of $.innerKeyWords) args_xh.titleFilters.push(keyWord);
|
||||||
console.log(`共${$.cookiesArr.length}个京东账号\n`);
|
console.log(`共${$.cookiesArr.length}个京东账号\n`);
|
||||||
if (args_xh.env) {
|
if (args_xh.env) {
|
||||||
@ -321,163 +271,23 @@ function requireConfig() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取商品列表并且过滤
|
|
||||||
async function try_feedsList(tabId, page) {
|
|
||||||
const body = {
|
|
||||||
functionId: "try_SpecFeedList",
|
|
||||||
appid: "newtry",
|
|
||||||
body: JSON.stringify({
|
|
||||||
tabId: tabId + "",
|
|
||||||
page: page,
|
|
||||||
version: 2,
|
|
||||||
source: "default",
|
|
||||||
client: "outer",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const h5st = await $.ParamsSignLite.sign(body)
|
|
||||||
|
|
||||||
try {
|
|
||||||
const {data} = await api({
|
|
||||||
method: "POST",
|
|
||||||
url: `https://api.m.jd.com/client.action`,
|
|
||||||
headers: {
|
|
||||||
"content-type": "application/x-www-form-urlencoded",
|
|
||||||
origin: "https://prodev.m.jd.com",
|
|
||||||
Referer: "https://prodev.m.jd.com/mall/active/3C751WNneAUaZ8Lw8xYN7cbSE8gm/index.html?ids=501730512%2C501676150&navh=49&stath=37&tttparams=wUQ86eyJhZGRyZXNzSWQiOjAsImRMYXQiOjAsImRMbmciOjAsImdMYXQiOiIzOS45NDQwOTMiLCJnTG5nIjoiMTE2LjQ4MjI3NiIsImdwc19hcmVhIjoiMF8wXzBfMCIsImxhdCI6MCwibG5nIjowLCJtb2RlbCI6IlJlZG1pIE5vdGUgMTJUIFBybyIsInBvc0xhdCI6IjM5Ljk0NDA5MyIsInBvc0xuZyI6IjExNi40ODIyNzYiLCJwcnN0YXRlIjoiMCIsInVlbXBzIjoiMC0wLTAiLCJ1bl9hcmVhIjoiMV83Ml81NTY3NF8wIn50%3D&preventPV=1&forceCurrentView=1",
|
|
||||||
"User-Agent": $.userAgent,
|
|
||||||
"x-referer-page": "https://prodev.m.jd.com/mall/active/3C751WNneAUaZ8Lw8xYN7cbSE8gm/index.html"
|
|
||||||
},
|
|
||||||
data: qs.stringify({
|
|
||||||
...body,
|
|
||||||
h5st: h5st.h5st
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
let tempKeyword = ``;
|
|
||||||
if (data.data) {
|
|
||||||
console.log(`第 ${size++} 次获取试用商品成功,tabId:${args_xh.tabId[$.nowTabIdIndex]} 的 第 ${page} 页`);
|
|
||||||
console.log(`获取到商品 ${data.data.feedList.length} 条`);
|
|
||||||
for (let item of data.data.feedList) {
|
|
||||||
if (item.applyNum === null) {
|
|
||||||
args_xh.printLog ? console.log(`商品未到申请时间:${item.skuTitle}\n`) : "";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (trialActivityIdList.length >= args_xh.maxLength) {
|
|
||||||
console.log("商品列表长度已满.结束获取");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (item.applyState === 1) {
|
|
||||||
args_xh.printLog ? console.log(`商品已申请试用:${item.skuTitle}\n`) : "";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (item.applyState !== null) {
|
|
||||||
args_xh.printLog ? console.log(`商品状态异常,未找到skuTitle\n`) : "";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (args_xh.passZhongCao) {
|
|
||||||
$.isPush = true;
|
|
||||||
if (item.tagList.length !== 0) {
|
|
||||||
for (let itemTag of item.tagList) {
|
|
||||||
if (itemTag.tagType === 3) {
|
|
||||||
args_xh.printLog ? console.log("商品被过滤,该商品是种草官专属") : "";
|
|
||||||
$.isPush = false;
|
|
||||||
break;
|
|
||||||
} else if (itemTag.tagType === 5) {
|
|
||||||
args_xh.printLog ? console.log("商品被跳过,该商品是付费试用!") : "";
|
|
||||||
$.isPush = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (item.skuTitle && $.isPush) {
|
|
||||||
args_xh.printLog ? console.log(`检测 tabId:${args_xh.tabId[$.nowTabIdIndex]} 的 第 ${page} 页 第 ${$.nowItem++ + 1} 个商品\n${item.skuTitle}`) : "";
|
|
||||||
if (args_xh.whiteList) {
|
|
||||||
if (args_xh.whiteListKeywords.some((fileter_word) => item.skuTitle.includes(fileter_word))) {
|
|
||||||
args_xh.printLog ? console.log(`商品白名单通过,将加入试用组,trialActivityId为${item.trialActivityId}\n`) : "";
|
|
||||||
trialActivityIdList.push(item.trialActivityId);
|
|
||||||
trialActivityTitleList.push(item.skuTitle);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tempKeyword = ``;
|
|
||||||
if (parseFloat(item.jdPrice) <= args_xh.jdPrice) {
|
|
||||||
args_xh.printLog ? console.log(`商品被过滤,商品价格 ${item.jdPrice} < ${args_xh.jdPrice} \n`) : "";
|
|
||||||
} else if (parseFloat(item.supplyNum) < args_xh.minSupplyNum && item.supplyNum !== null) {
|
|
||||||
args_xh.printLog ? console.log(`商品被过滤,提供申请的份数小于预设申请的份数 \n`) : "";
|
|
||||||
} else if (parseFloat(item.applyNum) > args_xh.applyNumFilter && item.applyNum !== null) {
|
|
||||||
args_xh.printLog ? console.log(`商品被过滤,已申请人数大于预设的${args_xh.applyNumFilter}人 \n`) : "";
|
|
||||||
} else if (item.jdPrice === null) {
|
|
||||||
args_xh.printLog ? console.log(`商品被过滤,商品无价,不能申请 \n`) : "";
|
|
||||||
} else if (parseFloat(item.trialPrice) > args_xh.trialPrice) {
|
|
||||||
args_xh.printLog ? console.log(`商品被过滤,商品试用价大于预设试用价 \n`) : "";
|
|
||||||
} else if (args_xh.titleFilters.some((fileter_word) => (item.skuTitle.includes(fileter_word) ? (tempKeyword = fileter_word) : ""))) {
|
|
||||||
args_xh.printLog ? console.log(`商品被过滤,含有关键词 ${tempKeyword}\n`) : "";
|
|
||||||
} else {
|
|
||||||
args_xh.printLog ? console.log(`商品通过,加入试用组,trialActivityId为${item.trialActivityId}\n`) : "";
|
|
||||||
if (trialActivityIdList.indexOf(item.trialActivityId) === -1) {
|
|
||||||
trialActivityIdList.push(item.trialActivityId);
|
|
||||||
trialActivityTitleList.push(item.skuTitle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ($.isPush !== false) {
|
|
||||||
console.error("skuTitle解析异常");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(`当前试用组长度为:${trialActivityIdList.length}`);
|
|
||||||
console.log(`下一页状态:${data.data.hasNext}`);
|
|
||||||
if (data.data.hasNext === false) {
|
|
||||||
if ($.nowTabIdIndex < args_xh.tabId.length) {
|
|
||||||
$.nowTabIdIndex++;
|
|
||||||
$.nowPage = 1;
|
|
||||||
$.nowItem = 1;
|
|
||||||
$.retrynum = 0;
|
|
||||||
} else {
|
|
||||||
// 这下是真的没了
|
|
||||||
$.retrynum = 999
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$.nowPage++;
|
|
||||||
$.retrynum = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log(`💩 获得试用列表失败: ${data.message}`);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
if (e.message === `Request failed with status code 403`) {
|
|
||||||
$.retrynum++;
|
|
||||||
if ($.retrynum === 4) {
|
|
||||||
$.isForbidden = true;
|
|
||||||
$.log("多次尝试失败,换个时间再试!");
|
|
||||||
} else {
|
|
||||||
console.log(`请求失败,第 ${$.retrynum} 次重试`);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log(e.message);
|
|
||||||
console.log(`${$.name} API请求失败,请检查网路重试`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function try_apply(title, activityId) {
|
async function try_apply(title, activityId) {
|
||||||
console.log(`申请试用商品提交中...`);
|
console.log(`申请试用商品提交中...`);
|
||||||
args_xh.printLog ? console.log(`商品:${title}`) : "";
|
args_xh.printLog ? console.log(`商品:${title}`) : "";
|
||||||
args_xh.printLog ? console.log(`id为:${activityId}`) : "";
|
args_xh.printLog ? console.log(`id为:${activityId}`) : "";
|
||||||
|
|
||||||
const body = {
|
const sign = await h5stSign({
|
||||||
functionId: "try_apply",
|
functionId: "try_apply",
|
||||||
appid: "newtry",
|
appid: "newtry",
|
||||||
body: JSON.stringify({
|
body: {
|
||||||
"activityId": activityId * 1,
|
"activityId": Number(activityId),
|
||||||
})
|
}
|
||||||
}
|
}, '20240616220153007;z5mm6z6ny9tgiz62;35fa0;tk03wbfcb1c2841lMisyeDJkVDljOEydj-ckiCHjIYSJ1W7xoMh0tq-jHSpwPgeelBG4C-99GSgmBbeb960pVPkbRRDb;b9425397f84d9562eb929109a424b25050f5d16849dd8187530792a36f092a5e;4.7;1718546513007;UOm5YmIikru95F6Y2j_aOPloesE0LYNBvUyh1hyaUIEa2WGNlLIeoVRcsMZcqWgWTFnOjkwc0Wfsw34nc-n9LANGlLShDUmeWeNTVNWwHWjEND1qe6qHqLYy0XHvOCOii9WbK167wpxvZ7sTBf76L627d2I2lmcmSx5t-6Pt51XG-yYCin67tQis5pE7qPpNgw0omdQtBapqp0mhA4VKFTIPQeLwuj4m4hNfXrS27fXA45dct9R-umfCHpCwN3M6IJtsi82_J7zHO0GM4sO5aSrYqaojrElDcxdbe_mKEGU7xKTMSEQR3EgqiB3JzxggCShAb1gPplWROuBzocQkrL3rpnz3FODrayk0QdOvSsXuaVHTn1DhnMleaN-6lDzlBLKzhuS0aea40k6Z2F1zEONM88GH6ptzhVQpiVLWRBbxUUGgw5S-Sid8dk9mJ3j46ekXRsHabaG8rl7KlrhCth7O')
|
||||||
|
|
||||||
const h5st = await $.ParamsSignLite.sign(body)
|
setBaseCookie();
|
||||||
const joylog = await $.smashUtils.sign({
|
const joylog = await $.smashUtils.sign({
|
||||||
...body,
|
...sign.body
|
||||||
h5st: h5st.h5st
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -586,7 +396,7 @@ function try_MyTrials(page, selected) {
|
|||||||
|
|
||||||
async function showMsg() {
|
async function showMsg() {
|
||||||
let message = ``;
|
let message = ``;
|
||||||
message += `👤 京东账号${$.index} ${$.nickName || $.UserName}\n`;
|
message += `👤 京东账号${$.index} ${$.UserName}\n`;
|
||||||
if ($.totalSuccess !== 0 && $.totalTry !== 0) {
|
if ($.totalSuccess !== 0 && $.totalTry !== 0) {
|
||||||
message += `🎉 本次提交申请:${$.totalSuccess}/${$.totalTry}个商品🛒\n`;
|
message += `🎉 本次提交申请:${$.totalSuccess}/${$.totalTry}个商品🛒\n`;
|
||||||
message += `🎉 ${$.successNum}个商品待领取\n`;
|
message += `🎉 ${$.successNum}个商品待领取\n`;
|
||||||
@ -601,70 +411,240 @@ async function showMsg() {
|
|||||||
message += `🗑 ${$.giveupNum}个商品已放弃\n\n`;
|
message += `🗑 ${$.giveupNum}个商品已放弃\n\n`;
|
||||||
}
|
}
|
||||||
if (!args_xh.jdNotify || args_xh.jdNotify === "false") {
|
if (!args_xh.jdNotify || args_xh.jdNotify === "false") {
|
||||||
$.msg($.name, ``, message, {
|
console.log($.name, message);
|
||||||
"open-url": "https://try.m.jd.com/user",
|
notifyMsg += `${message}`;
|
||||||
});
|
|
||||||
if ($.isNode()) notifyMsg += `${message}`;
|
|
||||||
} else {
|
} else {
|
||||||
console.log(message);
|
console.log(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function totalBean() {
|
/**
|
||||||
return new Promise(async (resolve) => {
|
* 获取账号剩余次数,目前每个账号只有5次
|
||||||
const options = {
|
*/
|
||||||
url: `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, headers: {
|
async function try_rafflecount() {
|
||||||
Accept: "application/json,text/plain, */*",
|
const options = {
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
method: 'POST',
|
||||||
"Accept-Encoding": "gzip, deflate, br",
|
url: 'https://api.m.jd.com/client.action',
|
||||||
"Accept-Language": "zh-cn",
|
headers: {
|
||||||
Connection: "keep-alive",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
Cookie: $.cookie,
|
Cookie: $.cookie,
|
||||||
Referer: "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2",
|
Origin: 'https://prodev.m.jd.com',
|
||||||
"User-Agent": $.userAgent,
|
Referer: "https://prodev.m.jd.com/mall/active/3C751WNneAUaZ8Lw8xYN7cbSE8gm/index.html",
|
||||||
}, timeout: 10000,
|
"User-Agent": $.userAgent,
|
||||||
};
|
},
|
||||||
$.restApi(options, (err, resp, data) => {
|
data: qs.stringify({
|
||||||
try {
|
appid: 'ysas-new',
|
||||||
if (err) {
|
functionId: 'try_rafflecount',
|
||||||
console.log(`${JSON.stringify(err)}`);
|
body: JSON.stringify({"previewTime": ""})
|
||||||
console.log(`${$.name} API请求失败,请检查网路重试`);
|
})
|
||||||
} else {
|
};
|
||||||
if (data) {
|
|
||||||
if (data["retcode"] === 13) {
|
try {
|
||||||
$.isLogin = false; //cookie过期
|
const {data} = await axios.request(options);
|
||||||
return;
|
|
||||||
}
|
if (data.code !== '0') {
|
||||||
if (data["retcode"] === 0) {
|
$.isLogin = false;
|
||||||
$.nickName = (data["base"] && data["base"].nickname) || $.UserName;
|
console.log(`${data.message}`);
|
||||||
} else {
|
return;
|
||||||
$.nickName = $.UserName;
|
}
|
||||||
}
|
console.log(`${data.data.promptDesc}${data.data.remainingNum}`)
|
||||||
} else {
|
if (data.data.remainingNum === 0) {
|
||||||
console.log(`京东服务器返回空数据`);
|
args_xh.except.push($.UserName);
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
} catch (e) {
|
console.log(e)
|
||||||
$.logErr(e, resp);
|
}
|
||||||
} finally {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function jsonParse(str) {
|
async function initSmashUtils() {
|
||||||
if (typeof str == "string") {
|
try {
|
||||||
try {
|
$.smashUtils = new SmashUtils(
|
||||||
return JSON.parse(str);
|
'https://prodev.m.jd.com/mall/active/3mpGVQDhvLsMvKfZZumWPQyWt83L/index.html?activityId=501742184&sku=10097544183544',
|
||||||
} catch (e) {
|
$.cookie,
|
||||||
console.log(e);
|
$.userAgent
|
||||||
$.msg($.name, "", "请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie");
|
);
|
||||||
return [];
|
$.smashUtils["getLocalData"]();
|
||||||
|
$.smashUtils["getAppOs"]();
|
||||||
|
$.smashUtils.getBlog();
|
||||||
|
$.smashUtils["getFpv"]();
|
||||||
|
await $.smashUtils.getInfo();
|
||||||
|
$.smashUtils.setjoyyaCookie("init");
|
||||||
|
$.smashUtils.getJrInfo();
|
||||||
|
} catch (e) {
|
||||||
|
$.smashUtils.getInterfaceData({
|
||||||
|
funcName: "other",
|
||||||
|
real_msg: "initial",
|
||||||
|
error_msg: e && e.message
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await $.smashUtils.initial({
|
||||||
|
appId: "50170_", debug: !1, preRequest: !0, onSign: function (e) {
|
||||||
|
e.code, e.message, e.data
|
||||||
|
}, onRequestTokenRemotely: function (e) {
|
||||||
|
e.code, e.message
|
||||||
|
}, onRequestToken: function (e) {
|
||||||
|
e.code, e.message
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取商品列表并且过滤
|
||||||
|
*/
|
||||||
|
async function try_feedsList(tabId, page) {
|
||||||
|
const sign = await h5stSign({
|
||||||
|
functionId: 'try_SpecFeedList',
|
||||||
|
appid: 'newtry',
|
||||||
|
body: {
|
||||||
|
tabId: String(tabId),
|
||||||
|
page: Number(page),
|
||||||
|
version: 2,
|
||||||
|
source: 'default',
|
||||||
|
client: 'outer',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'20240616184606839;z55tttgm69iy5gt3;35fa0;tk03w73961a5c41lMngyKzN4M3NZ9v6YiMHcUZzf-P--kImKPJxWOBADZAdB124IKB0-tMni0SNFkS-rY6y9NCO0kyT7;686da69d2b902071260b372ec783208bd23e2891bbe8d092fa88322f9d4af96c;4.7;1718534766839;UOGVDoANEFUxNUCVdiY9pn3sfPETGURG3lMUAqYwv2f3puLbYE75Mz4VKBAHMO4-qgP543iYlyjcq4SLHWq3kC4dKsNKK2LuLn_wCRQ-NRsgMdHsimMATwP_Kst5YN3fzVHakZmNBTqAAyt8S-19if5CXSlcYwOsVzmu7vGrSB3kHSfHw3e3Yl05nVUm_4l_VY2omdQtBapqp0mhA4VKFTIPQeLwuj4m4hNfXrS27fXA45dct9R-umfCHpCwN3M6IJtsi82_J7zHO0GM4sO5aSrYqaojrElDcxdbe_mKEGU7xKTMSEQR3EgqiB3JzxggCShAb1gPplWROuBzocQkrL3rpnz3FODrayk0QdOvSsXuaVHTn1DhnMleaN-6lDzlBLKzhuS0aea40k6Z2F1zEONM88GH6ptzhVQpiVLWRBbxUUGgw5S-Sid8dk9mJ3j46ekXRsHabaG8rl7KlrhCth7O'
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const {data} = await api({
|
||||||
|
method: "POST",
|
||||||
|
url: `https://api.m.jd.com/client.action`,
|
||||||
|
headers: {
|
||||||
|
"content-type": "application/x-www-form-urlencoded",
|
||||||
|
origin: "https://prodev.m.jd.com",
|
||||||
|
Referer: "https://prodev.m.jd.com/mall/active/3C751WNneAUaZ8Lw8xYN7cbSE8gm/index.html",
|
||||||
|
"User-Agent": $.userAgent,
|
||||||
|
"x-referer-page": "https://prodev.m.jd.com/mall/active/3C751WNneAUaZ8Lw8xYN7cbSE8gm/index.html"
|
||||||
|
},
|
||||||
|
data: sign.qs
|
||||||
|
});
|
||||||
|
|
||||||
|
let tempKeyword = ``;
|
||||||
|
if (data.code === '0') {
|
||||||
|
console.log(`第 ${size++} 次获取试用商品成功,tabId:${args_xh.tabId[$.nowTabIdIndex]} 的 第 ${page} 页`);
|
||||||
|
console.log(`获取到商品 ${data.data.feedList.length} 条`);
|
||||||
|
for (let item of data.data.feedList) {
|
||||||
|
if (item.applyNum === null) {
|
||||||
|
args_xh.printLog ? console.log(`商品未到申请时间:${item.skuTitle}\n`) : "";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (trialActivityIdList.length >= args_xh.maxLength) {
|
||||||
|
console.log("商品列表长度已满.结束获取");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (item.applyState === 1) {
|
||||||
|
args_xh.printLog ? console.log(`商品已申请试用:${item.skuTitle}\n`) : "";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (item.applyState !== null) {
|
||||||
|
args_xh.printLog ? console.log(`商品状态异常,未找到skuTitle\n`) : "";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (args_xh.passZhongCao) {
|
||||||
|
$.isPush = true;
|
||||||
|
if (item.tagList.length !== 0) {
|
||||||
|
for (let itemTag of item.tagList) {
|
||||||
|
if (itemTag.tagType === 3) {
|
||||||
|
args_xh.printLog ? console.log("商品被过滤,该商品是种草官专属") : "";
|
||||||
|
$.isPush = false;
|
||||||
|
break;
|
||||||
|
} else if (itemTag.tagType === 5) {
|
||||||
|
args_xh.printLog ? console.log("商品被跳过,该商品是付费试用!") : "";
|
||||||
|
$.isPush = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.skuTitle && $.isPush) {
|
||||||
|
args_xh.printLog ? console.log(`检测 tabId:${args_xh.tabId[$.nowTabIdIndex]} 的 第 ${page} 页 第 ${$.nowItem++ + 1} 个商品\n${item.skuTitle}`) : "";
|
||||||
|
if (args_xh.whiteList) {
|
||||||
|
if (args_xh.whiteListKeywords.some((fileter_word) => item.skuTitle.includes(fileter_word))) {
|
||||||
|
args_xh.printLog ? console.log(`商品白名单通过,将加入试用组,trialActivityId为${item.trialActivityId}\n`) : "";
|
||||||
|
trialActivityIdList.push(item.trialActivityId);
|
||||||
|
trialActivityTitleList.push(item.skuTitle);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tempKeyword = ``;
|
||||||
|
if (parseFloat(item.jdPrice) <= args_xh.jdPrice) {
|
||||||
|
args_xh.printLog ? console.log(`商品被过滤,商品价格 ${item.jdPrice} < ${args_xh.jdPrice} \n`) : "";
|
||||||
|
} else if (parseFloat(item.supplyNum) < args_xh.minSupplyNum && item.supplyNum !== null) {
|
||||||
|
args_xh.printLog ? console.log(`商品被过滤,提供申请的份数小于预设申请的份数 \n`) : "";
|
||||||
|
} else if (parseFloat(item.applyNum) > args_xh.applyNumFilter && item.applyNum !== null) {
|
||||||
|
args_xh.printLog ? console.log(`商品被过滤,已申请人数大于预设的${args_xh.applyNumFilter}人 \n`) : "";
|
||||||
|
} else if (item.jdPrice === null) {
|
||||||
|
args_xh.printLog ? console.log(`商品被过滤,商品无价,不能申请 \n`) : "";
|
||||||
|
} else if (parseFloat(item.trialPrice) > args_xh.trialPrice) {
|
||||||
|
args_xh.printLog ? console.log(`商品被过滤,商品试用价大于预设试用价 \n`) : "";
|
||||||
|
} else if (args_xh.titleFilters.some((fileter_word) => (item.skuTitle.includes(fileter_word) ? (tempKeyword = fileter_word) : ""))) {
|
||||||
|
args_xh.printLog ? console.log(`商品被过滤,含有关键词 ${tempKeyword}\n`) : "";
|
||||||
|
} else {
|
||||||
|
args_xh.printLog ? console.log(`商品通过,加入试用组,trialActivityId为${item.trialActivityId}\n`) : "";
|
||||||
|
if (trialActivityIdList.indexOf(item.trialActivityId) === -1) {
|
||||||
|
trialActivityIdList.push(item.trialActivityId);
|
||||||
|
trialActivityTitleList.push(item.skuTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ($.isPush !== false) {
|
||||||
|
console.error("skuTitle解析异常");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(`当前试用组长度为:${trialActivityIdList.length}`);
|
||||||
|
console.log(`下一页状态:${data.data.hasNext}`);
|
||||||
|
if (data.data.hasNext === false) {
|
||||||
|
if ($.nowTabIdIndex < args_xh.tabId.length) {
|
||||||
|
$.nowTabIdIndex++;
|
||||||
|
$.nowPage = 1;
|
||||||
|
$.nowItem = 1;
|
||||||
|
$.retrynum = 0;
|
||||||
|
} else {
|
||||||
|
// 这下是真的没了
|
||||||
|
$.retrynum = 999
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$.nowPage++;
|
||||||
|
$.retrynum = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(`💩 获得试用列表失败: ${data.message}`);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (e.message === `Request failed with status code 403`) {
|
||||||
|
$.retrynum++;
|
||||||
|
if ($.retrynum === 4) {
|
||||||
|
$.isForbidden = true;
|
||||||
|
$.log("多次尝试失败,换个时间再试!");
|
||||||
|
} else {
|
||||||
|
console.log(`403,第 ${$.retrynum} 次重试`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(e.message);
|
||||||
|
console.log(`${$.name} API请求失败,请检查网路重试`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function h5stSign(body, h5st) {
|
||||||
|
const options = {
|
||||||
|
method: 'POST',
|
||||||
|
url: 'https://jd.zhx47.xyz/h5st',
|
||||||
|
headers: {'content-type': 'application/json'},
|
||||||
|
data: {
|
||||||
|
version: '4.7.3',
|
||||||
|
pin: $.UserName,
|
||||||
|
ua: $.userAgent,
|
||||||
|
body,
|
||||||
|
h5st
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const {data} = await axios.request(options);
|
||||||
|
return data.body;
|
||||||
|
}
|
||||||
|
|
||||||
function Env(name, opts) {
|
function Env(name, opts) {
|
||||||
class Http {
|
class Http {
|
||||||
constructor(env) {
|
constructor(env) {
|
||||||
@ -710,84 +690,6 @@ function Env(name, opts) {
|
|||||||
this.log("", `🔔${this.name}, 开始!`);
|
this.log("", `🔔${this.name}, 开始!`);
|
||||||
}
|
}
|
||||||
|
|
||||||
isNode() {
|
|
||||||
return "undefined" !== typeof module && !!module.exports;
|
|
||||||
}
|
|
||||||
|
|
||||||
isQuanX() {
|
|
||||||
return "undefined" !== typeof $task;
|
|
||||||
}
|
|
||||||
|
|
||||||
isSurge() {
|
|
||||||
return "undefined" !== typeof $httpClient && "undefined" === typeof $loon;
|
|
||||||
}
|
|
||||||
|
|
||||||
isLoon() {
|
|
||||||
return "undefined" !== typeof $loon;
|
|
||||||
}
|
|
||||||
|
|
||||||
loaddata() {
|
|
||||||
if (this.isNode()) {
|
|
||||||
this.fs = this.fs ? this.fs : require("fs");
|
|
||||||
this.path = this.path ? this.path : require("path");
|
|
||||||
const curDirDataFilePath = this.path.resolve(this.dataFile);
|
|
||||||
const rootDirDataFilePath = this.path.resolve(process.cwd(), this.dataFile);
|
|
||||||
const isCurDirDataFile = this.fs.existsSync(curDirDataFilePath);
|
|
||||||
const isRootDirDataFile = !isCurDirDataFile && this.fs.existsSync(rootDirDataFilePath);
|
|
||||||
if (isCurDirDataFile || isRootDirDataFile) {
|
|
||||||
const datPath = isCurDirDataFile ? curDirDataFilePath : rootDirDataFilePath;
|
|
||||||
try {
|
|
||||||
return JSON.parse(this.fs.readFileSync(datPath));
|
|
||||||
} catch (e) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
} else return {};
|
|
||||||
} else return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
lodash_get(source, path, defaultValue = undefined) {
|
|
||||||
const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
||||||
let result = source;
|
|
||||||
for (const p of paths) {
|
|
||||||
result = Object(result)[p];
|
|
||||||
if (result === undefined) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
getdata(key) {
|
|
||||||
let val = this.getval(key);
|
|
||||||
// 如果以 @
|
|
||||||
if (/^@/.test(key)) {
|
|
||||||
const [, objkey, paths] = /^@(.*?)\.(.*?)$/.exec(key);
|
|
||||||
const objval = objkey ? this.getval(objkey) : "";
|
|
||||||
if (objval) {
|
|
||||||
try {
|
|
||||||
const objedval = JSON.parse(objval);
|
|
||||||
val = objedval ? this.lodash_get(objedval, paths, "") : val;
|
|
||||||
} catch (e) {
|
|
||||||
val = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
getval(key) {
|
|
||||||
if (this.isSurge() || this.isLoon()) {
|
|
||||||
return $persistentStore.read(key);
|
|
||||||
} else if (this.isQuanX()) {
|
|
||||||
return $prefs.valueForKey(key);
|
|
||||||
} else if (this.isNode()) {
|
|
||||||
this.data = this.loaddata();
|
|
||||||
return this.data[key];
|
|
||||||
} else {
|
|
||||||
return (this.data && this.data[key]) || null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
initAxios() {
|
initAxios() {
|
||||||
if (!this.axios) {
|
if (!this.axios) {
|
||||||
this.axios = axios.create();
|
this.axios = axios.create();
|
||||||
@ -809,71 +711,6 @@ function Env(name, opts) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统通知
|
|
||||||
*
|
|
||||||
* > 通知参数: 同时支持 QuanX 和 Loon 两种格式, EnvJs根据运行环境自动转换, Surge 环境不支持多媒体通知
|
|
||||||
*
|
|
||||||
* 示例:
|
|
||||||
* $.msg(title, subt, desc, 'twitter://')
|
|
||||||
* $.msg(title, subt, desc, { 'open-url': 'twitter://', 'media-url': 'https://github.githubassets.com/images/modules/open_graph/github-mark.png' })
|
|
||||||
* $.msg(title, subt, desc, { 'open-url': 'https://bing.com', 'media-url': 'https://github.githubassets.com/images/modules/open_graph/github-mark.png' })
|
|
||||||
*
|
|
||||||
* @param {*} title 标题
|
|
||||||
* @param {*} subt 副标题
|
|
||||||
* @param {*} desc 通知详情
|
|
||||||
* @param {*} opts 通知参数
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
msg(title = name, subt = "", desc = "", opts) {
|
|
||||||
const toEnvOpts = (rawopts) => {
|
|
||||||
if (!rawopts) return rawopts;
|
|
||||||
if (typeof rawopts === "string") {
|
|
||||||
if (this.isLoon()) return rawopts; else if (this.isQuanX()) return {
|
|
||||||
"open-url": rawopts,
|
|
||||||
}; else if (this.isSurge()) return {
|
|
||||||
url: rawopts,
|
|
||||||
}; else return undefined;
|
|
||||||
} else if (typeof rawopts === "object") {
|
|
||||||
if (this.isLoon()) {
|
|
||||||
let openUrl = rawopts.openUrl || rawopts.url || rawopts["open-url"];
|
|
||||||
let mediaUrl = rawopts.mediaUrl || rawopts["media-url"];
|
|
||||||
return {
|
|
||||||
openUrl, mediaUrl,
|
|
||||||
};
|
|
||||||
} else if (this.isQuanX()) {
|
|
||||||
let openUrl = rawopts["open-url"] || rawopts.url || rawopts.openUrl;
|
|
||||||
let mediaUrl = rawopts["media-url"] || rawopts.mediaUrl;
|
|
||||||
return {
|
|
||||||
"open-url": openUrl, "media-url": mediaUrl,
|
|
||||||
};
|
|
||||||
} else if (this.isSurge()) {
|
|
||||||
let openUrl = rawopts.url || rawopts.openUrl || rawopts["open-url"];
|
|
||||||
return {
|
|
||||||
url: openUrl,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (!this.isMute) {
|
|
||||||
if (this.isSurge() || this.isLoon()) {
|
|
||||||
$notification.post(title, subt, desc, toEnvOpts(opts));
|
|
||||||
} else if (this.isQuanX()) {
|
|
||||||
$notify(title, subt, desc, toEnvOpts(opts));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!this.isMuteLog) {
|
|
||||||
let logs = ["", "==============📣系统通知📣=============="];
|
|
||||||
logs.push(title);
|
|
||||||
subt ? logs.push(subt) : "";
|
|
||||||
desc ? logs.push(desc) : "";
|
|
||||||
console.log(logs.join("\n"));
|
|
||||||
this.logs = this.logs.concat(logs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log(...logs) {
|
log(...logs) {
|
||||||
if (logs.length > 0) {
|
if (logs.length > 0) {
|
||||||
this.logs = [...this.logs, ...logs];
|
this.logs = [...this.logs, ...logs];
|
||||||
@ -881,27 +718,14 @@ function Env(name, opts) {
|
|||||||
console.log(logs.join(this.logSeparator));
|
console.log(logs.join(this.logSeparator));
|
||||||
}
|
}
|
||||||
|
|
||||||
logErr(err, msg) {
|
|
||||||
const isPrintSack = !this.isSurge() && !this.isQuanX() && !this.isLoon();
|
|
||||||
if (!isPrintSack) {
|
|
||||||
this.log("", `❗️${this.name}, 错误!`, err);
|
|
||||||
} else {
|
|
||||||
this.log("", `❗️${this.name}, 错误!`, err.stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wait(time) {
|
wait(time) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, time));
|
return new Promise((resolve) => setTimeout(resolve, time));
|
||||||
}
|
}
|
||||||
|
|
||||||
done(val = {}) {
|
done() {
|
||||||
const endTime = new Date().getTime();
|
const endTime = new Date().getTime();
|
||||||
const costTime = (endTime - this.startTime) / 1000;
|
const costTime = (endTime - this.startTime) / 1000;
|
||||||
this.log("", `🔔${this.name}, 结束! 🕛 ${costTime} 秒`);
|
this.log("", `🔔${this.name}, 结束! 🕛 ${costTime} 秒`);
|
||||||
this.log();
|
|
||||||
if (this.isSurge() || this.isQuanX() || this.isLoon()) {
|
|
||||||
$done(val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,19 +1,25 @@
|
|||||||
function getBaseCookie(userAgent, url) {
|
function setBaseCookie() {
|
||||||
var cookie = "";
|
var cookie = [];
|
||||||
|
|
||||||
function genUuid() {
|
function genUuid() {
|
||||||
return new Date().getTime() + "" + parseInt(2147483647 * Math.random());
|
return new Date().getTime() + "" + parseInt(2147483647 * Math.random());
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCookie(e, t) {
|
function setCookie(e, t, i) {
|
||||||
if (e) {
|
if (e) {
|
||||||
cookie += " " + e + "=" + t + ";";
|
var n = "";
|
||||||
|
if (i) {
|
||||||
|
var a = new Date;
|
||||||
|
a.setTime(a.getTime() + i),
|
||||||
|
n = ";expires=" + a.toGMTString()
|
||||||
|
}
|
||||||
|
document.cookie = e + "=" + t + n + ";path=/;domain=jd.com;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setJdv(e, t) {
|
function setJdv(e, t) {
|
||||||
var i = isPrey(10) && (!e || e.length > 400) ? t + "|direct|-|none|-|" + new Date().getTime() : e;
|
var i = isPrey(10) && (!e || e.length > 400) ? t + "|direct|-|none|-|" + new Date().getTime() : e;
|
||||||
setCookie("__jdv", i);
|
setCookie("__jdv", i, 1296000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPrey(e) {
|
function isPrey(e) {
|
||||||
@ -22,28 +28,17 @@ function getBaseCookie(userAgent, url) {
|
|||||||
return !!r && 1 * r < e;
|
return !!r && 1 * r < e;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEmbedded() {
|
|
||||||
var e = userAgent || "";
|
|
||||||
return /^(jdapp|jdltapp|jdpingou|jdmini|yhdapp);/.test(e) || isJdLog();
|
|
||||||
}
|
|
||||||
|
|
||||||
function isJdLog() {
|
|
||||||
return (userAgent || "").indexOf(";jdlog;") > -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var r = 122270672, i = genUuid(), s = parseInt(new Date().getTime() / 1e3);
|
var r = 122270672, i = genUuid(), s = parseInt(new Date().getTime() / 1e3);
|
||||||
uuid = i;
|
var uuid = i;
|
||||||
|
|
||||||
var C, P = url && url.split("/")[2], A = !1;
|
setCookie("__jda", [r, i, s, s, s, 1].join("."), 15552000000);
|
||||||
|
setCookie("__jdb", [r, 1, i + "|" + 1, s].join("."), 1800000);
|
||||||
setCookie("__jda", [r, i, s, s, s, 1].join("."));
|
|
||||||
setCookie("__jdb", [r, 1, i + "|" + 1, s].join("."));
|
|
||||||
var j = encodeURIComponent([r, "direct", "-", "none", "-", new Date().getTime()].join("|"));
|
var j = encodeURIComponent([r, "direct", "-", "none", "-", new Date().getTime()].join("|"));
|
||||||
setJdv(j, r);
|
setJdv(j, r);
|
||||||
setCookie("__jdc", r);
|
setCookie("__jdc", r);
|
||||||
setCookie("mba_muid", encodeURI(uuid));
|
setCookie("mba_muid", encodeURI(i));
|
||||||
|
|
||||||
return cookie;
|
return cookie.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.getBaseCookie = getBaseCookie
|
module.exports.setBaseCookie = setBaseCookie
|
||||||
|
@ -3,7 +3,7 @@ const {JSDOM,ResourceLoader} = require("jsdom");
|
|||||||
const {CookieJar, Cookie} = require("tough-cookie");
|
const {CookieJar, Cookie} = require("tough-cookie");
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const {HttpCookieAgent, HttpsCookieAgent} = require('http-cookie-agent/http')
|
const {HttpCookieAgent, HttpsCookieAgent} = require('http-cookie-agent/http')
|
||||||
const {getBaseCookie} = require("./baseCookie");
|
const {setBaseCookie} = require("./baseCookie");
|
||||||
|
|
||||||
const crc32 = require('crc').crc32;
|
const crc32 = require('crc').crc32;
|
||||||
|
|
||||||
@ -153,13 +153,7 @@ class BaseUtils {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let baseCookie = getBaseCookie(userAgent, url);
|
setBaseCookie();
|
||||||
const baseCookies = baseCookie.split(';');
|
|
||||||
baseCookies.forEach((cookieString) => {
|
|
||||||
if (cookieString) {
|
|
||||||
global.document.cookie = cookieString.concat(";domain=.jd.com;path=/;expires=2099-04-16T07:09:14.000Z");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user