加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
blackUnique.js 79.88 KB
一键复制 编辑 原始数据 按行查看 历史
LMY 提交于 2022-05-03 15:38 . blackunique
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734
/*
APP:全球购骑士特权 直接appstore搜索下载
定时为每小时一次,务必在0分到5分之间运行,目前每天大概1毛7
提现需要关注微信公众号,在公众号里申请提现
青龙:
捉https://market.chuxingyouhui.com/promo-bargain-api/activity/mqq/api/indexTopInfo的包
然后填在blackJSON里面,注意按照JSON格式填写。用青龙面板的环境变量或者外面用双引号的,字符串内需要用\"转义
export blackJSON='{"black-token":"", "token":"", "User-Agent":"", "appId":""}'
V2P,圈X:重写方法 -- 点击右下角【我的】-> 【每日签到赚现金】
[task_local]
#全球购骑士特权
0 * * * * url/blackUnique.js, tag=全球购骑士特权, enabled=true
[rewrite_local]
https://market.chuxingyouhui.com/promo-bargain-api/activity/mqq/api/indexTopInfo? url script-request-header url/blackUnique.js
[MITM]
hostname = market.chuxingyouhui.com
*/
const jsname = '全球购骑士特权'
const $ = Env(jsname)
const notifyFlag = 1; //0为关闭通知,1为打开通知,默认为1
const logDebug = 0
//const notify = $.isNode() ? require('./sendNotify') : '';
let notifyStr = ''
let blackJSON = ($.isNode() ? (process.env.blackJSON) : ($.getval('blackJSON'))) || ''
let blackArr = []
let userIdx = 0
let reqTime = ''
let userSign = ''
let redPacketId = ''
let fruitId = ''
let userFruitId = ''
let activityId = ''
let redPacketCount = 0
let waterCount = 0
let fertilizerCount = 0
let clickTreeTimes = 1
let signRetryTimes = 3
let signRetryCount = 0
let totalMoney = 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提现需要关注微信公众号,在公众号里申请提现')
for(userIdx=0; userIdx<blackArr.length; userIdx++) {
console.log(`\n===== 开始用户${userIdx+1} 勋章任务 =====`)
await querySignStatus()
await listUserTask()
//await listRedPacket()
//收取存钱罐看视频需要前置条件
//await queryPiggyInfo()
//翻卡看视频需要前置条件
//await getUserFlopRecord()
}
/*
for(userIdx=0; userIdx<blackArr.length; userIdx++) {
console.log(`\n===== 开始用户${userIdx+1} 视频任务 =====`)
//收取存钱罐看视频需要前置条件
//await queryPiggyInfo()
//翻卡看视频需要前置条件
//await getUserFlopRecord()
}*/
for(userIdx=0; userIdx<blackArr.length; userIdx++) {
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("mqq/api/indexTopInfo?appId=") > -1) {
let blackCk = {"black-token":"", "token":"", "User-Agent":"", "appId":""}
let msgStr = ''
let matchItem = $request.url.match(/appId=([\w]+)/)
blackCk['appId'] = matchItem[1]
msgStr += `获取到appId: ${blackCk['appId']}\n`
blackCk['black-token'] = $request.headers['black-token']
msgStr += `获取到black-token: ${blackCk['black-token']}\n`
blackCk['token'] = $request.headers['token']
msgStr += `获取到token: ${blackCk['token']}\n`
blackCk['User-Agent'] = $request.headers['User-Agent']
msgStr += `获取到User-Agent: ${blackCk['User-Agent']}\n`
if(blackCk['black-token']) {
if(blackJSON) {
if(blackJSON.indexOf(blackCk['black-token']) == -1) {
blackJSON = blackJSON + '@' + JSON.stringify(blackCk)
numUser = blackJSON.split('@')
msgStr = `获取到第${numUser.length}个账户ck\n` + msgStr
$.setdata(blackJSON,'blackJSON')
$.msg(msgStr)
} else {
$.log('检测到重复的账户ck')
}
} else {
msgStr = `获取到第一个账户ck\n` + msgStr
$.setdata(JSON.stringify(blackCk),'blackJSON')
$.msg(msgStr)
}
}
}
}
async function checkEnv()
{
if(blackJSON) {
for(let users of blackJSON.split('@')) {
blackArr.push(JSON.parse(users))
}
} else {
console.log('未找到blackJSON')
return false
}
if(blackArr.length == 0) {
console.log('未找到有效的blackJSON')
return false
}
console.log(`共找到${blackArr.length}个用户`)
return true
}
//==========================================================================
//加密接口
async function getSignInfo(type, timeout=5000) {
signRetryCount++
let caller = printCaller()
//rndtime = Math.round(new Date().getTime())
return new Promise((resolve) => {
let url = {
url: `http://cxyh.sijia.fun/?type=${type}&token=${blackArr[userIdx]['token']}`,
headers: {
'Host' : 'cxyh.sijia.fun',
'Connection' : 'keep-alive',
},
};
$.get(url, async (err, resp, data) => {
try {
if (err) {
console.log("Fucntion " + caller + ": API请求失败");
if(signRetryCount < signRetryTimes) getSignInfo(type)
} else {
if (safeGet(data)) {
let result = JSON.parse(data);
if(logDebug) console.log(result);
if(result.success == true) {
reqTime = result.requests_time
userSign = result.sign
redPacketId = result.redPacketId ? result.redPacketId : ''
}
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve();
}
},timeout);
});
}
//获取视频信息
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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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='+blackArr[userIdx]['appId'],
headers: {
'Host' : 'market.chuxingyouhui.com',
'Origin' : 'https://m.black-unique.com',
'Accept-Encoding' : 'gzip, deflate, br',
'Connection' : 'keep-alive',
'black-token' : blackArr[userIdx]['black-token'],
'Accept' : 'application/json, text/plain, */*',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'Referer' : 'https://m.black-unique.com/',
'token' : blackArr[userIdx]['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='+blackArr[userIdx]['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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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<result.data.length; i++) {
let taskItem = result.data[i]
if(taskItem.status == 0 && taskItem.finishedTimes < taskItem.totalTimes) {
if(taskItem.taskType.indexOf('RECEIVE_MEDAL') > -1 && (rndtime < taskItem.receiveStartTime || rndtime > taskItem.receiveEndTime)) {
//非整点领勋章时间
continue
} else if(taskItem.taskType.indexOf('SHOPPING') > -1) {
//跳过购物任务
continue
} else if(taskItem.taskType.indexOf('BROWSE_ARTICLE') > -1) {
//看小说
continue
} else {
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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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='+blackArr[userIdx]['appId'],
headers: {
'Host' : 'market.chuxingyouhui.com',
'Origin' : 'https://m.black-unique.com',
'Accept-Encoding' : 'gzip, deflate, br',
'Connection' : 'keep-alive',
'black-token' : blackArr[userIdx]['black-token'],
'Accept' : 'application/json, text/plain, */*',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'Referer' : 'https://m.black-unique.com/',
'token' : blackArr[userIdx]['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 getBussinessInfo(946088114,7,'GOLDEN_CLICK','v3')
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":"${blackArr[userIdx]['appId']}","extraReq":${bussinessInfo}}`
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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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":"${blackArr[userIdx]['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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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<result.data.recordList.length; i++) {
let recordItem = result.data.recordList[i]
if(!recordItem.status) {
await getBussinessInfo(946087990,12,'WITHDRAWAL_WATCH_VIDEO','v3')
await userFlop(recordItem.serialNumber)
}
}
}
} else {
console.log(`查询翻牌状态失败:${result.msg}`)
}
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve();
}
});
});
}
//翻牌领提现额度
async function userFlop(serialNumber) {
let caller = printCaller()
//rndtime = Math.round(new Date().getTime())
reqBody = `{"appId":"${blackArr[userIdx]['appId']}","serialNumber":${serialNumber},"flopDay":"${todayDate}","extraReq":${bussinessInfo}}`
encodeBody = encodeURIComponent(reqBody)
return new Promise((resolve) => {
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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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',
'Accept-Language' : 'zh-CN,zh-Hans;q=0.9',
'newcomer' : 'true',
'Accept-Encoding' : 'gzip, deflate, br',
'token' : blackArr[userIdx]['token'],
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['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<result.data.redPacketList.length; i++) {
let redItem = result.data.redPacketList[i]
if(redItem.money > 0) {
redPacketCount++
}
if(redItem.status == 2 && redItem.money == 0 && redPacketCount < 7) {
signRetryCount = 0
await getSignInfo('open')
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, */*',
'ymd' : '0',
'newcomer' : 'true',
'token' : blackArr[userIdx]['token'],
'Accept-Language' : 'zh-CN,zh-Hans;q=0.9',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['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 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, */*',
'Accept-Language' : 'zh-CN,zh-Hans;q=0.9',
'token' : blackArr[userIdx]['token'],
'Accept-Encoding' : 'gzip, deflate, br',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['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":"${blackArr[userIdx]['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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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":"${blackArr[userIdx]['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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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 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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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<result.data.taskList.length; i++) {
let taskItem = result.data.taskList[i]
if(taskItem.taskType.indexOf('CLICK_DO_TASK') > -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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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}`)
}
}
}
} 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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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}`)
}
}
}
} 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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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<result.data.gardenFertilizerTaskDtoList.length; i++) {
let taskItem = result.data.gardenFertilizerTaskDtoList[i]
if(taskItem.taskType.indexOf('ORDER_FOR_FERTILIZER') == -1 && taskItem.status != 2) {
await doNutrientTask(taskItem.taskType,taskItem.taskId,taskItem.title)
}
}
}
} else {
console.log(`获取果园肥料任务失败:${result.msg}`)
}
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve();
}
});
});
}
//果园-完成肥料任务
async function doNutrientTask(taskType,taskId,taskTitle) {
let caller = printCaller()
//rndtime = Math.round(new Date().getTime())
reqBody = `{"taskId":"${taskId}","userFruitId":"${userFruitId}","taskType":"${taskType}","source":2}`
encodeBody = encodeURIComponent(reqBody)
return new Promise((resolve) => {
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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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}`)
}
}
}
} 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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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<result.data.userSmallFertilizerTool.remainNum; i++) {
await useFertilizer(result.data.userSmallFertilizerTool.userToolIds)
}
for(let i=0; i<result.data.userFertilizerTool.remainNum; i++) {
await useFertilizer(result.data.userFertilizerTool.userToolIds)
}
console.log(`施肥结束,本次共施肥${waterCount}次`)
}
} else {
console.log(`获取果园肥料状态失败:${result.msg}`)
}
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve();
}
});
});
}
//果园施肥
async function useFertilizer(userToolId) {
let caller = printCaller()
//rndtime = Math.round(new Date().getTime())
reqBody = `{"userFruitId":"${userFruitId}","userToolId":"${userToolId}"}`
encodeBody = encodeURIComponent(reqBody)
return new Promise((resolve) => {
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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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}`)
}
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve();
}
});
});
}
//果园-摇树得优惠券
async function getTreeCoupon() {
console.log(`\n开始摇树${clickTreeTimes}次得优惠券`)
for(let i=0; i<clickTreeTimes; i++) {
await clickTree()
}
}
//果园-点击树
async function clickTree() {
let caller = printCaller()
//rndtime = Math.round(new Date().getTime())
reqBody = `{"userFruitId":"${userFruitId}","appId":"${blackArr[userIdx]['appId']}"}`
encodeBody = encodeURIComponent(reqBody)
return new Promise((resolve) => {
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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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.hasReward == true) {
await receiveReward(result.data.rewardId,result.data.rewardName,result.data.rewardInfo)
}
} else {
console.log(`果园点击树失败:${result.msg}`)
}
}
}
} 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":"${blackArr[userIdx]['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' : blackArr[userIdx]['token'],
'Content-Type' : 'application/json;charset=utf-8',
'Origin' : 'https://m.black-unique.com',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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}`)
}
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve();
}
});
});
}
//查询账户信息
async function userInfo() {
console.log(`\n========= 账户${userIdx+1} 信息 =========`)
notifyStr += `========= 账户${userIdx+1} 信息 =========\n`
await getUserInfo()
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' : '*/*',
'Accept-Language' : 'zh-Hans-CN;q=1',
'token' : blackArr[userIdx]['token'],
'User-Agent' : blackArr[userIdx]['User-Agent'],
'black-token' : blackArr[userIdx]['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) {
totalMoney = 0
console.log(`【骑士卡号】:${result.data.userPointsResp.cardNo}`)
notifyStr += `【骑士卡号】:${result.data.userPointsResp.cardNo}\n`
console.log(`【现金余额】:${result.data.currencyBlanceResp.commission}元`)
notifyStr += `【现金余额】:${result.data.currencyBlanceResp.commission}元\n`
totalMoney += result.data.currencyBlanceResp.commission
} else {
console.log(`查询现金余额失败:${result.msg}`)
notifyStr += `查询现金余额失败:${result.msg}\n`
}
}
}
} 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='+blackArr[userIdx]['appId'],
headers: {
'Host' : 'market.chuxingyouhui.com',
'Origin' : 'https://m.black-unique.com',
'Accept-Encoding' : 'gzip, deflate, br',
'Connection' : 'keep-alive',
'black-token' : blackArr[userIdx]['black-token'],
'Accept' : 'application/json, text/plain, */*',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'Referer' : 'https://m.black-unique.com/',
'token' : blackArr[userIdx]['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}${result.data.score/10000}元`)
notifyStr += `【勋章余额】:${result.data.score}${result.data.score/10000}元\n`
totalMoney += Math.floor(result.data.score/10000)
totalMoney = Math.floor(totalMoney * 100)/100
console.log(`【可提现余额】:${totalMoney}元`)
notifyStr += `【可提现余额】:${totalMoney}元\n`
} else {
console.log(`查询勋章余额失败:${result.msg}`)
notifyStr += `查询勋章余额失败:${result.msg}\n`
}
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve();
}
});
});
}
//查询勋章余额
async function getUserInfo() {
let caller = printCaller()
//rndtime = Math.round(new Date().getTime())
return new Promise((resolve) => {
let url = {
url: 'https://facade-api.black-unique.com/user/common/v1/getUserInfo',
headers: {
'Host' : 'facade-api.black-unique.com',
'Origin' : 'https://m.black-unique.com',
'Accept-Encoding' : 'gzip, deflate, br',
'Connection' : 'keep-alive',
'black-token' : blackArr[userIdx]['black-token'],
'Accept' : 'application/json, text/plain, */*',
'User-Agent' : blackArr[userIdx]['User-Agent'],
'Referer' : 'https://m.black-unique.com/',
'token' : blackArr[userIdx]['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 == 0) {
console.log(`【用户手机】:${result.data.phone}`)
notifyStr += `【用户手机】:${result.data.phone}\n`
} else {
console.log(`查询用户手机失败:${result.msg}`)
notifyStr += `查询用户手机失败:${result.msg}\n`
}
}
}
} 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) }
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化