diff --git a/58tc.js b/58tc.js index 13227c8..9ccd4de 100644 --- a/58tc.js +++ b/58tc.js @@ -36,7 +36,6 @@ let notifyStr = '' let httpResult //global buffer -// process.env.wbtcCookie = 'PPU=UID=85475511850040&UN=1q50eb1ei&TT=731896f4de0840460c2362a88193dec4&PBODY=HpV7LXKYtw5Yz5PN77H8xUuS5tMJ2gVrfMH6-MnRWno0QTSD4AdPgBBzB235byGvmfx14WV3bmj4YUCf7RdE8cHIONbSYfy6cDcAbljXjpHN7hgBGdQXjiIHVzL9vohqPnDKHNkKy4ksApUkb8m4YqmbCGoqnk1KB52sRXRBsVQ&VER=1&CUID=oZr_q1CkAW_ByTAzCm0nCg' let userCookie = ($.isNode() ? process.env.wbtcCookie : $.getdata('wbtcCookie')) || ''; let userUA = ($.isNode() ? process.env.wbtcUA : $.getdata('wbtcUA')) || 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 WUBA/10.26.5'; let userCookieArr = [] @@ -46,9 +45,9 @@ let userIdx = 0 let userCount = 0 //let taskList = [1,2,3,4,5,6,7,9,10,13,15,16] -let taskList = [9, 10, 13] -let TASK_TIME = [7, 24] -let attendType = { 'oneDay': '一天打卡', 'multiDay': '三天打卡' } +let taskList = [1,9,10,13] +let TASK_TIME = [7,24] +let attendType = {'oneDay':'一天打卡', 'multiDay':'三天打卡'} let curHour = (new Date()).getHours() @@ -70,99 +69,99 @@ class UserInfo { this.task = [] this.reward = [] this.runTask = strArr[1] || 0 - - let taskStr = this.runTask == 1 ? '投入' : '不投入' + + let taskStr = this.runTask==1 ? '投入' : '不投入' console.log(`账号[${this.index}]现在小游戏矿石设置为:${taskStr}`) } - - async getTaskList (sceneId) { + + async getTaskList(sceneId) { let url = `https://taskframe.58.com/web/task/dolist?sceneId=${sceneId}&openpush=0&source=` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { - if (!result.result.taskList) return; + if(result.code == 0) { + if(!result.result.taskList) return; //status: 0 - 未完成,1 - 已完成,2 - 已领取 - for (let task of result.result.taskList) { + for(let task of result.result.taskList) { let doneStr = '' - if (task.taskTotalCount) { + if(task.taskTotalCount) { doneStr = ` ${task.taskDoneCount}/${task.taskTotalCount}` } - let statusStr = (task.status == 0) ? '未完成' : ((task.status == 1) ? '已完成' : '已领取') + let statusStr = (task.status==0) ? '未完成' : ((task.status==1) ? '已完成' : '已领取') console.log(`账号[${this.index}]任务[${sceneId}-${task.itemId}]:${doneStr} +${task.rewardDisplayValue} ${statusStr}`) - if (task.status == 0) { - this.task.push({ sceneId: sceneId, taskId: task.itemId }) - } else if (task.status == 1) { - this.reward.push({ sceneId: sceneId, taskId: task.itemId }) + if(task.status == 0) { + this.task.push({sceneId:sceneId,taskId:task.itemId}) + } else if(task.status == 1) { + this.reward.push({sceneId:sceneId,taskId:task.itemId}) } } } else { console.log(`账号[${this.index}]查询任务列表失败: ${result.message}`) } } - - async doTask (sceneId, taskId) { - //todo - return; - let url = `https://taskframe.58.com/web/task/dotask?timestamp=${(new Date()).getTime()}&sign=${randomString(32)}&taskId=${taskId}`//&taskData=15` + + async doTask(sceneId,taskId) { + var time = `${(new Date()).getTime()}` + var signo = `${time}${taskId}` + let url = `https://taskframe.58.com/web/task/dotask?timestamp=${time}&sign=${MD5Encrypt(signo)}&taskId=${taskId}`//&taskData=15` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]完成任务[${sceneId}-${taskId}]`) } else { console.log(`账号[${this.index}]完成任务[${sceneId}-${taskId}]失败: ${result.message}`) } } - - async getReward (sceneId, taskId) { - //todo - return; - let url = `https://taskframe.58.com/web/task/reward?timestamp=${(new Date()).getTime()}&sign=${randomString(32)}&taskId=${taskId}` + + async getReward(sceneId,taskId) { + var time = `${(new Date()).getTime()}` + var signo = `${time}${taskId}` + let url = `https://taskframe.58.com/web/task/reward?timestamp=${time}&sign=${MD5Encrypt(signo)}&taskId=${taskId}` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]领取任务[${sceneId}-${taskId}]奖励成功`) } else { console.log(`账号[${this.index}]领取任务[${sceneId}-${taskId}]奖励失败: ${result.message}`) } } - - async newbieMaininfo () { + + async newbieMaininfo() { let url = `https://rightsplatform.58.com/web/motivate/maininfo` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { this.newbie.coin = parseFloat(result.result.coin) this.newbie.isWithdraw = result.result.userWithdraw - if (result.result.todaySignDay <= 7) { - this.newbie.signItem = result.result.signInfo[result.result.todaySignDay - 1] - let signStr = (this.newbie.signItem.status == 0) ? '未签到' : '已签到' + if(result.result.todaySignDay<=7) { + this.newbie.signItem = result.result.signInfo[result.result.todaySignDay-1] + let signStr = (this.newbie.signItem.status==0) ? '未签到' : '已签到' console.log(`账号[${this.index}]今日新手任务${signStr}`) - if (this.newbie.signItem.status == 0) { + if(this.newbie.signItem.status == 0) { await $.wait(500) await this.newbieSign() } } console.log(`账号[${this.index}]新手金币余额:${this.newbie.coin}`) - if (this.newbie.isWithdraw == false) { - let sortList = result.result.withdrawInfo.sort(function (a, b) { return b.cardAmount - a.cardAmount }) - for (let withItem of sortList) { - if (this.newbie.coin >= withItem.cardCoin) { + if(this.newbie.isWithdraw==false) { + let sortList = result.result.withdrawInfo.sort(function(a,b) {return b.cardAmount-a.cardAmount}) + for(let withItem of sortList) { + if(this.newbie.coin >= withItem.cardCoin) { await $.wait(500) await this.newbieWithdraw(withItem) } @@ -172,52 +171,52 @@ class UserInfo { console.log(`账号[${this.index}]查询新手主页失败: ${result.message}`) } } - - async newbieSign () { + + async newbieSign() { let url = `https://rightsplatform.58.com/web/motivate/sign` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('post', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('post',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { this.newbie.coin += parseFloat(this.newbie.signItem.signCoin) console.log(`账号[${this.index}]新手任务第${this.newbie.signItem.number}天签到成功,获得${this.newbie.signItem.signCoin}金币`) } else { console.log(`账号[${this.index}]新手任务签到失败: ${result.message}`) } } - - async newbieWithdraw (withItem) { + + async newbieWithdraw(withItem) { let url = `https://rightsplatform.58.com/web/motivate/withdraw` let body = `id=${withItem.id}` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('post', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('post',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]成功兑换${withItem.cardAmount}元到矿石余额`) } else { console.log(`账号[${this.index}]兑换${withItem.cardAmount}元到矿石余额失败: ${result.message}`) } } - - async houseSignStatus () { + + async houseSignStatus() { let url = `https://lovely-house.58.com/sign/info` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { - for (let item of result.result) { - if (item.today == true) { - let signStr = (item.sign == false) ? '未签到' : '已签到' + if(result.code == 0) { + for(let item of result.result) { + if(item.today == true) { + let signStr = (item.sign==false) ? '未签到' : '已签到' console.log(`账号[${this.index}]今日我的家${signStr}`) - if (item.sign == false) { + if(item.sign == false) { await $.wait(500) await this.houseSign() } @@ -228,22 +227,22 @@ class UserInfo { console.log(`账号[${this.index}]查询我的家签到状态失败: ${result.message}`) } } - - async houseSign () { + + async houseSign() { let url = `https://lovely-house.58.com/sign/signin` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('post', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('post',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]我的家签到成功,获得${result.result.gold}金币`) } else { console.log(`账号[${this.index}]我的家签到失败: ${result.message}`) } } - + //打扫房间 async houseClean () { let furnitureId = await this.houseGetCleanId(); @@ -276,19 +275,19 @@ class UserInfo { return '0'; } - async houseWithdrawPage () { + async houseWithdrawPage() { let url = `https://lovely-house.58.com/web/exchange/info` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { this.house.coin = result.result.coin console.log(`账号[${this.index}]我的家金币余额:${this.house.coin}`) - let sortList = result.result.oreList.sort(function (a, b) { return b.amount - a.amount }) - if (sortList.length > 0 && sortList[0].oreStatus == 0 && this.house.coin >= sortList[0].coin) { + let sortList = result.result.oreList.sort(function(a,b) {return b.amount-a.amount}) + if(sortList.length>0 && sortList[0].oreStatus == 0 && this.house.coin >= sortList[0].coin) { await $.wait(500) await this.houseWithdraw(sortList[0]) } @@ -296,40 +295,40 @@ class UserInfo { console.log(`账号[${this.index}]查询我的家兑换页失败: ${result.message}`) } } - - async houseWithdraw (withItem) { + + async houseWithdraw(withItem) { let url = `https://lovely-house.58.com/web/exchange/ore` let body = `id=${withItem.id}` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('post', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('post',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]成功兑换${withItem.amount}矿石 ≈ ${withItem.money}元`) } else { console.log(`账号[${this.index}]兑换${withItem.amount}矿石失败: ${result.message}`) } } - - async oreMainpage (dotask = true) { + + async oreMainpage(dotask=true) { let url = `https://magicisland.58.com/web/mineral/main?openSettings=0` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { this.ore.sign = result.result.tasks.sign.state this.ore.dailyore = result.result.userInfo.dailyOre this.ore.ore = parseFloat(result.result.userInfo.minerOre) this.ore.money = parseFloat(result.result.userInfo.minerOreValue) - if (dotask) { + if(dotask) { let gameStatus = result.result.games.gameProcess let gameStr = '' - if (gameStatus.awardState == 0) { - if (gameStatus.gameNum == gameStatus.joinedNum) { + if(gameStatus.awardState==0) { + if(gameStatus.gameNum==gameStatus.joinedNum) { this.ore.gameFlag = 1 gameStr = '已完成' } else { @@ -340,18 +339,18 @@ class UserInfo { this.ore.gameFlag = 2 gameStr = '已领取' } - let signStr = (this.ore.sign == 0) ? '未签到' : '已签到' - let dailyStr = (this.ore.dailyore == 0) ? '未采集' : '已采集' + let signStr = (this.ore.sign==0) ? '未签到' : '已签到' + let dailyStr = (this.ore.dailyore==0) ? '未采集' : '已采集' console.log(`账号[${this.index}]今日神奇矿${dailyStr},${signStr},参加三个小游戏任务${gameStr}`) - if (this.ore.sign == 0) { + if(this.ore.sign==0) { await $.wait(500) await this.oreSign() } - if (this.ore.dailyore == 0) { + if(this.ore.dailyore==0) { await $.wait(500) await this.getDailyore() } - if (this.ore.gameFlag == 1) { + if(this.ore.gameFlag==1) { await $.wait(500) await this.oreGameScore() } @@ -361,31 +360,31 @@ class UserInfo { console.log(`账号[${this.index}]查询神奇矿主页失败: ${result.message}`) } } - - async getDailyore () { + + async getDailyore() { let url = `https://magicisland.58.com/web/mineral/dailyore` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]采集神奇矿成功`) } else { console.log(`账号[${this.index}]采集神奇矿失败: ${result.message}`) } } - - async oreSign () { + + async oreSign() { let url = `https://magicisland.58.com/web/sign/signInV2?sessionId=&successToken=&scene=null` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { this.ore.ore += parseFloat(result.result.ore) this.ore.money += parseFloat(result.result.amount) console.log(`账号[${this.index}]神奇矿签到成功,获得${result.result.ore}矿石 ≈ ${result.result.amount}元`) @@ -393,28 +392,28 @@ class UserInfo { console.log(`账号[${this.index}]神奇矿签到失败: ${result.message}`) } } - - async miningUserInfo () { + + async miningUserInfo() { let url = `https://magicisland.58.com/web/mining/userInfo` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { this.mining.enroll = result.result.status - let enrollStr = (this.mining.enroll == 0) ? '未召唤小帮手' : '已召唤小帮手' + let enrollStr = (this.mining.enroll==0) ? '未召唤小帮手' : '已召唤小帮手' console.log(`账号[${this.index}]神奇矿山${enrollStr}`) - if (result.result.grantList && result.result.grantList.length > 0) { - for (let mines of result.result.grantList) { + if(result.result.grantList && result.result.grantList.length > 0) { + for(let mines of result.result.grantList) { await $.wait(500) await this.miningGain(mines.id) } this.mining.enroll = 0 } - if (this.runTask == 1 && this.mining.enroll == 0) { - if (parseFloat(result.result.usableOre) >= result.result.threshold) { + if(this.runTask == 1 && this.mining.enroll==0) { + if(parseFloat(result.result.usableOre) >= result.result.threshold) { await $.wait(500) await this.miningEnroll() } else { @@ -425,66 +424,66 @@ class UserInfo { console.log(`账号[${this.index}]查询神奇矿山主页失败: ${result.message}`) } } - - async miningGain (id) { + + async miningGain(id) { let url = `https://magicisland.58.com/web/mining/gain?id=${id}` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]神奇矿山成功收取${result.result.gainOre}矿石`) } else { console.log(`账号[${this.index}]神奇矿山收取矿石失败: ${result.message}`) } } - - async miningEnroll () { + + async miningEnroll() { let url = `https://magicisland.58.com/web/mining/enroll` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]神奇矿山召唤小帮手成功`) } else { console.log(`账号[${this.index}]神奇矿山召唤小帮手失败: ${result.message}`) } } - - async auctionInfo () { + + async auctionInfo() { let url = `https://magicisland.58.com/web/auction/second` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) + let urlObject = populateUrlObject(url,this.cookie,body) urlObject.headers.Referer = 'https://magicisland.58.com/web/v/lowauctiondetail' - await httpRequest('get', urlObject) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { this.auction.status = result.result.bidInfo.bidStatus - let auctionStr = (this.auction.status == 0) ? '未参与竞拍' : '已参与竞拍' + let auctionStr = (this.auction.status==0) ? '未参与竞拍' : '已参与竞拍' console.log(`账号[${this.index}]今天${auctionStr}`) let maxBid = parseFloat(result.result.userInfo.usableOre) let bidNum = 1 - if (this.runTask == 1) { - if (this.auction.status == 0) { - if (maxBid >= bidNum) { + if(this.runTask == 1) { + if(this.auction.status==0) { + if(maxBid >= bidNum) { await $.wait(500) await this.auctionBid(bidNum) } else { console.log(`账号[${this.index}]可用矿石余额${maxBid}不足,不能竞拍出价${bidNum}矿石`) } - } else if (this.auction.status == 1) { + } else if(this.auction.status==1) { let lastBid = parseInt(result.result.bidInfo.bidOre) - bidNum = (lastBid) % 3 + 1 - if (maxBid >= bidNum) { + bidNum = (lastBid)%3 + 1 + if(maxBid >= bidNum) { await $.wait(500) - await this.auctionModify(bidNum, result.result.bidInfo.auctionNumber) + await this.auctionModify(bidNum,result.result.bidInfo.auctionNumber) } else { console.log(`账号[${this.index}]可用矿石余额${maxBid}不足,不能竞拍出价${bidNum}矿石`) } @@ -494,84 +493,84 @@ class UserInfo { console.log(`账号[${this.index}]查询低价竞拍主页失败: ${result.message}`) } } - - async auctionBid (prize) { + + async auctionBid(prize) { let url = `https://magicisland.58.com/web/auction/bid` let body = `ore=${prize}` - let urlObject = populateUrlObject(url, this.cookie, body) + let urlObject = populateUrlObject(url,this.cookie,body) urlObject.headers.Referer = 'https://magicisland.58.com/web/v/lowauctiondetail' - await httpRequest('post', urlObject) + await httpRequest('post',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]竞拍出价${prize}矿石成功`) } else { console.log(`账号[${this.index}]竞拍出价${prize}矿石失败: ${result.message}`) } } - - async auctionModify (prize, number) { + + async auctionModify(prize,number) { let url = `https://magicisland.58.com/web/auction/modify` let body = `ore=${prize}&number=${number}` - let urlObject = populateUrlObject(url, this.cookie, body) + let urlObject = populateUrlObject(url,this.cookie,body) urlObject.headers.Referer = 'https://magicisland.58.com/web/v/lowauctiondetail' - await httpRequest('post', urlObject) + await httpRequest('post',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]竞拍改价${prize}矿石成功`) } else { console.log(`账号[${this.index}]竞拍改价${prize}矿石失败: ${result.message}`) } } - - async oreGameScore () { + + async oreGameScore() { let url = `https://magicisland.58.com/web/mineral/gameprocessore` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]领取游戏完成奖励成功`) } else { console.log(`账号[${this.index}]领取游戏完成奖励失败: ${result.message}`) } } - - async attendanceDetail () { + + async attendanceDetail() { let url = `https://magicisland.58.com/web/attendance/detail/info?productorid=3` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { let attendList = '' console.log(`账号[${this.index}]今天打卡状态:`) - for (let item of result.result.infoList) { + for(let item of result.result.infoList) { let type = attendType[item.type] - let str = (item.userState == 0) ? '未报名' : ((item.userState == 5) ? '可打卡' : '已报名') + let str = (item.userState==0) ? '未报名' : ((item.userState==5) ? '可打卡' :'已报名') console.log(`账号[${this.index}]${type}${item.number}期 -- ${str}`) - if (item.userState == 0) { - if (this.runTask == 1) { - if (this.ore.ore >= item.oreLimitValue) { + if(item.userState==0) { + if(this.runTask == 1) { + if(this.ore.ore >= item.oreLimitValue) { await $.wait(500) await this.attendanceSignIn(item) } else { console.log(`账号[${this.index}]矿石余额${this.ore.ore}不足,不能花费${item.oreLimitValue}矿石报名${type}${item.number}期打卡`) } } - } else if (item.userState == 5) { - let numType = (item.type == 'multiDay') ? 'numberMany' : 'number' + } else if (item.userState==5) { + let numType = (item.type=='multiDay') ? 'numberMany' : 'number' attendList += `&${numType}=${item.number}` } } - if (attendList) { + if(attendList) { await $.wait(500) await this.attendanceAttend(attendList) } @@ -579,66 +578,66 @@ class UserInfo { console.log(`账号[${this.index}]查询打卡状态失败: ${result.message}`) } } - - async attendanceSignIn (item) { + + async attendanceSignIn(item) { let type = attendType[item.type] let url = `https://magicisland.58.com/web/attendance/signIn` let body = `number=${item.number}&category=${item.type}&productorid=3` - let urlObject = populateUrlObject(url, this.cookie, body) + let urlObject = populateUrlObject(url,this.cookie,body) urlObject.headers.Referer = 'https://magicisland.58.com/web/v/client' - await httpRequest('post', urlObject) + await httpRequest('post',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]报名${type}${item.number}期成功,预计可获得${result.result.averageRewardOre}矿石`) } else { console.log(`账号[${this.index}]报名${type}${item.number}期失败: ${result.message}`) } } - - async attendanceAttend (attendList) { + + async attendanceAttend(attendList) { let url = `https://magicisland.58.com/web/attendance/attend` let body = `productorid=3${attendList}` - let urlObject = populateUrlObject(url, this.cookie, body) + let urlObject = populateUrlObject(url,this.cookie,body) urlObject.headers.Referer = 'https://magicisland.58.com/web/v/client' - await httpRequest('post', urlObject) + await httpRequest('post',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]打卡成功`) } else { console.log(`账号[${this.index}]打卡失败: ${result.message}`) } } - - async cashSigninlist () { + + async cashSigninlist() { let url = `https://tzbl.58.com/tzbl/taskcenter/signinlist?requestSource=1` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { - this.cashSign = result.data.signInVO.status == 2 ? true : false + if(result.code == 0) { + this.cashSign = result.data.signInVO.status==2 ? true : false let cashStr = this.cashSign ? '未签到' : '已签到' console.log(`账号[${this.index}]今日现金签到页: ${cashStr}`) } else { console.log(`账号[${this.index}]查询现金签到失败: ${result.message}`) } } - - async cashSignin () { + + async cashSignin() { let url = `https://tzbl.58.com/tzbl/taskcenter/signin?requestSource=1` let body = `` - let urlObject = populateUrlObject(url, this.cookie, body) - await httpRequest('get', urlObject) + let urlObject = populateUrlObject(url,this.cookie,body) + await httpRequest('get',urlObject) let result = httpResult; - if (!result) return + if(!result) return //console.log(result) - if (result.code == 0) { + if(result.code == 0) { console.log(`账号[${this.index}]现金签到获得${result.data.amount}元`) } else { console.log(`账号[${this.index}]查询现金签到失败: ${result.message}`) @@ -649,153 +648,153 @@ class UserInfo { !(async () => { if (typeof $request !== "undefined") { await GetRewrite() - } else { - if (!(await checkEnv())) return + }else { + if(!(await checkEnv())) return console.log('====================\n') console.log(`如果要自定义UA,请把UA填到wbtcUA里,现在使用的UA是:\n${userUA}`) - + console.log('\n================== 现金签到 ==================') - for (let user of userList) { - await user.cashSigninlist(); + for(let user of userList) { + await user.cashSigninlist(); await $.wait(200); } - - for (let user of userList.filter(x => x.cashSign)) { - await user.cashSignin(); + + for(let user of userList.filter(x => x.cashSign)) { + await user.cashSignin(); await $.wait(200); } - + console.log('\n================== 矿山小游戏 ==================') - for (let user of userList) { - await user.miningUserInfo(); + for(let user of userList) { + await user.miningUserInfo(); await $.wait(200); } - + console.log('\n================== 竞拍小游戏 ==================') - for (let user of userList) { - await user.auctionInfo(); + for(let user of userList) { + await user.auctionInfo(); await $.wait(200); } - + console.log('\n================== 打卡小游戏 ==================') - for (let user of userList) { - await user.oreMainpage(false); + for(let user of userList) { + await user.oreMainpage(false); await $.wait(200); } - - for (let user of userList) { - await user.attendanceDetail(); + + for(let user of userList) { + await user.attendanceDetail(); await $.wait(200); } - - // console.log('\n================== 金币任务 ==================') - // if (curHour >= TASK_TIME[0] && curHour < TASK_TIME[1]) { - // console.log('\n查询任务...') - // for (let id of taskList) { - // for (let user of userList) { - // await user.getTaskList(id); - // await $.wait(200); - // } - // } - - // for (let user of userList) { - // maxTaskLen = getMax(user.task.length, maxTaskLen) - // maxRewardLen = getMax(user.reward.length, maxRewardLen) - // } - - // console.log('\n完成任务...') - // for(let i=0; i i i < x.reward.length)) { - // let item = user.reward[i] - // await user.getReward(item.sceneId, item.taskId); - // await $.wait(200); - // } - // await $.wait(500); - // } - // } else { - // console.log(`${TASK_TIME[0]}点到${TASK_TIME[1]}点之间会做金币任务`) - // } - + + console.log('\n================== 金币任务 ==================') + if(curHour>=TASK_TIME[0] && curHour i i $.logErr(e)) - .finally(() => $.done()) +.catch((e) => $.logErr(e)) +.finally(() => $.done()) /////////////////////////////////////////////////////////////////// -async function checkEnv () { - if (userCookie) { - for (let userCookies of userCookie.split('@')) { - if (userCookies) userList.push(new UserInfo(userCookies)) +async function checkEnv() { + if(userCookie) { + for(let userCookies of userCookie.split('@')) { + if(userCookies) userList.push(new UserInfo(userCookies)) } userCount = userList.length } else { console.log('未找到wbtcCookie') return; } - + console.log(`共找到${userCount}个账号`) return true } -async function GetRewrite () { - if ($request.url.indexOf('getIndexSignInInfo') > -1) { +async function GetRewrite() { + if($request.url.indexOf('getIndexSignInInfo') > -1) { let ppu = $request.headers.ppu ? $request.headers.ppu : $request.headers.PPU - if (!ppu) return; + if(!ppu) return; let uid = ppu.match(/UID=(\w+)/)[1] let ck = 'PPU=' + ppu - - if (userCookie) { - if (userCookie.indexOf('UID=' + uid) == -1) { + + if(userCookie) { + if(userCookie.indexOf('UID='+uid) == -1) { userCookie = userCookie + '@' + ck $.setdata(userCookie, 'wbtcCookie'); ckList = userCookie.split('@') - $.msg(jsname + ` 获取第${ckList.length}个wbtcCookie成功: ${ck}`) + $.msg(jsname+` 获取第${ckList.length}个wbtcCookie成功: ${ck}`) } else { - console.log(jsname + ` 找到重复的wbtcCookie,准备替换: ${ck}`) + console.log(jsname+` 找到重复的wbtcCookie,准备替换: ${ck}`) ckList = userCookie.split('@') - for (let i = 0; i < ckList.length; i++) { - if (ckList[i].indexOf('UID=' + uid) > -1) { + for(let i=0; i numStr.length) ? (length - numStr.length) : 0 + let numPad = (length>numStr.length) ? (length-numStr.length) : 0 let retStr = '' - for (let i = 0; i < numPad; i++) { + for(let i=0; i