mirror of
https://github.com/qitoqito/psyduck.git
synced 2026-01-12 04:30:42 +08:00
Create jd_task_vote.js
This commit is contained in:
parent
405d1b89d5
commit
70d594d682
124
parse/jd/jd_task_vote.js
Normal file
124
parse/jd/jd_task_vote.js
Normal file
@ -0,0 +1,124 @@
|
||||
import {Template} from '../../template.js'
|
||||
|
||||
export class Main extends Template {
|
||||
constructor() {
|
||||
super()
|
||||
this.profile = {
|
||||
title: '京东有奖投票',
|
||||
crontab: 3
|
||||
}
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
let date = new Date();
|
||||
let options = {year: 'numeric', month: '2-digit', day: '2-digit'};
|
||||
let formattedDate = date.toLocaleDateString('zh-CN', options).replace(/\//g, '-');
|
||||
for (let i of Array(3)) {
|
||||
let rank = await this.curl({
|
||||
'form': `functionId=hc_boss_queryBossRanking&body={"type":2,"rankingDay":"${formattedDate}"}&appid=home-marketing&client=apple&&clientVersion=15.1.53`,
|
||||
cookie: this.tester()
|
||||
}
|
||||
)
|
||||
if (this.haskey(rank, 'data.bossRankingInfo')) {
|
||||
this.code = rank.data.bossRankingInfo
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async main(p) {
|
||||
let user = p.data.user;
|
||||
let context = p.context;
|
||||
let info = await this.curl({
|
||||
'form': `appid=home-marketing&body={}&client=apple&clientVersion=15.1.53&functionId=hc_boss_queryInteractiveInfo`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '91a93',
|
||||
expire: {
|
||||
"code": 3,
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
let list = this.haskey(info, 'data.0.assignmentList') || []
|
||||
for (let i of list) {
|
||||
if (i.completionFlag) {
|
||||
p.log("任务完成:", i.assignmentName)
|
||||
}
|
||||
else if (i.assignmentName.includes("浏览")) {
|
||||
let activity = i.ext.shoppingActivity
|
||||
activity.reverse()
|
||||
for (let j = 0; j<(i.assignmentTimesLimit - i.completionCnt); j++) {
|
||||
let data = activity[j]
|
||||
p.log("正在浏览:", data.title)
|
||||
let doIt = await this.curl({
|
||||
'form': `functionId=hc_boss_doInteractiveAssignment&body={"type":4,"encryptAssignId":"${i.encryptAssignmentId}","itemId":"${data.itemId}","actionType":1,"jumpUrl":"${encodeURIComponent(data.url)}"}&appid=home-marketing&loginType=2&client=apple&osVersion=15.1.1&networkType=wifi&d_model=iPhone13%2C3&d_brand=iPhone&screen=390%2A844&openudid=a0114d4ed52e4588aa38c141909565afecb81298&clientVersion=15.1.53`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '91a93'
|
||||
}
|
||||
}
|
||||
)
|
||||
let suc = this.haskey(doIt, 'success')
|
||||
if (suc) {
|
||||
if (i.ext.waitDuration) {
|
||||
p.log('正在等待: ', i.ext.waitDuration)
|
||||
await this.wait(i.ext.waitDuration * 1000)
|
||||
}
|
||||
let award = await this.curl({
|
||||
'form': `functionId=hc_boss_doInteractiveAssignment&body={"type":4,"encryptAssignId":"${i.encryptAssignmentId}","itemId":"${data.itemId}","actionType":0,"jumpUrl":"${encodeURIComponent(data.url)}"}&appid=home-marketing&loginType=2&client=apple&osVersion=15.1.1&networkType=wifi&d_model=iPhone13%2C3&d_brand=iPhone&screen=390%2A844&openudid=a0114d4ed52e4588aa38c141909565afecb81298&clientVersion=15.1.53`,
|
||||
user,
|
||||
algo: {
|
||||
appId: '91a93'
|
||||
}
|
||||
}
|
||||
)
|
||||
if (this.haskey(award, 'data.rewardsInfo.successRewards.1')) {
|
||||
p.log(`获得人气值:`, award.data.rewardsInfo.successRewards[1].quantity);
|
||||
}
|
||||
else {
|
||||
p.log(this.haskey(award, 'msg'))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.code) {
|
||||
let s = await this.curl({
|
||||
'form': `functionId=hc_boss_queryFloatBar&body=%7B%7D&appid=home-marketing&client=apple&osVersion=15.1.1&networkType=wifi&d_model=iPhone13,3&d_brand=iPhone&screen=390*844&clientVersion=15.1.53`,
|
||||
user
|
||||
}
|
||||
)
|
||||
let remainBuff = this.haskey(s, 'data.remainBuff') || 0
|
||||
if (remainBuff && this.code) {
|
||||
for (let i of this.code) {
|
||||
let f = remainBuff>=50 ? 50 : remainBuff
|
||||
remainBuff -= f
|
||||
p.log("正在投票:", i.bossInfo.bossName)
|
||||
let vote = await this.curl({
|
||||
'form': `functionId=hc_boss_vote&body={"bossId":${i.bossInfo.bossId},"votes":${f}}&appid=home-marketing&client=apple&osVersion=15.1.1&networkType=wifi&d_model=iPhone13,3&d_brand=iPhone&screen=390*844&openudid=a0114d4ed52e4588aa38c141909565afecb81298&clientVersion=15.1.53`,
|
||||
user
|
||||
}
|
||||
)
|
||||
if (this.haskey(vote, 'data.voteCount')) {
|
||||
p.log("总共投票:", vote.data.voteCount)
|
||||
}
|
||||
if (remainBuff<=0) {
|
||||
break
|
||||
}
|
||||
await this.wait(2000)
|
||||
}
|
||||
}
|
||||
s = await this.curl({
|
||||
'form': `functionId=hc_boss_queryFloatBar&body=%7B%7D&appid=home-marketing&client=apple&osVersion=15.1.1&networkType=wifi&d_model=iPhone13,3&d_brand=iPhone&screen=390*844&clientVersion=15.1.53`,
|
||||
user
|
||||
}
|
||||
)
|
||||
remainBuff = this.haskey(s, 'data.remainBuff')
|
||||
if (remainBuff == 0) {
|
||||
p.info.work = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user