Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
shufflewzc committed Dec 4, 2021
1 parent 84c03f3 commit de1cefe
Show file tree
Hide file tree
Showing 6 changed files with 1,363 additions and 46 deletions.
25 changes: 17 additions & 8 deletions jd_daily_egg.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ const dailyEggUrl = "https://active.jd.com/forever/btgoose/?channelLv=yxjh&jrcon
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
const { JSDOM } = $.isNode() ? require('jsdom') : '';
const { window } = new JSDOM(``, { url: dailyEggUrl, runScripts: "outside-only", pretentToBeVisual: true, resources: "usable" })
const Faker = require('./utils/JDSignValidator.js')
const Faker = require('./JDSignValidator.js')
function oc(fn, defaultVal) {//optioanl chaining
try {
return fn()
} catch (e) {
return undefined
}
}
if ($.isNode()) {
Object.keys(jdCookieNode).forEach((item) => {
cookiesArr.push(jdCookieNode[item])
Expand Down Expand Up @@ -63,7 +70,8 @@ if ($.isNode()) {
const fakerBody = Faker.getBody(dailyEggUrl)
$.fp = fakerBody.fp
$.eid = await getClientData(fakerBody)
$.token = (await downloadUrl("https://gia.jd.com/m.html")).match(/var\s*?jd_risk_token_id\s*?=\s*["`'](\S*?)["`'];?/)?.[1] || ""
const temp = (await downloadUrl("https://gia.jd.com/m.html")).match(/var\s*?jd_risk_token_id\s*?=\s*["`'](\S*?)["`'];?/)
$.token = oc(() => temp[1]) || ""
await jdDailyEgg();
}
}
Expand All @@ -90,7 +98,8 @@ async function doTask(funcMissionId = null) {
errMissionID = [...errMissionID, ...errMissionID.map(x => x.toString())]
const taskWaitTime = 15
let res
let taskList = (await doApi("queryGooseTaskList", false))?.data ?? []
const temp = await doApi("queryGooseTaskList", false)
let taskList = oc(() => temp.data) || []
taskList = taskList.filter(x => [-1, 0, 1].includes(x.status) && !errMissionID.includes(x.missionId))
if (funcMissionId) taskList = taskList.filter(x => x.missionId === funcMissionId)
for (let task of taskList) {
Expand Down Expand Up @@ -131,7 +140,7 @@ async function doTask(funcMissionId = null) {
break
// 领奖状态
case 1:
awards = awards[0] ?? awards
awards = awards[0] || awards
let { awardRealNum, awardName } = awards
let msg = []
msg.push(funcMissionId ? `做任务'${name}'结果:成功!` : `任务'${name}'已可领奖。`)
Expand Down Expand Up @@ -229,9 +238,9 @@ function toDailyHome() {
console.log($.name + `(${arguments.callee.name})` + ":" + data.resultData.msg)
return
}
let shareUuid = data?.resultData?.data?.shareUuid
let shareUuid = oc(() => data.resultData.data.shareUuid)
if (!$.shareUuid && typeof shareUuid === 'string') Object.assign($, { shareUuid })
let isFirstLogin = data?.resultData?.data?.isFristLogin
let isFirstLogin = oc(() => data.resultData.data.isFristLogin)
if (typeof isFirstLogin === 'string') {
$.isFirstLogin = (() => { try { return JSON.parse(isFirstLogin) } catch (e) { return false } })()
} else if (typeof isFirstLogin === 'boolean') {
Expand Down Expand Up @@ -261,7 +270,7 @@ async function doApi(functionId = "", withSign = false, preBody = {}, preUrl = "
case "receiveGooseTask":
body = {
missionId: preBody.missionId.toString(),
shareUuid: $.inviteId ?? "",
shareUuid: $.inviteId || "",
riskDeviceInfo: $.riskDeviceInfo,
channelLv: "yxjh",
environment: "jrApp",
Expand Down Expand Up @@ -304,7 +313,7 @@ async function doApi(functionId = "", withSign = false, preBody = {}, preUrl = "
if (data.resultCode !== 0) {
console.log($.name + `(${functionId})` + ":" + data.resultMsg)
} else {
Object.assign(res, data?.resultData ?? {})
Object.assign(res, oc(() => data.resultData) || {})
}
} else {
}
Expand Down
Loading

0 comments on commit de1cefe

Please sign in to comment.