diff --git a/blackUnique.jpg b/blackUnique.jpg new file mode 100644 index 0000000..cb29696 Binary files /dev/null and b/blackUnique.jpg differ diff --git a/blackUnique.js b/blackUnique.js new file mode 100644 index 0000000..7862ff4 --- /dev/null +++ b/blackUnique.js @@ -0,0 +1,1669 @@ +/* +APP:全球购骑士特权 + +直接appstore搜索下载,方便的话可以微信扫下面图片二维码走邀请注册,谢谢 +https://raw.githubusercontent.com/leafxcy/JavaScript/main/blackUnique.jpg + +定时为每小时一次,务必在0分到5分之间运行,目前只写了每日领勋章和领取存钱罐的任务,大概每天3毛 +提现需要关注微信公众号,在公众号里申请提现 +请手动点一下签到页面的【收零花钱】领一次金币,去【果园】里选择水果种子 +只测试了IOS的青龙和V2P,暂不支持多账号 + +青龙: +捉https://market.chuxingyouhui.com/promo-bargain-api/activity/mqq/api/indexTopInfo?的包,获得appId +捉https://pyp-api.chuxingyouhui.com/api/app/userCenter/v1/info的包,获得其他header +然后填在blackJSON里面,注意按照JSON格式填写。用青龙面板的环境变量或者外面用双引号的,字符串内需要用\"转义 +export blackJSON='{"black-token":"", "token":"", "User-Agent":"", "device-value":"", "device-type":"", "phpUserId":"", "appId":""}' + +V2P,圈X:重写方法 -- 点击右下角【我的】-> 【每日签到赚现金】 +[task_local] +#全球购骑士特权 +0 * * * * https://raw.githubusercontent.com/leafxcy/JavaScript/main/blackUnique.js, tag=全球购骑士特权, enabled=true +[rewrite_local] +https://pyp-api.chuxingyouhui.com/api/app/userCenter/v1/info url script-request-header https://raw.githubusercontent.com/leafxcy/JavaScript/main/blackUnique.js +https://market.chuxingyouhui.com/promo-bargain-api/activity/mqq/api/indexTopInfo? url script-request-header https://raw.githubusercontent.com/leafxcy/JavaScript/main/blackUnique.js +[MITM] +hostname = *.chuxingyouhui.com + +*/ + +const jsname = '全球购骑士特权' +const $ = Env(jsname) +const notifyFlag = 1; //0为关闭通知,1为打开通知,默认为1 +const logDebug = 0 + +//const notify = $.isNode() ? require('./sendNotify') : ''; +let notifyStr = '' + +let blankJSON = {"black-token":"", "token":"", "User-Agent":"", "device-value":"", "device-type":"", "phpUserId":"", "appId":""} +let blackJSONStr = ($.isNode() ? (process.env.blackJSON) : ($.getval('blackJSON'))) || '' +let blackJSON = blackJSONStr ? JSON.parse(blackJSONStr) : blankJSON + +let reqTime = '' +let userSign = '' +let redPacketId = '' +let fruitId = '' +let userFruitId = '' +let activityId = '' +let redPacketCount = 0 +let waterCount = 0 +let fertilizerCount = 0 +let clickTreeTimes = 5 +let signRetryTimes = 3 +let signRetryCount = 0 + +var todayDate = formatDateTime(new Date()); +let bussinessInfo = '{}' + +let rndtime = "" //毫秒 + +/////////////////////////////////////////////////////////////////// + +!(async () => { + + if(typeof $request !== "undefined") + { + await getRewrite() + } + else + { + //检查环境变量 + if(!(await checkEnv())){ + return + } + + console.log('\n提现需要关注微信公众号,在公众号里申请提现') + + await querySignStatus() + + await listUserTask() + + //await listRedPacket() + + await queryPiggyInfo() + + //翻卡看视频需要前置条件 + //await getUserFlopRecord() + + await userFruitDetail() + + await waterTaskList() + + await nutrientTaskList() + + await userFertilizerDetail() + + await getTreeCoupon() + + await userInfo() + + await showmsg() + } + + +})() +.catch((e) => $.logErr(e)) +.finally(() => $.done()) + +//通知 +async function showmsg() { + + notifyBody = jsname + "运行通知\n\n" + notifyStr + + if (notifyFlag != 1) { + console.log(notifyBody); + } + + if (notifyFlag == 1) { + $.msg(notifyBody); + //if ($.isNode()){await notify.sendNotify($.name, notifyBody );} + } +} + +async function getRewrite() +{ + if($request.url.indexOf("userCenter/v1/info") > -1) { + if($request.headers['black-token']) { + blackJSON['black-token'] = $request.headers['black-token'] + $.log(`获取到black-token: ${blackJSON['black-token']}`) + $.msg(`获取到black-token: ${blackJSON['black-token']}`) + } + if($request.headers['token']) { + blackJSON['token'] = $request.headers['token'] + $.log(`获取到token: ${blackJSON['token']}`) + $.msg(`获取到token: ${blackJSON['token']}`) + } + if($request.headers['User-Agent']) { + blackJSON['User-Agent'] = $request.headers['User-Agent'] + $.log(`获取到User-Agent: ${blackJSON['User-Agent']}`) + $.msg(`获取到User-Agent: ${blackJSON['User-Agent']}`) + } + if($request.headers['device-value']) { + blackJSON['device-value'] = $request.headers['device-value'] + $.log(`获取到device-value: ${blackJSON['device-value']}`) + $.msg(`获取到device-value: ${blackJSON['device-value']}`) + } + if($request.headers['device-type']) { + blackJSON['device-type'] = $request.headers['device-type'] + $.log(`获取到device-type: ${blackJSON['device-type']}`) + $.msg(`获取到device-type: ${blackJSON['device-type']}`) + } + if($request.headers['phpUserId']) { + blackJSON['phpUserId'] = $request.headers['phpUserId'] + $.log(`获取到phpUserId: ${blackJSON['phpUserId']}`) + $.msg(`获取到phpUserId: ${blackJSON['phpUserId']}`) + } + $.setdata(JSON.stringify(blackJSON),'blackJSON') + } + + if($request.url.indexOf("mqq/api/indexTopInfo?appId=") > -1) { + blackJSON['appId'] = $request.url.match(/appId=([\w]+)/)[1] + $.log(`获取到appId: ${blackJSON['appId']}`) + $.msg(`获取到appId: ${blackJSON['appId']}`) + $.setdata(JSON.stringify(blackJSON),'blackJSON') + } +} + +async function checkEnv() +{ + if(!blackJSON['black-token'] || !blackJSON['token'] || !blackJSON['User-Agent'] || !blackJSON['device-value'] || !blackJSON['device-type'] || !blackJSON['phpUserId'] || !blackJSON['appId']) + { + $.log(`捉包信息不全,请检查空白字段并重新捉包: ${JSON.stringify(blackJSON)}\n`) + $.msg(`捉包信息不全,请检查空白字段并重新捉包: ${JSON.stringify(blackJSON)}\n`) + return false + } + + return true +} + +//========================================================================== +//获取视频信息 +async function getBussinessInfo(adId,activityType,bussinessType,version) { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + reqBody = `{"adId":"${adId}","activityType":${activityType},"bussinessType":"${bussinessType}","version":"${version}"}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/video/api/v1_0/getBussinessInfo', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + bussinessInfo = result.data ? JSON.stringify(result.data) : '{}' + } else { + console.log(`获取视频信息失败:${result.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//获取签到状态 +async function querySignStatus() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/activity/weekSign/api/v1_0/calendar?appId='+blackJSON['appId'], + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'Origin' : 'https://m.black-unique.com', + 'Accept-Encoding' : 'gzip, deflate, br', + 'Connection' : 'keep-alive', + 'black-token' : blackJSON['black-token'], + 'Accept' : 'application/json, text/plain, */*', + 'User-Agent' : blackJSON['User-Agent'], + 'Referer' : 'https://m.black-unique.com/', + 'token' : blackJSON['token'], + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + }, + }; + $.get(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + if(result.data && result.data.calendar && Array.isArray(result.data.calendar)) { + for(let i=0; i< result.data.calendar.length; i++) { + let signItem = result.data.calendar[i] + if(signItem.isToday == true) { + if(signItem.signStyle == 0) { + await doSign() + } else { + console.log(`\n今日已签到\n`) + } + } + } + } + } else { + console.log(`\n获取签到状态失败:${result.msg}\n`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//签到 +async function doSign() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + reqBody = `{}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/activity/weekSign/api/v1_0/sign?appId='+blackJSON['appId'], + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`\n签到成功获得:${result.data.reward}金币,已连续签到${result.data.continuouslyDay}天\n`) + } else { + console.log(`\n签到失败:${result.msg}\n`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//日常-任务列表 +async function listUserTask() { + let caller = printCaller() + rndtime = Math.round(new Date().getTime()) + reqBody = `{"activityType":13}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/activity/task/api/list_user_task', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + if(result.data && Array.isArray(result.data)) { + for(let i=0; i -1 && (rndtime < taskItem.receiveStartTime || rndtime > taskItem.receiveEndTime)) { + //非整点领勋章时间 + continue + } else if(taskItem.taskType.indexOf('SHOPPING') > -1) { + //跳过购物任务 + continue + } + await $.wait(1000) + await doTask(taskItem.taskType,taskItem.userTaskId,taskItem.taskTitle) + } + + } + } + } else { + console.log(`查询任务列表失败:${result.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//日常-完成任务 +async function doTask(taskType,userTaskId,taskTitle) { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + reqBody = `{"activityType":13,"taskType":"${taskType}","userTaskId":"${userTaskId}"}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/activity/task/api/doTask', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`完成任务【${result.data.taskTitle}】:获得${result.data.rewardScore}勋章`) + } else { + console.log(`完成任务【${taskTitle}】失败:${result.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//存钱罐状态 +async function queryPiggyInfo() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/activity/golden/api/queryUserAccountInfo?appId='+blackJSON['appId'], + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'Origin' : 'https://m.black-unique.com', + 'Accept-Encoding' : 'gzip, deflate, br', + 'Connection' : 'keep-alive', + 'black-token' : blackJSON['black-token'], + 'Accept' : 'application/json, text/plain, */*', + 'User-Agent' : blackJSON['User-Agent'], + 'Referer' : 'https://m.black-unique.com/', + 'token' : blackJSON['token'], + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + }, + }; + $.get(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + if(parseFloat(result.data.goldenAmount) < parseFloat(result.data.dayCeil)) { + if(parseFloat(result.data.piggyAmount) >= 1) { + await clickPiggy() + } + } else { + console.log(`\n存钱罐提取已达到当天上限:${result.data.dayCeil}\n`) + } + } else { + console.log(`\n查询存钱罐状态失败:${result.msg}\n`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//提取存钱罐金币 +async function clickPiggy() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + reqBody = `{"appId":"${blackJSON['appId']}"}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/activity/golden/api/v1_0/click', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`\n提取存钱罐金币成功,金币余额${result.data.goldenAmount}\n`) + } else { + console.log(`\n提取存钱罐金币失败:${result.msg}\n`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//查询翻牌领提现额度 +async function getUserFlopRecord() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + reqBody = `{"appId":"${blackJSON['appId']}","queryDay":"${todayDate}"}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/activity/flop/api/getUserFlopRecord', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + if(result.data && result.data.recordList && Array.isArray(result.data.recordList)) { + for (let i=0; i { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/activity/flop/api/flop', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`翻牌获得提现额度:${result.data.amount}元`) + } else { + console.log(`翻牌获得提现额度失败:${result.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//定点红包列表 +async function listRedPacket() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + curTime = new Date() + currentHour = curTime.getHours() + let isGetRedTime = ((currentHour < 23) && (currentHour > 6)) ? 1 : 0 + return new Promise((resolve) => { + let url = { + url: 'https://fanxian-api.chuxingyouhui.com/api/redPacketIncome/v1_0/listRedPacket', + headers: { + 'Host' : 'fanxian-api.chuxingyouhui.com', + 'phpUserId' : blackJSON['phpUserId'], + 'device-value' : blackJSON['device-value'], + 'device-type' : blackJSON['device-type'], + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'newcomer' : 'true', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'Referer' : 'https://m.black-unique.com/', + 'Content-Length' : '0', + 'Connection' : 'keep-alive', + 'Accept' : 'application/json, text/plain, */*', + }, + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + if(isGetRedTime == 1 && result.data && result.data.redPacketList && Array.isArray(result.data.redPacketList)) { + redPacketCount = 0 + for(let i=0; i 0) { + redPacketCount++ + } + if(redItem.status == 2 && redItem.money == 0 && redPacketCount < 7) { + signRetryCount = 0 + //await getSignInfo('open') + //await $.wait(500) + await openRedPacket() + } + } + } + } else { + console.log(`查询红包列表失败:${result.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//开定点红包 +async function openRedPacket() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()/1000) + return new Promise((resolve) => { + let url = { + url: 'https://pyp-api.chuxingyouhui.com/api/knightCard/redPacket/v1_0/openRedPacket', + headers: { + 'Host' : 'pyp-api.chuxingyouhui.com', + 'Accept' : 'application/json, text/plain, */*', + 'phpUserId' : blackJSON['phpUserId'], + 'device-value' : blackJSON['device-value'], + 'ymd' : '0', + 'device-type' : blackJSON['device-type'], + 'newcomer' : 'true', + 'token' : blackJSON['token'], + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'Referer' : 'https://m.black-unique.com/', + 'Accept-Encoding' : 'gzip, deflate, br', + 'Connection' : 'keep-alive', + 'Content-Type' : 'application/json;charset=utf-8', + }, + body: `{"click":false,"sign":"${userSign}","ts":"${reqTime}"}` + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`打开红包获得:${result.data.money}现金`) + signRetryCount = 0 + //await getSignInfo('boom') + //await $.wait(2000) + await boomRedPacket() + } else { + console.log(`打开红包失败:${result.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//定点红包翻倍 +async function boomRedPacket() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()/1000) + return new Promise((resolve) => { + let url = { + url: 'https://fanxian-api.chuxingyouhui.com/api/redPacket/increase/v1_0/boom', + headers: { + 'Host' : 'fanxian-api.chuxingyouhui.com', + 'Accept' : 'application/json, text/plain, */*', + 'phpUserId' : blackJSON['phpUserId'], + 'device-value' : blackJSON['device-value'], + 'device-type' : blackJSON['device-type'], + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'token' : blackJSON['token'], + 'Accept-Encoding' : 'gzip, deflate, br', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + 'Content-Type' : 'application/json;charset=utf-8', + }, + body: `{"redPacketId":"${redPacketId}","sign":"${userSign}","ts":"${reqTime}"}`, + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`红包翻倍获得:${result.data.redPacketIncreaseAmount}现金`) + } else { + console.log(`红包翻倍失败:${result.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//果园状态 +async function userFruitDetail() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()/1000) + reqBody = `{"appId":"${blackJSON['appId']}","isMiniProgram":false}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/userFruitDetail', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Connection' : 'keep-alive', + }, + body: reqBody, + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`你现在种的水果是 ${result.data.fruitName} ${result.data.specification},${result.data.progressWord}`) + console.log(`今天已浇水${result.data.wateredTimes}次,剩余水滴数量:${result.data.remainAmount}`) + fruitId = result.data.fruitId + userFruitId = result.data.userFruitId + activityId = result.data.activityId + if(result.data.canReceiveStatus == 1 && result.data.canReceiveAmount > 0) { + await receiveWaterDrop('TOMORROW_REWARD','null','每日水滴') + } + if(result.data.gardenStageRewardResp && result.data.gardenStageRewardResp.status == 1) { + await fruitStageReward() + } + if(result.data.remainAmount >= 10) { + waterCount = 0 + console.log(`开始浇水,请等候......`) + await wateringFruit() + console.log(`浇水结束,本次共浇水${waterCount}次`) + } + } else { + console.log(`查询果园状态失败:${result.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//果园水果进度奖励 +async function fruitStageReward() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()/1000) + reqBody = `{"userFruitId":"${userFruitId}","appId":"${blackJSON['appId']}"}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/receiveStageReward', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Connection' : 'keep-alive', + }, + body: reqBody, + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`领取水果进度奖励:${result.data.rewardNum}水滴`) + } else { + console.log(`领取水果进度奖励失败:${result.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//果园浇水 +async function wateringFruit() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()/1000) + reqBody = `{"userFruitId":"${userFruitId}"}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/watering', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Connection' : 'keep-alive', + }, + body: reqBody, + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + if(result.data.level && !result.data.remindType) { + if(result.data.upgrade == true) { + console.log(`果树升级到 ${result.data.level} 获得:${result.data.upgradeReward}水滴`) + } + waterCount++ + await $.wait(500) + await wateringFruit() + } + } else { + console.log(`浇水失败:${result.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//果园水滴任务 +async function waterTaskList() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()/1000) + reqBody = `{"activityId":"${activityId}","userFruitId":"${userFruitId}","clientType":1}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/userTaskList', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Connection' : 'keep-alive', + }, + body: reqBody, + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + if(result.data && result.data.taskList && Array.isArray(result.data.taskList)) { + for(let i=0; i -1 || + taskItem.taskType.indexOf('WATCH_VIDEO') > -1 || + taskItem.taskType.indexOf('APP_LOGIN') > -1) { + if(taskItem.status == 0) { + await doWaterTask(taskItem.taskType,taskItem.taskId,taskItem.title) + } else if(taskItem.status == 1) { + await receiveWaterDrop(taskItem.taskType,taskItem.userTaskId,taskItem.title) + } + } else if(taskItem.taskType.indexOf('EVERY_DAY_WATERING_REWARD') > -1 || + taskItem.taskType.indexOf('OPEN_CHEST') > -1) { + if(taskItem.status == 1) { + await receiveWaterDrop(taskItem.taskType,taskItem.userTaskId,taskItem.title) + } + } else { + if(taskItem.status == 0) { + await receiveWaterDrop(taskItem.taskType,taskItem.userTaskId,taskItem.title) + } + } + } + } + } else { + console.log(`获取果园水滴任务失败:${result.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//果园-完成水滴任务 +async function doWaterTask(taskType,taskId,taskTitle) { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + reqBody = `{"userFruitId":"${userFruitId}","taskType":"${taskType}","taskId":"${taskId}"}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/doTask', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`完成水滴任务【${taskTitle}】成功`) + } else { + console.log(`完成水滴任务【${taskTitle}】失败:${result.msg}`) + } + await $.wait(1000) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//果园-领取水滴 +async function receiveWaterDrop(taskType,userTaskId,taskTitle) { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + reqBody = `{"userFruitId":"${userFruitId}","taskType":"${taskType}","userTaskId":${userTaskId}}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/receiveWaterDrop', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`领取水滴任务【${taskTitle}】奖励:${result.data.reward}水滴`) + } else { + console.log(`领取水滴任务【${taskTitle}】奖励失败:${result.msg}`) + } + await $.wait(1000) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//果园肥料任务 +async function nutrientTaskList() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()/1000) + reqBody = `{"activityId":"${activityId}","userFruitId":"${userFruitId}"}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/getUserNutrientTaskList', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Connection' : 'keep-alive', + }, + body: reqBody, + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + if(result.data && result.data.gardenFertilizerTaskDtoList && Array.isArray(result.data.gardenFertilizerTaskDtoList)) { + for(let i=0; i { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/doTaskForNutrient', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`完成肥料任务【${taskTitle}】成功`) + } else { + console.log(`完成肥料任务【${taskTitle}】失败:${result.msg}`) + } + await $.wait(1000) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//果园肥料状态 +async function userFertilizerDetail(taskType,taskId,taskTitle) { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + reqBody = `{"activityId":"${activityId}","userFruitId":"${userFruitId}"}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/getUserFertilizerTool', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + fertilizerCount = 0 + if(result.data.userSmallFertilizerTool.remainNum > 0 || result.data.userFertilizerTool.remainNum > 0) { + for(let i=0; i { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/useFertilizer', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + //施肥成功 + } else { + console.log(`施肥失败:${result.msg}`) + } + await $.wait(500) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//果园-摇树得优惠券 +async function getTreeCoupon() { + console.log(`\n开始摇树${clickTreeTimes}次得优惠券`) + for(let i=0; i { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/clickTree', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + await $.wait(1000) + if(result.data.hasReward == true) { + await receiveReward(result.data.rewardId,result.data.rewardName,result.data.rewardInfo) + } + } else { + console.log(`果园点击树失败:${result.msg}`) + } + await $.wait(500) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//果园-获得树干奖励 +async function receiveReward(rewardId,rewardName,rewardInfo) { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + reqBody = `{"rewardId":"${rewardId}","userFruitId":"${userFruitId}","appId":"${blackJSON['appId']}"}` + encodeBody = encodeURIComponent(reqBody) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/garden/api/v1_0/receiveReward', + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'request-body' : encodeBody, + 'Accept' : 'application/json, text/plain, */*', + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding' : 'gzip, deflate, br', + 'token' : blackJSON['token'], + 'Content-Type' : 'application/json;charset=utf-8', + 'Origin' : 'https://m.black-unique.com', + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Referer' : 'https://m.black-unique.com/', + 'Connection' : 'keep-alive', + }, + body: reqBody + }; + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`获得优惠券:${rewardName} -- ${rewardInfo}`) + } else { + console.log(`获取优惠券失败:${result.msg}`) + } + await $.wait(1000) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//查询账户信息 +async function userInfo() { + console.log(`\n========= 账户信息 =========`) + notifyStr += `========= 账户信息 =========\n` + await userRebateInfo() + await userTopInfo() +} + +//查询现金余额 +async function userRebateInfo() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + return new Promise((resolve) => { + let url = { + url: 'https://pyp-api.chuxingyouhui.com/api/app/userCenter/v1/info', + headers: { + 'Host' : 'pyp-api.chuxingyouhui.com', + 'Accept' : '*/*', + 'phpUserId' : blackJSON['phpUserId'], + 'device-value' : blackJSON['device-value'], + 'device-type' : blackJSON['device-type'], + 'Accept-Language' : 'zh-Hans-CN;q=1', + 'token' : blackJSON['token'], + 'User-Agent' : blackJSON['User-Agent'], + 'black-token' : blackJSON['black-token'], + 'Accept-Encoding' : 'gzip, deflate, br', + 'Connection' : 'keep-alive', + }, + }; + $.get(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`【现金余额】:${result.data.currencyBlanceResp.commission}`) + notifyStr += `【现金余额】:${result.data.currencyBlanceResp.commission}\n` + } else { + console.log(`查询现金余额失败:${result.msg}`) + notifyStr += `查询现金余额失败:${result.msg}\n` + } + await $.wait(200) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//查询勋章余额 +async function userTopInfo() { + let caller = printCaller() + //rndtime = Math.round(new Date().getTime()) + return new Promise((resolve) => { + let url = { + url: 'https://market.chuxingyouhui.com/promo-bargain-api/activity/mqq/api/indexTopInfo?appId='+blackJSON['appId'], + headers: { + 'Host' : 'market.chuxingyouhui.com', + 'Origin' : 'https://m.black-unique.com', + 'Accept-Encoding' : 'gzip, deflate, br', + 'Connection' : 'keep-alive', + 'black-token' : blackJSON['black-token'], + 'Accept' : 'application/json, text/plain, */*', + 'User-Agent' : blackJSON['User-Agent'], + 'Referer' : 'https://m.black-unique.com/', + 'token' : blackJSON['token'], + 'Accept-Language' : 'zh-CN,zh-Hans;q=0.9', + }, + }; + $.get(url, async (err, resp, data) => { + try { + if (err) { + console.log("Fucntion " + caller + ": API请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + let result = JSON.parse(data); + if(logDebug) console.log(result); + if(result.code == 200) { + console.log(`【勋章余额】:${result.data.score}`) + notifyStr += `【勋章余额】:${result.data.score}\n` + } else { + console.log(`查询勋章余额失败:${result.msg}`) + notifyStr += `查询勋章余额失败:${result.msg}\n` + } + await $.wait(200) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +//////////////////////////////////////////////////////////////////// +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function printCaller(){ + return (new Error()).stack.split("\n")[2].trim().split(" ")[1] +} + +function formatDateTime(inputTime) { + var date = new Date(inputTime); + var y = date.getFullYear(); + var m = date.getMonth() + 1; + m = m < 10 ? ('0' + m) : m; + var d = date.getDate(); + d = d < 10 ? ('0' + d) : d; + var h = date.getHours(); + h = h < 10 ? ('0' + h) : h; + var minute = date.getMinutes(); + var second = date.getSeconds(); + minute = minute < 10 ? ('0' + minute) : minute; + second = second < 10 ? ('0' + second) : second; + return `${y}-${m}-${d}`; +}; + +function Env(t, e) { class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `\ud83d\udd14${this.name}, \u5f00\u59cb!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), a = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(a, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t) { let e = { "M+": (new Date).getMonth() + 1, "d+": (new Date).getDate(), "H+": (new Date).getHours(), "m+": (new Date).getMinutes(), "s+": (new Date).getSeconds(), "q+": Math.floor(((new Date).getMonth() + 3) / 3), S: (new Date).getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, ((new Date).getFullYear() + "").substr(4 - RegExp.$1.length))); for (let s in e) new RegExp("(" + s + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? e[s] : ("00" + e[s]).substr(("" + e[s]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))); let h = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="]; h.push(e), s && h.push(s), i && h.push(i), console.log(h.join("\n")), this.logs = this.logs.concat(h) } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t.stack) : this.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/jctq/jctq_rewrite_subscribe.json b/jctq/jctq_rewrite_subscribe.json index c83c209..d0888f5 100644 --- a/jctq/jctq_rewrite_subscribe.json +++ b/jctq/jctq_rewrite_subscribe.json @@ -107,7 +107,7 @@ }, }, { - "name": "晶彩抽奖", + "name": "晶彩天气抽奖", "type": "cron", "time": "31 8,16 * * *", "job": { @@ -116,7 +116,7 @@ }, }, { - "name": "晶彩每日宝箱", + "name": "晶彩天气每日宝箱", "type": "cron", "time": "24 21,22 * * *", "job": { @@ -125,7 +125,7 @@ }, }, { - "name": "晶彩好友签到红包", + "name": "晶彩天气好友红包", "type": "cron", "time": "32 2,6,20 * * *", "job": { @@ -144,4 +144,4 @@ } ] } -} \ No newline at end of file +} diff --git a/jctq/jctq_task_subscribe.json b/jctq/jctq_task_subscribe.json index 1e27df5..3817bc2 100644 --- a/jctq/jctq_task_subscribe.json +++ b/jctq/jctq_task_subscribe.json @@ -10,7 +10,7 @@ "time": "21 8,20 * * *", "job": { "type": "runjs", - "target": "jctqkkz.js" + "target": "https://raw.githubusercontent.com/leafxcy/JavaScript/main/jctq/jctqkkz.js" } }, { @@ -19,7 +19,7 @@ "time": "18 22 * * *", "job": { "type": "runjs", - "target": "jctq_today_score.js" + "target": "https://raw.githubusercontent.com/leafxcy/JavaScript/main/jctq/jctq_today_score.js" } }, { @@ -28,7 +28,7 @@ "time": "23 0,6 * * *", "job": { "type": "runjs", - "target": "jctqqd.js" + "target": "https://raw.githubusercontent.com/leafxcy/JavaScript/main/jctq/jctqqd.js" } }, { @@ -37,7 +37,7 @@ "time": "12 7,19 * * *", "job": { "type": "runjs", - "target": "jctqwz.js" + "target": "https://raw.githubusercontent.com/leafxcy/JavaScript/main/jctq/jctqwz.js" } }, { @@ -46,7 +46,7 @@ "time": "12 6,12,18 * * *", "job": { "type": "runjs", - "target": "jctq_share.js" + "target": "https://raw.githubusercontent.com/leafxcy/JavaScript/main/jctq/jctq_share.js" } }, { @@ -55,7 +55,7 @@ "time": "20 9,17 * * *", "job": { "type": "runjs", - "target": "jctq_Adv_video.js" + "target": "https://raw.githubusercontent.com/leafxcy/JavaScript/main/jctq/jctq_Adv_video.js" } }, { @@ -64,7 +64,7 @@ "time": "31 8,16 * * *", "job": { "type": "runjs", - "target": "jctq_Rotary.js" + "target": "https://raw.githubusercontent.com/leafxcy/JavaScript/main/jctq/jctq_Rotary.js" } }, { @@ -73,7 +73,7 @@ "time": "24 21,22 * * *", "job": { "type": "runjs", - "target": "jctqbox.js" + "target": "https://raw.githubusercontent.com/leafxcy/JavaScript/main/jctq/jctqbox.js" } }, { @@ -82,7 +82,7 @@ "time": "32 2,6,20 * * *", "job": { "type": "runjs", - "target": "jctq_friendSign.js" + "target": "https://raw.githubusercontent.com/leafxcy/JavaScript/main/jctq/jctq_friendSign.js" } }, { @@ -91,7 +91,7 @@ "time": "34 23 * * *", "job": { "type": "runjs", - "target": "jctq_withdraw.js" + "target": "https://raw.githubusercontent.com/leafxcy/JavaScript/main/jctq/jctq_withdraw.js" } } ] diff --git a/jrttjsb.js b/jrttjsb.js new file mode 100644 index 0000000..3ccd342 --- /dev/null +++ b/jrttjsb.js @@ -0,0 +1,1284 @@ +/* +IOS/安卓: 今日头条极速版 +邀请码: 1173836876 + +老用户每天几毛,新用户可能收益高点 +普通版定时: 1-59/15 6-23 * * * +激进版定时: 1-59/5 * * * * +多用户跑的时间会久一点,自己看着改定时吧 + +自定义UA:捉包拿到自己的UA,填到变量jrttjsbUA里,不填默认用安卓UA +自定义每次运行阅读文章的数量:填到变量jrttjsbReadNum,不填默认10篇 +农场和种树任务:默认不做,需要做的,把变量jrttjsbFarm填为1 + +V2P重写: +[task_local] +#今日头条极速版 +1-59/15 6-23 * * * https://raw.githubusercontent.com/leafxcy/JavaScript/main/jrttjsb.js, tag=今日头条极速版, enabled=true +[rewrite_local] +luckycat\/lite\/v1\/task\/page_data url script-request-header https://raw.githubusercontent.com/leafxcy/JavaScript/main/jrttjsb.js +[MITM] +#每个人的域名不同,都放进去MITM吧,还捉不到就自行捉包填写 +hostname = *.snssdk.com +hostname = *.toutiaoapi.com + +青龙把极速版捉包里面的cookie放到jrttjsbHeader里,多账户用@隔开 +*/ + +const jsname = '今日头条极速版' +const $ = Env(jsname) +const notifyFlag = 1; //0为关闭通知,1为打开通知,默认为1 +const logDebug = 0 + +//const notify = $.isNode() ? require('./sendNotify') : ''; +let notifyStr = '' + +let rndtime = "" //毫秒 +let httpResult //global buffer + +let host = 'i.snssdk.com' +let hostname = 'https://' + host + +let userAgent = ($.isNode() ? process.env.jrttjsbUA : $.getdata('jrttjsbUA')) || 'Dalvik/2.1.0 (Linux; U; Android 7.1.2; VOG-AL10 Build/HUAWEIVOG-AL10) NewsArticle/8.2.8 tt-ok/3.10.0.2'; +let userAgentArr = [] +let userHeader = ($.isNode() ? process.env.jrttjsbHeader : $.getdata('jrttjsbHeader')) || ''; +let userHeaderArr = [] +let jrttjsbFarm = ($.isNode() ? process.env.jrttjsbFarm : $.getdata('jrttjsbFarm')) || 0; + +let userIdx = 0 +let UAcount = 0 +let userStatus = [] +let maxReadPerRun = ($.isNode() ? process.env.jrttjsbReadNum : $.getdata('jrttjsbReadNum')) || 10; +let readList = [] + +let validList = [] +let adIdList = [26, 181, 186, 187, 188, 189, 190, 195, 210, 214, 216, 225, 308, 324, 327, 329] + +/////////////////////////////////////////////////////////////////// + +!(async () => { + + if(typeof $request !== "undefined") + { + await GetRewrite() + } + else + { + await showUpdateMsg() + + if(!(await checkEnv())) { + return + } + + await initAccountInfo() + await RunMultiUser() + } + + +})() +.catch((e) => $.logErr(e)) +.finally(() => $.done()) + +function showUpdateMsg() { + console.log('\n2021.12.15 9:30 更新:增加推送奖励,修复一个UA的bug,更改默认UA为安卓\n') +} + +//通知 +async function showmsg() { + + notifyBody = jsname + "运行通知\n\n" + notifyStr + + if (notifyFlag != 1) { + console.log(notifyBody); + } + + if (notifyFlag == 1) { + $.msg(notifyBody); + //if ($.isNode()){await notify.sendNotify($.name, notifyBody );} + } +} + +async function GetRewrite() { + if($request.url.indexOf('luckycat/lite/v1/task/page_data') > -1) { + let userCK = $request.headers.Cookie + + if(userHeader) { + if(userHeader.indexOf(userCK) == -1) { + userHeader = userHeader + '@' + userCK + $.setdata(userHeader, 'jrttjsbHeader'); + ckList = userHeader.split('@') + $.msg(jsname+` 获取第${ckList.length}个jrttjsbHeader成功: ${userCK}`) + } + } else { + $.setdata(userCK, 'jrttjsbHeader'); + $.msg(jsname+` 获取第1个jrttjsbHeader成功: ${userCK}`) + } + } +} + +async function checkEnv() { + if(userHeader) { + userHeaderArr = userHeader.split('@') + } else { + console.log('未找到jrttjsbHeader') + return false + } + if(userHeaderArr.length == 0) { + console.log('未找到有效的jrttjsbHeader') + return false + } + + if(userAgent) { + userAgentArr = userAgent.split('@') + } else { + console.log('未找到userAgent') + return false + } + UAcount = userAgentArr.length + + console.log(`共找到${userHeaderArr.length}个用户,${UAcount}个UA`) + return true +} + +async function initAccountInfo() { + for(userIdx=0; userIdx 0) await GetWalkBonus() + } else { + console.log(`用户${userIdx+1}走路状态失败:${result.err_tips}`) + } +} + +//走路奖励 +async function GetWalkBonus() { + let caller = printCaller() + let nowtime = Math.round(new Date().getTime()/1000) + let url = `${hostname}/luckycat/lite/v1/walk/bonus/?aid=35&update_version_code=85221&os_version=15.0&device_platform=iphone` + let body = `{"task_id":136,"enable_preload_exciting_video":0,"client_time":${nowtime},"rit":"","use_ecpm":0}` + let urlObject = populatePostUrl(url,body) + await httpPost(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.err_no == 0) { + console.log(`用户${userIdx+1}领取走路奖励获得${result.data.score_amount}金币`) + } else { + console.log(`用户${userIdx+1}领取走路奖励失败:${result.err_tips}`) + } +} + +//吃饭补贴 +async function DoneEat() { + let caller = printCaller() + let url = `${hostname}/luckycat/lite/v1/eat/done_eat/?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populatePostUrl(url) + await httpPost(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.err_no == 0) { + console.log(`用户${userIdx+1}领取吃饭补贴获得${result.data.score_amount}金币`) + } else { + console.log(`用户${userIdx+1}领取吃饭补贴失败:${result.err_tips}`) + } +} + +//睡觉状态 +async function QuerySleepStatus() { + let caller = printCaller() + let curTime = new Date() + let curHour = curTime.getHours() + let url = `${hostname}/luckycat/lite/v1/sleep/status/?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.err_no == 0) { + let sleepHour = Math.floor(result.data.sleep_last_time/36)/100 + if(result.data.sleeping == true) { + if(sleepHour>=12) { + await SleepStop() + } else if(result.data.sleep_unexchanged_score==result.data.max_coin && curHour >= 7) { + let rnd = Math.random() + if(rnd>0.95) { + await SleepStop() + } else { + console.log(`用户${userIdx+1}随机醒来时间,本次不进行醒来,已经睡了${sleepHour}小时,可以获得${result.data.sleep_unexchanged_score}金币`) + } + } else { + console.log(`用户${userIdx+1}睡眠中,已经睡了${sleepHour}小时,可以获得${result.data.sleep_unexchanged_score}金币,上限${result.data.max_coin}金币`) + } + } else { + if(result.data.history_amount > 0) { + await SleepDone(result.data.history_amount) + } + if(curHour >= 22 || curHour < 2) { + await SleepStart() + } else if(curHour >= 20) { + let rnd = Math.random() + if(rnd>0.95) { + await SleepStart() + } else { + console.log(`用户${userIdx+1}随机睡眠时间,本次不进行睡眠`) + } + } else { + console.log(`用户${userIdx+1}未到睡觉时间`) + } + } + } else { + console.log(`用户${userIdx+1}查询睡觉状态失败:${result.err_tips}`) + } +} + +//睡觉醒来 +async function SleepStop() { + let caller = printCaller() + let url = `${hostname}/luckycat/lite/v1/sleep/stop/?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populatePostUrl(url) + await httpPost(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.err_no == 0) { + let sleepHour = result.data.sleep_last_time/3600 + console.log(`用户${userIdx+1}结束睡眠,本次睡了${sleepHour}小时,可以领取${result.data.history_amount}金币`) + await SleepDone(result.data.history_amount) + } else { + console.log(`用户${userIdx+1}结束睡眠失败:${result.err_tips}`) + } +} + +//睡觉收金币 +async function SleepDone(amount) { + let caller = printCaller() + let timeInMS = Math.round(new Date().getTime()) + let url = `${hostname}/luckycat/lite/v1/sleep/done_task/?os_api=25&device_type=VOG-AL10&ssmix=a&manifest_version_code=8280&dpi=240&abflag=3&pass_through=default&use_ecpm=0&rom_version=25&rit=coin&app_name=news_article_lite&ab_client=a1%2Ce1%2Cf2%2Cg2%2Cf7&version_name=8.2.8&ab_version=668903%2C3491704%2C1859936%2C668908%2C3491714%2C668907%2C3491710%2C668905%2C3491678%2C668906%2C3491686%2C668904%2C3491669%2C3269751%2C3472846%2C3493942&plugin_state=7731332411413&sa_enable=0&ac=wifi&_request_from=web&update_version_code=82809&channel=lite2_tengxun&_rticket=${timeInMS}&status_bar_height=24&dq_param=0&device_platform=android&iid=1592553870724568&scm_build_version=1.0.0.1454&mac_address=88%3AB1%3A11%3A61%3A96%3A7B&version_code=828&polaris_version=1.0.5&tma_jssdk_version=1.95.0.28&is_pad=1&resolution=720*1280&os_version=7.1.2&language=zh&device_brand=HUAWEI&aid=35&ab_feature=z1&luckycat_version_name=4.2.0-rc.5&luckycat_version_code=420005` + let body = `{"score_amount":${amount},"enable_preload_exciting_video":0}` + let urlObject = populatePostUrl(url,body) + await httpPost(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.err_no == 0) { + console.log(`用户${userIdx+1}领取睡觉金币奖励${amount}金币成功`) + } else { + console.log(`用户${userIdx+1}领取睡觉金币奖励失败:${result.err_tips}`) + } +} + +//开始睡觉 +async function SleepStart() { + let caller = printCaller() + let url = `${hostname}/luckycat/lite/v1/sleep/start/?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populatePostUrl(url) + await httpPost(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.err_no == 0) { + console.log(`用户${userIdx+1}开始睡觉,ZZZzzz...`) + await SleepDone(result.data.history_amount) + } else { + console.log(`用户${userIdx+1}开始睡觉失败:${result.err_tips}`) + } +} + +//查询农场状态 +async function QueryFarmInfo() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/polling_info?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + if(result.data.info.offline_production) { + await FarmOfflineDouble() + } + if(result.data.info.water>=10) { + await FarmWater() + } + if(result.data.info.box_num>0) { + await FarmOpenBox() + } + } else { + console.log(`用户${userIdx+1}查询农场状态失败:${result.message}`) + } +} + +//进入农场 +async function EnterFarm() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/home_info?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + console.log(result) + if(result.status_code == 0) { + + } else { + console.log(`用户${userIdx+1}进入农场失败:${result.message}`) + } +} + +//农场-离线奖励翻倍 +async function FarmOfflineDouble() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/double_reward?watch_ad=1&aid=35` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}农场离线产量翻倍成功`) + } else { + console.log(`用户${userIdx+1}农场离线产量翻倍失败:${result.message}`) + } +} + +//农场-领取三餐礼包 +async function RewardFarmThreeGift(gift_id) { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/reward/gift?game_client_version_code=2&gift_id=${gift_id}&watch_ad=0&double=0&aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}领取农场三餐礼包获得${result.data.reward_num}水滴`) + } else { + console.log(`用户${userIdx+1}领取农场三餐礼包失败:${result.message}`) + } +} + +//农场-三餐礼包状态 +async function QueryFarmThreeGift() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/gift/list?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + for(let item of result.data) { + if(item.status==1) { + await RewardFarmThreeGift(item.gift_id) + } + } + } else { + console.log(`用户${userIdx+1}查询农场三餐礼包状态失败:${result.message}`) + } +} + +//查询农场任务列表 +async function QueryFarmTask() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/daily_task/list?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + for(let item of result.data) { + if(item.status==1) { + await RewardFarmTask(item.task_id) + } + } + } else { + console.log(`用户${userIdx+1}查询农场任务列表失败:${result.message}`) + } +} + +//农场-领取任务奖励 +async function RewardFarmTask(id) { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/reward/task?task_id=${id}&aid=35` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + let typeStr = (result.data.reward_type==1) ? '水滴' : '化肥' + console.log(`用户${userIdx+1}领取农场任务奖励[task_id=${result.data.task_id}]获得${result.data.reward_num}${typeStr},剩余${typeStr}数量${result.data.current_num}`) + } else { + console.log(`用户${userIdx+1}领取农场任务奖励失败:${result.message}`) + } +} + +//农场-浇水 +async function FarmWater() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/land_water?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}农场浇水成功,剩余水滴:${result.data.water}`) + if(result.data.water>=10) { + await $.wait(1500) //min time 1000 + await FarmWater() + } + } else { + console.log(`用户${userIdx+1}农场浇水失败:${result.message}`) + } +} + +//农场-开宝箱 +async function FarmOpenBox() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/box/open?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}开农场宝箱获得${result.data.incr_coin}金币`) + if(result.data.excitation_ad_score_amount>0) await FarmOpenBoxVideo() + } else { + console.log(`用户${userIdx+1}开农场宝箱失败:${result.message}`) + } +} + +//农场-宝箱视频 +async function FarmOpenBoxVideo() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/excitation_ad/add?excitation_ad_score_amount=134&device_id=2392172203611735&aid=35&os_version=15.0&update_version_code=85221` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}看农场宝箱视频获得${result.data.incr_coin}金币`) + } else { + console.log(`用户${userIdx+1}看农场宝箱视频失败:${result.message}`) + } +} + +//农场-签到状态 +async function QueryFarmSignStatus() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/sign_in/list?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + for(let item of result.data.sign) { + if(item.status==1) { + await FarmSign() + break + } + } + } else { + console.log(`用户${userIdx+1}查询签到状态失败:${result.message}`) + } +} + +//农场-签到 +async function FarmSign() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/reward/sign_in?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + let str = (result.data.reward_type==1)?'水滴':'化肥' + console.log(`用户${userIdx+1}签到获得${result.data.reward_num}${str},剩余${str}数量${result.data.cur_reward_num}`) + } else { + console.log(`用户${userIdx+1}签到失败:${result.message}`) + } +} + +//农场-签到视频翻倍 +async function FarmSignDouble() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/reward/double_sign_in?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + let str = (result.data.reward_type==1)?'水滴':'化肥' + console.log(`用户${userIdx+1}签到翻倍获得${result.data.reward_num}{str},剩余${str}数量${result.data.cur_reward_num}`) + } else { + console.log(`用户${userIdx+1}签到翻倍失败:${result.message}`) + } +} + +//农场-土地状态 +async function QueryFarmLandStatus() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/home_info?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + for(let item of result.data.info.lands) { + if(item.status==false && item.unlock_able==true) { + await FarmUnlock(item.land_id) + break + } + } + } else { + console.log(`用户${userIdx+1}查询土地状态失败:${result.message}`) + } +} + +//农场-土地解锁 +async function FarmUnlock(land_id) { + let caller = printCaller() + let url = `${hostname}/ttgame/game_farm/land/unlock?land_id=${land_id}&aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}解锁${land_id}号土地成功`) + } else { + console.log(`用户${userIdx+1}解锁${land_id}号土地失败:${result.message}`) + } +} + +//种树-签到状态 +async function QueryTreeSignStatus() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/sign_in/list?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + if(result.data.today == false) { + await TreeSign() + } + } else { + console.log(`用户${userIdx+1}查询种树签到状态失败:${result.message}`) + } +} + +//种树-签到 +async function TreeSign() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/sign_in/reward?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}种树签到获得${result.data.reward_item.num}${result.data.reward_item.name}`) + } else { + console.log(`用户${userIdx+1}种树签到失败:${result.message}`) + } +} + +//种树-二选一-选项 +async function QueryTreeChallenge() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/challenge/list?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + let bestChoice = 0 + let maxWater = 0 + for(let item of result.data.tasks) { + if(item.state==0 && item.water_times>maxWater) { + maxWater = item.water_times + bestChoice = item.id + } + } + if(bestChoice>0) await TreeChallengeChoose(bestChoice) + } else { + console.log(`用户${userIdx+1}查询挑战任务失败:${result.message}`) + } +} + +//种树-二选一-选择 +async function TreeChallengeChoose(id) { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/challenge/choose?task_id=${id}&aid=35` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}选择浇水${result.data.red_point.times}次挑战`) + } else { + console.log(`用户${userIdx+1}选择浇水挑战失败:${result.message}`) + } +} + +//种树-二选一-领奖 +async function TreeChallengeReward() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/challenge/reward?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}领取浇水挑战奖励获得${result.data.reward_item.num}水滴`) + } else { + console.log(`用户${userIdx+1}领取浇水挑战奖励失败:${result.message}`) + } +} + +//种树-化肥签到 +async function TreeNutrientSign() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/nutrient/sign_in?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + if(result.data.is_rewarded==true) { + console.log(`用户${userIdx+1}种树化肥签到获得${result.data.reward_item.num}{result.data.reward_item.name}`) + } else { + console.log(`用户${userIdx+1}种树化肥签到成功`) + } + } else { + console.log(`用户${userIdx+1}种树化肥签到失败:${result.message}`) + } +} + +//种树-领取三餐礼包 +async function RewardTreeThreeGift(task_id) { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/three_gift/reward?task_id=${task_id}&watch_ad=0&extra_ad_num=0&aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}领取种树三餐礼包获得${result.data.reward_item.num}${result.data.reward_item.name}`) + } else { + console.log(`用户${userIdx+1}领取种树三餐礼包失败:${result.message}`) + } +} + +//种树-三餐礼包状态 +async function QueryTreeThreeGift() { + let caller = printCaller() + let curTime = new Date() + let curHour = curTime.getHours() + let url = `${hostname}/ttgame/game_orchard/three_gift/list?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + for(let item of result.data.gift_list) { + if(item.rounds==1 && curHour >= item.available_time.begin && curHour < item.available_time.end) { + await RewardTreeThreeGift(item.id) + } + } + } else { + console.log(`用户${userIdx+1}查询种树三餐礼包状态失败:${result.message}`) + } +} + +//种树-水滴任务列表 +async function QueryTreeWaterTask() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/tasks/list?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + for(let item of result.data.tasks_v2) { + if(item.reward_item.state==4) { + await TreeWaterReward(item.id) + await $.wait(1500) + } + } + } else { + console.log(`用户${userIdx+1}查询种树水滴任务列表失败:${result.message}`) + } +} + +//种树-水滴领奖 +async function TreeWaterReward(task_id) { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/tasks/reward?task_id=${task_id}&do_action=0&aid=35` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}领取水滴任务[id=${task_id}]获得${result.data.reward_item.num}${result.data.reward_item.name}`) + } else { + console.log(`用户${userIdx+1}领取水滴任务[id=${task_id}]失败:${result.message}`) + } +} + +//种树-浇水 +async function TreeWater() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/tree/water?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}种树浇水成功,剩余水滴:${result.data.kettle.water_num}`) + if(result.data.kettle.water_num>=100) { + await $.wait(1500) //min time 1000 + await TreeWaterTenTimes() + } else if(result.data.kettle.water_num>=10) { + await $.wait(1500) //min time 1000 + await TreeWater() + } + } else { + console.log(`用户${userIdx+1}种树浇水失败:${result.message}`) + } +} + +//种树-浇水10次 +async function TreeWaterTenTimes() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/tree/tenfold_water?times=10&aid=35` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}种树浇水10次成功,剩余水滴:${result.data.kettle.water_num}`) + if(result.data.kettle.water_num>=100) { + await $.wait(1500) //min time 1000 + await TreeWaterTenTimes() + } else if(result.data.kettle.water_num>=10) { + await $.wait(1500) //min time 1000 + await TreeWater() + } + } else { + console.log(`用户${userIdx+1}种树浇水失败:${result.message}`) + } +} + +//种树-信息 +async function QueryTreeStatus() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/polling_info?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + if(result.data.red_points.challenge && result.data.red_points.challenge.state==4) { + await TreeChallengeReward() + } + if(result.data.bottle.state==1) { + await RewardTreeWaterBottle() + } + if(result.data.red_points.box && result.data.red_points.box.rounds>0 && result.data.red_points.box.state==4) { + await TreeOpenBox() + } + if(result.data.kettle.water_num >= 100) { + await TreeWaterTenTimes() + } else if(result.data.kettle.water_num>=10) { + await TreeWater() + } + } else { + console.log(`用户${userIdx+1}查询种树信息失败:${result.message}`) + } +} + +//种树-水瓶奖励 +async function RewardTreeWaterBottle() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/water_bottle/reward?aid=35&update_version_code=85221&device_platform=iphone&&device_type=iPhone13,2` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}领取种树水瓶奖励获得${result.data.reward_item.num}水滴`) + } else { + console.log(`用户${userIdx+1}领取种树水瓶奖励失败:${result.message}`) + } +} + +//种树-开宝箱 +async function TreeOpenBox() { + let caller = printCaller() + let url = `${hostname}/ttgame/game_orchard/box2/open?watch_ad=0&aid=35` + let urlObject = populateGetUrl(url) + await httpGet(urlObject,caller) + let result = httpResult; + if(!result) return + //console.log(result) + if(result.status_code == 0) { + console.log(`用户${userIdx+1}种树开宝箱获得${result.data.incr_coin}金币`) + } else { + console.log(`用户${userIdx+1}种树开宝箱失败:${result.message}`) + } +} +//////////////////////////////////////////////////////////////////// +function populatePostUrl(url,reqBody=''){ + let timeInMS = Math.round(new Date().getTime()) + let timeInSecond = Math.floor(timeInMS/1000) + let urlObject = { + url: url, + headers: { + 'Accept-Encoding' : 'gzip', + 'X-SS-REQ-TICKET' : timeInMS, + 'passport-sdk-version' : '30', + 'sdk-version' : '2', + 'x-vc-bdturing-sdk-version' : '2.0.0', + 'User-Agent' : userAgentArr[userIdx%UAcount], + 'Cookie' : userHeaderArr[userIdx], + 'X-Khronos' : timeInSecond, + 'Content-Type' : 'application/json; charset=utf-8', + 'Host' : host, + 'Connection' : 'Keep-Alive', + }, + body: reqBody + } + return urlObject; +} + +function populateGetUrl(url){ + let timeInMS = Math.round(new Date().getTime()) + let timeInSecond = Math.floor(timeInMS/1000) + let urlObject = { + url: url, + headers: { + 'Accept-Encoding' : 'gzip', + 'X-SS-REQ-TICKET' : timeInMS, + 'passport-sdk-version' : '30', + 'sdk-version' : '2', + 'x-vc-bdturing-sdk-version' : '2.0.0', + 'User-Agent' : userAgentArr[userIdx%UAcount], + 'Cookie' : userHeaderArr[userIdx], + 'X-Khronos' : timeInSecond, + 'Content-Type' : 'application/json; charset=utf-8', + 'Host' : host, + 'Connection' : 'Keep-Alive', + } + } + return urlObject; +} + +async function httpPost(url,caller) { + httpResult = null + return new Promise((resolve) => { + $.post(url, async (err, resp, data) => { + try { + if (err) { + console.log(caller + ": post请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + httpResult = JSON.parse(data); + if(logDebug) console.log(httpResult); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +async function httpGet(url,caller) { + httpResult = null + return new Promise((resolve) => { + $.get(url, async (err, resp, data) => { + try { + if (err) { + console.log(caller + ": get请求失败"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data,caller)) { + httpResult = JSON.parse(data); + if(logDebug) console.log(httpResult); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +function safeGet(data,caller) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } else { + console.log(`Function ${caller}: 未知错误`); + console.log(data) + } + } catch (e) { + console.log(e); + console.log(`Function ${caller}: 服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function printCaller(){ + return (new Error()).stack.split("\n")[2].trim().split(" ")[1] +} + +function getMin(a,b){ + return ((a { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `\ud83d\udd14${this.name}, \u5f00\u59cb!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), a = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(a, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t) { let e = { "M+": (new Date).getMonth() + 1, "d+": (new Date).getDate(), "H+": (new Date).getHours(), "m+": (new Date).getMinutes(), "s+": (new Date).getSeconds(), "q+": Math.floor(((new Date).getMonth() + 3) / 3), S: (new Date).getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, ((new Date).getFullYear() + "").substr(4 - RegExp.$1.length))); for (let s in e) new RegExp("(" + s + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? e[s] : ("00" + e[s]).substr(("" + e[s]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))); let h = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="]; h.push(e), s && h.push(s), i && h.push(i), console.log(h.join("\n")), this.logs = this.logs.concat(h) } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t.stack) : this.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/shangtuo.js b/shangtuo.js deleted file mode 100644 index 41664f4..0000000 --- a/shangtuo.js +++ /dev/null @@ -1,1744 +0,0 @@ -/* -商拓 - -下载地址: -复制链接后,在微信里打开: -https://shatuvip.com/pages/login/register?recom_code=5290130 - -或微信扫描二维码下载 -https://raw.githubusercontent.com/leafxcy/JavaScript/main/shangtuo.jpg - -推荐码: 5290130 -抢券时段为7:00到23:59,建议在8点后跑脚本,7点有可能会卡 - -玩法:进APP后,先手动去全球分红->提取分红金,然后在个人中心->分红余额->提现一次0.03元(需要上传支付宝和微信收款码),就可以跑脚本了 -脚本会自动看广告得分红金,抢券,提现 -主要收入为抢券得到的红包余额,最低提现0.5。分红金每日会产生分红,但是需要满88才能提现。 -推广余额需要拉人头,大家可以拿着这个脚本,用自己的推荐码去发展下线 -现在会首先尝试提现推广余额,然后尝试提现红包余额 -脚本默认红包余额满0.5自动提现,可以自己新建一个环境变量 stCash 设定红包余额提现金额,export stCash=20 -!!!但是不建议提现20块以下,因为手续费高,只有0.5手续费低!!! - -CK有效期较短,可能几天后需要重新捉 -只测试了IOS,测试过V2P,青龙可以跑 - -青龙: -捉api.shatuvip.com的包,大部分包里都有Authorization和User-Agent,分别保存在shangtuoAuth和shangtuoUA里 -多账号用@分开,例子如下: -export shangtuoAuth="asdfjhkjafqweqwe@askjfbhsakjeh" -export shangtuoUA="UA1@UA2" - -重写食用: -打开商拓即可,如果没有获取到,刷新一下广告首页 - -V2P重写: https://api.shatuvip.com/advert/getAdvertPage? https://raw.githubusercontent.com/leafxcy/JavaScript/main/shangtuo.js - -圈X: -[task_local] -#商拓 -30 9,21 * * * shangtuo.js, tag=商拓, enabled=true - -[rewrite_local] -https://api.shatuvip.com/advert/getAdvertPage? url script-request-header https://raw.githubusercontent.com/leafxcy/JavaScript/main/shangtuo.js - -[MITM] -hostname = api.shatuvip.com - -*/ - - -const $ = new Env('商拓'); -let shangtuoAuthArr = [] -let shangtuoUAArr = [] -let shangtuoAuth = '' -let shangtuoUA = '' -let userNum = 0 -let userInfo = "" - -var packWithdrawAmount = ($.isNode() ? (process.env.stCash) : ($.getval('stCash'))) || 0.5; - -let secretCode - -let compTaskFlag -let grabFlag -let grabCount -let getBondListFlag -let quanList - -let logDebug = 0 -let logCaller = 0 - -const notify = $.isNode() ? require('./sendNotify') : ''; - -!(async () => { - if (typeof $request !== "undefined") { - await getRewrite() - } else { - - if(await checkEnv()) { - - console.log(`推荐大家拿着这个脚本,用自己的邀请码去发展下线\n`) - console.log(`共${shangtuoAuthArr.length}个账号\n`) - for (userNum = 0; userNum < shangtuoAuthArr.length; userNum++) { - - if (shangtuoAuthArr[userNum]) { - shangtuoAuth = shangtuoAuthArr[userNum]; - shangtuoUA = shangtuoUAArr[userNum] - accountStatus = 1 - - console.log(`\n=================== 开始账户${userNum + 1} ===================`) - - //账户信息查询 - await getUserInfoData(1) - await $.wait(1000); - - if(accountStatus) { - - //看广告得分红金 - await getAdvertPage(1); - await $.wait(1000); - - //提取分红金 - await changeDividendBonusToBalance(); - await $.wait(1000); - - //出售券 - await getTradeToPage(1); - await $.wait(1000); - - //查询团队 - await getTeamData(); - await $.wait(1000); - - //收取直推活跃红包 - await getALlRecommendAdvertListPage(0,1); - await $.wait(1000); - - //收取间推活跃红包 - await getALlRecommendAdvertListPage(0,2); - await $.wait(1000); - - //转换红包余额 - await getPackBalance(0); - await $.wait(1000); - - //抢券 - await getUserBalance(); - await $.wait(1000); - - //优先尝试提现分红金余额 - await getUserBalanceWith() - await $.wait(1000); - - //然后尝试提现推广余额 - await getPopularizeBalance() - await $.wait(1000); - - //最后尝试提现红包余额 - await getPackBalance(1); - await $.wait(1000); - - //账户信息查询 - await getUserInfoData(0) - await $.wait(1000); - } - } - } - - $.msg(userInfo) - if($.isNode()) await notify.sendNotify($.name, userInfo) - } - } - -})() -.catch((e) => $.logErr(e)) -.finally(() => $.done()) - -function checkEnv() { - - let shangtuoAuths = $.isNode() ? (process.env.shangtuoAuth) : ($.getval('shangtuoAuth')) - let shangtuoUAs = $.isNode() ? (process.env.shangtuoUA) : ($.getval('shangtuoUA')) - - if(!shangtuoAuths || !shangtuoUAs) { - str1 = shangtuoAuths ? "" : "shangtuoAuths" - str2 = shangtuoUAs ? "" : "shangtuoUAs" - $.log(`未找到环境变量: ${str1} ${str2},请重新捉包并正确填写\n`) - return false - } - - let shangtuoAuthArrs - if (shangtuoAuths.indexOf('#') > -1) { - shangtuoAuthArrs = shangtuoAuths.split('#'); - console.log(`您选择的是用"#"隔开shangtuoAuth\n`) - } else if (shangtuoAuths.indexOf('@') > -1) { - shangtuoAuthArrs = shangtuoAuths.split('@'); - console.log(`您选择的是用"@"隔开shangtuoAuth\n`) - } else { - shangtuoAuthArrs = [shangtuoAuths] - }; - Object.keys(shangtuoAuthArrs).forEach((item) => { - if (shangtuoAuthArrs[item]) { - shangtuoAuthArr.push(shangtuoAuthArrs[item]) - } - }) - - let shangtuoUAArrs - if (shangtuoUAs.indexOf('#') > -1) { - shangtuoUAArrs = shangtuoUAs.split('#'); - console.log(`您选择的是用"#"隔开shangtuoUA\n`) - } else if (shangtuoUAs.indexOf('@') > -1) { - shangtuoUAArrs = shangtuoUAs.split('@'); - console.log(`您选择的是用"@"隔开shangtuoUA\n`) - } else { - shangtuoUAArrs = [shangtuoUAs] - }; - Object.keys(shangtuoUAArrs).forEach((item) => { - if (shangtuoUAArrs[item]) { - shangtuoUAArr.push(shangtuoUAArrs[item]) - } - }) - - return true -} - -function getRewrite() { - if ($request.url.indexOf("getAdvertPage?") > -1) { - shangtuoAuth = $request.headers['Authorization'] - if (shangtuoAuth) { - $.setdata(shangtuoAuth, `shangtuoAuth`) - $.log(`获取shangtuoAuth成功:${shangtuoAuth}`) - $.msg(`获取shangtuoAuth成功:${shangtuoAuth}`) - } - - shangtuoUA = $request.headers['User-Agent'] - if (shangtuoUA) { - $.setdata(shangtuoUA, `shangtuoUA`) - $.log(`获取shangtuoUA成功:${shangtuoUA}`) - $.msg(`获取shangtuoUA成功:${shangtuoUA}`) - } - } -} - -//用户信息 -function getUserInfoData(checkStatus,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/user/getUserInfoData`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if (result.code == 0) { - if(checkStatus) { - console.log(`\n账户${userNum+1}名称:${result.result.nickname}`) - userInfo += `\n账户${userNum+1}名称:${result.result.nickname}\n` - } else { - console.log(`\n账户${userNum+1}名称:${result.result.nickname}`) - console.log(` 推荐码: ${result.result.recom_code}`) - userInfo += ` 推荐码: ${result.result.recom_code}\n` - console.log(` 分红金总额:${result.result.dividend}`) - userInfo += ` 分红金总额:${result.result.dividend}\n` - console.log(` 分红余额: ${result.result.balance_with}`) - userInfo += ` 分红余额: ${result.result.balance_with}\n` - console.log(` 红包余额: ${result.result.balance_packet}`) - userInfo += ` 红包余额: ${result.result.balance_packet}\n` - console.log(` 推广余额: ${result.result.balance_extend}`) - userInfo += ` 推广余额: ${result.result.balance_extend}\n` - console.log(` 可售商券: ${result.result.bond_count}`) - userInfo += ` 可售商券: ${result.result.bond_count}\n` - console.log(` 消费余额: ${result.result.balance}`) - userInfo += ` 消费余额: ${result.result.balance}\n` - console.log(` 消费商券: ${result.result.balance_bonds}`) - userInfo += ` 消费商券: ${result.result.balance_bonds}\n` - } - } else { - console.log(`\n获取账户${userNum+1}信息失败: ${result.msg}`) - if(result.msg.indexOf('登录超时') > -1) { - accountStatus = 0 - userInfo += `\n获取账户${userNum+1}信息失败: ${result.msg},请尝试重新捉CK\n` - } - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//广告列表id -function getAdvertPage(pageNo,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve) => { - let request = { - url: `https://api.shatuvip.com/advert/getAdvertPage?type=1&pageNo=${pageNo}&column_id=1`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if (result.code == 0) { - console.log(`获取分红金广告任务列表成功`) - adNum = result.result.length - compTaskFlag = 1 - for(let i=0; i { - let request = { - url: `https://api.shatuvip.com/advert/getAdvertInfo?id=${cid}`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if (result.code == 0) { - console.log(`开始浏览广告${cid}`) - secretCode = result.result.uniTime2 - await $.wait(7000); - } else { - console.log(`浏览广告失败: ${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//获取分红金 -function completeTask(cid,secret,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/advert/completeTask`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - body: `{"id": ${cid}, "secret": "${secret}"}`, - } - - $.post(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if (result.code == 0) { - if(result.msg) { - console.log(`获得${result.msg}`) - compTaskFlag = 1 - } else { - console.log(`没有获得分红金,结束浏览广告`) - } - } else { - console.log(`获取分红金失败:${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//提取分红金 -function changeDividendBonusToBalance(timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/user/changeDividendBonusToBalance`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if(result.code == 0) { - console.log(`提取分红金获得: ${result.result.bonus}`) - userInfo += `提取分红金获得: ${result.result.bonus}\n` - } else { - console.log(`提取分红金失败: ${result.msg}`) - } - - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//出售券列表 -function getTradeToPage(pageNo,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve) => { - let request = { - url: `https://api.shatuvip.com/user/getTradeToPage?pageNo=${pageNo}`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if (result.code == 0) { - for (i = 0; i < result.result.length; i++) { - quanItem = result.result[i] - if(quanItem.locking) { - console.log(`${quanItem.price}券${quanItem.id}出售等待时间:${quanItem.locking}`) - } else { - await getPriceSection(quanItem.id,quanItem.price) - } - } - } else { - console.log(`获取出售券列表失败: ${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//设置券出售金额 -function getPriceSection(id,price,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve) => { - let request = { - url: `https://api.shatuvip.com/market/getPriceSection?id=${id}`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if (result.code == 0) { - sellPrice = result.result.max - console.log(`${price}券可出售金额为${result.result.min}到${result.result.max},设置为${sellPrice}`) - await tradePutShop(id,price,sellPrice) - } else { - console.log(`获取券可出售金额失败: ${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//券出售 -function tradePutShop(id,price,sellPrice,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/user/tradePutShop`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - body: `{"id": ${id}, "price": "${sellPrice}"}`, - } - - $.post(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - console.log(`出售${price}券结果:${result.msg}`) - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//抢券操作 -async function getAllBondList(balance) { - let i = 1 - quanList = [] - getBondListFlag = 1 - while(getBondListFlag) { - await getBondList(i,balance) - i++ - } - - let sortList = quanList.sort(function(a,b){return b["face_price"]-a["face_price"]}); - - let numList = sortList.length - for(let i=0; i { - let request = { - url: `https://api.shatuvip.com/bond/getBondList?pageNo=${pageNo}`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - await $.wait(500) - if (result.code == 0) { - if(result.result && result.result[0]) { - let numList = result.result.length - console.log(`获取抢券列表第${pageNo}页成功,找到${numList}个抢券ID`) - for(let i=0; i= quanItem.price) { - quanList.push(quanItem) - } - } - } else { - //没有可抢的券了,停止查询 - getBondListFlag = 0 - } - } else { - console.log(`获取抢券列表失败:${result.msg}`) - getBondListFlag = 0 - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//获取抢券广告id -function getBondAdvertId(face_price,id,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/advert/getBondAdvertId`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if (result.code == 0) { - await getAdvertInfo(result.result.id); - await grab(face_price,id,result.result.token) - } else { - console.log(`获取抢券广告ID失败:${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - - -//抢券 -function grab(face_price,id,token,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - grabCount++ - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/bond/grab`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - body: `{"bond_id": ${id}, "__token__": "${token}"}`, - } - - $.post(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if (result.code == 0) { - console.log(`抢${face_price}券成功:${result.msg}`) - await $.wait(1000) - } else { - console.log(`抢${face_price}券失败:${result.msg}`) - grabFlag = 0 - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - - }) -} - -//团队人数 -function getTeamData(timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/team/getTeamData`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if(result.code == 0) { - console.log(`推广总人数:${result.result.num}`) - console.log(`----直推人数:${result.result.sonNum}`) - console.log(`--------有效直推:${result.result.sonAttestationNum}`) - console.log(`--------无效直推:${result.result.songNoAttestationNum}`) - console.log(`----间推人数:${result.result.grandsonNum}`) - console.log(`--------有效间推:${result.result.grandsonAttestationNum}`) - console.log(`--------无效间推:${result.result.grandsonNoAttestationNum}`) - } else { - console.log(`查询团队人数失败:${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//团队列表 -//type: 1 -- 直推, 2 -- 间推 -function getALlRecommendAdvertListPage(pageNum,type,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/team/getALlRecommendAdvertListPage?pageNo=${pageNum}&type=${type}`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if(result.code == 0) { - await $.wait(500) - if(result.result && result.result[0]){ - for(let i=0; i { - let request = { - url: `https://api.shatuvip.com/team/grabTeamWith`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - body: `{"recom_code":${recom_code}}`, - } - - $.post(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - await $.wait(500); - let result = JSON.parse(data) - if(logDebug) console.log(result) - if(result.code == 0) { - console.log(`收取团队活跃红包成功:${result.msg}`) - } else { - console.log(`收取团队活跃红包失败:${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//消费余额查询 -function getUserBalance(timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/user/getUserBalance`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - await $.wait(500); - if(result.code == 0) { - console.log(`\n消费余额:${result.result.balance},开始抢券`) - await getAllBondList(result.result.balance) - } else { - console.log(`\n查询消费余额失败:${result.msg}`) - await getAllBondList(0) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//分红金余额查询 -function getUserBalanceWith(timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/user/getUserBalanceWith`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if(result.code == 0) { - await $.wait(1000); - if(result.result.balance >= 88) { - console.log(`\n分红金余额:${result.result.balance},开始尝试提现`) - await getBalanceWithdrawalData(0,result.result.balance) - } else { - console.log(`\n分红金余额:${result.result.balance},不执行提现`) - } - } else { - console.log(`\n查询分红金余额失败:${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//推广余额查询 -function getPopularizeBalance(timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/user/getPopularizeBalance`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if(result.code == 0) { - await $.wait(1000); - if(result.result.balance >= 1) { - console.log(`\n推广余额:${result.result.balance},开始尝试提现`) - await getBalanceWithdrawalData(2,result.result.balance) - } else { - console.log(`\n推广余额:${result.result.balance},不执行提现`) - } - } else { - console.log(`\n查询推广余额失败:${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//红包余额查询 -//move: 0 -- 转换为消费余额, 1 -- 提现 -function getPackBalance(move,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/user/getPackBalance`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if(result.code == 0) { - await $.wait(1000); - if(move == 0) { - if(result.result.balance > 0) { - console.log(``) - await balancePackChangeBalance(result.result.balance) - } - } else { - if(result.result.balance >= packWithdrawAmount) { - console.log(`\n红包余额${result.result.balance},尝试为你提现${packWithdrawAmount}`) - await getBalanceWithdrawalData(1,result.result.balance,packWithdrawAmount) - } else { - console.log(`\n红包余额${result.result.balance},不足${packWithdrawAmount},不执行提现`) - } - } - } else { - console.log(`\n查询红包余额失败:${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//红包余额转换消费余额 -function balancePackChangeBalance(balance,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/user/balancePackChangeBalance`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - body: `{"balance":"${balance}"}`, - } - - $.post(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - await $.wait(1000); - let result = JSON.parse(data) - if(logDebug) console.log(result) - if(result.code == 0) { - console.log(`\n将红包余额${balance}转换为消费余额来抢更高面额的券`) - } else { - console.log(`\n红包余额转换失败:${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//提现列表 -//type: 0 -- 分红金余额, 1 -- 红包余额, 2 -- 推广余额 -function getBalanceWithdrawalData(type,balance,withdrawAmount=0,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/withdrawal/getBalanceWithdrawalData?type=${type}`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if(result.code == 0) { - await $.wait(1000); - let withdrawId = 0 - let withdrawBalance = 0 - for(let i=0; i 0) { - //指定提现数量 - if(withdrawItem.balance == withdrawAmount) { - withdrawId = withdrawItem.id - withdrawBalance = withdrawItem.balance - break; - } - }else { - if(balance >= withdrawItem.balance && withdrawItem.balance > withdrawBalance) { - withdrawId = withdrawItem.id - withdrawBalance = withdrawItem.balance - } - } - } - if(withdrawBalance != 0 && withdrawId!= 0) { - await queryWithdrawId(withdrawId,withdrawBalance) - } else { - console.log(`余额不足`) - } - } else { - console.log(`查询提现列表失败:${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//提现ID查询 -function queryWithdrawId(id,balance,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/withdrawal/with?withdrawal_id=${id}`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - } - - $.get(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - let result = JSON.parse(data) - if(logDebug) console.log(result) - if(result.code == 0) { - await $.wait(1000); - let withdrawFee = result.result["with"] - let withdrawMoney = balance - withdrawFee - console.log(`发起提现${balance}元,手续费${withdrawFee},到手${withdrawMoney}`) - await balanceWithdrawal(id,withdrawMoney) - } else { - console.log(`查询提现ID${id}失败:${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - -//提现 -function balanceWithdrawal(id,withdrawMoney,timeout = 0) { - if(logCaller) console.log("call "+ printCaller()) - return new Promise((resolve, reject) => { - let request = { - url: `https://api.shatuvip.com/withdrawal/balanceWithdrawal`, - headers: { - "Host": "api.shatuvip.com", - "Origin": "https://shatuvip.com", - "Connection": "keep-alive", - "Authorization": shangtuoAuth, - "User-Agent": shangtuoUA, - "Content-Type": "application/json", - "Accept": "*/*", - "Referer": "https://shatuvip.com/", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh-Hans;q=0.9" - }, - body: `{"id": "${id}", "type": "1"}`, - } - - $.post(request, async (err, resp, data) => { - try { - if (err) { - console.log("API请求失败"); - console.log(err + " at function " + printCaller()); - } else { - if (safeGet(data)) { - await $.wait(1000); - let result = JSON.parse(data) - if(logDebug) console.log(result) - if(result.code == 0) { - console.log(`${result.msg},预计到账${withdrawMoney}元`) - userInfo += `${result.msg},预计到账${withdrawMoney}元\n` - } else { - console.log(`提现失败:${result.msg}`) - } - } - } - } catch (e) { - console.log(e + " at function " + printCaller(), resp); - } finally { - resolve(); - } - }) - }) -} - - -//=========================================================================================== -function safeGet(data) { - try { - if (typeof JSON.parse(data) == "object") { - return true; - } - } catch (e) { - console.log(e); - console.log(`服务器访问数据为空`); - return false; - } -} - -function printCaller(){ - return (new Error()).stack.split("\n")[2].trim().split(" ")[1] -} - -function Env(t, e) { - class s { - constructor(t) { - this.env = t - } - send(t, e = "GET") { - t = "string" == typeof t ? { - url: t - } : t; - let s = this.get; - return "POST" === e && (s = this.post), new Promise((e, i) => { - s.call(this, t, (t, s, r) => { - t ? i(t) : e(s) - }) - }) - } - get(t) { - return this.send.call(this.env, t) - } - post(t) { - return this.send.call(this.env, t, "POST") - } - } - return new class { - constructor(t, e) { - this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `\ud83d\udd14${this.name}, \u5f00\u59cb!`) - } - isNode() { - return "undefined" != typeof module && !!module.exports - } - isQuanX() { - return "undefined" != typeof $task - } - isSurge() { - return "undefined" != typeof $httpClient && "undefined" == typeof $loon - } - isLoon() { - return "undefined" != typeof $loon - } - toObj(t, e = null) { - try { - return JSON.parse(t) - } catch { - return e - } - } - toStr(t, e = null) { - try { - return JSON.stringify(t) - } catch { - return e - } - } - getjson(t, e) { - let s = e; - const i = this.getdata(t); - if (i) try { - s = JSON.parse(this.getdata(t)) - } catch {} - return s - } - setjson(t, e) { - try { - return this.setdata(JSON.stringify(t), e) - } catch { - return !1 - } - } - getScript(t) { - return new Promise(e => { - this.get({ - url: t - }, (t, s, i) => e(i)) - }) - } - runScript(t, e) { - return new Promise(s => { - let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); - i = i ? i.replace(/\n/g, "").trim() : i; - let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); - r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; - const [o, h] = i.split("@"), a = { - url: `http://${h}/v1/scripting/evaluate`, - body: { - script_text: t, - mock_type: "cron", - timeout: r - }, - headers: { - "X-Key": o, - Accept: "*/*" - } - }; - this.post(a, (t, e, i) => s(i)) - }).catch(t => this.logErr(t)) - } - loaddata() { - if (!this.isNode()) return {}; { - this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); - const t = this.path.resolve(this.dataFile), - e = this.path.resolve(process.cwd(), this.dataFile), - s = this.fs.existsSync(t), - i = !s && this.fs.existsSync(e); - if (!s && !i) return {}; { - const i = s ? t : e; - try { - return JSON.parse(this.fs.readFileSync(i)) - } catch (t) { - return {} - } - } - } - } - writedata() { - if (this.isNode()) { - this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); - const t = this.path.resolve(this.dataFile), - e = this.path.resolve(process.cwd(), this.dataFile), - s = this.fs.existsSync(t), - i = !s && this.fs.existsSync(e), - r = JSON.stringify(this.data); - s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) - } - } - lodash_get(t, e, s) { - const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); - let r = t; - for (const t of i) - if (r = Object(r)[t], void 0 === r) return s; - return r - } - lodash_set(t, e, s) { - return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) - } - getdata(t) { - let e = this.getval(t); - if (/^@/.test(t)) { - const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; - if (r) try { - const t = JSON.parse(r); - e = t ? this.lodash_get(t, i, "") : e - } catch (t) { - e = "" - } - } - return e - } - setdata(t, e) { - let s = !1; - if (/^@/.test(e)) { - const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; - try { - const e = JSON.parse(h); - this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) - } catch (e) { - const o = {}; - this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) - } - } else s = this.setval(t, e); - return s - } - getval(t) { - return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null - } - setval(t, e) { - return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null - } - initGotEnv(t) { - this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) - } - get(t, e = (() => {})) { - t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { - "X-Surge-Skip-Scripting": !1 - })), $httpClient.get(t, (t, s, i) => { - !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) - })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { - hints: !1 - })), $task.fetch(t).then(t => { - const { - statusCode: s, - statusCode: i, - headers: r, - body: o - } = t; - e(null, { - status: s, - statusCode: i, - headers: r, - body: o - }, o) - }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { - try { - if (t.headers["set-cookie"]) { - const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); - this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar - } - } catch (t) { - this.logErr(t) - } - }).then(t => { - const { - statusCode: s, - statusCode: i, - headers: r, - body: o - } = t; - e(null, { - status: s, - statusCode: i, - headers: r, - body: o - }, o) - }, t => { - const { - message: s, - resp: i - } = t; - e(s, i, i && i.body) - })) - } - post(t, e = (() => {})) { - if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { - "X-Surge-Skip-Scripting": !1 - })), $httpClient.post(t, (t, s, i) => { - !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) - }); - else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { - hints: !1 - })), $task.fetch(t).then(t => { - const { - statusCode: s, - statusCode: i, - headers: r, - body: o - } = t; - e(null, { - status: s, - statusCode: i, - headers: r, - body: o - }, o) - }, t => e(t)); - else if (this.isNode()) { - this.initGotEnv(t); - const { - url: s, - ...i - } = t; - this.got.post(s, i).then(t => { - const { - statusCode: s, - statusCode: i, - headers: r, - body: o - } = t; - e(null, { - status: s, - statusCode: i, - headers: r, - body: o - }, o) - }, t => { - const { - message: s, - resp: i - } = t; - e(s, i, i && i.body) - }) - } - } - time(t) { - let e = { - "M+": (new Date).getMonth() + 1, - "d+": (new Date).getDate(), - "H+": (new Date).getHours(), - "m+": (new Date).getMinutes(), - "s+": (new Date).getSeconds(), - "q+": Math.floor(((new Date).getMonth() + 3) / 3), - S: (new Date).getMilliseconds() - }; - /(y+)/.test(t) && (t = t.replace(RegExp.$1, ((new Date).getFullYear() + "").substr(4 - RegExp.$1.length))); - for (let s in e) new RegExp("(" + s + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? e[s] : ("00" + e[s]).substr(("" + e[s]).length))); - return t - } - msg(e = t, s = "", i = "", r) { - const o = t => { - if (!t) return t; - if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { - "open-url": t - } : this.isSurge() ? { - url: t - } : void 0; - if ("object" == typeof t) { - if (this.isLoon()) { - let e = t.openUrl || t.url || t["open-url"], - s = t.mediaUrl || t["media-url"]; - return { - openUrl: e, - mediaUrl: s - } - } - if (this.isQuanX()) { - let e = t["open-url"] || t.url || t.openUrl, - s = t["media-url"] || t.mediaUrl; - return { - "open-url": e, - "media-url": s - } - } - if (this.isSurge()) { - let e = t.url || t.openUrl || t["open-url"]; - return { - url: e - } - } - } - }; - this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))); - let h = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="]; - h.push(e), s && h.push(s), i && h.push(i), console.log(h.join("\n")), this.logs = this.logs.concat(h) - } - log(...t) { - t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) - } - logErr(t, e) { - const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); - s ? this.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t.stack) : this.log("", `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t) - } - wait(t) { - return new Promise(e => setTimeout(e, t)) - } - done(t = {}) { - const e = (new Date).getTime(), - s = (e - this.startTime) / 1e3; - this.log("", `\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) - } - }(t, e) -}