diff --git a/jd_fans.js b/jd_fans.js index 3cfef1d..4bd539e 100644 --- a/jd_fans.js +++ b/jd_fans.js @@ -8,8 +8,8 @@ //活动列表 let activityList = [ - { 'id': '56881c929e5f4918aec928b3dbc56620', 'endTime': 1664553606000 }, - { 'id': '2d52f30124b041808e68e8a470ce0ef7', 'endTime': 1666025778000 }, + { 'id': "6db6851a9cd14261badf3645515bad22", 'endTime': 1669824000000 }, + { 'id': "2b793b802aec4bc49f0358dbad059087", 'endTime': 1671811200000 }, ]; const $ = new Env('粉丝互动-加密'); diff --git a/jd_lzkjInteract.py b/jd_lzkjInteract.py new file mode 100644 index 0000000..d12db48 --- /dev/null +++ b/jd_lzkjInteract.py @@ -0,0 +1,643 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +""" +File: jd_lzkjInteract.py(jd_lzkjInteract邀请有礼) +Author: HarbourJ +Date: 2022/11/24 10:00 +TG: https://t.me/HarbourToulu +TgChat: https://t.me/HarbourChat +cron: 1 1 1 1 1 1 +new Env('jd_lzkjInteract邀请有礼'); +ActivityEntry: https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10006&activityId=1595256546199793665&templateId=20201228083300yqrhyl011&nodeId=101001005&prd=cjwx +Description: 邀请xx人xx豆,自动助力,自动领奖,‼️该活动部分类型 有且仅能领取一次奖励,默认领最高档豆🎁,或者手动领取 + 变量:export jd_lzkjInteractId="活动🆔" #活动链接中的activityId参数 + export jd_lzkjInteractUserId="你的shareUserId邀请码" +""" + +import time, requests, sys, re, os, json, random +from datetime import datetime +from urllib.parse import quote_plus, unquote_plus +from functools import partial +from sendNotify import * +print = partial(print, flush=True) +import warnings +warnings.filterwarnings("ignore", category=DeprecationWarning) +try: + from jd_sign import * +except ImportError as e: + print(e) + if "No module" in str(e): + print("请先运行HarbourJ库依赖一键安装脚本(jd_check_dependent.py),安装jd_sign.so依赖") +try: + from jdCookie import get_cookies + getCk = get_cookies() +except: + print("请先下载依赖脚本,\n下载链接: https://raw.githubusercontent.com/HarbourJ/HarbourToulu/main/jdCookie.py") + sys.exit(3) + +redis_url = os.environ.get("redis_url") if os.environ.get("redis_url") else "172.17.0.1" +redis_port = os.environ.get("redis_port") if os.environ.get("redis_port") else "6379" +redis_pwd = os.environ.get("redis_pwd") if os.environ.get("redis_pwd") else "" +activityId = os.environ.get("jd_lzkjInteractId") if os.environ.get("jd_lzkjInteractId") else "" +share_userId = os.environ.get("jd_lzkjInteractUserId") if os.environ.get("jd_lzkjInteractUserId") else "" + +if not activityId: + print("⚠️未发现有效活动变量jd_lzkjInteractId,退出程序!") + sys.exit() + +templateId = "20201228083300yqrhyl011" +activity_url = f"https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10006&activityId={activityId}&shareUserId={share_userId}&templateId={templateId}&nodeId=101001005&prd=null&sid=c77e8b335974724742827d7c42f951cw&un_area=12_1212_11111_22222" +print(f"【🛳活动入口】{activity_url}") + +def redis_conn(): + try: + import redis + try: + pool = redis.ConnectionPool(host=redis_url, port=6379, decode_responses=True, socket_connect_timeout=5, password=redis_pwd) + r = redis.Redis(connection_pool=pool) + r.get('conn_test') + print('✅redis连接成功') + return r + except: + print("⚠️redis连接异常") + except: + print("⚠️缺少redis依赖,请运行pip3 install redis") + sys.exit() + +def getToken(ck, r=None): + host = f'{activityUrl.split("com/")[0]}com' + try: + # redis缓存Token 活动域名+pt_pin + pt_pin = unquote_plus(re.compile(r'pt_pin=(.*?);').findall(ck)[0]) + except: + # redis缓存Token 活动域名+ck前7位(获取pin失败) + pt_pin = ck[:15] + try: + if r is not None: + Token = r.get(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}') + # print("Token过期时间", r.ttl(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}')) + if Token is not None: + print(f"♻️获取缓存Token") + return Token + else: + # print("🈳去设置Token缓存") + s.headers = { + 'Connection': 'keep-alive', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', + 'User-Agent': '', + 'Cookie': ck, + 'Host': 'api.m.jd.com', + 'Referer': '', + 'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9', + 'Accept': '*/*' + } + sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator') + # print(sign_txt) + f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30) + if f.status_code != 200: + print(f.status_code) + return + else: + if "参数异常" in f.text: + return + Token_new = f.json()['token'] + # print(f"Token->: {Token_new}") + if r.set(f'{activityUrl.split("https://")[1].split("-")[0]}_{pt_pin}', Token_new, ex=1800): + print("✅Token缓存成功") + else: + print("❌Token缓存失败") + return Token_new + else: + s.headers = { + 'Connection': 'keep-alive', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', + 'User-Agent': '', + 'Cookie': ck, + 'Host': 'api.m.jd.com', + 'Referer': '', + 'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9', + 'Accept': '*/*' + } + sign_txt = sign({"url": f"{host}", "id": ""}, 'isvObfuscator') + # print(sign_txt) + f = s.post('https://api.m.jd.com/client.action', verify=False, timeout=30) + if f.status_code != 200: + print(f.status_code) + return + else: + if "参数异常" in f.text: + return + Token = f.json()['token'] + print(f"✅获取实时Token") + return Token + except: + return + +def getJdTime(): + jdTime = int(round(time.time() * 1000)) + return jdTime + +def randomString(e, flag=False): + t = "0123456789abcdef" + if flag: t = t.upper() + n = [random.choice(t) for _ in range(e)] + return ''.join(n) + +def check(ck): + try: + url = 'https://me-api.jd.com/user_new/info/GetJDUserInfoUnion' + header = { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": ck, + "User-Agent": ua, + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate", + } + result = requests.get(url=url, headers=header).text + codestate = json.loads(result) + if codestate['retcode'] == '1001': + msg = "当前ck已失效,请检查" + return {'code': 1001, 'data': msg} + elif codestate['retcode'] == '0' and 'userInfo' in codestate['data']: + nickName = codestate['data']['userInfo']['baseInfo']['nickname'] + return {'code': 200, 'name': nickName, 'ck': cookie} + except Exception as e: + return {'code': 0, 'data': e} + +def getActivity(): + url = activityUrl + headers = { + 'Host': 'lzkj-isv.isvjcloud.com', + 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'User-Agent': ua, + 'Accept-Language': 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'Connection': 'keep-alive' + } + response = requests.request("GET", url, headers=headers) + if response.status_code != 200: + print(response.status_code, "⚠️ip疑似黑了,休息一会再来撸~") + sys.exit() + +def getUserInfo(shareUserId): + url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/user-info/login" + body = { + "status": "0", + "activityId": activityId, + "source": "01", + "tokenPin": token, + "shareUserId": shareUserId + } + headers = { + 'Host': 'lzkj-isv.isvjcloud.com', + 'Accept': 'application/json, text/plain, */*', + 'Accept-Language': 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'token': '', + 'Content-Type': 'application/json;charset=UTF-8', + 'Origin': 'https://lzkj-isv.isvjcloud.com', + 'User-Agent': ua, + 'Connection': 'keep-alive', + 'Referer': activityUrl, + 'Cookie': f'IsvToken={token};' + } + response = requests.request("POST", url, headers=headers, data=json.dumps(body)) + if response.status_code == 200: + res = response.json() + if res['data']: + return res['data'] + else: + print(res) + else: + print(response.status_code, "⚠️ip疑似黑了,休息一会再来撸~") + sys.exit() + +def guestMyself(Token, shareUserId): + url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/task/bargain/guest/myself" + body = { + "shareUserId": shareUserId + } + headers = { + 'Host': 'lzkj-isv.isvjcloud.com', + 'Accept': 'application/json, text/plain, */*', + 'Accept-Language': 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'token': Token, + 'Content-Type': 'application/json;charset=UTF-8', + 'Origin': 'https://lzkj-isv.isvjcloud.com', + 'User-Agent': ua, + 'Connection': 'keep-alive', + 'Referer': activityUrl + } + requests.post(url, headers=headers, data=json.dumps(body)) + +def getMember(Token, shareUserId): + url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/task/member/getMember" + body = { + "shareUserId": shareUserId + } + headers = { + 'Host': 'lzkj-isv.isvjcloud.com', + 'Accept': 'application/json, text/plain, */*', + 'Accept-Language': 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'token': Token, + 'Content-Type': 'application/json;charset=UTF-8', + 'Origin': 'https://lzkj-isv.isvjcloud.com', + 'User-Agent': ua, + 'Connection': 'keep-alive', + 'Referer': activityUrl + } + response = requests.post(url, headers=headers, data=json.dumps(body)) + try: + res = response.json() + inviteNum = res['data']['shareUser'] + return inviteNum + except Exception as e: + print(str(e)) + return False + +def prizeList(Token): + url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/task/member/prizeList" + body = {} + headers = { + 'Host': 'lzkj-isv.isvjcloud.com', + 'Accept': 'application/json, text/plain, */*', + 'Accept-Language': 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'token': Token, + 'Content-Type': 'application/json;charset=UTF-8', + 'Origin': 'https://lzkj-isv.isvjcloud.com', + 'User-Agent': ua, + 'Connection': 'keep-alive', + 'Referer': activityUrl + } + response = requests.post(url, headers=headers, data=json.dumps(body)) + try: + return response.json() + except: + return False + +def joinCheck(Token): + url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/join/check" + body = { + "status": "0" + } + headers = { + 'Host': 'lzkj-isv.isvjcloud.com', + 'Accept': 'application/json, text/plain, */*', + 'Accept-Language': 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'token': Token, + 'Content-Type': 'application/json;charset=UTF-8', + 'Origin': 'https://lzkj-isv.isvjcloud.com', + 'User-Agent': ua, + 'Connection': 'keep-alive', + 'Referer': activityUrl + } + response = requests.post(url, headers=headers, data=json.dumps(body)) + try: + return response.json() + except: + return False + +def getUserId(Token): + url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/task/share/getUserId" + body = {} + headers = { + 'Host': 'lzkj-isv.isvjcloud.com', + 'Accept': 'application/json, text/plain, */*', + 'Accept-Language': 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'token': Token, + 'Content-Type': 'application/json;charset=UTF-8', + 'Origin': 'https://lzkj-isv.isvjcloud.com', + 'User-Agent': ua, + 'Connection': 'keep-alive', + 'Referer': activityUrl + } + response = requests.post(url, headers=headers, data=json.dumps(body)) + try: + return response.json()['data']['shareUserId'] + except Exception as e: + print(str(e)) + +def receiveAcquire(Token, id): + url = "https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/api/prize/receive/acquire" + body = { + "prizeInfoId": id, + "status": 1 + } + headers = { + 'Host': 'lzkj-isv.isvjcloud.com', + 'Accept': 'application/json, text/plain, */*', + 'Accept-Language': 'zh-CN,zh-Hans;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'token': Token, + 'Content-Type': 'application/json;charset=UTF-8', + 'Origin': 'https://lzkj-isv.isvjcloud.com', + 'User-Agent': ua, + 'Connection': 'keep-alive', + 'Referer': activityUrl + } + response = requests.post(url, headers=headers, data=json.dumps(body)) + try: + return response.json()['resp_code'] + except: + print(response.text) + return False + +def bindWithVender(cookie, venderId): + try: + s.headers = { + 'Connection': 'keep-alive', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', + 'User-Agent': ua, + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Referer': 'https://shopmember.m.jd.com/', + 'Accept-Language': 'zh-Hans-CN;q=1 en-CN;q=0.9', + 'Accept': '*/*' + } + s.params = { + 'appid': 'jd_shop_member', + 'functionId': 'bindWithVender', + 'body': json.dumps({ + 'venderId': venderId, + 'shopId': venderId, + 'bindByVerifyCodeFlag': 1 + }, separators=(',', ':')) + } + res = s.post('https://api.m.jd.com/', verify=False, timeout=30).json() + if res['success']: + return res['message'] + except Exception as e: + print(e) + +def getShopOpenCardInfo(cookie, venderId): + shopcard_url = f"https://shopmember.m.jd.com/shopcard/?venderId={venderId}&channel=401&returnUrl={quote_plus(activityUrl)}" + try: + body = {"venderId": str(venderId), "channel": "8019006"} + url = f'https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body={json.dumps(body)}&client=H5&clientVersion=9.2.0&uuid=88888' + headers = { + 'Host': 'api.m.jd.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'Cookie': cookie, + 'User-Agent': ua, + 'Accept-Language': 'zh-cn', + 'Referer': shopcard_url, + 'Accept-Encoding': 'gzip, deflate' + } + response = requests.get(url=url, headers=headers, timeout=5).text + res = json.loads(response) + if res['success']: + venderCardName = res['result']['shopMemberCardInfo']['venderCardName'] + openCardStatus = res['result']['userInfo']['openCardStatus'] + return venderCardName, openCardStatus + else: + return False, 1 + except: + return False, 1 + + +if __name__ == '__main__': + r = redis_conn() + try: + cks = getCk + if not cks: + sys.exit() + except: + print("未获取到有效COOKIE,退出程序!") + sys.exit() + global shareUuid, inviteSuccNum, activityUrl, firstCk, MSG + inviteSuccNum = 0 + MSG = '' + title = "🗣消息提醒:lzkjInteract邀请有礼" + if len(cks) == 1: + shareUserId = share_userId + activityUrl = activity_url + else: + try: + shareUserId = remote_redis(f"lzkj_{activityId}", 2) + activityUrl = f"https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10006&activityId={activityId}&shareUserId={shareUserId}&templateId={templateId}&nodeId=101001005&prd=null&sid=c77e8b335974724742827d7c42f951cw&un_area=12_1212_11111_22222" + except: + shareUserId = share_userId + activityUrl = activity_url + num = 0 + for cookie in cks[:]: + num += 1 + if num == 1: + firstCk = cookie + if num % 5 == 0: + print("⏰等待5s,休息一下") + time.sleep(5) + global ua, token + ua = userAgent() + try: + pt_pin = re.compile(r'pt_pin=(.*?);').findall(cookie)[0] + pt_pin = unquote_plus(pt_pin) + except IndexError: + pt_pin = f'用户{num}' + print(f'\n******开始【京东账号{num}】{pt_pin} *********\n') + print(datetime.now()) + + result = check(cookie) + if result['code'] != 200: + print(f"⚠️当前CK失效!跳过") + continue + token = getToken(cookie, r) + if token is None: + if num == 1: + print(f"⚠️车头获取Token失败,退出本程序!") + sys.exit() + print(f"⚠️获取Token失败!⏰等待3s") + time.sleep(3) + continue + time.sleep(0.5) + getActivity() + time.sleep(0.5) + userInfo = getUserInfo(shareUserId) + if not userInfo: + if num == 1: + print('⚠️无法获取userInfo,退出本程序!') + sys.exit() + time.sleep(2) + continue + shopId = userInfo['shopId'] + Token = userInfo['token'] + shopName = userInfo['shopName'] + actName = userInfo['actName'] + joinCodeInfo = userInfo['joinInfo']['joinCodeInfo'] + customerId = userInfo['customerId'] + time.sleep(0.3) + guestMyself(Token, shareUserId) + time.sleep(0.3) + + if num == 1: + print(f"✅ 开启【{actName}】活动") + print(f"店铺名称:{shopName} {shopId}") + MSG += f'✅账号[{pt_pin}] 开启{actName}活动\n📝活动地址 {activityUrl.split("&sid=")[0]}\n' + if shareUserId: + print(f"CK1准备助力【{shareUserId}】") + else: + print(f"未填写助力码,CK1准备助力💨") + if joinCodeInfo['joinDes'] != '不是会员无法参加': + print("已经是会员,助力失败!") + joinCheck(Token) + time.sleep(0.2) + inviteNum = getMember(Token, shareUserId) + time.sleep(0.2) + inviteSuccNum = inviteNum # 接口显示已邀请人数 + print(f"🧑🤝🧑 CK1已邀请{inviteNum}人\n") + time.sleep(0.2) + prizeListResponse = prizeList(Token) + prizeListRecord = [] + prizeNameList = [] + receiveIndex = 0 + index = 0 + try: + for prizeitem in prizeListResponse['data']['prizeInfo']: + index += 1 + print(f"🎁 奖品: {prizeitem['prizeName']}, 助力人数: {prizeitem['days']}, 总数:{prizeitem['allNum']}, 剩余:{prizeitem['leftNum']}, ID: {prizeitem['id']}") + prizeNameList.append(f"🎁奖品:{prizeitem['prizeName']},助力人数:{prizeitem['days']},总数:{prizeitem['allNum']},剩余:{prizeitem['leftNum']}\n") + if prizeitem['leftNum'] > 0: + prizeListRecord.append((prizeitem['prizeName'], prizeitem['days'], prizeitem['id'])) + if "京豆" in prizeitem['prizeName']: + receiveIndex += 1 + MSG += f"🎁当前活动奖品如下: \n{str(''.join(prizeNameList))}\n" + print(f"‼️该活动部分有且仅能领取一次奖励,默认自动领最高档豆🎁,或者手动领取\n") + except: + print('⚠️无法获取奖品列表, 退出本程序!') + sys.exit() + if prizeListRecord == []: + print('⚠️无奖品可领, 退出本程序!') + sys.exit() + if receiveIndex < 1: + receiveIndex = index + for prizeinfo in prizeListRecord[receiveIndex-1:receiveIndex]: + if inviteSuccNum >= prizeinfo[1]: + print(f'已达到领取条件, 开始领取 {prizeinfo[0]}') + receive_result = receiveAcquire(Token, prizeinfo[2]) + if receive_result == 0: + print(f'🎉🎉 领取奖励成功') + MSG += f"🎉成功领取 {prizeinfo[0]}\n" + elif receive_result == 60002: + print(f'🎉🎉 奖励已经领取过') + MSG += f"🎉已经领取过 {prizeinfo[0]}\n" + elif receive_result == 60009: + print(f'🎉🎉 奖励已经领取过其他奖励或未达到领取标准建议手动领取!') + MSG += f"🎉奖励已经领取过其他奖励或未达到领取标准建议手动领取 {prizeinfo[0]}\n" + else: + print(f'💥💥 领取奖励失败') + MSG += f"💥💥 领取奖励失败 {prizeinfo[0]}\n" + time.sleep(1.5) + if inviteSuccNum >= prizeListRecord[receiveIndex-1][1]: + print("奖励已领完") + MSG += f"🤖奖励已领完\n" + if len(cks) > 1: + send(title, MSG) + sys.exit() + actorUuid = getUserId(Token) + time.sleep(0.3) + if not actorUuid: + if num == 1: + print(f'⚠️ 无法获取车头邀请码, 退出本程序!') + sys.exit() + print(f"\n后面账号全部助力 {actorUuid}") + shareUserId = actorUuid + activityUrl = f"https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10006&activityId={activityId}&shareUserId={shareUserId}&templateId={templateId}&nodeId=101001005&prd=null&sid=c77e8b335974724742827d7c42f951cw&un_area=12_1212_11111_22222" + continue + else: + inviteSuccNum = 0 + + if joinCodeInfo['joinDes'] == '不是会员无法参加': + print(f"未开卡 现在去开卡") + open_result = bindWithVender(cookie, shopId) + if open_result is not None: + if "火爆" in open_result or "失败" in open_result or "解绑" in open_result: + print(f"\t💥💥 {open_result}\n‼️助力失败") + continue + else: + print(f"\t🎉🎉 {open_result}") + if num != 1: + inviteSuccNum += 1 + print(f"🛳已经邀请{inviteSuccNum}人") + time.sleep(0.3) + joinCheck(Token) + time.sleep(0.3) + getMember(Token, shareUserId) + time.sleep(0.3) + prizeListResponse = prizeList(Token) + prizeListRecord = [] + prizeNameList = [] + receiveIndex = 0 + index = 0 + try: + for prizeitem in prizeListResponse['data']['prizeInfo']: + index += 1 + if num == 1: + print(f"🎁 奖品: {prizeitem['prizeName']}, 助力人数: {prizeitem['days']}, 总数:{prizeitem['allNum']}, 剩余:{prizeitem['leftNum']}, ID: {prizeitem['id']}") + prizeNameList.append(f"🎁奖品:{prizeitem['prizeName']},助力人数:{prizeitem['days']},总数:{prizeitem['allNum']},剩余:{prizeitem['leftNum']}\n") + if prizeitem['leftNum'] > 0: + prizeListRecord.append((prizeitem['prizeName'], prizeitem['days'], prizeitem['id'])) + if "京豆" in prizeitem['prizeName']: + receiveIndex += 1 + if prizeNameList: + MSG += f"🎁当前活动奖品如下: \n{str(''.join(prizeNameList))}\n" + print(f"‼️该活动部分有且仅能领取一次奖励,默认自动领最高档豆🎁,或者手动领取\n") + except: + print('⚠️无法获取奖品列表, 退出本程序!') + sys.exit() + if prizeListRecord == []: + print('⚠️无奖品可领, 退出本程序!') + sys.exit() + for prizeinfo in prizeListRecord[receiveIndex - 1:receiveIndex]: + if inviteSuccNum >= prizeinfo[1]: + print(f'CK1已达到领取条件, 开始领取 {prizeinfo[0]}') + time.sleep(0.2) + token = getToken(firstCk, r) + time.sleep(0.2) + getActivity() + time.sleep(0.2) + Token0 = getUserInfo(shareUserId)['token'] + receive_result = receiveAcquire(Token0, prizeinfo[2]) + if receive_result == 0: + print(f'🎉🎉 领取奖励成功') + MSG += f"🎉成功领取 {prizeinfo[0]}\n" + elif receive_result == 60002: + print(f'🎉🎉 奖励已经领取过') + MSG += f"🎉已经领取过 {prizeinfo[0]}\n" + elif receive_result == 60009: + print(f'🎉🎉 奖励已经领取过其他奖励或未达到领取标准建议手动领取!') + MSG += f"🎉奖励已经领取过其他奖励或未达到领取标准建议手动领取 {prizeinfo[0]}\n" + else: + print(f'💥💥 领取奖励失败') + MSG += f"💥💥 领取奖励失败 {prizeinfo[0]}\n" + time.sleep(1.5) + if inviteSuccNum >= prizeListRecord[receiveIndex - 1][1]: + print("🤖奖励已领完") + MSG += f"🤖奖励已领完\n" + if len(cks) > 1: + send(title, MSG) + sys.exit() + time.sleep(0.3) + if num == 1: + actorUuid = getUserId(Token) + if not actorUuid: + print(f'⚠️无法获取车头邀请码, 退出本程序!') + sys.exit() + print(f"后面账号全部助力 {actorUuid}") + shareUserId = actorUuid + activityUrl = f"https://lzkj-isv.isvjcloud.com/prod/cc/interactsaas/index?activityType=10006&activityId={activityId}&shareUserId={shareUserId}&templateId={templateId}&nodeId=101001005&prd=null&sid=c77e8b335974724742827d7c42f951cw&un_area=12_1212_11111_22222" + else: + print(f"⛈已开卡,无法完成助力") + + time.sleep(2) diff --git a/jd_tanwei.js b/jd_tanwei.js new file mode 100644 index 0000000..8b271a4 --- /dev/null +++ b/jd_tanwei.js @@ -0,0 +1,253 @@ + +/* +探味奇遇记 +35 20 * * * https://raw.githubusercontent.com/6dylan6/jdpro/main/jd_tanwei.js + */ + +const $ = new Env('探味奇遇记'); +const notify = $.isNode() ? require('./sendNotify') : ''; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message = ''; +let encryptProjectId = '3HA2DP3nNTXrHQjpfMFSQM2whztd'; +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; + } + 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 + } + await twqyj(); + await $.wait(1000) + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function twqyj() { + try { + let tk = await queryInteractiveInfo(); + for (let key of Object.keys(tk.assignmentList).reverse()){ + let vo = tk.assignmentList[key] + if (vo.completionFlag && vo.assignmentType != 30) { + console.log('此任务已完成') + } else if (new Date(vo.assignmentStartTime).getTime() > Date.now()) { + console.log('此任务还没到开放时间:',vo.assignmentStartTime) + } else if (vo.assignmentType == 30) { + await dotask(encryptProjectId,vo.encryptAssignmentId,{"ext":{"exchangeNum":1}}) + } else { + if (vo.ext && vo.ext.extraType == 'sign1') { + await sign(encryptProjectId,vo.encryptAssignmentId) + } else { + await dotask(encryptProjectId,vo.encryptAssignmentId) + } + } + await $.wait(1000) + } + } catch (e) { + $.logErr(e) + } + +} + +async function queryInteractiveInfo() { + return new Promise(async (resolve) => { + $.post(taskUrl("queryInteractiveInfo", {"encryptProjectId":encryptProjectId,"sourceCode":"acemsg0406"}), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`queryInteractiveInfo API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data) + } + }) + }) +} + +async function sign(encryptProjectId, AssignmentId) { + return new Promise(async (resolve) => { + $.post(taskUrl("doInteractiveAssignment", { "encryptProjectId": encryptProjectId, "encryptAssignmentId": AssignmentId, "sourceCode": "acemsg0406", "itemId": "1", "completionFlag": "true" }), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`doInteractiveAssignment API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data) + if (data.subCode == 0) { + if (data.rewardsInfo.successRewards['3'] && data.rewardsInfo.successRewards['3'].length != 0) { + console.log(`${data.rewardsInfo.successRewards['3'][0].rewardName},获得${data.rewardsInfo.successRewards['3'][0].quantity}京豆`); + } else if (data.rewardsInfo.failRewards.length != 0) { + console.log(`失败:${data.rewardsInfo.failRewards[0].msg}`); + } + } else { + console.log(data.msg); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data) + } + }) + }) +} + +async function dotask(encryptProjectId, AssignmentId, body1 = {}) { + let body = { "encryptProjectId": encryptProjectId, "encryptAssignmentId": AssignmentId, "sourceCode": "acemsg0406", "completionFlag": true,...body1} + return new Promise(async (resolve) => { + $.post(taskUrl("doInteractiveAssignment", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`doInteractiveAssignment API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data) + if (data.subCode == '0' && data.rewardsInfo.hasOwnProperty('successRewards') ) { + if (data.rewardsInfo.successRewards['3'] && data.rewardsInfo.successRewards['3'].length != 0) { + console.log(`${data.rewardsInfo.successRewards['3'][0].rewardName},获得${data.rewardsInfo.successRewards['3'][0].quantity}京豆`); +// } else if (data.rewardsInfo.failRewards.length != 0) { +// console.log(`失败:${data.rewardsInfo.failRewards[0].msg}`); + } + } else { + console.log(data.msg); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data) + } + }) + }) +} + +function taskUrl(functionId, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${functionId}&body=${encodeURI(JSON.stringify(body))}&appid=publicUseApi&client=wh5&clientVersion=1.0.0&networkType=&t=${(new Date).getTime()}`, + headers: { + 'Host': 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Origin': 'https://h5.m.jd.com', + '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://h5.m.jd.com/babelDiy/Zeus/4HEXbcWBwHW2yxmoY9LnBoCZ9kcB/index.html', + 'Cookie': cookie + } + } +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + url: "https://wq.jd.com/user_new/info/GetJDUserInfoUnion?sceneval=2", + headers: { + Host: "wq.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; + return; + } + if (data['retcode'] === 0 && data.data && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + console.log('京东服务器返回空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +function showMsg() { + return new Promise(resolve => { + if (!jdNotify) { + $.msg($.name, '', `${message}`); + } else { + $.log(`京东账号${$.index}${$.nickName}\n${message}`); + } + resolve() + }) +} +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