Skip to content

Commit 941839b

Browse files
committed
更新[京东618]: 增加随机等待时间, 可以在 BoxJs 手动调整
1 parent 70afe17 commit 941839b

2 files changed

Lines changed: 57 additions & 18 deletions

File tree

‎chavy.box.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ function getSystemApps() {
123123
name: '京东618',
124124
keys: ['chavy_url_jd816', 'chavy_body_jd816', 'chavy_headers_jd816'],
125125
settings: [
126+
{ id: 'CFG_618_radomms_min', name: '最小随机等待 (毫秒)', val: 2000, type: 'text', desc: '在任务默认的等待时间基础上,再增加的随机等待时间!' },
127+
{ id: 'CFG_618_radomms_max', name: '最大随机等待 (毫秒)', val: 5000, type: 'text', desc: '在任务默认的等待时间基础上,再增加的随机等待时间!' },
126128
{ id: 'CFG_618_isSignShop', name: '商店签到', val: true, type: 'boolean', desc: '71 家商店, 如果每天都签不上, 可以关掉了! 默认: true' },
127129
{ id: 'CFG_618_isJoinBrand', name: '品牌会员', val: false, type: 'boolean', desc: '25 个品牌, 会自动加入品牌会员! 默认: true' },
128130
{ id: 'CFG_BOOM_times_JD618', name: '炸弹次数', val: 1, type: 'text', desc: '总共发送多少次炸弹! 默认: 1' },

‎jd/jd.618.js‎

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ $.VAL_body = $.getdata('chavy_body_jd816')
44
$.VAL_headers = $.getdata('chavy_headers_jd816')
55
$.VAL_isSignShop = $.getdata('CFG_618_isSignShop') || 'true'
66
$.VAL_isJoinBrand = $.getdata('CFG_618_isJoinBrand') || 'false'
7+
$.VAL_radommsMin = $.getdata('CFG_618_radomms_min') || '2000'
8+
$.VAL_radommsMax = $.getdata('CFG_618_radomms_max') || '5000'
79

810
!(async () => {
911
$.log('', `🔔 ${$.name}, 开始!`, '')
@@ -31,7 +33,8 @@ function getData() {
3133
$.log(`❕ ${$.name}, 获取密钥!`)
3234
$.log(` 密钥 = ${$.secretp.slice(0, 10)}...`)
3335
$.log(` 等级 = ${_info.raiseInfo.scoreLevel}`)
34-
$.log(` 分数 = ${_info.raiseInfo.totalScore} => ${_info.raiseInfo.nextLevelScore}`, '')
36+
$.log(` 分数 = ${_info.raiseInfo.totalScore} => ${_info.raiseInfo.nextLevelScore}`)
37+
$.log(` 延时 = ${$.VAL_radommsMin} => ${$.VAL_radommsMax} 毫秒`, '')
3538
} catch (e) {
3639
$.log(`❗️ ${$.name}, 获取密钥!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
3740
} finally {
@@ -109,7 +112,11 @@ async function execActs() {
109112
for (let _actIdx = 0; _actIdx < $.acts.length; _actIdx++) {
110113
const _act = $.acts[_actIdx]
111114
$.log(` ${_actIdx + 1}. ${_act.name} (${_act.times}/${_act.maxTimes})`)
112-
// // 跳过:邀请好友、加入战队
115+
if (_act.times === _act.maxTimes) {
116+
$.log(` @跳过: 全部完成!`, '')
117+
continue
118+
}
119+
// 跳过:邀请好友、加入战队
113120
if ([2, 12].includes(_act.id)) {
114121
$.log(' 跳过!', '')
115122
continue
@@ -120,20 +127,32 @@ async function execActs() {
120127
for (let subactIdx = 0; subactIdx < _act.subacts.length; subactIdx++) {
121128
const subact = _act.subacts[subactIdx]
122129
$.log(` ${subactIdx + 1}. ${subact.name} (${subact.times}/${subact.maxTimes})`)
130+
if (subact.times === subact.maxTimes) {
131+
$.log(` @跳过: 全部完成!`, '')
132+
continue
133+
}
123134
for (let subataskIdx = 0; subataskIdx < subact.tasks.length; subataskIdx++) {
124135
const subatask = subact.tasks[subataskIdx]
125136
$.log(` ${subataskIdx + 1}. ${subatask.name.slice(0, 15)}...`)
137+
if (subatask._raw.status && subatask._raw.status === 2) {
138+
$.log(` @跳过: 已经做过!`, '')
139+
continue
140+
}
126141
await sendtask(subact, subatask, true)
127142
$.log(` @认领任务: ${subatask.isClaimSuc ? '🟢' : '🔴'}`)
128143
if (subatask.isskip) {
129144
$.log(` @跳过: ${subatask.msg}`)
130-
$.log(` @等待: 0.5 秒`, '')
131-
await new Promise($.wait(500))
145+
const randomms = genRadomms()
146+
$.log(` @等待: 8 秒 + ${randomms} 毫秒`, '')
147+
await new Promise($.wait(8000 + randomms))
132148
} else {
133-
$.log(` @等待: ${subact.waitDuration} 秒`)
134-
await new Promise($.wait(subact.waitDuration * 1000))
149+
const randomms = genRadomms()
150+
$.log(` @等待: ${subact.waitDuration} 秒 + ${randomms} 毫秒`)
151+
await new Promise($.wait(subact.waitDuration * 1000 + randomms))
135152
await sendtask(subact, subatask)
136-
$.log(` @完成任务: ${subatask.isExecSuc ? '🟢' : '🔴'}`, '')
153+
$.log(` @完成任务: ${subatask.isExecSuc ? '🟢' : '🔴'}`)
154+
$.log(` @等待: 5 秒 + ${randomms} 毫秒`, '')
155+
await new Promise($.wait(5000 + randomms))
137156
}
138157
}
139158
}
@@ -146,10 +165,13 @@ async function execActs() {
146165
$.log(` ${taskIdx + 1}. ${task.name}`)
147166
await joinBrand(task)
148167
$.log(` @加入会员: ${task.isJoinSuc ? '🟢' : '🔴'}`)
149-
$.log(` @等待: ${_act.waitDuration} 秒`)
150-
await new Promise($.wait(_act.waitDuration * 1000))
168+
const randomms = genRadomms()
169+
$.log(` @等待: ${_act.waitDuration} 秒 + ${randomms} 毫秒`)
170+
await new Promise($.wait(_act.waitDuration * 1000 + randomms))
151171
await brandAward(task)
152-
$.log(` @完成任务: ${task.isAwardSuc ? '🟢' : '🔴'}`, '')
172+
$.log(` @完成任务: ${task.isAwardSuc ? '🟢' : '🔴'}`)
173+
$.log(` @等待: 5 秒 + ${randomms} 毫秒`, '')
174+
await new Promise($.wait(5000 + randomms))
153175
}
154176
} else {
155177
$.log(` @跳过: BoxJs 设置为 关闭 品牌会员!`, '')
@@ -160,17 +182,25 @@ async function execActs() {
160182
for (let taskIdx = 0; taskIdx < _act.tasks.length; taskIdx++) {
161183
const task = _act.tasks[taskIdx]
162184
$.log(` ${taskIdx + 1}. ${task.name}`)
185+
if (task._raw.status && task._raw.status === 2) {
186+
$.log(` @跳过: 已经做过!`, '')
187+
continue
188+
}
163189
await sendtask(_act, task, true)
164190
$.log(` @认领任务: ${task.isClaimSuc ? '🟢' : '🔴'}`)
165191
if (task.isskip || task.ishot) {
166192
$.log(` @跳过: ${task.msg}`)
167-
$.log(` @等待: 0.5 秒`, '')
168-
await new Promise($.wait(500))
193+
const randomms = genRadomms()
194+
$.log(` @等待: 8 秒 + ${randomms} 毫秒`, '')
195+
await new Promise($.wait(8000 + randomms))
169196
} else {
170-
$.log(` @等待: ${_act.waitDuration} 秒`)
171-
await new Promise($.wait(_act.waitDuration * 1000))
197+
const randomms = genRadomms()
198+
$.log(` @等待: ${_act.waitDuration} 秒 + ${randomms} 毫秒`)
199+
await new Promise($.wait(_act.waitDuration * 1000 + randomms))
172200
await sendtask(_act, task)
173-
$.log(` @完成任务: ${task.isExecSuc ? '🟢' : '🔴'}`, '')
201+
$.log(` @完成任务: ${task.isExecSuc ? '🟢' : '🔴'}`)
202+
$.log(` @等待: 5 秒 + ${randomms} 毫秒`, '')
203+
await new Promise($.wait(5000 + randomms))
174204
}
175205
}
176206
}
@@ -185,8 +215,9 @@ async function execActs() {
185215
await signshop(shop)
186216
shop.msg = /,/.test(shop.msg) ? shop.msg.split(',')[1] : shop.msg
187217
$.log(` @签到: ${shop.isSuc ? '🟢 已领取!' : shop.code === 402 ? '⚪️ 无效活动!' : `🔴 ${shop.msg}`}`)
188-
$.log(` @等待: 1 秒`, '')
189-
await new Promise($.wait(1000))
218+
const randomms = genRadomms()
219+
$.log(` @等待: 8 秒 + ${randomms} 毫秒`, '')
220+
await new Promise($.wait(8000 + randomms))
190221
}
191222
} else {
192223
$.log(` @跳过: BoxJs 设置为 关闭 商店签到!`, '')
@@ -240,8 +271,8 @@ function sendtask(act, task, isClaim = false) {
240271
actionType: isClaim ? 1 : undefined,
241272
safeStr: JSON.stringify({ secretp: $.secretp })
242273
}
243-
244274
$.post(taskurl('cakebaker_ckCollectScore', JSON.stringify(body)), (error, response, data) => {
275+
console.log(data)
245276
try {
246277
const _data = JSON.parse(data)
247278
const _issuc = _data.data.bizCode === 0 || _data.data.bizCode === -5 || _data.data.bizCode === -15
@@ -335,6 +366,12 @@ function taskurl(fid, body = '{}') {
335366
return url
336367
}
337368

369+
function genRadomms() {
370+
const max = $.VAL_radommsMax * 1
371+
const min = $.VAL_radommsMin * 1
372+
return parseInt(Math.random() * (max - min + 1) + min, 10)
373+
}
374+
338375
function showmsg() {}
339376

340377
// prettier-ignore

0 commit comments

Comments
 (0)