Skip to content

Commit 2e6f2a0

Browse files
committed
更新[京东618]: 可以在 BoxJs 内关闭商店签到
1 parent 8293e62 commit 2e6f2a0

2 files changed

Lines changed: 38 additions & 34 deletions

File tree

‎chavy.box.js‎

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ function getSystemApps() {
123123
name: '京东618',
124124
keys: ['chavy_url_jd816', 'chavy_body_jd816', 'chavy_headers_jd816'],
125125
settings: [
126-
{ id: 'CFG_BOOM_times_JD618', name: '炸弹次数', val: '1', type: 'text', desc: '总共发送多少次炸弹!' },
127-
{ id: 'CFG_BOOM_interval_JD618', name: '炸弹间隔 (毫秒)', val: '100', type: 'text', desc: '每次间隔多少毫秒!' }
126+
{ id: 'CFG_618_isSignShop', name: '商店签到', val: true, type: 'boolean', desc: '71家商店, 如果每天都签不上, 可以关掉了! 默认: true' },
127+
{ id: 'CFG_BOOM_times_JD618', name: '炸弹次数', val: 1, type: 'text', desc: '总共发送多少次炸弹! 默认: 1' },
128+
{ id: 'CFG_BOOM_interval_JD618', name: '炸弹间隔 (毫秒)', val: 100, type: 'text', desc: '每次间隔多少毫秒! 默认: 100' }
128129
],
129130
author: '@chavyleung',
130131
repo: 'https://github.com/chavyleung/scripts/tree/master/jd',
@@ -165,7 +166,14 @@ function getSystemApps() {
165166
})
166167
Array.isArray(app.settings) &&
167168
app.settings.forEach((setting) => {
168-
setting.val = $.getdata(setting.id) || setting.val
169+
const val = $.getdata(setting.id)
170+
if (setting.type === 'boolean') {
171+
setting.val = val === null ? setting.val : val === 'true'
172+
} else if (setting.type === 'int') {
173+
setting.val = val * 1 || setting.val
174+
} else {
175+
setting.val = val || setting.val
176+
}
169177
})
170178
})
171179
return sysapps
@@ -219,9 +227,9 @@ function handleApi() {
219227
settings.forEach((setting) => {
220228
const oldval = $.getdata(setting.id)
221229
const newval = setting.val
222-
const usesuc = $.setdata(newval, setting.id)
230+
const usesuc = $.setdata(`${newval}`, setting.id)
223231
$.log(`❕ ${$.name}, 保存设置: ${setting.id} ${usesuc ? '成功' : '失败'}!`, `旧值: ${oldval}`, `新值: ${newval}`)
224-
$.setdata(newval, setting.id)
232+
$.setdata(`${newval}`, setting.id)
225233
})
226234
$.subt = `保存设置: 成功! `
227235
$.msg($.name, $.subt, '')
@@ -237,7 +245,7 @@ function handleApi() {
237245
session.datas.forEach((data) => {
238246
const oldval = $.getdata(data.key)
239247
const newval = data.val
240-
const usesuc = $.setdata(newval, data.key)
248+
const usesuc = $.setdata(`${newval}`, data.key)
241249
$.log(`❕ ${$.name}, 替换数据: ${data.key} ${usesuc ? '成功' : '失败'}!`, `旧值: ${oldval}`, `新值: ${newval}`)
242250
})
243251
$.subt = `应用会话: 成功 (${session.appName})`
@@ -370,24 +378,26 @@ function printHtml(data, curapp = null) {
370378
</v-card>
371379
</v-container>
372380
<v-container fluid v-if="ui.curview === 'appsession'">
373-
<v-card class="mx-auto">
381+
<v-card class="mx-auto mb-4">
374382
<template v-if="Array.isArray(ui.curapp.settings)">
375383
<v-subheader v-if="Array.isArray(ui.curapp.settings)">
376384
应用设置 ({{ ui.curapp.settings.length }})
377385
</v-subheader>
378386
<v-form class="pl-4 pr-4">
379387
<template v-for="(setting, settingIdx) in ui.curapp.settings">
380388
<v-text-field :label="setting.name" v-model="setting.val" :hint="setting.desc" v-if="setting.type === 'text'"></v-text-field>
381-
<v-slider :label="setting.name" v-model="setting.val" :hint="setting.desc" :min="setting.min" :max="setting.max" thumb-label="always" v-if="setting.type === 'slider'"></v-slider>
389+
<v-slider :label="setting.name" v-model="setting.val" :hint="setting.desc" :min="setting.min" :max="setting.max" thumb-label="always" v-else-if="setting.type === 'slider'"></v-slider>
390+
<v-switch :label="setting.name" v-model="setting.val" :hint="setting.desc" v-else-if="setting.type === 'boolean'"></v-switch>
382391
</template>
383392
</v-form>
384393
<v-divider></v-divider>
385394
<v-card-actions>
386395
<v-spacer></v-spacer>
387396
<v-btn small text color="success" @click="onSavePops">保存设置</v-btn>
388397
</v-card-actions>
389-
<v-divider></v-divider>
390398
</template>
399+
</v-card>
400+
<v-card class="mx-auto">
391401
<v-subheader>
392402
当前会话 ({{ ui.curapp.datas.length }})
393403
<v-spacer></v-spacer>
@@ -420,17 +430,6 @@ function printHtml(data, curapp = null) {
420430
<v-card class="ml-10 mt-4" v-for="(session, sessionIdx) in ui.curappSessions" :key="session.id">
421431
<v-subheader>
422432
#{{ sessionIdx + 1 }} {{ session.name }}
423-
<v-spacer></v-spacer>
424-
<v-menu bottom left>
425-
<template v-slot:activator="{ on }">
426-
<v-btn icon v-on="on"><v-icon>mdi-dots-vertical</v-icon></v-btn>
427-
</template>
428-
<v-list>
429-
<v-list-item @click="" v-clipboard:copy="JSON.stringify(session)" v-clipboard:success="onCopy">
430-
<v-list-item-title>复制会话</v-list-item-title>
431-
</v-list-item>
432-
</v-list>
433-
</v-menu>
434433
</v-subheader>
435434
<v-list-item two-line dense v-for="(data, dataIdx) in session.datas" :key="dataIdx">
436435
<v-list-item-content>
@@ -440,7 +439,7 @@ function printHtml(data, curapp = null) {
440439
</v-list-item>
441440
<v-divider></v-divider>
442441
<v-card-actions>
443-
<v-btn x-small text color="grey">{{ session.createTime }}</v-btn>
442+
<v-btn small text color="grey">{{ session.createTime }}</v-btn>
444443
<v-spacer></v-spacer>
445444
<v-btn small text color="error" @click="onDelSession(session)">删除</v-btn>
446445
<v-btn small text color="success" @click="onUseSession(session)">应用</v-btn>

‎jd/jd.618.js‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const $ = new Env('京东618')
22
$.VAL_url = $.getdata('chavy_url_jd816')
33
$.VAL_body = $.getdata('chavy_body_jd816')
44
$.VAL_headers = $.getdata('chavy_headers_jd816')
5+
$.VAL_isSignShop = $.getdata('CFG_618_isSignShop') || 'true'
56

67
!(async () => {
78
$.log('', `🔔 ${$.name}, 开始!`, '')
@@ -50,7 +51,7 @@ function getShops() {
5051
const _shopact = {
5152
_raw: _shopa,
5253
id: _shopa.venderId,
53-
name: _shopa.name,
54+
name: _shopa.name
5455
}
5556
$.shopActs.push(_shopact)
5657
})
@@ -80,7 +81,7 @@ function getActs() {
8081
maxTimes: _a.maxTimes,
8182
waitDuration: _a.waitDuration === 0 ? 1 : _a.waitDuration,
8283
isProd: _a.productInfoVos ? true : false,
83-
tasks: [],
84+
tasks: []
8485
}
8586
const _vo = _a[Object.keys(_a).find((key) => _a[key]?.itemId || _a[key][0]?.itemId)]
8687
if (Array.isArray(_vo)) {
@@ -162,14 +163,18 @@ async function execActs() {
162163

163164
// 商店签到
164165
$.log(` ${$.acts.length + 1}. 商店签到 (${$.shopActs.length})`)
165-
for (let _shopIdx = 0; _shopIdx < $.shopActs.length; _shopIdx++) {
166-
const shop = $.shopActs[_shopIdx]
167-
$.log(` ${_shopIdx + 1}. ${shop.name}`)
168-
await signshop(shop)
169-
shop.msg = /,/.test(shop.msg) ? shop.msg.split(',')[1] : shop.msg
170-
$.log(` @签到: ${shop.isSuc ? '🟢 已领取!' : shop.code === 402 ? '⚪️ 无效活动!' : `🔴 ${shop.msg}`}`)
171-
$.log(` @等待: 1 秒`, '')
172-
await new Promise($.wait(1000))
166+
if ($.VAL_isSignShop === 'true' || $.VAL_isSignShop === true) {
167+
for (let _shopIdx = 0; _shopIdx < $.shopActs.length; _shopIdx++) {
168+
const shop = $.shopActs[_shopIdx]
169+
$.log(` ${_shopIdx + 1}. ${shop.name}`)
170+
await signshop(shop)
171+
shop.msg = /,/.test(shop.msg) ? shop.msg.split(',')[1] : shop.msg
172+
$.log(` @签到: ${shop.isSuc ? '🟢 已领取!' : shop.code === 402 ? '⚪️ 无效活动!' : `🔴 ${shop.msg}`}`)
173+
$.log(` @等待: 1 秒`, '')
174+
await new Promise($.wait(1000))
175+
}
176+
} else {
177+
$.log(` @跳过: BoxJs 设置为 关闭 商店签到!`, '')
173178
}
174179
}
175180

@@ -191,14 +196,14 @@ function getProdAct(act) {
191196
maxTimes: _suba.maxTimes,
192197
waitDuration: _suba.waitDuration === 0 ? 1 : _suba.waitDuration,
193198
isProd: _suba.productInfoVos ? true : false,
194-
tasks: [],
199+
tasks: []
195200
}
196201
_suba.productInfoVos.slice(0, 5).forEach((_prodvo) => {
197202
const _taskname = _prodvo.skuName || _prodvo.title || _prodvo.shopName || _prodvo.taskName || '未知名称'
198203
_subact.tasks.push({
199204
_raw: _prodvo,
200205
id: _prodvo.itemId,
201-
name: _taskname,
206+
name: _taskname
202207
})
203208
})
204209
act.subacts.push(_subact)
@@ -218,7 +223,7 @@ function sendtask(act, task, isClaim = false) {
218223
taskId: act.id,
219224
itemId: task.id,
220225
actionType: isClaim ? 1 : undefined,
221-
safeStr: JSON.stringify({ secretp: $.secretp }),
226+
safeStr: JSON.stringify({ secretp: $.secretp })
222227
}
223228

224229
$.post(taskurl('cakebaker_ckCollectScore', JSON.stringify(body)), (error, response, data) => {

0 commit comments

Comments
 (0)