diff --git a/jd_fcwb.py b/jd_fcwb.py index 6f18d17..a69932b 100644 --- a/jd_fcwb.py +++ b/jd_fcwb.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- ''' -cron: 1 1 1 1 * +cron: 11 11 10 11 * jd_fcwb.py new Env('发财挖宝'); 活动入口: 京东极速版 > 我的 > 发财挖宝 最高可得总和为10元的微信零钱和红包 @@ -14,7 +14,7 @@ import sys sys.path.append('../../tmp') print('\n运行本脚本之前请手动进入游戏点击一个方块\n') print('\n挖的如果都是0.01红包就是黑了,别挣扎了!\n') -print('\n默认自动领取奖励,关闭请在代码383行加上#号注释即可\n') +print('\n默认关闭自动领取奖励,开启请在主函数最后调用的函数前面删除#号注释即可\n') try: import requests except Exception as e: @@ -73,7 +73,7 @@ def ua(): try: from jdEnv import USER_AGENTS as a except: - a='jdpingou;android;5.5.0;11;network/wifi;model/M2102K1C;appBuild/18299;partner/lcjx11;session/110;pap/JA2019_3111789;brand/Xiaomi;Mozilla/5.0 (Linux; Android 11; M2102K1C Build/RKQ1.201112.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/92.0.4515.159 Mobile Safari/537.36' + a = 'jdltapp;iPhone;3.8.18;;;M/5.0;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;hasOCPay/0;appBuild/1157;supportBestPay/0;jdSupportDarkMode/0;ef/1;ep/%7B%22ciphertype%22%3A5%2C%22cipher%22%3A%7B%22ud%22%3A%22D2PtYzKmY2S5ENY0ZJqmDNTrDtrtZtrsCWPuDtSzY2DvYzq3Y2GzDm%3D%3D%22%2C%22sv%22%3A%22CJCkDm%3D%3D%22%2C%22iad%22%3A%22%22%7D%2C%22ts%22%3A1660017794%2C%22hdid%22%3A%22TQXsGHnakmmgYnwstgBuo1lumKk2DznsrnZM56ldiQM%22%2C%22version%22%3A%221.0.3%22%2C%22appname%22%3A%22com.jd.jdmobilelite%22%2C%22ridx%22%3A1%7D;Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;' return a # 13位时间戳 @@ -102,12 +102,12 @@ class Judge_env(object): except: pass return a -cookie_list=Judge_env().main_run() -def taskGetUrl(functionId, body, cookie): - url=f'https://api.m.jd.com/?functionId={functionId}&body={json.dumps(body)}&t={gettimestamp()}&appid=activities_platform&client=H5&clientVersion=1.0.0' - headers={ +cookie_list = Judge_env().main_run() +async def taskGetUrl(functionId, body, cookie): + url = f'https://api.m.jd.com/?functionId={functionId}&body={json.dumps(body)}&t={gettimestamp()}&appid=activities_platform&client=H5&clientVersion=1.0.0' + headers = { 'Cookie': cookie, 'Host': 'api.m.jd.com', 'Connection': 'keep-alive', @@ -118,92 +118,95 @@ def taskGetUrl(functionId, body, cookie): 'Accept-Language': 'zh-cn', 'Accept-Encoding': 'gzip, deflate, br', } - for n in range(3): + for n in range(5): + time.sleep(1) try: - res=requests.get(url,headers=headers, timeout=30).json() + res = requests.get(url, headers=headers, timeout=30).json() return res - except: - if n==2: - print('API请求失败,请检查网路重试❗\n') + except Exception as e: + # errorMsg = f"❌ 第{e.__traceback__.tb_lineno}行:{e}" + # print(errorMsg) + if n == 4: + print('API请求失败,请检查网路重试❗\n') # 剩余血量 -def xueliang(cookie): - body={"linkId":linkId,"round":1} - res=taskGetUrl("happyDigHome", body, cookie) +async def xueliang(cookie): + body = {"linkId": linkId} + res = await taskGetUrl("happyDigHome", body, cookie) if not res: return - if res['code']==0: + if res['code'] == 0: if res['success']: - curRound=res['data']['curRound'] # 未知 - blood=res['data']['blood'] # 剩余血量 - return blood + curRound = res['data']['curRound'] # 未知 + blood = res['data']['blood'] # 剩余血量 + return blood -def jinge(cookie,i): - body={"linkId":linkId} - res=taskGetUrl("happyDigHome", body, cookie) + +async def jinge(cookie, i): + body = {"linkId": linkId} + res = await taskGetUrl("happyDigHome", body, cookie) if not res: return - if res['code']==0: + if res['code'] == 0: if res['success']: - curRound=res['data']['curRound'] # 未知 - blood=res['data']['blood'] # 剩余血量 - roundList=res['data']['roundList'] # 3个总池子 - roundList_n=roundList[0] - redAmount=roundList_n['redAmount'] # 当前池已得京东红包 - cashAmount=roundList_n['cashAmount'] # 当前池已得微信红包 + curRound = res['data']['curRound'] # 未知 + blood = res['data']['blood'] # 剩余血量 + roundList = res['data']['roundList'] # 3个总池子 + roundList_n = roundList[0] + redAmount = roundList_n['redAmount'] # 当前池已得京东红包 + cashAmount = roundList_n['cashAmount'] # 当前池已得微信红包 - return [blood,redAmount,cashAmount] + return [blood, redAmount, cashAmount] # 页面数据 -def happyDigHome(cookie): - body={"linkId":linkId,"round":1} - res=taskGetUrl("happyDigHome", body, cookie) +async def happyDigHome(cookie): + body = {"linkId": linkId} + res = await taskGetUrl("happyDigHome", body, cookie) exit_flag = "false" if not res: return - if res['code']==0: + if res['code'] == 0: if res['success']: - curRound=res['data']['curRound'] # 未知 - incep_blood=res['data']['blood'] # 剩余血量 - roundList=res['data']['roundList'] # 3个总池子 - for e,roundList_n in enumerate(roundList): # 迭代每个池子 - roundid=roundList_n['round'] # 池序号 - state=roundList_n['state'] - rows=roundList_n['rows'] # 池规模,rows*rows - redAmount=roundList_n['redAmount'] # 当前池已得京东红包 - cashAmount=roundList_n['cashAmount'] # 当前池已得微信红包 - leftAmount=roundList_n['leftAmount'] # 剩余红包? - chunks=roundList_n['chunks'] # 当前池详情list - - a=jinge(cookie,roundid) - if roundid==1: - print(f'\n开始 "入门" 难度关卡({rows}*{rows})') - elif roundid==2: - print(f'\n开始 "挑战" 难度关卡({rows}*{rows})') - elif roundid==3: - print(f'\n开始 "终极" 难度关卡({rows}*{rows})') - print(f'当前剩余血量 {a[0]}🩸') + curRound = res['data']['curRound'] # 未知 + incep_blood = res['data']['blood'] # 剩余血量 + roundList = res['data']['roundList'] # 3个总池子 + for e, roundList_n in enumerate(roundList): # 迭代每个池子 + roundid = roundList_n['round'] # 池序号 + state = roundList_n['state'] + # 池规模,rows*rows + rows = roundList_n['rows'] + # 当前池已得京东红包 + redAmount = roundList_n['redAmount'] + # 当前池已得微信红包 + cashAmount = roundList_n['cashAmount'] + leftAmount = roundList_n['leftAmount'] # 剩余红包? + # 当前池详情list + chunks = roundList_n['chunks'] + a = await jinge(cookie, roundid) + if roundid == 1: + print(f'\n开始进行 "入门" 难度关卡,剩余血量 {a[0]}🩸\n') + elif roundid == 2: + print(f'\n开始进行 "挑战" 难度关卡,剩余血量 {a[0]}🩸\n') + elif roundid == 3: + print(f'\n开始进行 "终极" 难度关卡,剩余血量 {a[0]}🩸\n') ## print(f'当前池已得京东红包 {a[2]}\n当前池已得微信红包 {a[1]}\n') - _blood=xueliang(cookie) - if _blood>1 or incep_blood>=21: - happyDigDo(cookie,roundid,0,0) - if e==0 or e==1: - roundid_n=4 + _blood = await xueliang(cookie) + if _blood > 1: + # await happyDigDo(cookie, roundid, 0, 0) + if e == 0 or e == 1: + roundid_n = 4 else: - roundid_n=5 + roundid_n = 5 for n in range(roundid_n): for i in range(roundid_n): - _blood=xueliang(cookie) - if _blood>1 or incep_blood>=21: + _blood = await xueliang(cookie) + if _blood > 1: ## print(f'当前血量为 {_blood}') - a=n+1 - b=i+1 - print(f'挖取坐标({a},{b})') - happyDigDo(cookie,roundid,n,i) + await happyDigDo(cookie, roundid, n, i) else: - a=jinge(cookie,roundid) - print(f'没血了,不挖了') + a = await jinge(cookie, roundid) + print(f'没血了,溜了溜了\n') exit_flag = "true" ## print(f'当前池已得京东红包 {a[2]}\n当前池已得微信红包 {a[1]}\n') break @@ -218,139 +221,116 @@ def happyDigHome(cookie): print(f'获取数据失败\n{res}\n') - # 玩一玩 -def apDoTask(cookie): - print('开始做玩一玩任务') - body={"linkId":linkId,"taskType":"BROWSE_CHANNEL","taskId":962,"channel":4,"itemId":"https%3A%2F%2Fwqs.jd.com%2Fsns%2F202210%2F20%2Fmake-money-shop%2Findex.html%3FactiveId%3D63526d8f5fe613a6adb48f03","checkVersion":False} - res=taskGetUrl('apDoTask', body, cookie) - if not res: - return - try: - if res['success']: - print('玩好了') - else: - print(f"{res['errMsg']}") - except: - print(f"错误\n{res}") - - -# 挖宝 -def happyDigDo(cookie,roundid,rowIdx,colIdx): - body={"round":roundid,"rowIdx":rowIdx,"colIdx":colIdx,"linkId":linkId} - res=taskGetUrl("happyDigDo", body, cookie) +# 玩一玩 +async def apDoTask(cookie): + print('开始做玩一玩任务') + body={"linkId":linkId,"taskType":"BROWSE_CHANNEL","taskId":962,"channel":4,"itemId":"https%3A%2F%2Fwqs.jd.com%2Fsns%2F202210%2F20%2Fmake-money-shop%2Findex.html%3FactiveId%3D63526d8f5fe613a6adb48f03","checkVersion":False} + res = await taskGetUrl('apDoTask', body, cookie) if not res: return - if res['code']==0: + try: if res['success']: - typeid=res['data']['chunk']['type'] - if typeid==2: - print(f"获得极速版红包 {res['data']['chunk']['value']} 🧧\n") - elif typeid==3: - print(f"🎉 获得微信零钱 {res['data']['chunk']['value']} 💰\n") - elif typeid==4: - print(f"💥Boom💥 挖到了炸弹 💣\n") - elif typeid==1: - print(f"获得优惠券 🎟️\n") - else: - print(f'不知道挖到了什么 🎁\n') + print('玩好了') else: - print(f'{res}\n挖宝失败\n') + print(f"{res['errMsg']}") + except: + print(f"错误\n{res}") + + +# 挖宝 +async def happyDigDo(cookie, roundid, rowIdx, colIdx): + body = {"round": roundid, "rowIdx": rowIdx, + "colIdx": colIdx, "linkId": linkId} + res = await taskGetUrl("happyDigDo", body, cookie) + + a = rowIdx + 1 + b = colIdx + 1 + coordinateText = f"坐标({a},{b}) ➜ " + if not res: + return + if res['code'] == 0: + if res['success']: + typeid = res['data']['chunk']['type'] + if typeid == 2: + print(coordinateText + f"🧧 {res['data']['chunk']['value']}元极速版红包") + elif typeid == 3: + print(coordinateText + f"💰 {res['data']['chunk']['value']}元微信现金") + elif typeid == 4: + print(coordinateText + f"💣 炸弹") + elif typeid == 1: + print(coordinateText + f"🎟️ 优惠券") + else: + print(f'未知内容') + else: + print(coordinateText + f'挖宝失败({res["errCode"]})') else: - print(f'{res}\n挖宝失败\n') + print(coordinateText + f'挖宝失败({res["errMsg"]})') -# # 助力码 -# def inviteCode(cookie): -# global inviteCode_1_list,inviteCode_2_list -# body={"linkId":linkId} -# res=taskGetUrl("happyDigHome", body, cookie) -# if not res: -# return -# try: -# if res['success']: -# print(f"账号{get_pin(cookie)}助力码为{res['data']['inviteCode']}") -# inviteCode_1_list.append(res['data']['inviteCode']) -# print(f"账号{get_pin(cookie)}助力码为{res['data']['markedPin']}") -# inviteCode_2_list.append(res['data']['markedPin']) -# else: -# print('快去买买买吧') -# except: -# print(f"错误\n{res}\n") - -# # 助力 -# def happyDigHelp(cookie,fcwbinviter,fcwbinviteCode): -# print(f"账号 {get_pin(cookie)} 去助力{fcwbinviteCode}") -# xueliang(cookie) -# body={"linkId":linkId,"inviter":fcwbinviter,"inviteCode":fcwbinviteCode} -# res=taskGetUrl("happyDigHelp", body, cookie) -# if res['success']: -# print('助力成功') -# else: -# print(res['errMsg']) # 领取奖励 -def happyDigExchange(cookie): - for n in range(1,4): - xueliang(cookie) - print(f"\n开始领取第{n}场的奖励") - body={"round":n,"linkId":linkId} - res=taskGetUrl("happyDigExchange", body, cookie) +async def happyDigExchange(cookie): + for n in range(1, 4): + await xueliang(cookie) + # print(f"\n开始领取第{n}场的奖励") + body = {"round": n, "linkId": linkId} + res = await taskGetUrl("happyDigExchange", body, cookie) if not res: return - if res['code']==0: - if res['success']: - try: - print(f"已领取极速版红包 {res['data']['redValue']} 🧧") - except: - print('') - if res['data']['wxValue'] != "0": - try: - print(f"可提现微信零钱 {res['data']['wxValue']} 💰") - except: - pass - else: - print(res['errMsg']) - else: - print(res['errMsg']) - + # if res['code'] == 0: + # if res['success']: + # try: + # print(f"已领取极速版红包 {res['data']['redValue']} 🧧") + # except: + # print('') + # if res['data']['wxValue'] != "0": + # try: + # print(f"待提现微信现金 {res['data']['wxValue']} 💰") + # except: + # pass + # else: + # print(res['errMsg']) # 微信现金id -def spring_reward_list(cookie): - happyDigExchange(cookie) - xueliang(cookie) - - body={"linkId":linkId,"pageNum":1,"pageSize":6} - res=taskGetUrl("spring_reward_list", body, cookie) - - if res['code']==0: +async def spring_reward_list(cookie): + await happyDigExchange(cookie) + await xueliang(cookie) + + body = {"linkId": linkId, "pageNum": 1, "pageSize": 6} + res = await taskGetUrl("spring_reward_list", body, cookie) + + if res['code'] == 0: if res['success']: - items=res['data']['items'] + items = res['data']['items'] for _items in items: - amount=_items['amount'] # 金额 - prizeDesc=_items['prizeDesc'] # 金额备注 - amountid=_items['id'] # 金额id - poolBaseId=_items['poolBaseId'] - prizeGroupId=_items['prizeGroupId'] - prizeBaseId=_items['prizeBaseId'] - if '红包' in f"{prizeDesc}": - continue - if '券' in f"{prizeDesc}": - continue + amount = _items['amount'] # 金额 + prizeDesc = _items['prizeDesc'] # 奖品描述 + prizeType = _items['prizeType'] # 奖品类型(1券,2红包,4微信零钱) + amountid = _items['id'] # 金额id + poolBaseId = _items['poolBaseId'] + prizeGroupId = _items['prizeGroupId'] + prizeBaseId = _items['prizeBaseId'] + if prizeType == 4: + print(f'开始提现 {amount} 微信现金💰') + for n in range(1, 3): + result = await WeChat(cookie, amountid, poolBaseId, prizeGroupId, prizeBaseId) + time.sleep(10) ## 上一比金额提现完才可以提现下一笔 + if (result): break else: - print('\n去提现微信零钱 💰') - time.sleep(5) - wecat(cookie,amountid,poolBaseId,prizeGroupId,prizeBaseId) + continue else: print(f'获取数据失败\n{res}\n') else: print(f'获取数据失败\n{res}\n') # 微信提现 -def wecat(cookie,amountid,poolBaseId,prizeGroupId,prizeBaseId): - xueliang(cookie) - - url='https://api.m.jd.com' - headers={ + + +async def WeChat(cookie, amountid, poolBaseId, prizeGroupId, prizeBaseId): + await xueliang(cookie) + + url = 'https://api.m.jd.com' + headers = { 'Cookie': cookie, 'Host': 'api.m.jd.com', 'Connection': 'keep-alive', @@ -360,33 +340,34 @@ def wecat(cookie,amountid,poolBaseId,prizeGroupId,prizeBaseId): 'Accept-Language': 'zh-cn', 'Accept-Encoding': 'gzip, deflate, br', } - body={"businessSource":"happyDiggerH5Cash","base":{"id":amountid,"business":"happyDigger","poolBaseId":poolBaseId,"prizeGroupId":prizeGroupId,"prizeBaseId":prizeBaseId,"prizeType":4},"linkId":linkId} - data=f"functionId=apCashWithDraw&body={json.dumps(body)}&t=1635596380119&appid=activities_platform&client=H5&clientVersion=1.0.0" + body = {"businessSource": "happyDiggerH5Cash", "base": {"id": amountid, "business": "happyDigger", "poolBaseId": poolBaseId, "prizeGroupId": prizeGroupId, "prizeBaseId": prizeBaseId, "prizeType": 4}, "linkId": linkId} + data = f"functionId=apCashWithDraw&body={json.dumps(body)}&t={gettimestamp()}&appid=activities_platform&client=H5&clientVersion=1.0.0" for n in range(3): try: - res=requests.post(url,headers=headers,data=data,timeout=30).json() + res = requests.post(url, headers=headers, data=data, timeout=30).json() break except: - if n==2: - print('API请求失败,请检查网路重试❗\n') + if n == 2: + print('API请求失败,请检查网路重试❗\n') try: - if res['code']==0: + if res['code'] == 0: if res['success']: - print(res['data']['message']+'\n') + print(res['data']['message']+'') + return True except: print(res) - print('') - + return False -def main(): - print('🔔发财挖宝,开始!\n') + +async def main(): + print('🔔发财挖宝 - 挖宝,开始!\n') # print('获取助力码\n') # global inviteCode_1_list,inviteCode_2_list # inviteCode_1_list=list() # inviteCode_2_list=list() # for cookie in cookie_list: - # inviteCode(cookie) + # inviteCode(cookie) # print('互助\n') # inviteCode_2_list=inviteCode_2_list[:2] @@ -395,14 +376,14 @@ def main(): # for cookie in cookie_list: # happyDigHelp(cookie,fcwbinviter,fcwbinviteCode) - print(f'====================共{len(cookie_list)}京东个账号Cookie=========\n') + print(f'================= 共{len(cookie_list)}个京东账号Cookie =================\n') - for e,cookie in enumerate(cookie_list,start=1): - print(f'******开始【账号 {e}】 {get_pin(cookie)} *********\n') - apDoTask(cookie) - happyDigHome(cookie) - spring_reward_list(cookie) + for e, cookie in enumerate(cookie_list, start=1): + print(f'******开始【京东账号{e}】{get_pin(cookie)}******\n') + await apDoTask(cookie) + await happyDigHome(cookie) + #await spring_reward_list(cookie) if __name__ == '__main__': - main() + asyncio.run(main()) diff --git a/jd_makemoneyshop.js b/jd_makemoneyshop.js index 4c49c04..c8dbc73 100644 --- a/jd_makemoneyshop.js +++ b/jd_makemoneyshop.js @@ -9,7 +9,7 @@ DYJSHAREID = 'xxx&xxx&xxx' 10 10 10 10 * https://raw.githubusercontent.com/6dylan6/jdpro/main/jd_makemoneyshop.js By: https://github.com/6dylan6/jdpro -updatetime: 2022/11/4 修复领取奖励不全的问题 +updatetime: 2022/11/10 助力满下一个 */ const $ = new Env('特价版大赢家'); @@ -70,7 +70,9 @@ let helpinfo = {}; console.log('\n\n开始助力...') for (let j = 0; j < shareId.length; j++) { console.log('\n去助力--> ' + shareId[j]); + helpnum = 1; for (let i = 0; i < cookiesArr.length; i++) { + if (helpnum == 10) {console.log('助力已满,跳出!\n');break}; if (cookiesArr[i]) { cookie = cookiesArr[i]; $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); @@ -217,6 +219,7 @@ function help(shareid) { if (data.code == 0) { console.log('助力成功!'); helpinfo[$.UserName].nohelp = 1; + helpnum++; } else if (data.msg === '已助力') { console.log('你已助力过TA!') helpinfo[$.UserName].nohelp = 1; diff --git a/jd_wish.js b/jd_wish.js index 7e367b9..029ca20 100644 --- a/jd_wish.js +++ b/jd_wish.js @@ -1,19 +1,18 @@ /* 众筹许愿池 活动入口:京东-京东众筹-众筹许愿池 -cron "2 2 29 2 *" jd_wish.js +15 12,19 * * * jd_wish.js */ - const $ = new Env('众筹许愿池'); const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; - - let message = '', allMessage = ''; +//IOS等用户直接用NobyDa的jd cookie let cookiesArr = [], cookie = ''; const JD_API_HOST = 'https://api.m.jd.com/client.action'; let appIdArr = ["1FVRZxKiD"]; -let appNameArr = ["超级大转盘"]; +let appNameArr = ["超级转盘"]; let appId, appName; $.shareCode = []; if ($.isNode()) { @@ -29,10 +28,10 @@ if ($.isNode()) { $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); return; } - if(appIdArr.length <= 0) { - console.log(`\n暂无活动~\n`); - return; - } + if(appIdArr.length <= 0) { + console.log(`\n暂无活动~\n`); + return; + } for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { cookie = cookiesArr[i]; @@ -41,7 +40,7 @@ if ($.isNode()) { $.isLogin = true; $.nickName = ''; message = ''; - //await TotalBean(); + await TotalBean(); console.log(`\n*******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); if (!$.isLogin) { $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); @@ -51,13 +50,12 @@ if ($.isNode()) { } continue } - for (let j = 0; j < appIdArr.length; j++) { appId = appIdArr[j] appName = appNameArr[j] console.log(`\n开始第${j + 1}个活动:${appName}\n`) await jd_wish(); - await $.wait(2000) + await $.wait(2000) } } } @@ -65,7 +63,12 @@ if ($.isNode()) { if ($.isNode()) await notify.sendNotify($.name, allMessage); $.msg($.name, '', allMessage) } - let res = []; + let res = await getAuthorShareCode('https://cdn.jsdelivr.net/gh/6dylan6/updateTeam@main/shareCodes/wish.json') + if (!res) { + $.http.get({url: 'https://cdn.jsdelivr.net/gh/6dylan6/updateTeam@main/shareCodes/wish.json'}).then((resp) => {}).catch((e) => console.log('刷新CDN异常', e)); + await $.wait(1000) + res = await getAuthorShareCode('https://cdn.jsdelivr.net/gh/6dylan6/updateTeam@main/shareCodes/wish.json') + } $.shareCode = [...$.shareCode, ...(res || [])] for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { @@ -106,9 +109,9 @@ if ($.isNode()) { }) async function jd_wish() { try { - $.hasEnd = false; + $.hasEnd = false; await healthyDay_getHomeData(); - if($.hasEnd) return; + if($.hasEnd) return; await $.wait(2000) let getHomeDataRes = (await healthyDay_getHomeData(false)).data.result.userInfo @@ -124,12 +127,13 @@ async function jd_wish() { $.canLottery = true for (let j = 0; j < forNum && $.canLottery; j++) { await interact_template_getLotteryResult() - if (j == 9 && $.canLottery) { + if (j == 9 && $.canLottery) { console.log('抽太多次了,下次再继续吧!'); break } await $.wait(2000) } + if (message) allMessage += `京东账号${$.index} ${$.nickName || $.UserName}\n${appName}\n${message}${$.index !== cookiesArr.length ? '\n\n' : ''}` } catch (e) { $.logErr(e) @@ -138,7 +142,6 @@ async function jd_wish() { async function healthyDay_getHomeData(type = true) { return new Promise(async resolve => { - // console.log(taskUrl('healthyDay_getHomeData', { "appId": appId, "taskToken": "", "channelId": 1 })); $.post(taskUrl('healthyDay_getHomeData', { "appId": appId, "taskToken": "", "channelId": 1 }), async (err, resp, data) => { try { if (err) { @@ -148,109 +151,109 @@ async function healthyDay_getHomeData(type = true) { if (safeGet(data)) { data = JSON.parse(data); // console.log(data); - if(data.data.bizCode === 0) { - if (type) { - for (let key of Object.keys(data.data.result.hotTaskVos).reverse()) { - let vo = data.data.result.hotTaskVos[key] - if (vo.status !== 2) { - if (vo.taskType === 13 || vo.taskType === 12) { - console.log(`点击热区`) - await harmony_collectScore({ "appId": appId, "taskToken": vo.simpleRecordInfoVo.taskToken, "taskId": vo.taskId, "actionType": "0" }, vo.taskType) - await $.wait(1000) - } else { - console.log(`【${vo.taskName}】已完成\n`) - } - } - } - for (let key of Object.keys(data.data.result.taskVos).reverse()) { - let vo = data.data.result.taskVos[key] - if (vo.status !== 2) { - if (vo.taskType === 13 || vo.taskType === 12) { - console.log(`签到`) - await harmony_collectScore({ "appId": appId, "taskToken": vo.simpleRecordInfoVo.taskToken, "taskId": vo.taskId, "actionType": "0" }, vo.taskType) - await $.wait(1000) - } else if (vo.taskType === 1) { - for (let key of Object.keys(vo.followShopVo)) { - let followShopVo = vo.followShopVo[key] - if (followShopVo.status !== 2) { - console.log(`【${followShopVo.shopName}】${vo.subTitleName}`) - await harmony_collectScore({ "appId": appId, "taskToken": followShopVo.taskToken, "taskId": vo.taskId, "actionType": "0" }) - await $.wait(1000) - } - } - } else if (vo.taskType === 5) { - for (let key of Object.keys(vo.browseShopVo)) { - let browseShopVo = vo.browseShopVo[key] - if (browseShopVo.status !== 2) { - console.log(`【${browseShopVo.skuName}】${vo.subTitleName}`) - await harmony_collectScore({ "appId": appId, "taskToken": browseShopVo.taskToken, "taskId": vo.taskId, "actionType": "0" }) - await $.wait(1000) - } - } - } else if (vo.taskType === 15) { - for (let key of Object.keys(vo.productInfoVos)) { - let productInfoVos = vo.productInfoVos[key] - if (productInfoVos.status !== 2) { - console.log(`【${productInfoVos.skuName}】${vo.subTitleName}`) - await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) - await $.wait(1000) - } - } - } else if (vo.taskType === 3) { - for (let key of Object.keys(vo.shoppingActivityVos)) { - let shoppingActivityVos = vo.shoppingActivityVos[key] - if (shoppingActivityVos.status !== 2) { - console.log(`【${vo.subTitleName}】`) - await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) - await $.wait(1000) - } - } - } else if (vo.taskType === 8) { - for (let key of Object.keys(vo.productInfoVos)) { - let productInfoVos = vo.productInfoVos[key] - if (productInfoVos.status !== 2) { - console.log(`【${productInfoVos.skuName}】${vo.subTitleName}`) - await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "1" }) - await $.wait(vo.waitDuration * 1000) - await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) - await $.wait(1000) - } - } - } else if (vo.taskType === 27 && vo.taskId === 18) { - console.log(`【${vo.subTitleName}】`) - await harmony_collectScore({ "appId": appId, "taskToken": vo.productInfoVos[0].taskToken, "taskId": vo.taskId, "actionType": "0" }) - } else if (vo.taskType === 9 || vo.taskType === 26) { - for (let key of Object.keys(vo.shoppingActivityVos)) { - let shoppingActivityVos = vo.shoppingActivityVos[key] - if (shoppingActivityVos.status !== 2) { - console.log(`【${shoppingActivityVos.title}】${vo.subTitleName}`) - if (vo.taskType === 9) { - await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "1" }) - await $.wait(vo.waitDuration * 1000) - } - await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) - await $.wait(1000) - } - } - } else if (vo.taskType === 14) { - console.log(`【京东账号${$.index}(${$.UserName})的${appName}好友互助码】${vo.assistTaskDetailVo.taskToken}\n`) - if (vo.times !== vo.maxTimes) { - $.shareCode.push({ - "code": vo.assistTaskDetailVo.taskToken, - "appId": appId, - "use": $.UserName - }) - } - } + if(data.data.bizCode === 0) { + if (type) { + for (let key of Object.keys(data.data.result.hotTaskVos).reverse()) { + let vo = data.data.result.hotTaskVos[key] + if (vo.status !== 2) { + if (vo.taskType === 13 || vo.taskType === 12) { + console.log(`点击热区`) + await harmony_collectScore({ "appId": appId, "taskToken": vo.simpleRecordInfoVo.taskToken, "taskId": vo.taskId, "actionType": "0" }, vo.taskType) + await $.wait(1000) } else { - console.log(`【${vo.taskName}】已完成\n`) + console.log(`【${vo.taskName}】已完成\n`) + } + } + } + for (let key of Object.keys(data.data.result.taskVos).reverse()) { + let vo = data.data.result.taskVos[key] + if (vo.status !== 2) { + if (vo.taskType === 13 || vo.taskType === 12) { + console.log(`签到`) + await harmony_collectScore({ "appId": appId, "taskToken": vo.simpleRecordInfoVo.taskToken, "taskId": vo.taskId, "actionType": "0" }, vo.taskType) + await $.wait(1000) + } else if (vo.taskType === 1) { + for (let key of Object.keys(vo.followShopVo)) { + let followShopVo = vo.followShopVo[key] + if (followShopVo.status !== 2) { + console.log(`【${followShopVo.shopName}】${vo.subTitleName}`) + await harmony_collectScore({ "appId": appId, "taskToken": followShopVo.taskToken, "taskId": vo.taskId, "actionType": "0" }) + await $.wait(1000) + } + } + } else if (vo.taskType === 5) { + for (let key of Object.keys(vo.browseShopVo)) { + let browseShopVo = vo.browseShopVo[key] + if (browseShopVo.status !== 2) { + console.log(`【${browseShopVo.skuName}】${vo.subTitleName}`) + await harmony_collectScore({ "appId": appId, "taskToken": browseShopVo.taskToken, "taskId": vo.taskId, "actionType": "0" }) + await $.wait(1000) + } + } + } else if (vo.taskType === 15) { + for (let key of Object.keys(vo.productInfoVos)) { + let productInfoVos = vo.productInfoVos[key] + if (productInfoVos.status !== 2) { + console.log(`【${productInfoVos.skuName}】${vo.subTitleName}`) + await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) + await $.wait(1000) + } + } + } else if (vo.taskType === 3) { + for (let key of Object.keys(vo.shoppingActivityVos)) { + let shoppingActivityVos = vo.shoppingActivityVos[key] + if (shoppingActivityVos.status !== 2) { + console.log(`【${vo.subTitleName}】`) + await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) + await $.wait(1000) + } + } + } else if (vo.taskType === 8) { + for (let key of Object.keys(vo.productInfoVos)) { + let productInfoVos = vo.productInfoVos[key] + if (productInfoVos.status !== 2) { + console.log(`【${productInfoVos.skuName}】${vo.subTitleName}`) + await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "1" }) + await $.wait(vo.waitDuration * 1000) + await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) + await $.wait(1000) + } + } + } else if (vo.taskType === 27 && vo.taskId === 18) { + console.log(`【${vo.subTitleName}】`) + await harmony_collectScore({ "appId": appId, "taskToken": vo.productInfoVos[0].taskToken, "taskId": vo.taskId, "actionType": "0" }) + } else if (vo.taskType === 9 || vo.taskType === 26) { + for (let key of Object.keys(vo.shoppingActivityVos)) { + let shoppingActivityVos = vo.shoppingActivityVos[key] + if (shoppingActivityVos.status !== 2) { + console.log(`【${shoppingActivityVos.title}】${vo.subTitleName}`) + if (vo.taskType === 9) { + await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "1" }) + await $.wait(vo.waitDuration * 1000) + } + await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) + await $.wait(1000) + } + } + } else if (vo.taskType === 14) { + console.log(`【京东账号${$.index}(${$.UserName})的${appName}好友互助码】${vo.assistTaskDetailVo.taskToken}\n`) + if (vo.times !== vo.maxTimes) { + $.shareCode.push({ + "code": vo.assistTaskDetailVo.taskToken, + "appId": appId, + "use": $.UserName + }) + } } + } else { + console.log(`【${vo.taskName}】已完成\n`) } } - } else { - console.log(`黑号,火爆了\n`) - $.hasEnd = true; } + } else { + console.log(`黑号,火爆了\n`) + $.hasEnd = true; + } } } } catch (e) { @@ -455,8 +458,5 @@ function jsonParse(str) { } } } - - - // prettier-ignore function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${this.name}, 开始!`)}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();s&&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,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in i)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?i[e]:("00"+i[e]).substr((""+i[e]).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}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file