From 1ca5178e14c84318b05d857c0f5cde07a17e6090 Mon Sep 17 00:00:00 2001 From: haptear Date: Thu, 16 Jun 2022 16:33:39 +0800 Subject: [PATCH] tx --- app_kyin.js | 3 ++ csh.js | 145 ++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 126 insertions(+), 22 deletions(-) diff --git a/app_kyin.js b/app_kyin.js index b5a5f51..50f5580 100644 --- a/app_kyin.js +++ b/app_kyin.js @@ -35,6 +35,9 @@ cron 0-59/10 6-20 * * * 脚本地址:https://gitee.com/soy-tool/app-script/raw/master/app_kyin.js +http://h5.kaixinyf.cn/api/invite/get_share_info +通过分享/邀请页面 可以抓包 +邀请码 2CHAQM */ diff --git a/csh.js b/csh.js index 26f750f..f26bbee 100644 --- a/csh.js +++ b/csh.js @@ -1,4 +1,4 @@ -/* +/* 潮生活(小程序) export cshCookie='token=xxxxx&openId=yyyyy' @@ -35,10 +35,12 @@ class UserInfo { this.param = $.str2json(str) this.stopFlag = false - this.pageLimit = 3 + this.articlePageLimit = 3 + this.prizePageLimit = 1 + this.prizeList = [] } - async getUserInfo() { + async getUserInfo(isNotify=false) { try { let url = `https://dh.wbgj.cn/integral_applet_2/integral/user/info` let bodyParam = { @@ -55,10 +57,14 @@ class UserInfo { this.valid = true this.name = result.info.wxUser.nickName this.integral = result.info.wxUser.integral - console.log(`昵称:${this.name}`) - console.log(`积分:${this.integral}`) + if(isNotify) { + $.logAndNotify(`[${this.name}] 积分:${this.integral}`) + } else { + console.log(`昵称:${this.name}`) + console.log(`积分:${this.integral}`) + } } else { - console.log(`账号[${this.index}]CK失效: ${result.message}`) + $.logAndNotify(`账号[${this.name}]CK失效: ${result.message}`) } } catch(e) { console.log(e) @@ -84,19 +90,19 @@ class UserInfo { if(!result) return //console.log(result) if(result.state==0) { - this.pageLimit = result.info.page.totalPage - console.log(`账号[${this.index}]获取到第${page}页${result.info.weixinArtivleList.length}篇文章,共${result.info.page.totalPage}页`) + this.articlePageLimit = result.info.page.totalPage + console.log(`账号[${this.name}]获取到第${page}页${result.info.weixinArtivleList.length}篇文章,共${result.info.page.totalPage}页`) for(let item of result.info.weixinArtivleList) { if(!item.read) { await this.visit(item,result.info.readToken) if(this.stopFlag) break; let rndwaittime = Math.floor(Math.random()*RANDOM_WAIT_TIME) + ROUND_WAIT_TIME - console.log(`账号[${this.index}]等待${rndwaittime/1000}秒继续阅读...`) + console.log(`账号[${this.name}]等待${rndwaittime/1000}秒继续阅读...`) await $.wait(rndwaittime) } } } else { - console.log(`账号[${this.index}]获取文章列表失败: ${result.message}`) + console.log(`账号[${this.name}]获取文章列表失败: ${result.message}`) } } catch(e) { console.log(e) @@ -123,7 +129,7 @@ class UserInfo { if(result.state==0) { await this.award(item,readToken) } else { - console.log(`账号[${this.index}]开始阅读文章[${item.tag}]失败: ${result.message}`) + console.log(`账号[${this.name}]开始阅读文章[${item.tag}]失败: ${result.message}`) } } catch(e) { console.log(e) @@ -150,9 +156,9 @@ class UserInfo { if(!result) return //console.log(result) if(result.state==0) { - console.log(`账号[${this.index}]阅读文章[${item.tag}]成功`) + console.log(`账号[${this.name}]阅读文章[${item.tag}]成功`) } else { - console.log(`账号[${this.index}]阅读文章[${item.tag}]失败: ${result.message}`) + console.log(`账号[${this.name}]阅读文章[${item.tag}]失败: ${result.message}`) if(result.message.indexOf('用户处于锁定时间') > -1) { this.stopFlag = true } @@ -164,15 +170,99 @@ class UserInfo { } } + async getPrizeList(page) { + try { + let url = `https://dh.wbgj.cn/integral_applet_2/integral/convert_center/prize` + let bodyParam = { + token: this.param.token, + openId: this.param.openId, + page: page, + } + let body = getSign(bodyParam) + let urlObject = populateUrlObject(url,body) + await httpRequest('post',urlObject) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.state==0) { + this.prizePageLimit = result.info.page.totalPage + for(let item of result.info.prizeList) { + this.prizeList.push(item) + } + } else { + console.log(`账号[${this.name}]获取第${page}页提现列表失败: ${result.message}`) + } + } catch(e) { + console.log(e) + } finally { + return Promise.resolve(1); + } + } + + async exchange(item) { + try { + let url = `https://dh.wbgj.cn/integral_applet_2/integral/convert_center/exchange/prize` + let bodyParam = { + token: this.param.token, + openId: this.param.openId, + code: '', + convertId: item.convertId, + phone: '', + account: '', + } + let body = getSign(bodyParam) + let urlObject = populateUrlObject(url,body) + await httpRequest('post',urlObject) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.state==0) { + this.integral -= item.integral + $.logAndNotify(`账号[${this.name}]提现[${item.prizeName}]成功`) + } else { + $.logAndNotify(`账号[${this.name}]提现[${item.prizeName}]失败: ${result.message}`) + } + } catch(e) { + console.log(e) + } finally { + return Promise.resolve(1); + } + } + + async userExchangeTask() { + try { + await this.getUserInfo(true); + await this.getPrizeList(1); + if(this.prizePageLimit > 1) { + for(let i=2; i<=this.prizePageLimit; i++) { + await this.getPrizeList(i); + } + } + if(this.prizeList.length > 0) { + for(let item of this.prizeList.sort(function(a,b) {return b.prizeWorth-a.prizeWorth})) { + if(this.integral < item.integral) continue; + if(item.prizeCount - item.drawCount <= 0) continue; + await this.exchange(item) + } + } else { + $.logAndNotify(`账号[${this.name}]没有获取到提现选项`) + } + } catch(e) { + console.log(e) + } finally { + return Promise.resolve(1); + } + } + async userTask() { try { await this.articleList(1); - if(this.pageLimit > 1) { - for(let i=2; i<=this.pageLimit && !this.stopFlag; i++) { + if(this.articlePageLimit > 1) { + for(let i=2; i<=this.articlePageLimit && !this.stopFlag; i++) { await this.articleList(i); } } - console.log(`账号[${this.index}]已完成阅读`) + console.log(`账号[${this.name}]已完成阅读`) } catch(e) { console.log(e) } finally { @@ -295,15 +385,26 @@ function getSign(e) { for(let user of userList) { console.log(`\n============= 账号[${user.index}] =============`) - await user.getUserInfo(); + await user.getUserInfo(false); } - console.log(`\n============= 开始阅读 =============`) - let taskall = [] - for(let user of userList.filter(x => x.valid)) { - taskall.push(user.userTask()) + let validUserList = userList.filter(x => x.valid) + + if(validUserList.length > 0) { + console.log(`\n============= 开始阅读 =============`) + let taskall = [] + for(let user of validUserList) { + taskall.push(user.userTask()) + } + await Promise.all(taskall); + + console.log(`\n============= 提现 =============`) + for(let user of validUserList) { + await user.userExchangeTask(true); + } } - await Promise.all(taskall); + + await $.showmsg(); } })() .catch((e) => console.log(e))