diff --git a/jd_fcwb.py b/jd_fcwb.py deleted file mode 100644 index 6fdb3ee..0000000 --- a/jd_fcwb.py +++ /dev/null @@ -1,408 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -''' -cron: 1 1 1 1 * -new Env('发财挖宝'); -活动入口: 京东极速版 > 我的 > 发财挖宝 -最高可得总和为10元的微信零钱和红包 -脚本功能为: 挖宝,提现,没有助力功能,当血量剩余 1 时停止挖宝,领取奖励并提现 - -目前需要完成逛一逛任务并且下单任务才能通关,不做的话大概可得1.5~2块的微信零钱 -''' -import os,json,random,time,re,string,functools,asyncio -import sys -sys.path.append('../../tmp') -print('\n运行本脚本之前请手动进入游戏点击一个方块\n') -print('\n挖的如果都是0.01红包就是黑了,别挣扎了!\n') -print('\n默认自动领取奖励,关闭请在代码383行加上#号注释即可\n') -try: - import requests -except Exception as e: - print(str(e) + "\n缺少requests模块, 请执行命令:pip3 install requests\n") -requests.packages.urllib3.disable_warnings() - - -linkId="pTTvJeSTrpthgk9ASBVGsw" - - -# 获取pin -cookie_findall=re.compile(r'pt_pin=(.+?);') -def get_pin(cookie): - try: - return cookie_findall.findall(cookie)[0] - except: - print('ck格式不正确,请检查') - -# 读取环境变量 -def get_env(env): - try: - if env in os.environ: - a=os.environ[env] - elif '/ql' in os.path.abspath(os.path.dirname(__file__)): - try: - a=v4_env(env,'/ql/config/config.sh') - except: - a=eval(env) - elif '/jd' in os.path.abspath(os.path.dirname(__file__)): - try: - a=v4_env(env,'/jd/config/config.sh') - except: - a=eval(env) - else: - a=eval(env) - except: - a='' - return a - -# v4 -def v4_env(env,paths): - b=re.compile(r'(?:export )?'+env+r' ?= ?[\"\'](.*?)[\"\']', re.I) - with open(paths, 'r') as f: - for line in f.readlines(): - try: - c=b.match(line).group(1) - break - except: - pass - return c - - -# 随机ua -def ua(): - sys.path.append(os.path.abspath('.')) - 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' - return a - -# 13位时间戳 -def gettimestamp(): - return str(int(time.time() * 1000)) - -## 获取cooie -class Judge_env(object): - def main_run(self): - if '/jd' in os.path.abspath(os.path.dirname(__file__)): - cookie_list=self.v4_cookie() - else: - cookie_list=os.environ["JD_COOKIE"].split('&') # 获取cookie_list的合集 - if len(cookie_list)<1: - print('请填写环境变量JD_COOKIE\n') - return cookie_list - - def v4_cookie(self): - a=[] - b=re.compile(r'Cookie'+'.*?=\"(.*?)\"', re.I) - with open('/jd/config/config.sh', 'r') as f: - for line in f.readlines(): - try: - regular=b.match(line).group(1) - a.append(regular) - 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': cookie, - 'Host': 'api.m.jd.com', - 'Connection': 'keep-alive', - 'origin': 'https://bnzf.jd.com', - 'Content-Type': 'application/x-www-form-urlencoded', - 'accept': 'application/json, text/plain, */*', - "User-Agent": ua(), - 'Accept-Language': 'zh-cn', - 'Accept-Encoding': 'gzip, deflate, br', - } - for n in range(3): - try: - res=requests.get(url,headers=headers, timeout=10).json() - return res - except: - if n==2: - print('API请求失败,请检查网路重试❗\n') - - -# 剩余血量 -def xueliang(cookie): - body={"linkId":linkId,"round":1} - res=taskGetUrl("happyDigHome", body, cookie) - if not res: - return - if res['code']==0: - if res['success']: - curRound=res['data']['curRound'] # 未知 - blood=res['data']['blood'] # 剩余血量 - return blood - -def jinge(cookie,i): - body={"linkId":linkId} - res=taskGetUrl("happyDigHome", body, cookie) - if not res: - return - 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'] # 当前池已得微信红包 - - return [blood,redAmount,cashAmount] - -# 页面数据 -def happyDigHome(cookie): - body={"linkId":linkId,"round":1} - res=taskGetUrl("happyDigHome", body, cookie) - exit_flag = "false" - if not res: - return - 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]}🩸') - ## 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 - else: - 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: - ## print(f'当前血量为 {_blood}') - a=n+1 - b=i+1 - print(f'挖取坐标({a},{b})') - happyDigDo(cookie,roundid,n,i) - else: - a=jinge(cookie,roundid) - print(f'没血了,不挖了') - exit_flag = "true" - ## print(f'当前池已得京东红包 {a[2]}\n当前池已得微信红包 {a[1]}\n') - break - - if exit_flag == "true": - break - if exit_flag == "true": - break - else: - print(f'获取数据失败\n{res}\n') - else: - print(f'获取数据失败\n{res}\n') - - - # 玩一玩 -def apDoTask(cookie): - print('开始做玩一玩任务') - body={"linkId":linkId,"taskType":"BROWSE_CHANNEL","taskId":454,"channel":4,"itemId":"https%3A%2F%2Fsignfree.jd.com%2F%3FactivityId%3DPiuLvM8vamONsWzC0wqBGQ","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) - if not res: - return - if res['code']==0: - 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') - else: - print(f'{res}\n挖宝失败\n') - else: - print(f'{res}\n挖宝失败\n') - -# # 助力码 -# 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) - 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']) - - - -# 微信现金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: - if res['success']: - 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 - else: - print('\n去提现微信零钱 💰') - time.sleep(3.2) - wecat(cookie,amountid,poolBaseId,prizeGroupId,prizeBaseId) - 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={ - 'Cookie': cookie, - 'Host': 'api.m.jd.com', - 'Connection': 'keep-alive', - 'origin': 'https://bnzf.jd.com', - 'Content-Type': 'application/x-www-form-urlencoded', - "User-Agent": ua(), - '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" - for n in range(3): - try: - res=requests.post(url,headers=headers,data=data,timeout=10).json() - break - except: - if n==2: - print('API请求失败,请检查网路重试❗\n') - try: - if res['code']==0: - if res['success']: - print(res['data']['message']+'\n') - except: - print(res) - print('') - - -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) - - # print('互助\n') - # inviteCode_2_list=inviteCode_2_list[:2] - # for e,fcwbinviter in enumerate(inviteCode_2_list): - # fcwbinviteCode=inviteCode_1_list[e] - # for cookie in cookie_list: - # happyDigHelp(cookie,fcwbinviter,fcwbinviteCode) - - 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) - - -if __name__ == '__main__': - main() diff --git a/jd_fruit_old.js b/jd_fruit_old.js deleted file mode 100644 index 1519efd..0000000 --- a/jd_fruit_old.js +++ /dev/null @@ -1,1605 +0,0 @@ -/* -东东水果:脚本更新地址 https://gitee.com/lxk0301/jd_scripts/raw/master/jd_fruit.js -更新时间:2021-8-20 -活动入口:京东APP我的-更多工具-东东农场 -东东农场活动链接:https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html -已支持IOS双京东账号,Node.js支持N个京东账号 -脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js -互助码shareCode请先手动运行脚本查看打印可看到 -一天只能帮助3个人。多出的助力码无效 - -==========================Quantumultx========================= -[task_local] -#jd免费水果 -5 6-18/6 7 7 7 https://gitee.com/lxk0301/jd_scripts/raw/master/jd_fruit.js, tag=东东农场, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdnc.png, enabled=true -=========================Loon============================= -[Script] -cron "5 6-18/6 7 7 7" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_fruit.js,tag=东东农场 - -=========================Surge============================ -东东农场 = type=cron,cronexp="5 6-18/6 7 7 7",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_fruit.js - -=========================小火箭=========================== -东东农场 = type=cron,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_fruit.js, cronexpr="5 6-18/6 7 7 7", timeout=3600, enable=true - -jd免费水果 搬的https://github.com/liuxiaoyucc/jd-helper/blob/a6f275d9785748014fc6cca821e58427162e9336/fruit/fruit.js -*/ -const $ = new Env('东东农场互助版-老版'); -let cookiesArr = [], cookie = '', isBox = false, notify,allMessage = ''; -//助力好友分享码(最多3个,否则后面的助力失败),原因:京东农场每人每天只有3次助力机会 -//此此内容是IOS用户下载脚本到本地使用,填写互助码的地方,同一京东账号的好友互助码请使用@符号隔开。 -//下面给出两个账号的填写示例(iOS只支持2个京东账号) - -let newShareCodes=[]; -let message = '', subTitle = '', option = {}, isFruitFinished = false; -const retainWater = $.isNode() ? (process.env.retainWater ? process.env.retainWater : 100) : ($.getdata('retainWater') ? $.getdata('retainWater') : 100);//保留水滴大于多少g,默认100g; -let jdNotify = false;//是否关闭通知,false打开通知推送,true关闭通知推送 -let jdFruitBeanCard = false;//农场使用水滴换豆卡(如果出现限时活动时100g水换20豆,此时比浇水划算,推荐换豆),true表示换豆(不浇水),false表示不换豆(继续浇水),脚本默认是浇水 -const JD_API_HOST = 'https://api.m.jd.com/client.action'; -const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html%22%20%7D`; -let NowHour = new Date().getHours(); -let llhelp=true; -if ($.isNode() && process.env.CC_NOHELPAFTER8) { - if (process.env.CC_NOHELPAFTER8=="true"){ - if (NowHour>8){ - llhelp=false; - console.log(`现在是9点后时段,不启用互助....`); - } - } -} -const fs = require('fs'); -let boolneedUpdate=false; -let strShare = './Fruit_ShareCache.json'; -let Fileexists = fs.existsSync(strShare); -let TempShareCache = []; -if (Fileexists) { - console.log("检测到东东农场缓存文件Fruit_ShareCache.json,载入..."); - TempShareCache = fs.readFileSync(strShare, 'utf-8'); - if (TempShareCache) { - TempShareCache = TempShareCache.toString(); - TempShareCache = JSON.parse(TempShareCache); - } -} - -let WP_APP_TOKEN_ONE = ""; -/* if ($.isNode()) { - if (process.env.WP_APP_TOKEN_ONE) { - WP_APP_TOKEN_ONE = process.env.WP_APP_TOKEN_ONE; - } -} - -if (WP_APP_TOKEN_ONE) { - console.log(`检测到已配置Wxpusher的Token,启用一对一推送...`); - if (NowHour <9 || NowHour > 21) { - WP_APP_TOKEN_ONE = ""; - console.log(`农场只在9点后和22点前启用一对一推送,故此次暂时取消一对一推送...`); - } -} else - console.log(`检测到未配置Wxpusher的Token,禁用一对一推送...`); */ -let lnrun=0; -let llgetshare=false; -let NoNeedCodes = []; -!(async () => { - - await requireConfig(); - if (!cookiesArr[0]) { - $.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 (llhelp) { - console.log('开始收集您的互助码,用于账号内部互助,请稍等...'); - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - await TotalBean(); - 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" - }); - - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } - message = ''; - subTitle = ''; - option = {}; - $.retry = 0; - llgetshare=false; - await GetCollect(); - if(llgetshare){ - await $.wait(5000); - lnrun++; - } - if(lnrun==10){ - console.log(`访问接口次数达到10次,休息一分钟.....`); - await $.wait(60*1000); - lnrun=0; - } - } - } - if (boolneedUpdate) { - var str = JSON.stringify(TempShareCache, null, 2); - fs.writeFile(strShare, str, function (err) { - if (err) { - console.log(err); - console.log("缓存文件Fruit_ShareCache.json更新失败!"); - } else { - console.log("缓存文件Fruit_ShareCache.json更新成功!"); - } - }) - } - } - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - 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" - }); - - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } - message = ''; - subTitle = ''; - option = {}; - $.retry = 0; - - lnrun++; - await jdFruit(); - if (lnrun == 5) { - console.log(`访问接口次数达到5次,休息一分钟.....`); - await $.wait(60 * 1000); - lnrun = 0; - } - } - } - if ($.isNode() && allMessage && $.ctrTemp) { - await notify.sendNotify(`${$.name}`, `${allMessage}`) - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) -async function jdFruit() { - subTitle = `【京东账号${$.index}】${$.nickName || $.UserName}`; - try { - await initForFarm(); - if ($.farmInfo.farmUserPro) { - message = `【水果名称】${$.farmInfo.farmUserPro.name}\n`; - console.log(`\n【已成功兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`); - message += `【已兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`; - await masterHelpShare();//助力好友 - if ($.farmInfo.treeState === 2 || $.farmInfo.treeState === 3) { - option['open-url'] = urlSchema; - $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); - if ($.isNode()) { - await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}水果已可领取`, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看`); - } - if ($.isNode() && WP_APP_TOKEN_ONE) { - await notify.sendNotifybyWxPucher($.name, `【京东账号】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n【领取步骤】京东->我的->东东农场兑换京东红包,可以用于京东app的任意商品.`, `${$.UserName}`); - } - return - } else if ($.farmInfo.treeState === 1) { - console.log(`\n${$.farmInfo.farmUserPro.name}种植中...\n`) - } else if ($.farmInfo.treeState === 0) { - //已下单购买, 但未开始种植新的水果 - option['open-url'] = urlSchema; - $.msg($.name, ``, `【京东账号${$.index}】 ${$.nickName || $.UserName}\n【提醒⏰】您忘了种植新的水果\n请去京东APP或微信小程序选购并种植新的水果\n点击弹窗即达`, option); - if ($.isNode()) { - await notify.sendNotify(`${$.name} - 您忘了种植新的水果`, `京东账号${$.index} ${$.nickName || $.UserName}\n【提醒⏰】您忘了种植新的水果\n请去京东APP或微信小程序选购并种植新的水果`); - } - return - } - await doDailyTask(); - await doTenWater();//浇水十次 - await getFirstWaterAward();//领取首次浇水奖励 - await getTenWaterAward();//领取10浇水奖励 - await getWaterFriendGotAward();//领取为2好友浇水奖励 - await duck(); - await doTenWaterAgain();//再次浇水 - await predictionFruit();//预测水果成熟时间 - } else { - console.log(`初始化农场数据异常, 请登录京东 app查看农场功能是否正常`); - message+=`初始化农场数据异常, 请登录京东 app查看农场功能是否正常`; - } - } catch (e) { - console.log(`任务执行异常,请检查执行日志 ‼️‼️`); - $.logErr(e); - const errMsg = `京东账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`; - if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg); - $.msg($.name, '', `${errMsg}`) - } - await showMsg(); -} -async function doDailyTask() { - await taskInitForFarm(); - console.log(`开始签到`); - if (!$.farmTask.signInit.todaySigned) { - await signForFarm(); //签到 - if ($.signResult.code === "0") { - console.log(`【签到成功】获得${$.signResult.amount}g💧\\n`) - //message += `【签到成功】获得${$.signResult.amount}g💧\n`//连续签到${signResult.signDay}天 - } else { - // message += `签到失败,详询日志\n`; - console.log(`签到结果: ${JSON.stringify($.signResult)}`); - } - } else { - console.log(`今天已签到,连续签到${$.farmTask.signInit.totalSigned},下次签到可得${$.farmTask.signInit.signEnergyEachAmount}g\n`); - } - // 被水滴砸中 - console.log(`被水滴砸中: ${$.farmInfo.todayGotWaterGoalTask.canPop ? '是' : '否'}`); - if ($.farmInfo.todayGotWaterGoalTask.canPop) { - await gotWaterGoalTaskForFarm(); - if ($.goalResult.code === '0') { - console.log(`【被水滴砸中】获得${$.goalResult.addEnergy}g💧\\n`); - // message += `【被水滴砸中】获得${$.goalResult.addEnergy}g💧\n` - } - } - console.log(`签到结束,开始广告浏览任务`); - if ($.farmTask.gotBrowseTaskAdInit.f) { - console.log(`今天已经做过浏览广告任务\n`); - } else { - let adverts = $.farmTask.gotBrowseTaskAdInit.userBrowseTaskAds - let browseReward = 0 - let browseSuccess = 0 - let browseFail = 0 - for (let advert of adverts) { //开始浏览广告 - if (advert.limit <= advert.hadFinishedTimes) { - // browseReward+=advert.reward - console.log(`${advert.mainTitle}+ ' 已完成`);//,获得${advert.reward}g - continue; - } - console.log('正在进行广告浏览任务: ' + advert.mainTitle); - await browseAdTaskForFarm(advert.advertId, 0); - if ($.browseResult.code === '0') { - console.log(`${advert.mainTitle}浏览任务完成`); - //领取奖励 - await browseAdTaskForFarm(advert.advertId, 1); - if ($.browseRwardResult.code === '0') { - console.log(`领取浏览${advert.mainTitle}广告奖励成功,获得${$.browseRwardResult.amount}g`) - browseReward += $.browseRwardResult.amount - browseSuccess++ - } else { - browseFail++ - console.log(`领取浏览广告奖励结果: ${JSON.stringify($.browseRwardResult)}`) - } - } else { - browseFail++ - console.log(`广告浏览任务结果: ${JSON.stringify($.browseResult)}`); - } - } - if (browseFail > 0) { - console.log(`【广告浏览】完成${browseSuccess}个,失败${browseFail},获得${browseReward}g💧\\n`); - // message += `【广告浏览】完成${browseSuccess}个,失败${browseFail},获得${browseReward}g💧\n`; - } else { - console.log(`【广告浏览】完成${browseSuccess}个,获得${browseReward}g💧\n`); - // message += `【广告浏览】完成${browseSuccess}个,获得${browseReward}g💧\n`; - } - } - //定时领水 - if (!$.farmTask.gotThreeMealInit.f) { - // - await gotThreeMealForFarm(); - if ($.threeMeal.code === "0") { - console.log(`【定时领水】获得${$.threeMeal.amount}g💧\n`); - // message += `【定时领水】获得${$.threeMeal.amount}g💧\n`; - } else { - // message += `【定时领水】失败,详询日志\n`; - console.log(`定时领水成功结果: ${JSON.stringify($.threeMeal)}`); - } - } else { - console.log('当前不在定时领水时间断或者已经领过\n') - } - //给好友浇水 - if (!$.farmTask.waterFriendTaskInit.f) { - if ($.farmTask.waterFriendTaskInit.waterFriendCountKey < $.farmTask.waterFriendTaskInit.waterFriendMax) { - await doFriendsWater(); - } - } else { - console.log(`给${$.farmTask.waterFriendTaskInit.waterFriendMax}个好友浇水任务已完成\n`) - } - - await getAwardInviteFriend(); - await clockInIn();//打卡领水 - await executeWaterRains();//水滴雨 - await getExtraAward();//领取额外水滴奖励 - await turntableFarm()//天天抽奖得好礼 -} -async function predictionFruit() { - console.log('开始预测水果成熟时间\n'); - await initForFarm(); - await taskInitForFarm(); - let waterEveryDayT = $.farmTask.totalWaterTaskInit.totalWaterTaskTimes;//今天到到目前为止,浇了多少次水 - message += `【今日共浇水】${waterEveryDayT}次\n`; - message += `【剩余 水滴】${$.farmInfo.farmUserPro.totalEnergy}g💧\n`; - message += `【水果🍉进度】${(($.farmInfo.farmUserPro.treeEnergy / $.farmInfo.farmUserPro.treeTotalEnergy) * 100).toFixed(2)}%,已浇水${$.farmInfo.farmUserPro.treeEnergy / 10}次,还需${($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy) / 10}次\n` - if ($.farmInfo.toFlowTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) { - message += `【开花进度】再浇水${$.farmInfo.toFlowTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次开花\n` - } else if ($.farmInfo.toFruitTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) { - message += `【结果进度】再浇水${$.farmInfo.toFruitTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次结果\n` - } - // 预测n天后水果课可兑换功能 - let waterTotalT = ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy - $.farmInfo.farmUserPro.totalEnergy) / 10;//一共还需浇多少次水 - - let waterD = Math.ceil(waterTotalT / waterEveryDayT); - - message += `【预测】${waterD === 1 ? '明天' : waterD === 2 ? '后天' : waterD + '天之后'}(${timeFormat(24 * 60 * 60 * 1000 * waterD + Date.now())}日)可兑换水果🍉` -} -//浇水十次 -async function doTenWater() { - try { - jdFruitBeanCard = $.getdata('jdFruitBeanCard') ? $.getdata('jdFruitBeanCard') : jdFruitBeanCard; - if ($.isNode() && process.env.FRUIT_BEAN_CARD) { - jdFruitBeanCard = process.env.FRUIT_BEAN_CARD; - } - await myCardInfoForFarm(); - const { - fastCard, - doubleCard, - beanCard, - signCard - } = $.myCardInfoRes; - /* if (`${jdFruitBeanCard}` === 'true' && JSON.stringify($.myCardInfoRes).match(`限时翻倍`) && beanCard > 0) { - console.log(`您设置的是使用水滴换豆卡,且背包有水滴换豆卡${beanCard}张, 跳过10次浇水任务`) - return - } */ - if ($.farmTask.totalWaterTaskInit.totalWaterTaskTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) { - console.log(`\n准备浇水十次`); - let waterCount = 0; - isFruitFinished = false; - for (; waterCount < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit - $.farmTask.totalWaterTaskInit.totalWaterTaskTimes; waterCount++) { - console.log(`第${waterCount + 1}次浇水`); - await waterGoodForFarm(); - console.log(`本次浇水结果: ${JSON.stringify($.waterResult)}`); - if ($.waterResult.code === '0') { - console.log(`剩余水滴${$.waterResult.totalEnergy}g`); - if ($.waterResult.finished) { - // 已证实,waterResult.finished为true,表示水果可以去领取兑换了 - isFruitFinished = true; - break - } else { - if ($.waterResult.totalEnergy < 10) { - console.log(`水滴不够,结束浇水`) - break - } - await gotStageAward(); //领取阶段性水滴奖励 - } - } else { - console.log('浇水出现失败异常,跳出不在继续浇水') - break; - } - } - if (isFruitFinished) { - option['open-url'] = urlSchema; - $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); - $.done(); - if ($.isNode()) { - await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}水果已可领取`, `京东账号${$.index} ${$.nickName || $.UserName}\n${$.farmInfo.farmUserPro.name}已可领取`); - } - if ($.isNode() && WP_APP_TOKEN_ONE) { - await notify.sendNotifybyWxPucher($.name, `【京东账号】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n【领取步骤】京东->我的->东东农场兑换京东红包,可以用于京东app的任意商品.`, `${$.UserName}`); - } - } - } else { - console.log('\n今日已完成10次浇水任务\n'); - } - } catch (e) { - console.log(`doTenWater 任务执行异常‼️‼️`); - $.logErr(e); - } -} -//领取首次浇水奖励 -async function getFirstWaterAward() { - await taskInitForFarm(); - //领取首次浇水奖励 - if (!$.farmTask.firstWaterInit.f && $.farmTask.firstWaterInit.totalWaterTimes > 0) { - await firstWaterTaskForFarm(); - if ($.firstWaterReward.code === '0') { - console.log(`【首次浇水奖励】获得${$.firstWaterReward.amount}g💧\n`); - // message += `【首次浇水奖励】获得${$.firstWaterReward.amount}g💧\n`; - } else { - // message += '【首次浇水奖励】领取奖励失败,详询日志\n'; - console.log(`领取首次浇水奖励结果: ${JSON.stringify($.firstWaterReward)}`); - } - } else { - console.log('首次浇水奖励已领取\n') - } -} -//领取十次浇水奖励 -async function getTenWaterAward() { - //领取10次浇水奖励 - if (!$.farmTask.totalWaterTaskInit.f && $.farmTask.totalWaterTaskInit.totalWaterTaskTimes >= $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) { - await totalWaterTaskForFarm(); - if ($.totalWaterReward.code === '0') { - console.log(`【十次浇水奖励】获得${$.totalWaterReward.totalWaterTaskEnergy}g💧\n`); - // message += `【十次浇水奖励】获得${$.totalWaterReward.totalWaterTaskEnergy}g💧\n`; - } else { - // message += '【十次浇水奖励】领取奖励失败,详询日志\n'; - console.log(`领取10次浇水奖励结果: ${JSON.stringify($.totalWaterReward)}`); - } - } else if ($.farmTask.totalWaterTaskInit.totalWaterTaskTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) { - // message += `【十次浇水奖励】任务未完成,今日浇水${$.farmTask.totalWaterTaskInit.totalWaterTaskTimes}次\n`; - console.log(`【十次浇水奖励】任务未完成,今日浇水${$.farmTask.totalWaterTaskInit.totalWaterTaskTimes}次\n`); - } - console.log('finished 水果任务完成!'); -} -//再次浇水 -async function doTenWaterAgain() { - console.log('开始检查剩余水滴能否再次浇水再次浇水\n'); - await initForFarm(); - let totalEnergy = $.farmInfo.farmUserPro.totalEnergy; - console.log(`剩余水滴${totalEnergy}g\n`); - await myCardInfoForFarm(); - const { fastCard, doubleCard, beanCard, signCard } = $.myCardInfoRes; - console.log(`背包已有道具:\n快速浇水卡:${fastCard === -1 ? '未解锁' : fastCard + '张'}\n水滴翻倍卡:${doubleCard === -1 ? '未解锁' : doubleCard + '张'}\n水滴换京豆卡:${beanCard === -1 ? '未解锁' : beanCard + '张'}\n加签卡:${signCard === -1 ? '未解锁' : signCard + '张'}\n`) - if (totalEnergy >= 100 && doubleCard > 0) { - //使用翻倍水滴卡 - for (let i = 0; i < new Array(doubleCard).fill('').length; i++) { - await userMyCardForFarm('doubleCard'); - console.log(`使用翻倍水滴卡结果:${JSON.stringify($.userMyCardRes)}`); - } - await initForFarm(); - totalEnergy = $.farmInfo.farmUserPro.totalEnergy; - } - if (signCard > 0) { - //使用加签卡 - for (let i = 0; i < new Array(signCard).fill('').length; i++) { - await userMyCardForFarm('signCard'); - console.log(`使用加签卡结果:${JSON.stringify($.userMyCardRes)}`); - } - await initForFarm(); - totalEnergy = $.farmInfo.farmUserPro.totalEnergy; - } - jdFruitBeanCard = $.getdata('jdFruitBeanCard') ? $.getdata('jdFruitBeanCard') : jdFruitBeanCard; - if ($.isNode() && process.env.FRUIT_BEAN_CARD) { - jdFruitBeanCard = process.env.FRUIT_BEAN_CARD; - } - if (`${jdFruitBeanCard}` === 'true' && JSON.stringify($.myCardInfoRes).match('限时翻倍')) { - console.log(`\n您设置的是水滴换豆功能,现在为您换豆`); - - for (let lncount = 0; lncount < $.myCardInfoRes.beanCard; lncount++) { - if (totalEnergy >= 150 && $.myCardInfoRes.beanCard > 0) { - //使用水滴换豆卡 - await userMyCardForFarm('beanCard'); - console.log(`使用水滴换豆卡结果:${JSON.stringify($.userMyCardRes)}`); - if ($.userMyCardRes.code === '0') { - totalEnergy=totalEnergy-100; - message += `【水滴换豆卡】获得${$.userMyCardRes.beanCount}个京豆\n`; - } - } else { - console.log(`您目前水滴:${totalEnergy}g,水滴换豆卡${$.myCardInfoRes.beanCard}张,暂不满足水滴换豆的条件,为您继续浇水`) - break; - } - } - return; - } - // if (totalEnergy > 100 && $.myCardInfoRes.fastCard > 0) { - // //使用快速浇水卡 - // await userMyCardForFarm('fastCard'); - // console.log(`使用快速浇水卡结果:${JSON.stringify($.userMyCardRes)}`); - // if ($.userMyCardRes.code === '0') { - // console.log(`已使用快速浇水卡浇水${$.userMyCardRes.waterEnergy}g`); - // } - // await initForFarm(); - // totalEnergy = $.farmInfo.farmUserPro.totalEnergy; - // } - // 所有的浇水(10次浇水)任务,获取水滴任务完成后,如果剩余水滴大于等于60g,则继续浇水(保留部分水滴是用于完成第二天的浇水10次的任务) - let overageEnergy = totalEnergy - retainWater; - if (totalEnergy >= ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy)) { - //如果现有的水滴,大于水果可兑换所需的对滴(也就是把水滴浇完,水果就能兑换了) - isFruitFinished = false; - for (let i = 0; i < ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy) / 10; i++) { - await waterGoodForFarm(); - console.log(`本次浇水结果(水果马上就可兑换了): ${JSON.stringify($.waterResult)}`); - if ($.waterResult.code === '0') { - console.log('\n浇水10g成功\n'); - if ($.waterResult.finished) { - // 已证实,waterResult.finished为true,表示水果可以去领取兑换了 - isFruitFinished = true; - break - } else { - console.log(`目前水滴【${$.waterResult.totalEnergy}】g,继续浇水,水果马上就可以兑换了`) - } - } else { - console.log('浇水出现失败异常,跳出不在继续浇水') - break; - } - } - if (isFruitFinished) { - option['open-url'] = urlSchema; - $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); - $.done(); - if ($.isNode()) { - await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}水果已可领取`, `京东账号${$.index} ${$.nickName || $.UserName}\n${$.farmInfo.farmUserPro.name}已可领取`); - } - if ($.isNode() && WP_APP_TOKEN_ONE) { - await notify.sendNotifybyWxPucher($.name, `【京东账号】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n【领取步骤】京东->我的->东东农场兑换京东红包,可以用于京东app的任意商品.`, `${$.UserName}`); - } - } - } else if (overageEnergy >= 10) { - console.log("目前剩余水滴:【" + totalEnergy + "】g,可继续浇水"); - isFruitFinished = false; - for (let i = 0; i < parseInt(overageEnergy / 10); i++) { - await waterGoodForFarm(); - console.log(`本次浇水结果: ${JSON.stringify($.waterResult)}`); - if ($.waterResult.code === '0') { - console.log(`\n浇水10g成功,剩余${$.waterResult.totalEnergy}\n`) - if ($.waterResult.finished) { - // 已证实,waterResult.finished为true,表示水果可以去领取兑换了 - isFruitFinished = true; - break - } else { - await gotStageAward() - } - } else { - console.log('浇水出现失败异常,跳出不在继续浇水') - break; - } - } - if (isFruitFinished) { - option['open-url'] = urlSchema; - $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); - $.done(); - if ($.isNode()) { - await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}水果已可领取`, `京东账号${$.index} ${$.nickName || $.UserName}\n${$.farmInfo.farmUserPro.name}已可领取`); - } - if ($.isNode() && WP_APP_TOKEN_ONE) { - await notify.sendNotifybyWxPucher($.name, `【京东账号】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n【领取步骤】京东->我的->东东农场兑换京东红包,可以用于京东app的任意商品.`, `${$.UserName}`); - } - } - } else { - console.log("目前剩余水滴:【" + totalEnergy + "】g,不再继续浇水,保留部分水滴用于完成第二天【十次浇水得水滴】任务") - } -} -//领取阶段性水滴奖励 -function gotStageAward() { - return new Promise(async resolve => { - if ($.waterResult.waterStatus === 0 && $.waterResult.treeEnergy === 10) { - console.log('果树发芽了,奖励30g水滴'); - await gotStageAwardForFarm('1'); - console.log(`浇水阶段奖励1领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`); - if ($.gotStageAwardForFarmRes.code === '0') { - // message += `【果树发芽了】奖励${$.gotStageAwardForFarmRes.addEnergy}\n`; - console.log(`【果树发芽了】奖励${$.gotStageAwardForFarmRes.addEnergy}\n`); - } - } else if ($.waterResult.waterStatus === 1) { - console.log('果树开花了,奖励40g水滴'); - await gotStageAwardForFarm('2'); - console.log(`浇水阶段奖励2领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`); - if ($.gotStageAwardForFarmRes.code === '0') { - // message += `【果树开花了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`; - console.log(`【果树开花了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`); - } - } else if ($.waterResult.waterStatus === 2) { - console.log('果树长出小果子啦, 奖励50g水滴'); - await gotStageAwardForFarm('3'); - console.log(`浇水阶段奖励3领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`) - if ($.gotStageAwardForFarmRes.code === '0') { - // message += `【果树结果了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`; - console.log(`【果树结果了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`); - } - } - resolve() - }) -} -//天天抽奖活动 -async function turntableFarm() { - await initForTurntableFarm(); - if ($.initForTurntableFarmRes.code === '0') { - //领取定时奖励 //4小时一次 - let { timingIntervalHours, timingLastSysTime, sysTime, timingGotStatus, remainLotteryTimes, turntableInfos } = $.initForTurntableFarmRes; - - if (!timingGotStatus) { - console.log(`是否到了领取免费赠送的抽奖机会----${sysTime > (timingLastSysTime + 60 * 60 * timingIntervalHours * 1000)}`) - if (sysTime > (timingLastSysTime + 60 * 60 * timingIntervalHours * 1000)) { - await timingAwardForTurntableFarm(); - console.log(`领取定时奖励结果${JSON.stringify($.timingAwardRes)}`); - await initForTurntableFarm(); - remainLotteryTimes = $.initForTurntableFarmRes.remainLotteryTimes; - } else { - console.log(`免费赠送的抽奖机会未到时间`) - } - } else { - console.log('4小时候免费赠送的抽奖机会已领取') - } - if ($.initForTurntableFarmRes.turntableBrowserAds && $.initForTurntableFarmRes.turntableBrowserAds.length > 0) { - for (let index = 0; index < $.initForTurntableFarmRes.turntableBrowserAds.length; index++) { - if (!$.initForTurntableFarmRes.turntableBrowserAds[index].status) { - console.log(`开始浏览天天抽奖的第${index + 1}个逛会场任务`) - await browserForTurntableFarm(1, $.initForTurntableFarmRes.turntableBrowserAds[index].adId); - if ($.browserForTurntableFarmRes.code === '0' && $.browserForTurntableFarmRes.status) { - console.log(`第${index + 1}个逛会场任务完成,开始领取水滴奖励\n`) - await browserForTurntableFarm(2, $.initForTurntableFarmRes.turntableBrowserAds[index].adId); - if ($.browserForTurntableFarmRes.code === '0') { - console.log(`第${index + 1}个逛会场任务领取水滴奖励完成\n`) - await initForTurntableFarm(); - remainLotteryTimes = $.initForTurntableFarmRes.remainLotteryTimes; - } - } - } else { - console.log(`浏览天天抽奖的第${index + 1}个逛会场任务已完成`) - } - } - } - //天天抽奖助力 - console.log('开始天天抽奖--好友助力--每人每天只有三次助力机会.') - for (let code of newShareCodes) { - if (code === $.farmInfo.farmUserPro.shareCode) { - console.log('天天抽奖-不能自己给自己助力\n') - continue - } - await lotteryMasterHelp(code); - // console.log('天天抽奖助力结果',lotteryMasterHelpRes.helpResult) - if ($.lotteryMasterHelpRes.helpResult.code === '0') { - console.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}成功\n`) - } else if ($.lotteryMasterHelpRes.helpResult.code === '11') { - console.log(`天天抽奖-不要重复助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}\n`) - } else if ($.lotteryMasterHelpRes.helpResult.code === '13') { - console.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}失败,助力次数耗尽\n`); - break; - } - } - console.log(`---天天抽奖次数remainLotteryTimes----${remainLotteryTimes}次`) - //抽奖 - if (remainLotteryTimes > 0) { - console.log('开始抽奖') - let lotteryResult = ''; - for (let i = 0; i < new Array(remainLotteryTimes).fill('').length; i++) { - await lotteryForTurntableFarm() - console.log(`第${i + 1}次抽奖结果${JSON.stringify($.lotteryRes)}`); - if ($.lotteryRes.code === '0') { - turntableInfos.map((item) => { - if (item.type === $.lotteryRes.type) { - console.log(`lotteryRes.type${$.lotteryRes.type}`); - if ($.lotteryRes.type.match(/bean/g) && $.lotteryRes.type.match(/bean/g)[0] === 'bean') { - lotteryResult += `${item.name}个,`; - } else if ($.lotteryRes.type.match(/water/g) && $.lotteryRes.type.match(/water/g)[0] === 'water') { - lotteryResult += `${item.name},`; - } else { - lotteryResult += `${item.name},`; - } - } - }) - //没有次数了 - if ($.lotteryRes.remainLotteryTimes === 0) { - break - } - } - } - if (lotteryResult) { - console.log(`【天天抽奖】${lotteryResult.substr(0, lotteryResult.length - 1)}\n`) - // message += `【天天抽奖】${lotteryResult.substr(0, lotteryResult.length - 1)}\n`; - } - } else { - console.log('天天抽奖--抽奖机会为0次') - } - } else { - console.log('初始化天天抽奖得好礼失败') - } -} -//领取额外奖励水滴 -async function getExtraAward() { - await farmAssistInit(); - if ($.farmAssistResult.code === "0") { - if ($.farmAssistResult.assistFriendList && $.farmAssistResult.assistFriendList.length >= 2) { - if ($.farmAssistResult.status === 2) { - let num = 0; - for (let key of Object.keys($.farmAssistResult.assistStageList)) { - let vo = $.farmAssistResult.assistStageList[key] - if (vo.stageStaus === 2) { - await receiveStageEnergy() - if ($.receiveStageEnergy.code === "0") { - console.log(`已成功领取第${key + 1}阶段好友助力奖励:【${$.receiveStageEnergy.amount}】g水`) - num += $.receiveStageEnergy.amount - } - } - } - message += `【额外奖励】${num}g水领取成功\n`; - } else if ($.farmAssistResult.status === 3) { - console.log("已经领取过8好友助力额外奖励"); - message += `【额外奖励】已被领取过\n`; - } - } else { - console.log("助力好友未达到2个"); - message += `【额外奖励】领取失败,原因:给您助力的人未达2个\n`; - } - if ($.farmAssistResult.assistFriendList && $.farmAssistResult.assistFriendList.length > 0) { - let str = ''; - $.farmAssistResult.assistFriendList.map((item, index) => { - if (index === ($.farmAssistResult.assistFriendList.length - 1)) { - str += item.nickName || "匿名用户"; - } else { - str += (item.nickName || "匿名用户") + ','; - } - let date = new Date(item.time); - let time = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getMinutes(); - console.log(`\n京东昵称【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力\n`); - }) - message += `【助力您的好友】${str}\n`; - } - console.log('领取额外奖励水滴结束\n'); - } else { - await masterHelpTaskInitForFarm(); - if ($.masterHelpResult.code === '0') { - if ($.masterHelpResult.masterHelpPeoples && $.masterHelpResult.masterHelpPeoples.length >= 5) { - // 已有五人助力。领取助力后的奖励 - if (!$.masterHelpResult.masterGotFinal) { - await masterGotFinishedTaskForFarm(); - if ($.masterGotFinished.code === '0') { - console.log(`已成功领取好友助力奖励:【${$.masterGotFinished.amount}】g水`); - message += `【额外奖励】${$.masterGotFinished.amount}g水领取成功\n`; - } - } else { - console.log("已经领取过5好友助力额外奖励"); - message += `【额外奖励】已被领取过\n`; - } - } else { - console.log("助力好友未达到5个"); - message += `【额外奖励】领取失败,原因:给您助力的人未达5个\n`; - } - if ($.masterHelpResult.masterHelpPeoples && $.masterHelpResult.masterHelpPeoples.length > 0) { - let str = ''; - $.masterHelpResult.masterHelpPeoples.map((item, index) => { - if (index === ($.masterHelpResult.masterHelpPeoples.length - 1)) { - str += item.nickName || "匿名用户"; - } else { - str += (item.nickName || "匿名用户") + ','; - } - let date = new Date(item.time); - let time = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getMinutes(); - console.log(`\n京东昵称【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力\n`); - }) - message += `【助力您的好友】${str}\n`; - } - console.log('领取额外奖励水滴结束\n'); - } - } -} -//助力好友 -async function masterHelpShare() { - - await initForFarm(); - let salveHelpAddWater = 0; - let remainTimes = 3;//今日剩余助力次数,默认3次(京东农场每人每天3次助力机会)。 - let helpSuccessPeoples = '';//成功助力好友 - if(llhelp){ - console.log('开始助力好友') - for (let code of newShareCodes) { - if(NoNeedCodes){ - var llnoneed=false; - for (let NoNeedCode of NoNeedCodes) { - if (code==NoNeedCode){ - llnoneed=true; - break; - } - } - if(llnoneed){ - console.log(`${code}助力已满,跳过...`); - continue; - } - } - console.log(`${$.UserName}开始助力: ${code}`); - if (!code) continue; - if (!$.farmInfo.farmUserPro) { - console.log('未种植,跳过助力\n') - continue - } - if (code === $.farmInfo.farmUserPro.shareCode) { - console.log('不能为自己助力哦,跳过自己的shareCode\n') - continue - } - await masterHelp(code); - if ($.helpResult.code === '0') { - if ($.helpResult.helpResult.code === '0') { - //助力成功 - salveHelpAddWater += $.helpResult.helpResult.salveHelpAddWater; - console.log(`【助力好友结果】: 已成功给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力`); - console.log(`给好友【${$.helpResult.helpResult.masterUserInfo.nickName}】助力获得${$.helpResult.helpResult.salveHelpAddWater}g水滴`) - helpSuccessPeoples += ($.helpResult.helpResult.masterUserInfo.nickName || '匿名用户') + ','; - } else if ($.helpResult.helpResult.code === '8') { - console.log(`【助力好友结果】: 助力【${$.helpResult.helpResult.masterUserInfo.nickName}】失败,您今天助力次数已耗尽`); - } else if ($.helpResult.helpResult.code === '9') { - console.log(`【助力好友结果】: 之前给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力过了`); - } else if ($.helpResult.helpResult.code === '10') { - NoNeedCodes.push(code); - console.log(`【助力好友结果】: 好友【${$.helpResult.helpResult.masterUserInfo.nickName}】已满五人助力`); - } else { - console.log(`助力其他情况:${JSON.stringify($.helpResult.helpResult)}`); - } - console.log(`【今日助力次数还剩】${$.helpResult.helpResult.remainTimes}次\n`); - remainTimes = $.helpResult.helpResult.remainTimes; - if ($.helpResult.helpResult.remainTimes === 0) { - console.log(`您当前助力次数已耗尽,跳出助力`); - break - } - } else { - console.log(`助力失败::${JSON.stringify($.helpResult)}`); - } - } - } - if ($.isLoon() || $.isQuanX() || $.isSurge()) { - let helpSuccessPeoplesKey = timeFormat() + $.farmInfo.farmUserPro.shareCode; - if (!$.getdata(helpSuccessPeoplesKey)) { - //把前一天的清除 - $.setdata('', timeFormat(Date.now() - 24 * 60 * 60 * 1000) + $.farmInfo.farmUserPro.shareCode); - $.setdata('', helpSuccessPeoplesKey); - } - if (helpSuccessPeoples) { - if ($.getdata(helpSuccessPeoplesKey)) { - $.setdata($.getdata(helpSuccessPeoplesKey) + ',' + helpSuccessPeoples, helpSuccessPeoplesKey); - } else { - $.setdata(helpSuccessPeoples, helpSuccessPeoplesKey); - } - } - helpSuccessPeoples = $.getdata(helpSuccessPeoplesKey); - } - if (helpSuccessPeoples && helpSuccessPeoples.length > 0) { - message += `【您助力的好友👬】${helpSuccessPeoples.substr(0, helpSuccessPeoples.length - 1)}\n`; - } - if (salveHelpAddWater > 0) { - // message += `【助力好友👬】获得${salveHelpAddWater}g💧\n`; - console.log(`【助力好友👬】获得${salveHelpAddWater}g💧\n`); - } - message += `【今日剩余助力👬】${remainTimes}次\n`; -} -//水滴雨 -async function executeWaterRains() { - let executeWaterRain = !$.farmTask.waterRainInit.f; - if (executeWaterRain) { - console.log(`水滴雨任务,每天两次,最多可得10g水滴`); - console.log(`两次水滴雨任务是否全部完成:${$.farmTask.waterRainInit.f ? '是' : '否'}`); - if ($.farmTask.waterRainInit.lastTime) { - if (Date.now() < ($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000)) { - executeWaterRain = false; - // message += `【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】未到时间,请${new Date($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000).toLocaleTimeString()}再试\n`; - console.log(`【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】未到时间,请${new Date($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000).toLocaleTimeString()}再试\n`); - } - } - if (executeWaterRain) { - console.log(`开始水滴雨任务,这是第${$.farmTask.waterRainInit.winTimes + 1}次,剩余${2 - ($.farmTask.waterRainInit.winTimes + 1)}次`); - await waterRainForFarm(); - console.log('水滴雨waterRain'); - if ($.waterRain.code === '0') { - console.log('水滴雨任务执行成功,获得水滴:' + $.waterRain.addEnergy + 'g'); - console.log(`【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】获得${$.waterRain.addEnergy}g水滴\n`); - // message += `【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】获得${$.waterRain.addEnergy}g水滴\n`; - } - } - } else { - // message += `【水滴雨】已全部完成,获得20g💧\n`; - } -} -//打卡领水活动 -async function clockInIn() { - console.log('开始打卡领水活动(签到,关注,领券)'); - await clockInInitForFarm(); - if ($.clockInInit.code === '0') { - // 签到得水滴 - if (!$.clockInInit.todaySigned) { - console.log('开始今日签到'); - await clockInForFarm(); - console.log(`打卡结果${JSON.stringify($.clockInForFarmRes)}`); - if ($.clockInForFarmRes.code === '0') { - // message += `【第${$.clockInForFarmRes.signDay}天签到】获得${$.clockInForFarmRes.amount}g💧\n`; - console.log(`【第${$.clockInForFarmRes.signDay}天签到】获得${$.clockInForFarmRes.amount}g💧\n`) - if ($.clockInForFarmRes.signDay === 7) { - //可以领取惊喜礼包 - console.log('开始领取--惊喜礼包38g水滴'); - await gotClockInGift(); - if ($.gotClockInGiftRes.code === '0') { - // message += `【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`; - console.log(`【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`); - } - } - } - } - if ($.clockInInit.todaySigned && $.clockInInit.totalSigned === 7) { - console.log('开始领取--惊喜礼包38g水滴'); - await gotClockInGift(); - if ($.gotClockInGiftRes.code === '0') { - // message += `【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`; - console.log(`【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`); - } - } - // 限时关注得水滴 - if ($.clockInInit.themes && $.clockInInit.themes.length > 0) { - for (let item of $.clockInInit.themes) { - if (!item.hadGot) { - console.log(`关注ID${item.id}`); - await clockInFollowForFarm(item.id, "theme", "1"); - console.log(`themeStep1--结果${JSON.stringify($.themeStep1)}`); - if ($.themeStep1.code === '0') { - await clockInFollowForFarm(item.id, "theme", "2"); - console.log(`themeStep2--结果${JSON.stringify($.themeStep2)}`); - if ($.themeStep2.code === '0') { - console.log(`关注${item.name},获得水滴${$.themeStep2.amount}g`); - } - } - } - } - } - // 限时领券得水滴 - if ($.clockInInit.venderCoupons && $.clockInInit.venderCoupons.length > 0) { - for (let item of $.clockInInit.venderCoupons) { - if (!item.hadGot) { - console.log(`领券的ID${item.id}`); - await clockInFollowForFarm(item.id, "venderCoupon", "1"); - console.log(`venderCouponStep1--结果${JSON.stringify($.venderCouponStep1)}`); - if ($.venderCouponStep1.code === '0') { - await clockInFollowForFarm(item.id, "venderCoupon", "2"); - if ($.venderCouponStep2.code === '0') { - console.log(`venderCouponStep2--结果${JSON.stringify($.venderCouponStep2)}`); - console.log(`从${item.name}领券,获得水滴${$.venderCouponStep2.amount}g`); - } - } - } - } - } - } - console.log('开始打卡领水活动(签到,关注,领券)结束\n'); -} -// -async function getAwardInviteFriend() { - await friendListInitForFarm();//查询好友列表 - // console.log(`查询好友列表数据:${JSON.stringify($.friendList)}\n`) - if ($.friendList) { - console.log(`\n今日已邀请好友${$.friendList.inviteFriendCount}个 / 每日邀请上限${$.friendList.inviteFriendMax}个`); - console.log(`开始删除${$.friendList.friends && $.friendList.friends.length}个好友,可拿每天的邀请奖励`); - if ($.friendList.friends && $.friendList.friends.length > 0) { - for (let friend of $.friendList.friends) { - console.log(`\n开始删除好友 [${friend.shareCode}]`); - const deleteFriendForFarm = await request('deleteFriendForFarm', { "shareCode": `${friend.shareCode}`, "version": 8, "channel": 1 }); - if (deleteFriendForFarm && deleteFriendForFarm.code === '0') { - console.log(`删除好友 [${friend.shareCode}] 成功\n`); - } - } - } - await receiveFriendInvite();//为他人助力,接受邀请成为别人的好友 - if ($.friendList.inviteFriendCount > 0) { - if ($.friendList.inviteFriendCount > $.friendList.inviteFriendGotAwardCount) { - console.log('开始领取邀请好友的奖励'); - await awardInviteFriendForFarm(); - console.log(`领取邀请好友的奖励结果::${JSON.stringify($.awardInviteFriendRes)}`); - } - } else { - console.log('今日未邀请过好友') - } - } else { - console.log(`查询好友列表失败\n`); - } -} -//给好友浇水 -async function doFriendsWater() { - await friendListInitForFarm(); - console.log('开始给好友浇水...'); - await taskInitForFarm(); - const { waterFriendCountKey, waterFriendMax } = $.farmTask.waterFriendTaskInit; - console.log(`今日已给${waterFriendCountKey}个好友浇水`); - if (waterFriendCountKey < waterFriendMax) { - let needWaterFriends = []; - if ($.friendList.friends && $.friendList.friends.length > 0) { - $.friendList.friends.map((item, index) => { - if (item.friendState === 1) { - if (needWaterFriends.length < (waterFriendMax - waterFriendCountKey)) { - needWaterFriends.push(item.shareCode); - } - } - }); - console.log(`需要浇水的好友列表shareCodes:${JSON.stringify(needWaterFriends)}`); - let waterFriendsCount = 0, cardInfoStr = ''; - for (let index = 0; index < needWaterFriends.length; index++) { - await waterFriendForFarm(needWaterFriends[index]); - console.log(`为第${index + 1}个好友浇水结果:${JSON.stringify($.waterFriendForFarmRes)}\n`) - if ($.waterFriendForFarmRes.code === '0') { - waterFriendsCount++; - if ($.waterFriendForFarmRes.cardInfo) { - console.log('为好友浇水获得道具了'); - if ($.waterFriendForFarmRes.cardInfo.type === 'beanCard') { - console.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`); - cardInfoStr += `水滴换豆卡,`; - } else if ($.waterFriendForFarmRes.cardInfo.type === 'fastCard') { - console.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`); - cardInfoStr += `快速浇水卡,`; - } else if ($.waterFriendForFarmRes.cardInfo.type === 'doubleCard') { - console.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`); - cardInfoStr += `水滴翻倍卡,`; - } else if ($.waterFriendForFarmRes.cardInfo.type === 'signCard') { - console.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`); - cardInfoStr += `加签卡,`; - } - } - } else if ($.waterFriendForFarmRes.code === '11') { - console.log('水滴不够,跳出浇水') - } - } - // message += `【好友浇水】已给${waterFriendsCount}个好友浇水,消耗${waterFriendsCount * 10}g水\n`; - console.log(`【好友浇水】已给${waterFriendsCount}个好友浇水,消耗${waterFriendsCount * 10}g水\n`); - if (cardInfoStr && cardInfoStr.length > 0) { - // message += `【好友浇水奖励】${cardInfoStr.substr(0, cardInfoStr.length - 1)}\n`; - console.log(`【好友浇水奖励】${cardInfoStr.substr(0, cardInfoStr.length - 1)}\n`); - } - } else { - console.log('您的好友列表暂无好友,快去邀请您的好友吧!') - } - } else { - console.log(`今日已为好友浇水量已达${waterFriendMax}个`) - } -} -//领取给3个好友浇水后的奖励水滴 -async function getWaterFriendGotAward() { - await taskInitForFarm(); - const { waterFriendCountKey, waterFriendMax, waterFriendSendWater, waterFriendGotAward } = $.farmTask.waterFriendTaskInit - if (waterFriendCountKey >= waterFriendMax) { - if (!waterFriendGotAward) { - await waterFriendGotAwardForFarm(); - console.log(`领取给${waterFriendMax}个好友浇水后的奖励水滴::${JSON.stringify($.waterFriendGotAwardRes)}`) - if ($.waterFriendGotAwardRes.code === '0') { - // message += `【给${waterFriendMax}好友浇水】奖励${$.waterFriendGotAwardRes.addWater}g水滴\n`; - console.log(`【给${waterFriendMax}好友浇水】奖励${$.waterFriendGotAwardRes.addWater}g水滴\n`); - } - } else { - console.log(`给好友浇水的${waterFriendSendWater}g水滴奖励已领取\n`); - // message += `【给${waterFriendMax}好友浇水】奖励${waterFriendSendWater}g水滴已领取\n`; - } - } else { - console.log(`暂未给${waterFriendMax}个好友浇水\n`); - } -} -//接收成为对方好友的邀请 -async function receiveFriendInvite() { - for (let code of newShareCodes) { - if (code === $.farmInfo.farmUserPro.shareCode) { - console.log('自己不能邀请自己成为好友噢\n') - continue - } - await inviteFriend(code); - // console.log(`接收邀请成为好友结果:${JSON.stringify($.inviteFriendRes)}`) - if ($.inviteFriendRes && $.inviteFriendRes.helpResult && $.inviteFriendRes.helpResult.code === '0') { - console.log(`接收邀请成为好友结果成功,您已成为${$.inviteFriendRes.helpResult.masterUserInfo.nickName}的好友`) - } else if ($.inviteFriendRes && $.inviteFriendRes.helpResult && $.inviteFriendRes.helpResult.code === '17') { - console.log(`接收邀请成为好友结果失败,对方已是您的好友`) - } - } - // console.log(`开始接受6fbd26cc27ac44d6a7fed34092453f77的邀请\n`) - // await inviteFriend('6fbd26cc27ac44d6a7fed34092453f77'); - // console.log(`接收邀请成为好友结果:${JSON.stringify($.inviteFriendRes.helpResult)}`) - // if ($.inviteFriendRes.helpResult.code === '0') { - // console.log(`您已成为${$.inviteFriendRes.helpResult.masterUserInfo.nickName}的好友`) - // } else if ($.inviteFriendRes.helpResult.code === '17') { - // console.log(`对方已是您的好友`) - // } -} -async function duck() { - for (let i = 0; i < 10; i++) { - //这里循环十次 - await getFullCollectionReward(); - if ($.duckRes.code === '0') { - if (!$.duckRes.hasLimit) { - console.log(`小鸭子游戏:${$.duckRes.title}`); - // if ($.duckRes.type !== 3) { - // console.log(`${$.duckRes.title}`); - // if ($.duckRes.type === 1) { - // message += `【小鸭子】为你带回了水滴\n`; - // } else if ($.duckRes.type === 2) { - // message += `【小鸭子】为你带回快速浇水卡\n` - // } - // } - } else { - console.log(`${$.duckRes.title}`) - break; - } - } else if ($.duckRes.code === '10') { - console.log(`小鸭子游戏达到上限`) - break; - } - } -} -async function GetCollect() { - try { - console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】`); - var llfound = false; - var strShareCode = ""; - if (TempShareCache) { - for (let j = 0; j < TempShareCache.length; j++) { - if (TempShareCache[j].pt_pin == $.UserName) { - llfound = true; - strShareCode = TempShareCache[j].ShareCode; - } - } - } - if (!llfound) { - console.log($.UserName + "该账号无缓存,尝试联网获取互助码....."); - llgetshare=true; - await initForFarm(); - if ($.farmInfo.farmUserPro) { - var tempAddCK = {}; - strShareCode=$.farmInfo.farmUserPro.shareCode; - tempAddCK = { - "pt_pin": $.UserName, - "ShareCode": strShareCode - }; - TempShareCache.push(tempAddCK); - //标识,需要更新缓存文件 - boolneedUpdate = true; - } - } - - if (strShareCode) { - console.log(`\n`+strShareCode); - newShareCodes.push(strShareCode) - } else { - console.log(`\n数据异常`); - } - } catch (e) { - $.logErr(e); - } -} -// ========================API调用接口======================== -//鸭子,点我有惊喜 -async function getFullCollectionReward() { - return new Promise(resolve => { - const body = { "type": 2, "version": 6, "channel": 2 }; - $.post(taskUrl("getFullCollectionReward", body), (err, resp, data) => { - try { - if (err) { - console.log('\ngetFullCollectionReward: API查询请求失败 ‼️‼️'); - console.log(JSON.stringify(err)); - $.logErr(err); - } else { - if (safeGet(data)) { - $.duckRes = JSON.parse(data); - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -/** - * 领取10次浇水奖励API - */ -async function totalWaterTaskForFarm() { - const functionId = arguments.callee.name.toString(); - $.totalWaterReward = await request(functionId); -} -//领取首次浇水奖励API -async function firstWaterTaskForFarm() { - const functionId = arguments.callee.name.toString(); - $.firstWaterReward = await request(functionId); -} -//领取给3个好友浇水后的奖励水滴API -async function waterFriendGotAwardForFarm() { - const functionId = arguments.callee.name.toString(); - $.waterFriendGotAwardRes = await request(functionId, { "version": 4, "channel": 1 }); -} -// 查询背包道具卡API -async function myCardInfoForFarm() { - const functionId = arguments.callee.name.toString(); - $.myCardInfoRes = await request(functionId, { "version": 5, "channel": 1 }); -} -//使用道具卡API -async function userMyCardForFarm(cardType) { - const functionId = arguments.callee.name.toString(); - $.userMyCardRes = await request(functionId, { "cardType": cardType }); -} -/** - * 领取浇水过程中的阶段性奖励 - * @param type - * @returns {Promise} - */ -async function gotStageAwardForFarm(type) { - $.gotStageAwardForFarmRes = await request(arguments.callee.name.toString(), { 'type': type }); -} -//浇水API -async function waterGoodForFarm() { - await $.wait(2000); - console.log('等待了2秒'); - - const functionId = arguments.callee.name.toString(); - $.waterResult = await request(functionId); -} -// 初始化集卡抽奖活动数据API -async function initForTurntableFarm() { - $.initForTurntableFarmRes = await request(arguments.callee.name.toString(), { version: 4, channel: 1 }); -} -async function lotteryForTurntableFarm() { - await $.wait(3000); - console.log('等待了3秒'); - $.lotteryRes = await request(arguments.callee.name.toString(), { type: 1, version: 4, channel: 1 }); -} - -async function timingAwardForTurntableFarm() { - $.timingAwardRes = await request(arguments.callee.name.toString(), { version: 4, channel: 1 }); -} - -async function browserForTurntableFarm(type, adId) { - if (type === 1) { - console.log('浏览爆品会场'); - } - if (type === 2) { - console.log('天天抽奖浏览任务领取水滴'); - } - const body = { "type": type, "adId": adId, "version": 4, "channel": 1 }; - $.browserForTurntableFarmRes = await request(arguments.callee.name.toString(), body); - // 浏览爆品会场8秒 -} -//天天抽奖浏览任务领取水滴API -async function browserForTurntableFarm2(type) { - const body = { "type": 2, "adId": type, "version": 4, "channel": 1 }; - $.browserForTurntableFarm2Res = await request('browserForTurntableFarm', body); -} -/** - * 天天抽奖拿好礼-助力API(每人每天三次助力机会) - */ -async function lotteryMasterHelp() { - $.lotteryMasterHelpRes = await request(`initForFarm`, { - imageUrl: "", - nickName: "", - shareCode: arguments[0] + '-3', - babelChannel: "3", - version: 4, - channel: 1 - }); -} - -//领取5人助力后的额外奖励API -async function masterGotFinishedTaskForFarm() { - const functionId = arguments.callee.name.toString(); - $.masterGotFinished = await request(functionId); -} -//助力好友信息API -async function masterHelpTaskInitForFarm() { - const functionId = arguments.callee.name.toString(); - $.masterHelpResult = await request(functionId); -} -//新版助力好友信息API -async function farmAssistInit() { - const functionId = arguments.callee.name.toString(); - $.farmAssistResult = await request(functionId, {"version":14,"channel":1,"babelChannel":"120"}); -} -//新版领取助力奖励API -async function receiveStageEnergy() { - const functionId = arguments.callee.name.toString(); - $.receiveStageEnergy = await request(functionId, {"version":14,"channel":1,"babelChannel":"120"}); -} -//接受对方邀请,成为对方好友的API -async function inviteFriend() { - $.inviteFriendRes = await request(`initForFarm`, { - imageUrl: "", - nickName: "", - shareCode: arguments[0] + '-inviteFriend', - version: 4, - channel: 2 - }); -} -// 助力好友API -async function masterHelp() { - $.helpResult = await request(`initForFarm`, { - imageUrl: "", - nickName: "", - shareCode: arguments[0], - babelChannel: "3", - version: 2, - channel: 1 - }); -} -/** - * 水滴雨API - */ -async function waterRainForFarm() { - const functionId = arguments.callee.name.toString(); - const body = { "type": 1, "hongBaoTimes": 100, "version": 3 }; - $.waterRain = await request(functionId, body); -} -/** - * 打卡领水API - */ -async function clockInInitForFarm() { - const functionId = arguments.callee.name.toString(); - $.clockInInit = await request(functionId); -} - -// 连续签到API -async function clockInForFarm() { - const functionId = arguments.callee.name.toString(); - $.clockInForFarmRes = await request(functionId, { "type": 1 }); -} - -//关注,领券等API -async function clockInFollowForFarm(id, type, step) { - const functionId = arguments.callee.name.toString(); - let body = { - id, - type, - step - } - if (type === 'theme') { - if (step === '1') { - $.themeStep1 = await request(functionId, body); - } else if (step === '2') { - $.themeStep2 = await request(functionId, body); - } - } else if (type === 'venderCoupon') { - if (step === '1') { - $.venderCouponStep1 = await request(functionId, body); - } else if (step === '2') { - $.venderCouponStep2 = await request(functionId, body); - } - } -} - -// 领取连续签到7天的惊喜礼包API -async function gotClockInGift() { - $.gotClockInGiftRes = await request('clockInForFarm', { "type": 2 }) -} - -//定时领水API -async function gotThreeMealForFarm() { - const functionId = arguments.callee.name.toString(); - $.threeMeal = await request(functionId); -} -/** - * 浏览广告任务API - * type为0时, 完成浏览任务 - * type为1时, 领取浏览任务奖励 - */ -async function browseAdTaskForFarm(advertId, type) { - const functionId = arguments.callee.name.toString(); - if (type === 0) { - $.browseResult = await request(functionId, {advertId, type}); - } else if (type === 1) { - $.browseRwardResult = await request(functionId, {advertId, type}); - } -} -// 被水滴砸中API -async function gotWaterGoalTaskForFarm() { - $.goalResult = await request(arguments.callee.name.toString(), { type: 3 }); -} -//签到API -async function signForFarm() { - const functionId = arguments.callee.name.toString(); - $.signResult = await request(functionId); -} -/** - * 初始化农场, 可获取果树及用户信息API - */ -async function initForFarm() { - return new Promise(resolve => { - const option = { - url: `${JD_API_HOST}?functionId=initForFarm`, - body: `body=${escape(JSON.stringify({ "version": 4 }))}&appid=wh5&clientVersion=9.1.0`, - headers: { - "accept": "*/*", - "accept-encoding": "gzip, deflate, br", - "accept-language": "zh-CN,zh;q=0.9", - "cache-control": "no-cache", - "cookie": cookie, - "origin": "https://home.m.jd.com", - "pragma": "no-cache", - "referer": "https://home.m.jd.com/myJd/newhome.action", - "sec-fetch-dest": "empty", - "sec-fetch-mode": "cors", - "sec-fetch-site": "same-site", - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - "Content-Type": "application/x-www-form-urlencoded" - }, - timeout: 10000, - }; - $.post(option, (err, resp, data) => { - try { - if (err) { - console.log('\ninitForFarm: API查询请求失败 ‼️‼️'); - console.log(JSON.stringify(err)); - $.logErr(err); - } else { - if (safeGet(data)) { - $.farmInfo = JSON.parse(data) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -// 初始化任务列表API -async function taskInitForFarm() { - console.log('\n初始化任务列表') - const functionId = arguments.callee.name.toString(); - $.farmTask = await request(functionId, { "version": 14, "channel": 1, "babelChannel": "120" }); -} -//获取好友列表API -async function friendListInitForFarm() { - $.friendList = await request('friendListInitForFarm', { "version": 4, "channel": 1 }); - // console.log('aa', aa); -} -// 领取邀请好友的奖励API -async function awardInviteFriendForFarm() { - $.awardInviteFriendRes = await request('awardInviteFriendForFarm'); -} -//为好友浇水API -async function waterFriendForFarm(shareCode) { - const body = { "shareCode": shareCode, "version": 6, "channel": 1 } - $.waterFriendForFarmRes = await request('waterFriendForFarm', body); -} -async function showMsg() { - if ($.isNode() && process.env.FRUIT_NOTIFY_CONTROL) { - $.ctrTemp = `${process.env.FRUIT_NOTIFY_CONTROL}` === 'false'; - } else if ($.getdata('jdFruitNotify')) { - $.ctrTemp = $.getdata('jdFruitNotify') === 'false'; - } else { - $.ctrTemp = `${jdNotify}` === 'false'; - } - if ($.ctrTemp) { - $.msg($.name, subTitle, message, option); - if ($.isNode()) { - allMessage += `${subTitle}\n${message}${$.index !== cookiesArr.length ? '\n\n' : ''}`; - // await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `${subTitle}\n${message}`); - } - } else { - $.log(`\n${message}\n`); - } -} - -function timeFormat(time) { - let date; - if (time) { - date = new Date(time) - } else { - date = new Date(); - } - return date.getFullYear() + '-' + ((date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)) + '-' + (date.getDate() >= 10 ? date.getDate() : '0' + date.getDate()); -} - -function requireConfig() { - return new Promise(resolve => { - console.log('开始获取配置文件\n') - notify = $.isNode() ? require('./sendNotify') : ''; - //Node.js用户请在jdCookie.js处填写京东ck; - const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; - //IOS等用户直接用NobyDa的jd cookie - if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - if (jdCookieNode[item]) { - cookiesArr.push(jdCookieNode[item]) - } - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; - } else { - cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); - } - console.log(`共${cookiesArr.length}个京东账号\n`) - $.shareCodesArr = []; - resolve() - }) -} -function TotalBean() { - return new Promise(async resolve => { - const options = { - url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", - headers: { - Host: "me-api.jd.com", - Accept: "*/*", - Connection: "keep-alive", - Cookie: cookie, - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - "Accept-Language": "zh-cn", - "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", - "Accept-Encoding": "gzip, deflate, br" - } - } - $.get(options, (err, resp, data) => { - try { - if (err) { - $.logErr(err) - } else { - if (data) { - data = JSON.parse(data); - if (data['retcode'] === "1001") { - $.isLogin = false; //cookie过期 - return; - } - if (data['retcode'] === "0" && data.data && data.data.hasOwnProperty("userInfo")) { - $.nickName = data.data.userInfo.baseInfo.nickname; - } - } else { - $.log('京东服务器返回空数据'); - } - } - } catch (e) { - $.logErr(e) - } finally { - resolve(); - } - }) - }) -} -function request(function_id, body = {}, timeout = 1000) { - return new Promise(resolve => { - setTimeout(() => { - $.get(taskUrl(function_id, body), (err, resp, data) => { - try { - if (err) { - console.log('\nrequest: API查询请求失败 ‼️‼️') - console.log(JSON.stringify(err)); - console.log(`function_id:${function_id}`) - $.logErr(err); - } else { - if (safeGet(data)) { - data = JSON.parse(data); - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }, timeout) - }) -} -function safeGet(data) { - try { - if (typeof JSON.parse(data) == "object") { - return true; - } - } catch (e) { - console.log(e); - console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); - return false; - } -} -function taskUrl(function_id, body = {}) { - return { - url: `${JD_API_HOST}?functionId=${function_id}&body=${encodeURIComponent(JSON.stringify(body))}&appid=wh5`, - headers: { - "Host": "api.m.jd.com", - "Accept": "*/*", - "Origin": "https://carry.m.jd.com", - "Accept-Encoding": "gzip, deflate, br", - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - "Accept-Language": "zh-CN,zh-Hans;q=0.9", - "Referer": "https://carry.m.jd.com/", - "Cookie": cookie - }, - timeout: 10000 - } -} -function jsonParse(str) { - if (typeof str == "string") { - try { - return JSON.parse(str); - } catch (e) { - console.log(e); - $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') - return []; - } - } -} -// 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) } diff --git a/jd_mncryyj.js b/jd_mncryyj.js deleted file mode 100644 index eb2d301..0000000 --- a/jd_mncryyj.js +++ /dev/null @@ -1,340 +0,0 @@ -/* -[task_local] -#4月蒙牛春日音乐节抽奖机 -31 14 9-21/3 4 * jd_mncryyj.js, tag=4月蒙牛春日音乐节抽奖机, enabled=true - -from https://github.com/KingRan/KR/blob/main/jd_mncryyj.js - - */ -const $ = new Env('4月蒙牛春日音乐节抽奖机'); -const notify = $.isNode() ? require('./sendNotify') : ''; -//Node.js用户请在jdCookie.js处填写京东ck; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 -$.configCode = "445d31ec3db740b992b2f6798c0fd646"; -//IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], cookie = '', message; -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { - }; -} else { - cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); -} -!(async () => { - console.log('入口下拉:https://prodev.m.jd.com/mall/active/ymjgzZHsgzyCr2zoDcg7wrgEZLK/index.html') - if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); - return; - } - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - message = ''; - 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" }); - - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } - await jdmodule(); - //await showMsg(); - } - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) - -function showMsg() { - return new Promise(resolve => { - $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); - resolve() - }) -} - - -async function jdmodule() { - let runTime = 0; - do { - await getinfo(); //获取任务 - $.hasFinish = true; - await run(); - runTime++; - } while (!$.hasFinish && runTime < 10); - await getinfo(); - console.log("开始抽奖"); - for (let x = 0; x < $.chanceLeft; x++) { - await join(); - await $.wait(1500) - } -} - -//运行 -async function run() { - try { - for (let vo of $.taskinfo) { - if (vo.hasFinish === true) { - continue; - } - if (vo.taskName == '每日签到') { - console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); - await doTask(vo.taskType, vo.taskItem.itemId, vo.id); - await getReward(vo.taskType, vo.taskItem.itemId, vo.id); - } - if (vo.taskType == 3) { - console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); - await getinfo2(vo.taskItem.itemLink); - await $.wait(1000 * vo.viewTime) - await doTask(vo.taskType, vo.taskItem.itemId, vo.id); - await getReward(vo.taskType, vo.taskItem.itemId, vo.id); - } - if (vo.taskType == 4) { - console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); - await doTask(vo.taskType, vo.taskItem.itemId, vo.id); - await getReward(vo.taskType, vo.taskItem.itemId, vo.id); - } - if (vo.taskType == 2) { - console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); - await doTask(vo.taskType, vo.taskItem.itemId, vo.id); - await getReward(vo.taskType, vo.taskItem.itemId, vo.id); - } - $.hasFinish = false; - } - } catch (e) { - console.log(e); - } -} - - -// 获取任务 -function getinfo() { - return new Promise(resolve => { - $.get({ - url: `https://jdjoy.jd.com/module/task/draw/get?configCode=${$.configCode}&unionCardCode=`, - headers: { - 'Host': 'jdjoy.jd.com', - 'accept': '*/*', - 'content-type': 'application/json', - "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", - "origin": "https://prodev.m.jd.com", - 'X-Requested-With': 'com.jingdong.app.mall', - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - 'accept-language': 'zh-Hans-CN;q=1', - 'cookie': cookie - }, - }, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} getinfo请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - $.chanceLeft = data.data.chanceLeft; - if (data.success == true) { - $.taskinfo = data.data.taskConfig - } else { - console.log(data.errorMessage); - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - }) - }) -} - -//抽奖 -function join() { - return new Promise(async (resolve) => { - $.get({ - url: `https://jdjoy.jd.com/module/task/draw/join?configCode=${$.configCode}&fp=${randomWord(false, 32, 32)}&eid=`, - headers: { - 'Host': 'jdjoy.jd.com', - 'accept': '*/*', - 'content-type': 'application/json', - "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", - "origin": "https://prodev.m.jd.com", - 'X-Requested-With': 'com.jingdong.app.mall', - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - 'accept-language': 'zh-Hans-CN;q=1', - 'cookie': cookie - }, - }, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`join请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data.success == true) { - console.log(`抽奖结果:${data.data.rewardName}`); - } - else { - console.log(data.errorMessage); - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - }) - }) -} - -//做任务 -function doTask(taskType, itemId, taskid) { - return new Promise(resolve => { - let options = taskPostUrl('doTask', `{"configCode":"${$.configCode}","taskType":${taskType},"itemId":"${itemId}","taskId":${taskid}}`) - $.post(options, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`); - console.log(`doTask 请求失败,请检查网路重试`); - } else { - data = JSON.parse(data); - if (data.success == true) { - console.log("任务成功"); - } else { - console.log(data.errorMessage); - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - }); - }); -} - - -//领取任务奖励 -function getReward(taskType, itemId, taskid) { - return new Promise(resolve => { - let options = taskPostUrl('getReward', `{"configCode":"${$.configCode}","taskType":${taskType},"itemId":"${itemId}","taskId":${taskid}}`) - $.post(options, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`); - console.log(`getReward 请求失败,请检查网路重试`); - } else { - data = JSON.parse(data); - if (data.success == true) { - console.log("任务奖励领取成功"); - } else { - console.log(data.errorMessage); - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - }); - }); -} - -function getinfo2(url2) { - return new Promise(resolve => { - $.get({ - url: url2, - headers: { - 'Host': 'pro.m.jd.com', - 'accept': '*/*', - 'content-type': 'application/x-www-form-urlencoded', - 'referer': '', - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - 'accept-language': 'zh-Hans-CN;q=1', - 'cookie': cookie - }, - }, (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`getinfo2 API请求失败,请检查网路重试`) - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} - -function taskPostUrl(function_id, body = {}) { - return { - url: `https://jdjoy.jd.com/module/task/draw/${function_id}`, - body: `${(body)}`, - headers: { - "Accept": "application/json, text/plain, */*", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - "Connection": "keep-alive", - "Content-Type": "application/json", - "Host": "jdjoy.jd.com", - "x-requested-with": "com.jingdong.app.mall", - "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", - "origin": "https://prodev.m.jd.com", - "Cookie": cookie, - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - } - } -} - -function safeGet(data) { - try { - if (typeof JSON.parse(data) == "object") { - return true; - } - } catch (e) { - console.log(e); - console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); - return false; - } -} -function jsonParse(str) { - if (typeof str == "string") { - try { - return JSON.parse(str); - } catch (e) { - console.log(e); - $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') - return []; - } - } -} - -function randomWord(randomFlag, min, max) { - var str = "", - range = min, - arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; - - // 随机产生 - if (randomFlag) { - range = Math.round(Math.random() * (max - min)) + min; - } - for (var i = 0; i < range; i++) { - pos = Math.round(Math.random() * (arr.length - 1)); - str += arr[pos]; - } - return 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)} diff --git a/jd_mofang.ts b/jd_mofang.ts deleted file mode 100644 index 452b38e..0000000 --- a/jd_mofang.ts +++ /dev/null @@ -1,134 +0,0 @@ -/** - * 京东-新品-魔方 - * rabbit log - * cron: 10 9,12,15 * * * - */ - -import {requireConfig, wait, post, get} from './TS_USER_AGENTS' -import {existsSync} from "fs"; -import * as dotenv from 'dotenv' - -let cookie: string = '', res: any = '', UserName: string, index: number, log: string = '' -let rabbitToken: string = process.env.RABBIT_TOKEN || '', tg_id: string = process.env.TG_ID || '', mf_logs: any - -!(async () => { - dotenv.config() - if (existsSync('./test/mf_log.ts')) { - mf_logs = require('./test/mf_log').mf_logs - } else { - console.log('./test/mf_log not found') - } - let cookiesArr: any = await requireConfig() - for (let i = 0; i < cookiesArr.length; i++) { - cookie = cookiesArr[i] - UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) - index = i + 1 - console.log(`\n开始【京东账号${index}】${UserName}\n`) - - res = await api("functionId=getInteractionHomeInfo&body=%7B%22sign%22%3A%22u6vtLQ7ztxgykLEr%22%7D&appid=content_ecology&client=wh5&clientVersion=1.0.0") - let sign: string = res.result.taskConfig.projectId - - res = await api(`functionId=queryInteractiveInfo&body=%7B%22encryptProjectId%22%3A%22${sign}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`) - for (let t of res.assignmentList) { - if (t.completionCnt < t.assignmentTimesLimit) { - if (t.ext) { - if (t.assignmentName === '每日签到') { - if (t.ext.sign1.status === 1) { - let signDay: number = t.ext.sign1.signList?.length || 0, - type: number = t.rewards[signDay].rewardType - console.log(signDay, type) - log = await getLog() - res = await api(`functionId=doInteractiveAssignment&body=${JSON.stringify({ - "encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": "1", "actionType": "", "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"} - })}&client=wh5&clientVersion=1.0.0&appid=content_ecology`) - console.log('签到成功') - } else { - console.log('已签到') - } - } - - for (let proInfo of t.ext.productsInfo ?? []) { - if (proInfo.status === 1) { - console.log(t.assignmentName) - log = await getLog() - res = await api(`functionId=doInteractiveAssignment&body=${encodeURIComponent(JSON.stringify({"encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": 0, "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"}}))}&client=wh5&clientVersion=1.0.0&appid=content_ecology`) - console.log(res.msg) - if (res.msg === '任务已完成') { - break - } - } - } - - for (let proInfo of t.ext.shoppingActivity ?? []) { - if (proInfo.status === 1) { - console.log(t.assignmentName) - log = await getLog() - res = await api(`functionId=doInteractiveAssignment&body=${encodeURIComponent(JSON.stringify({"encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": 1, "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"}}))}&client=wh5&clientVersion=1.0.0&appid=content_ecology`) - console.log(res.msg) - await wait(t.ext.waitDuration * 1000) - log = await getLog() - res = await api(`functionId=doInteractiveAssignment&body=${encodeURIComponent(JSON.stringify({"encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": 0, "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"}}))}&client=wh5&clientVersion=1.0.0&appid=content_ecology`) - console.log(res.msg) - } - } - - for (let proInfo of t.ext.browseShop ?? []) { - if (proInfo.status === 1) { - console.log(t.assignmentName) - log = await getLog() - res = await api(`functionId=doInteractiveAssignment&body=${JSON.stringify({ - "encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": 1, "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"} - })}&client=wh5&clientVersion=1.0.0&appid=content_ecology`) - console.log(res.msg) - await wait(t.ext.waitDuration * 1000) - log = await getLog() - res = await api(`functionId=doInteractiveAssignment&body=${JSON.stringify({ - "encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": 0, "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"} - })}&client=wh5&clientVersion=1.0.0&appid=content_ecology`) - console.log(res.msg) - } - } - - for (let proInfo of t.ext.addCart ?? []) { - if (proInfo.status === 1) { - console.log(t.assignmentName) - log = await getLog() - res = await api(`functionId=doInteractiveAssignment&body=${encodeURIComponent(JSON.stringify({"encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": "0", "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFJGh5"}}))}&client=wh5&clientVersion=1.0.0&appid=content_ecology`) - console.log(res.msg) - if (res.msg === '任务已完成') { - break - } - } - } - } else if (t.assignmentName === '去新品频道逛逛') { - - } - } - } - } -})() - -async function api(params: string) { - await wait(1000) - return await post("https://api.m.jd.com/client.action", params, { - 'Content-Type': 'application/x-www-form-urlencoded', - "User-Agent": "Mozilla/5.0 (Linux; U; Android 8.0.0; zh-cn; Mi Note 2 Build/OPR1.170623.032) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.128 Mobile Safari/537.36 XiaoMi/MiuiBrowser/10.1.1", - 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2bf3XEEyWG11pQzPGkKpKX2GxJz2/index.html', - 'Origin': 'https://h5.m.jd.com', - 'Host': 'api.m.jd.com', - 'Cookie': cookie - }) -} - -async function getLog() { - if (rabbitToken && tg_id) { - console.log('rabbit log api') - let {data} = await get(`http://www.madrabbit.cf:8080/license/log?tg_id=${tg_id}&token=${rabbitToken}`) - return `'"random":"${data.random}","log":"${data.log}"'` - } else if (mf_logs) { - return mf_logs[Math.floor(Math.random() * mf_logs.length)] - } else { - console.log('No log') - process.exit(0) - } -} \ No newline at end of file diff --git a/jd_moneyTree.js b/jd_moneyTree.js deleted file mode 100644 index d9ae835..0000000 --- a/jd_moneyTree.js +++ /dev/null @@ -1,885 +0,0 @@ -/* -京东摇钱树 :jd_moneyTree.js -更新时间:2021-4-23 -活动入口:京东APP我的-更多工具-摇钱树,[活动链接](https://uua.jr.jd.com/uc-fe-wxgrowing/moneytree/index/?channel=yxhd) -京东摇钱树支持京东双账号 -注:如果使用Node.js, 需自行安装'crypto-js,got,http-server,tough-cookie'模块. 例: npm install crypto-js http-server tough-cookie got --save -===============Quantumultx=============== -[task_local] -#京东摇钱树 -3 0-23/2 * * * jd_moneyTree.js, tag=京东摇钱树, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdyqs.png, enabled=true - -==============Loon=========== -[Script] -cron "3 0-23/2 * * *" script-path=jd_moneyTree.js,tag=京东摇钱树 - -===============Surge=========== -京东摇钱树 = type=cron,cronexp="3 0-23/2 * * *",wake-system=1,timeout=3600,script-path=jd_moneyTree.js - -============小火箭========= -京东摇钱树 = type=cron,script-path=jd_moneyTree.js, cronexpr="3 0-23/2 * * *", timeout=3600, enable=true -*/ - -const $ = new Env('京东摇钱树'); -const notify = $.isNode() ? require('./sendNotify') : ''; -//Node.js用户请在jdCookie.js处填写京东ck; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; - -//IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], cookie = '', allMsg = ``; -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; -} else { - cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); -} - -let jdNotify = true;//是否开启静默运行,默认true -let sellFruit = true;//是否卖出金果得到金币,默认'true' -const JD_API_HOST = 'https://ms.jr.jd.com/gw/generic/uc/h5/m'; -let userInfo = null, taskInfo = [], message = '', subTitle = '', fruitTotal = 0; -!(async () => { - if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); - } - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - //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"}); - - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } - message = ''; - subTitle = ''; - await jd_moneyTree(); - } - } - if (allMsg) { - jdNotify = $.isNode() ? (process.env.MONEYTREE_NOTIFY_CONTROL ? process.env.MONEYTREE_NOTIFY_CONTROL : jdNotify) : ($.getdata('jdMoneyTreeNotify') ? $.getdata('jdMoneyTreeNotify') : jdNotify); - if (!jdNotify || jdNotify === 'false') { - if ($.isNode()) await notify.sendNotify($.name, allMsg); - $.msg($.name, '', allMsg) - } - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) - -async function jd_moneyTree() { - try { - const userRes = await user_info(); - if (!userRes || !userRes.realName) return - await signEveryDay(); - // await dayWork(); - await harvest(); - await sell(); - await myWealth(); - await stealFriendFruit() - - $.log(`\n${message}\n`); - } catch (e) { - $.logErr(e) - } -} - -function user_info() { - console.log('初始化摇钱树个人信息'); - const params = { - "sharePin": "", - "shareType": 1, - "channelLV": "", - "source": 2, - "riskDeviceParam": { - "eid": "", - "fp": "", - "sdkToken": "", - "token": "", - "jstub": "", - "appType": "2", - } - } - params.riskDeviceParam = JSON.stringify(params.riskDeviceParam); - // await $.wait(5000); //歇口气儿, 不然会报操作频繁 - return new Promise((resolve, reject) => { - $.post(taskurl('login', params), async (err, resp, data) => { - try { - if (err) { - console.log("\n摇钱树京东API请求失败 ‼️‼️") - console.log(JSON.stringify(err)); - } else { - if (data) { - const res = JSON.parse(data); - if (res && res.resultCode === 0) { - $.isLogin = true; - console.log('resultCode为0') - if (res.resultData.data) { - userInfo = res.resultData.data; - // userInfo.realName = null; - if (userInfo.realName) { - // console.log(`助力码sharePin为::${userInfo.sharePin}`); - $.treeMsgTime = userInfo.sharePin; - subTitle = `【${userInfo.nick}】${userInfo.treeInfo.treeName}`; - // message += `【我的金果数量】${userInfo.treeInfo.fruit}\n`; - // message += `【我的金币数量】${userInfo.treeInfo.coin}\n`; - // message += `【距离${userInfo.treeInfo.level + 1}级摇钱树还差】${userInfo.treeInfo.progressLeft}\n`; - } else { - $.log(`京东账号${$.index}${$.UserName}运行失败\n此账号未实名认证或者未参与过此活动\n①如未参与活动,请先去京东app参加摇钱树活动\n入口:我的->游戏与互动->查看更多\n②如未实名认证,请进行实名认证`) - // $.msg($.name, `【提示】京东账号${$.index}${$.UserName}运行失败`, '此账号未实名认证或者未参与过此活动\n①如未参与活动,请先去京东app参加摇钱树活动\n入口:我的->游戏与互动->查看更多\n②如未实名认证,请进行实名认证', {"open-url": "openApp.jdMobile://"}); - } - } - } else { - console.log(`其他情况::${JSON.stringify(res)}`); - } - } else { - console.log(`京东api返回数据为空,请检查自身原因`) - } - } - } catch (eor) { - $.logErr(eor, err) - } finally { - resolve(userInfo) - } - }) - }) -} - -function dayWork() { - console.log(`开始做任务userInfo了\n`) - return new Promise(async resolve => { - const data = { - "source": 0, - "linkMissionIds": ["666", "667"], - "LinkMissionIdValues": [7, 7], - "riskDeviceParam": { - "eid": "", - "dt": "", - "ma": "", - "im": "", - "os": "", - "osv": "", - "ip": "", - "apid": "", - "ia": "", - "uu": "", - "cv": "", - "nt": "", - "at": "1", - "fp": "", - "token": "" - } - }; - let response = await request('dayWork', data); - // console.log(`获取任务的信息:${JSON.stringify(response)}\n`) - let canTask = []; - taskInfo = []; - if (response && response.resultCode === 0) { - if (response.resultData.code === '200') { - response.resultData.data.map((item) => { - if (item.prizeType === 2) { - canTask.push(item); - } - if (item.workType === 7 && item.prizeType === 0) { - // missionId.push(item.mid); - taskInfo.push(item); - } - // if (item.workType === 7 && item.prizeType === 0) { - // missionId2 = item.mid; - // } - }) - } - } - console.log(`canTask::${JSON.stringify(canTask)}\n`) - console.log(`浏览任务列表taskInfo::${JSON.stringify(taskInfo)}\n`) - for (let item of canTask) { - if (item.workType === 1) { - // 签到任务 - // let signRes = await sign(); - // console.log(`签到结果:${JSON.stringify(signRes)}`); - if (item.workStatus === 0) { - // const data = {"source":2,"workType":1,"opType":2}; - // let signRes = await request('doWork', data); - let signRes = await sign(); - console.log(`三餐签到结果:${JSON.stringify(signRes)}`); - } else if (item.workStatus === 2) { - console.log(`三餐签到任务已经做过`) - } else if (item.workStatus === -1) { - console.log(`三餐签到任务不在时间范围内`) - } - } else if (item.workType === 2) { - // 分享任务 - if (item.workStatus === 0) { - // share(); - const data = {"source": 0, "workType": 2, "opType": 1}; - //开始分享 - // let shareRes = await request('doWork', data); - let shareRes = await share(data); - console.log(`开始分享的动作:${JSON.stringify(shareRes)}`); - const b = {"source": 0, "workType": 2, "opType": 2}; - // let shareResJL = await request('doWork', b); - let shareResJL = await share(b); - console.log(`领取分享后的奖励:${JSON.stringify(shareResJL)}`) - } else if (item.workStatus === 2) { - console.log(`分享任务已经做过`) - } - } - } - for (let task of taskInfo) { - if (task.mid && task.workStatus === 0 && task.mid !=666 && task.mid !=667) { - console.log('开始做浏览任务'); - // yield setUserLinkStatus(task.mid); - let aa = await setUserLinkStatus(task.mid); - console.log(`aaa${JSON.stringify(aa)}`); - } else if (task.mid && task.workStatus === 1) { - console.log(`workStatus === 1开始领取浏览后的奖励:mid:${task.mid}`); - let receiveAwardRes = await receiveAward(task.mid); - console.log(`领取浏览任务奖励成功:${JSON.stringify(receiveAwardRes)}`) - } else if (task.mid && task.workStatus === 2) { - console.log('所有的浏览任务都做完了') - } - } - resolve(); - }); -} - -function harvest() { - if (!userInfo) return - const data = { - "source": 2, - "sharePin": "", - "userId": userInfo.userInfo, - "userToken": userInfo.userToken, - "shareType": 1, - "channel": "", - "riskDeviceParam": { - "eid": "", - "appType": 2, - "fp": "", - "jstub": "", - "sdkToken": "", - "token": "" - } - } - data.riskDeviceParam = JSON.stringify(data.riskDeviceParam); - return new Promise((rs, rj) => { - request('harvest', data).then((harvestRes) => { - if (harvestRes && harvestRes.resultCode === 0 && harvestRes.resultData.code === '200') { - console.log(`\n收获金果成功:${JSON.stringify(harvestRes)}\n`) - let data = harvestRes.resultData.data; - message += `【距离${data.treeInfo.level + 1}级摇钱树还差】${data.treeInfo.progressLeft}\n`; - fruitTotal = data.treeInfo.fruit; - } else { - console.log(`\n收获金果异常:${JSON.stringify(harvestRes)}`) - } - rs() - // gen.next(); - }) - }) - // request('harvest', data).then((harvestRes) => { - // if (harvestRes.resultCode === 0 && harvestRes.resultData.code === '200') { - // let data = harvestRes.resultData.data; - // message += `【距离${data.treeInfo.level + 1}级摇钱树还差】${data.treeInfo.progressLeft}\n`; - // fruitTotal = data.treeInfo.fruit; - // gen.next(); - // } - // }) -} - -//卖出金果,得到金币 -function sell() { - return new Promise((rs, rj) => { - const params = { - "source": 2, - "jtCount": 7.000000000000001, - "riskDeviceParam": { - "eid": "", - "fp": "", - "sdkToken": "", - "token": "", - "jstub": "", - "appType": 2, - } - } - params.riskDeviceParam = JSON.stringify(params.riskDeviceParam);//这一步,不可省略,否则提交会报错(和login接口一样) - console.log(`目前金果数量${fruitTotal}`) - sellFruit = $.isNode() ? (process.env.MONEY_TREE_SELL_FRUIT ? process.env.MONEY_TREE_SELL_FRUIT : `${sellFruit}`) : ($.getdata('MONEY_TREE_SELL_FRUIT') ? $.getdata('MONEY_TREE_SELL_FRUIT') : `${sellFruit}`); - if (sellFruit && sellFruit === 'false') { - console.log(`\n设置的不卖出金果\n`) - rs() - return - } - if (fruitTotal >= 8000 * 7) { - if (userInfo['jtRest'] === 0) { - console.log(`\n今日已卖出5.6万金果(已达上限),获得0.07金贴\n`) - rs() - return - } - request('sell', params).then((sellRes) => { - if (sellRes && sellRes['resultCode'] === 0) { - if (sellRes['resultData']['code'] === '200') { - if (sellRes['resultData']['data']['sell'] === 0) { - console.log(`卖出金果成功,获得0.07金贴\n`); - allMsg += `账号${$.index}:${$.nickName || $.UserName}\n今日成功卖出5.6万金果,获得0.07金贴${$.index !== cookiesArr.length ? '\n\n' : ''}` - } else { - console.log(`卖出金果失败:${JSON.stringify(sellRes)}\n`) - } - } - } - rs() - }) - } else { - console.log(`当前金果数量不够兑换 0.07金贴\n`); - rs() - } - // request('sell', params).then(response => { - // rs(response); - // }) - }) - // request('sell', params).then((sellRes) => { - // console.log(`卖出金果结果:${JSON.stringify(sellRes)}\n`) - // gen.next(); - // }) -} - -//获取金币和金果数量 -function myWealth() { - return new Promise((resolve) => { - const params = { - "source": 2, - "riskDeviceParam": { - "eid": "", - "dt": "", - "ma": "", - "im": "", - "os": "", - "osv": "", - "ip": "", - "apid": "", - "ia": "", - "uu": "", - "cv": "", - "nt": "", - "at": "1", - "fp": "", - "token": "" - } - } - params.riskDeviceParam = JSON.stringify(params.riskDeviceParam);//这一步,不可省略,否则提交会报错(和login接口一样) - request('myWealth', params).then(res => { - if (res && res.resultCode === 0 && res.resultData.code === '200') { - console.log(`金贴和金果数量::${JSON.stringify(res)}`); - message += `【我的金果数量】${res.resultData.data.gaAmount}\n`; - message += `【我的金贴数量】${res.resultData.data.gcAmount / 100}\n`; - } - resolve(); - }) - }); -} - -function sign() { - console.log('开始三餐签到') - const data = {"source": 2, "workType": 1, "opType": 2}; - return new Promise((rs, rj) => { - request('doWork', data).then(response => { - rs(response); - }) - }) -} - -function signIndex() { - const params = { - "source": 0, - "riskDeviceParam": { - "eid": "", - "dt": "", - "ma": "", - "im": "", - "os": "", - "osv": "", - "ip": "", - "apid": "", - "ia": "", - "uu": "", - "cv": "", - "nt": "", - "at": "1", - "fp": "", - "token": "" - } - } - return new Promise((rs, rj) => { - request('signIndex', params).then(response => { - rs(response); - }) - }) -} - -function signEveryDay() { - return new Promise(async (resolve) => { - try { - let signIndexRes = await signIndex(); - if (signIndexRes.resultCode === 0) { - console.log(`每日签到条件查询:${signIndexRes.resultData.data.canSign === 2 ? '可以签到' : '已经签到过了'}`); - if (signIndexRes.resultData && signIndexRes.resultData.data.canSign == 2) { - console.log('准备每日签到') - let signOneRes = await signOne(signIndexRes.resultData.data.signDay); - console.log(`第${signIndexRes.resultData.data.signDay}日签到结果:${JSON.stringify(signOneRes)}`); - if (signIndexRes.resultData.data.signDay === 7) { - let getSignAwardRes = await getSignAward(); - console.log(`店铺券(49-10)领取结果:${JSON.stringify(getSignAwardRes)}`) - if (getSignAwardRes.resultCode === 0 && getSignAwardRes.data.code === 0) { - message += `【7日签到奖励领取】${getSignAwardRes.datamessage}\n` - } - } - } - } - } catch (e) { - $.logErr(e); - } finally { - resolve() - } - }) -} - -function signOne(signDay) { - const params = { - "source": 0, - "signDay": signDay, - "riskDeviceParam": { - "eid": "", - "dt": "", - "ma": "", - "im": "", - "os": "", - "osv": "", - "ip": "", - "apid": "", - "ia": "", - "uu": "", - "cv": "", - "nt": "", - "at": "1", - "fp": "", - "token": "" - } - } - return new Promise((rs, rj) => { - request('signOne', params).then(response => { - rs(response); - }) - }) -} - -// 领取七日签到后的奖励(店铺优惠券) -function getSignAward() { - const params = { - "source": 2, - "awardType": 2, - "deviceRiskParam": 1, - "riskDeviceParam": { - "eid": "", - "dt": "", - "ma": "", - "im": "", - "os": "", - "osv": "", - "ip": "", - "apid": "", - "ia": "", - "uu": "", - "cv": "", - "nt": "", - "at": "1", - "fp": "", - "token": "" - } - } - return new Promise((rs, rj) => { - request('getSignAward', params).then(response => { - rs(response); - }) - }) -} - -// 浏览任务 -async function setUserLinkStatus(missionId) { - let index = 0; - do { - const params = { - "missionId": missionId, - "pushStatus": 1, - "keyValue": index, - "riskDeviceParam": { - "eid": "", - "dt": "", - "ma": "", - "im": "", - "os": "", - "osv": "", - "ip": "", - "apid": "", - "ia": "", - "uu": "", - "cv": "", - "nt": "", - "at": "1", - "fp": "", - "token": "" - } - } - let response = await request('setUserLinkStatus', params) - console.log(`missionId为${missionId}::第${index + 1}次浏览活动完成: ${JSON.stringify(response)}`); - // if (resultCode === 0) { - // let sportRevardResult = await getSportReward(); - // console.log(`领取遛狗奖励完成: ${JSON.stringify(sportRevardResult)}`); - // } - index++; - } while (index < 7) //不知道结束的条件,目前写死循环7次吧 - console.log('浏览店铺任务结束'); - console.log('开始领取浏览后的奖励'); - let receiveAwardRes = await receiveAward(missionId); - console.log(`领取浏览任务奖励成功:${JSON.stringify(receiveAwardRes)}`) - return new Promise((resolve, reject) => { - resolve(receiveAwardRes); - }) - // gen.next(); -} - -// 领取浏览后的奖励 -function receiveAward(mid) { - if (!mid) return - mid = mid + ""; - const params = { - "source": 0, - "workType": 7, - "opType": 2, - "mid": mid, - "riskDeviceParam": { - "eid": "", - "dt": "", - "ma": "", - "im": "", - "os": "", - "osv": "", - "ip": "", - "apid": "", - "ia": "", - "uu": "", - "cv": "", - "nt": "", - "at": "1", - "fp": "", - "token": "" - } - } - return new Promise((rs, rj) => { - request('doWork', params).then(response => { - rs(response); - }) - }) -} - -function share(data) { - if (data.opType === 1) { - console.log(`开始做分享任务\n`) - } else { - console.log(`开始做领取分享后的奖励\n`) - } - return new Promise((rs, rj) => { - request('doWork', data).then(response => { - rs(response); - }) - }) -} - -async function stealFriendFruit() { - await friendRank(); - if ($.friendRankList && $.friendRankList.length > 0) { - const canSteal = $.friendRankList.some((item) => { - const boxShareCode = item.steal - return (boxShareCode === true); - }); - if (canSteal) { - $.amount = 0; - for (let item of $.friendRankList) { - if (!item.self && item.steal) { - await friendTreeRoom(item.encryPin); - const stealFruitRes = await stealFruit(item.encryPin, $.friendTree.stoleInfo); - if (stealFruitRes && stealFruitRes.resultCode === 0 && stealFruitRes.resultData.code === '200') { - $.amount += stealFruitRes.resultData.data.amount; - } - } - } - message += `【偷取好友金果】共${$.amount}个\n`; - } else { - console.log(`今日已偷过好友的金果了,暂无好友可偷,请明天再来\n`) - } - } else { - console.log(`您暂无好友,故跳过`); - } -} - -//获取好友列表API -async function friendRank() { - await $.wait(1000); //歇口气儿, 不然会报操作频繁 - const params = { - "source": 2, - "riskDeviceParam": { - "eid": "", - "dt": "", - "ma": "", - "im": "", - "os": "", - "osv": "", - "ip": "", - "apid": "", - "ia": "", - "uu": "", - "cv": "", - "nt": "", - "at": "1", - "fp": "", - "token": "" - } - } - params.riskDeviceParam = JSON.stringify(params.riskDeviceParam);//这一步,不可省略,否则提交会报错(和login接口一样) - return new Promise((resolve, reject) => { - $.post(taskurl('friendRank', params), (err, resp, data) => { - try { - if (err) { - console.log("\n摇钱树京东API请求失败 ‼️‼️"); - console.log(JSON.stringify(err)); - $.logErr(err); - } else { - if (data) { - data = JSON.parse(data); - $.friendRankList = data.resultData.data; - } else { - console.log(`京东api返回数据为空,请检查自身原因`) - } - } - } catch (eor) { - $.logErr(eor, err) - } finally { - resolve() - } - }) - }) -} - -// 进入好友房间API -async function friendTreeRoom(friendPin) { - await $.wait(1000); //歇口气儿, 不然会报操作频繁 - const params = { - "source": 2, - "friendPin": friendPin, - "riskDeviceParam": { - "eid": "", - "dt": "", - "ma": "", - "im": "", - "os": "", - "osv": "", - "ip": "", - "apid": "", - "ia": "", - "uu": "", - "cv": "", - "nt": "", - "at": "1", - "fp": "", - "token": "" - } - } - params.riskDeviceParam = JSON.stringify(params.riskDeviceParam);//这一步,不可省略,否则提交会报错(和login接口一样) - return new Promise((resolve, reject) => { - $.post(taskurl('friendTree', params), (err, resp, data) => { - try { - if (err) { - console.log("\n摇钱树京东API请求失败 ‼️‼️"); - console.log(JSON.stringify(err)); - $.logErr(err); - } else { - if (data) { - data = JSON.parse(data); - $.friendTree = data.resultData.data; - } else { - console.log(`京东api返回数据为空,请检查自身原因`) - } - } - } catch (eor) { - $.logErr(eor, err) - } finally { - resolve() - } - }) - }) -} - -//偷好友金果API -async function stealFruit(friendPin, stoleId) { - await $.wait(1000); //歇口气儿, 不然会报操作频繁 - const params = { - "source": 2, - "friendPin": friendPin, - "stoleId": stoleId, - "riskDeviceParam": { - "eid": "", - "dt": "", - "ma": "", - "im": "", - "os": "", - "osv": "", - "ip": "", - "apid": "", - "ia": "", - "uu": "", - "cv": "", - "nt": "", - "at": "1", - "fp": "", - "token": "" - } - } - params.riskDeviceParam = JSON.stringify(params.riskDeviceParam);//这一步,不可省略,否则提交会报错(和login接口一样) - return new Promise((resolve, reject) => { - $.post(taskurl('stealFruit', params), (err, resp, data) => { - try { - if (err) { - console.log("\n摇钱树京东API请求失败 ‼️‼️"); - console.log(JSON.stringify(err)); - $.logErr(err); - } else { - if (data) { - data = JSON.parse(data); - } else { - console.log(`京东api返回数据为空,请检查自身原因`) - } - } - } catch (eor) { - $.logErr(eor, err) - } finally { - resolve(data) - } - }) - }) -} - - -async function request(function_id, body = {}) { - await $.wait(1000); //歇口气儿, 不然会报操作频繁 - return new Promise((resolve, reject) => { - $.post(taskurl(function_id, body), (err, resp, data) => { - try { - if (err) { - console.log("\n摇钱树京东API请求失败 ‼️‼️"); - console.log(JSON.stringify(err)); - $.logErr(err); - } else { - if (data) { - data = JSON.parse(data); - } else { - console.log(`京东api返回数据为空,请检查自身原因`) - } - } - } catch (eor) { - $.msg("摇钱树-初始化个人信息" + eor.name + "‼️", JSON.stringify(eor), eor.message) - } finally { - resolve(data) - } - }) - }) -} - -function taskurl(function_id, body) { - return { - url: JD_API_HOST + '/' + function_id + '?_=' + new Date().getTime() * 1000, - body: `reqData=${function_id === 'harvest' || function_id === 'login' || function_id === 'signIndex' || function_id === 'signOne' || function_id === 'setUserLinkStatus' || function_id === 'dayWork' || function_id === 'getSignAward' || function_id === 'sell' || function_id === 'friendRank' || function_id === 'friendTree' || function_id === 'stealFruit' ? encodeURIComponent(JSON.stringify(body)) : JSON.stringify(body)}`, - headers: { - 'Accept': `application/json`, - 'Origin': `https://uua.jr.jd.com`, - 'Accept-Encoding': `gzip, deflate, br`, - 'Cookie': cookie, - 'Content-Type': `application/x-www-form-urlencoded;charset=UTF-8`, - 'Host': `ms.jr.jd.com`, - 'Connection': `keep-alive`, - 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - 'Referer': `https://uua.jr.jd.com/uc-fe-wxgrowing/moneytree/index`, - 'Accept-Language': `zh-cn` - } - } -} - -function TotalBean() { - return new Promise(async resolve => { - const options = { - "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, - "headers": { - "Accept": "application/json,text/plain, */*", - "Content-Type": "application/x-www-form-urlencoded", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - "Connection": "keep-alive", - "Cookie": cookie, - "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") - } - } - $.post(options, (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (data) { - data = JSON.parse(data); - if (data['retcode'] === 13) { - $.isLogin = false; //cookie过期 - return - } - if (data['retcode'] === 0) { - $.nickName = (data['base'] && data['base'].nickname) || $.UserName; - } else { - $.nickName = $.UserName - } - } else { - console.log(`京东服务器返回空数据`) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function jsonParse(str) { - if (typeof str == "string") { - try { - return JSON.parse(str); - } catch (e) { - console.log(e); - $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') - return []; - } - } -} -// prettier-ignore -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("",`🔔${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)} diff --git a/jd_moneyTree_heip.js b/jd_moneyTree_heip.js deleted file mode 100644 index 33fae2c..0000000 --- a/jd_moneyTree_heip.js +++ /dev/null @@ -1,290 +0,0 @@ -/* - -0-59/30 * * * * jd_moneyTree_heip.js - -*/ -const $ = new Env('京东摇钱树助力'); -const notify = $.isNode() ? require('./sendNotify') : ''; -//Node.js用户请在jdCookie.js处填写京东ck; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; - -//IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], cookie = '', sharePin = ''; -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; -} else { - cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); -} - -const JD_API_HOST = 'https://ms.jr.jd.com/gw/generic/uc/h5/m'; -let userInfo = null, canRun = '', subTitle = ''; -!(async () => { - await requireConfig() - await $.wait(1000); - if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); - } - console.log(`\n****开始获取摇钱树互助码****\n`); - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - await TotalBean(); - 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" }); - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } - message = ''; - subTitle = ''; - await getsharePin(); - await $.wait(1000); - } - } - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) - $.index = i + 1; - $.isLogin = true; - $.canRun = true; - $.nickName = ''; - await TotalBean(); - console.log(`\n****开始【京东账号${$.index}】${$.nickName || $.UserName}****\n`); - message = ''; - subTitle = ''; - await shareCodesFormat(); - await $.wait(1000); - await helpFriends(); - } - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) - -async function helpFriends() { - try { - for (let code of $.newShareCodes) { - console.log(`去助力${code}`) - await help(code) - await $.wait(1000) - if (!$.canRun) { - break; - } - } - } catch (e) { - $.logErr(e) - } -} - -function getsharePin() { - const params = { "sharePin": "", "shareType": 1, "channelLV": "", "source": 2, "riskDeviceParam": { "eid": "", "fp": "", "sdkToken": "", "token": "", "jstub": "", "appType": "2", } } - params.riskDeviceParam = JSON.stringify(params.riskDeviceParam); - return new Promise((resolve, reject) => { - $.post(taskurl('login', params), async (err, resp, data) => { - try { - if (err) { - console.log("\n摇钱树京东API请求失败 ‼️‼️") - console.log(JSON.stringify(err)); - } else { - if (data) { - const res = JSON.parse(data); - if (res && res.resultCode === 0) { - $.isLogin = true; - if (res.resultData.data) { - userInfo = res.resultData.data; - if (userInfo.realName) { - console.log(`【京东账号${$.index}(${$.UserName})的摇钱树好友互助码】${userInfo.sharePin}`); - } else { - $.log(`京东账号${$.index}${$.UserName}运行失败\n此账号未实名认证或者未参与过此活动\n①如未参与活动,请先去京东app参加摇钱树活动\n入口:我的->游戏与互动->查看更多\n②如未实名认证,请进行实名认证`) - } - } - } else { - console.log(`其他情况::${JSON.stringify(res)}`); - } - } else { - console.log(`京东api返回数据为空,请检查自身原因`) - } - } - } catch (eor) { - $.logErr(eor, err) - } finally { - resolve(userInfo) - } - }) - }) -} - -function help(sharePin) { - const params = { "sharePin": sharePin, "shareType": 1, "channelLV": "", "source": 2, "riskDeviceParam": { "eid": "", "fp": "", "sdkToken": "", "token": "", "jstub": "", "appType": "2", } } - params.riskDeviceParam = JSON.stringify(params.riskDeviceParam); - return new Promise((resolve, reject) => { - $.post(taskurl('login', params), async (err, resp, data) => { - try { - if (err) { - console.log("\n摇钱树京东API请求失败 ‼️‼️") - console.log(JSON.stringify(err)); - } else { - if (data) { - const res = JSON.parse(data); - if (res && res.resultCode === 0) { - $.isLogin = true; - if (res.resultData.data) { - userInfo = res.resultData.data; - console.log(res.resultData.msg); - if (userInfo.realName) { - } else { - $.canRun = false; - $.log(`京东账号${$.index}${$.UserName}运行失败\n此账号未实名认证或者未参与过此活动\n①如未参与活动,请先去京东app参加摇钱树活动\n入口:我的->游戏与互动->查看更多\n②如未实名认证,请进行实名认证`) - } - } - } else { - console.log(`其他情况::${JSON.stringify(res)}`); - } - } else { - console.log(`京东api返回数据为空,请检查自身原因`) - } - } - } catch (eor) { - $.logErr(eor, err) - } finally { - resolve(userInfo) - } - }) - }) -} - -function taskurl(function_id, body) { - return { - url: JD_API_HOST + '/' + function_id + '?_=' + new Date().getTime() * 1000, - body: `reqData=${function_id === 'login' || function_id === 'signIndex' ? encodeURIComponent(JSON.stringify(body)) : JSON.stringify(body)}`, - headers: { - 'Accept': `application/json`, - 'Origin': `https://uua.jr.jd.com`, - 'Accept-Encoding': `gzip, deflate, br`, - 'Cookie': cookie, - 'Content-Type': `application/x-www-form-urlencoded;charset=UTF-8`, - 'Host': `ms.jr.jd.com`, - 'Connection': `keep-alive`, - 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - 'Referer': `https://uua.jr.jd.com/uc-fe-wxgrowing/moneytree/index`, - 'Accept-Language': `zh-cn` - } - } -} - -function requireConfig() { - return new Promise(resolve => { - console.log(`开始获取${$.name}配置文件\n`); - //Node.js用户请在jdCookie.js处填写京东ck; - let shareCodes = [] - console.log(`共${cookiesArr.length}个京东账号\n`); - $.shareCodesArr = []; - if ($.isNode()) { - //自定义助力码 - if (process.env.MONEYTREE_SHARECODES) { - if (process.env.MONEYTREE_SHARECODES.indexOf('\n') > -1) { - shareCodes = process.env.MONEYTREE_SHARECODES.split('\n'); - } else { - shareCodes = process.env.MONEYTREE_SHARECODES.split('&'); - } - } - Object.keys(shareCodes).forEach((item) => { - if (shareCodes[item]) { - $.shareCodesArr.push(shareCodes[item]) - } - }) - } - console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); - resolve() - }) -} - -function shareCodesFormat() { - return new Promise(async resolve => { - $.newShareCodes = []; - let inviteCodes = [ - '' - ]; - if ($.shareCodesArr[$.index - 1]) { - $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); - } else { - console.log(`由于您第${$.index}个京东账号未提供shareCode,将为本脚本作者【zero205】助力\n`) - const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); - $.newShareCodes = inviteCodes[tempIndex].split('@'); - } - console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) - resolve(); - }) -} - -function TotalBean() { - return new Promise(async resolve => { - const options = { - "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, - "headers": { - "Accept": "application/json,text/plain, */*", - "Content-Type": "application/x-www-form-urlencoded", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - "Connection": "keep-alive", - "Cookie": cookie, - "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") - } - } - $.post(options, (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (data) { - data = JSON.parse(data); - if (data['retcode'] === 13) { - $.isLogin = false; //cookie过期 - return - } - if (data['retcode'] === 0) { - $.nickName = (data['base'] && data['base'].nickname) || $.UserName; - } else { - $.nickName = $.UserName - } - } else { - console.log(`京东服务器返回空数据`) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function jsonParse(str) { - if (typeof str == "string") { - try { - return JSON.parse(str); - } catch (e) { - console.log(e); - $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') - return []; - } - } -} -// prettier-ignore -function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); "undefined" != typeof process && JSON.stringify(process.env.JD_COOKIE).indexOf("jd_4685b2157f874") > -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 diff --git a/jd_tyt_ks.js b/jd_tyt_ks.js deleted file mode 100644 index 384c49d..0000000 --- a/jd_tyt_ks.js +++ /dev/null @@ -1,556 +0,0 @@ -/* -分享到QQ查看邀请码 packetId就是 -#自定义变量 -export tytpacketId="" - [task_local] -#推一推助力码 -0 0 * * * jd_tyt.js, tag=推一推, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true -注意:助力码每天会变,旧的不可用。 -助力逻辑:优先助力互助码变量 -入口-极速版-推推赚大钱 5元无门槛卷 大概需要50人助力 -*/ -const $ = new Env('推推赚大钱-快速'); -const notify = $.isNode() ? require('./sendNotify') : ''; -//Node.js用户请在jdCookie.js处填写京东ck; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -const ua = `jdltapp;iPhone;3.1.0;${Math.ceil(Math.random()*4+10)}.${Math.ceil(Math.random()*4)};${randomString(40)}` -var status = 0 - -//IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], - cookie = '', - message; -let tytpacketId = ''; -if (process.env.tytpacketId) { - tytpacketId = process.env.tytpacketId; -} -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - // if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; -} else { - cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); -} -const JD_API_HOST = 'https://api.m.jd.com/client.action'; - -!(async() => { - if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { - "open-url": "https://bean.m.jd.com/bean/signIndex.action" - }); - return; - } - console.log("推一推开始") - for (let i = cookiesArr.length - 1; i > 0; i--) { - if (cookiesArr[i]) { - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - message = ''; - 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" - }); - - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } - if (status == 1) { - break - } - await tythelp() - await $.wait(15000) - } - } - console.log("推一推结束") -})() -.catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) - -function tythelp() { - return new Promise(async(resolve) => { - let options = { - url: `https://api.m.jd.com/?t=1623066557140`, - - body: `functionId=helpCoinDozer&appid=station-soa-h5&client=H5&clientVersion=1.0.0&t=1623120183787&body={"actId":"3075b6eab065464dad1c4042d345ac97","channel":"coin_dozer","antiToken":"","referer":"-1","frontendInitStatus":"s","packetId":"${tytpacketId}","helperStatus":"0"}&_ste=1&_stk=appid,body,client,clientVersion,functionId,t&h5st=20210608104303790;8489907903583162;10005;tk01w89681aa9a8nZDdIanIyWnVuWFLK4gnqY+05WKcPY3NWU2dcfa73B7PBM7ufJEN0U+4MyHW5N2mT/RNMq72ycJxH;7e6b956f1a8a71b269a0038bbb4abd24bcfb834a88910818cf1bdfc55b7b96e5`, - headers: { - "Origin": "https://pushgold.jd.com", - "Host": "api.m.jd.com", - "Accept": "application/json, text/plain, */*", - "User-Agent": ua, - "Cookie": cookie, - } - } - - $.post(options, async(err, resp, data) => { - try { - data = JSON.parse(data); - - if (data.code == 0) { - console.log("帮砍:" + data.data.amount) - - } else if (data.msg.indexOf("完成") != -1) { - console.log("已完成砍价") - status = 1 - } else { - if (data.msg !== "need verify"){ - console.log(data.msg) - } - console.log(data.msg) - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - }); - }); -} - -function randomString(e) { - e = e || 32; - let t = "abcdefhijkmnprstwxyz2345678", - a = t.length, - n = ""; - for (i = 0; i < e; i++) - n += t.charAt(Math.floor(Math.random() * a)); - return n -} -async function taskPostUrl(functionId, body) { - return { - url: `${JD_API_HOST}`, - body: `functionId=${functionId}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&appid=content_ecology&uuid=6898c30638c55142969304c8e2167997fa59eb54&t=1622588448365`, - headers: { - 'Cookie': cookie, - 'Host': 'api.m.jd.com', - 'Connection': 'keep-alive', - 'Content-Type': 'application/x-www-form-urlencoded', - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - 'Accept-Language': 'zh-cn', - 'Accept-Encoding': 'gzip, deflate, br', - } - } -} - - -async function TotalBean() { - return new Promise(async resolve => { - const options = { - "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, - "headers": { - "Accept": "application/json,text/plain, */*", - "Content-Type": "application/x-www-form-urlencoded", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - "Connection": "keep-alive", - "Cookie": cookie, - "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") - } - } - $.post(options, (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (data) { - data = JSON.parse(data); - if (data["retcode"] === 13) { - $.isLogin = false; //cookie过期 - return; - } - if (data["retcode"] === 0) { - $.nickName = (data["base"] && data["base"].nickname) || $.UserName; - } else { - $.nickName = $.UserName; - } - } else { - console.log(`京东服务器返回空数据`) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} -async function safeGet(data) { - try { - if (typeof JSON.parse(data) == "object") { - return true; - } - } catch (e) { - console.log(e); - console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); - return false; - } -} - -function jsonParse(str) { - if (typeof str == "string") { - try { - return JSON.parse(str); - } catch (e) { - console.log(e); - $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') - return []; - } - } -} -// 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 diff --git a/jx_aid_cashback.js b/jx_aid_cashback.js deleted file mode 100644 index cb68b0d..0000000 --- a/jx_aid_cashback.js +++ /dev/null @@ -1,49 +0,0 @@ -let common = require("./function/common"); -let $ = new common.env('京喜购物返红包助力'); -let min = 5, - help = $.config[$.filename(__filename)] || Math.min(min, $.config.JdMain) || min; -$.setOptions({ - headers: { - 'content-type': 'application/json', - 'user-agent': 'jdapp;iPhone;9.4.6;14.2;965af808880443e4c1306a54afdd5d5ae771de46;network/wifi;supportApplePay/0;hasUPPay/0;hasOCPay/0;model/iPhone8,4;addressid/;supportBestPay/0;appBuild/167618;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', - 'referer': 'https://happy.m.jd.com/babelDiy/Zeus/3ugedFa7yA6NhxLN5gw2L3PF9sQC/index.html?asid=287215626&un_area=12_904_905_57901&lng=117.612969135975&lat=23.94014745198865', - } -}); -$.readme = ` -在京喜下单,如订单有购物返现,脚本会自动查询返现groupid并予以助力,目前每个账号每天能助力3次 -44 */6 * * * task ${$.runfile} -export ${$.runfile}=2 #如需增加被助力账号,在这边修改人数 -` -eval(common.eval.mainEval($)); -async function prepare() { - let url = `https://wq.jd.com/bases/orderlist/list?order_type=3&start_page=1&last_page=0&page_size=10&callersource=newbiz&t=${$.timestamp}&traceid=&g_ty=ls&g_tk=606717070` - for (let j of cookies['help']) { - $.setCookie(j); - await $.curl(url) - try { - for (let k of $.source.orderList) { - try { - let orderid = k.parentId != '0' ? k.parentId : k.orderId - let url = `https://wq.jd.com/fanxianzl/zhuli/QueryGroupDetail?isquerydraw=1&orderid=${orderid}&groupid=&sceneval=2&g_login_type=1&g_ty=ls` - let dec = await jxAlgo.dec(url) - await $.curl(dec.url) - let now = parseInt(new Date() / 1000) - let end = $.source.data.groupinfo.end_time - if (end > now && $.source.data.groupinfo.openhongbaosum != $.source.data.groupinfo.totalhongbaosum) { - let groupid = $.source.data.groupinfo.groupid; - $.sharecode.push({ - 'groupid': groupid - }) - } - } catch (e) {} - } - } catch (e) {} - } -} -async function main(id) { - common.assert(id.groupid, '没有可助力ID') - let url = `http://wq.jd.com/fanxianzl/zhuli/Help?groupid=${id.groupid}&_stk=groupid&_ste=2&g_ty=ls&g_tk=1710198667&sceneval=2&g_login_type=1` - let dec = await jxAlgo.dec(url) - await $.curl(dec.url) - console.log($.source.data.prize.discount) -}