diff --git a/jd_cash_Mod_Panda.js b/jd_cash.js similarity index 93% rename from jd_cash_Mod_Panda.js rename to jd_cash.js index 395b9b5..b4e90cb 100644 --- a/jd_cash_Mod_Panda.js +++ b/jd_cash.js @@ -3,22 +3,23 @@ 可互助,助力码每日不变,只变日期 活动入口:京东APP搜索领现金进入 更新时间:2021-06-07 +PandaToken 请前往 https://t.me/pang_da_bot 获取Token 已支持IOS双京东账号,Node.js支持N个京东账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js ============Quantumultx=============== [task_local] #签到领现金 -2 0-23/4 * * * jd_cash.js, tag=签到领现金, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true +11 1,20 * * * jd_cash.js, tag=签到领现金, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true ================Loon============== [Script] -cron "2 0-23/4 * * *" script-path=jd_cash.js,tag=签到领现金 +cron "11 1,20 * * *" script-path=jd_cash.js,tag=签到领现金 ===============Surge================= -签到领现金 = type=cron,cronexp="2 0-23/4 * * *",wake-system=1,timeout=3600,script-path=jd_cash.js +签到领现金 = type=cron,cronexp="11 1,20 * * *",wake-system=1,timeout=3600,script-path=jd_cash.js ============小火箭========= -签到领现金 = type=cron,script-path=jd_cash.js, cronexpr="2 0-23/4 * * *", timeout=3600, enable=true +签到领现金 = type=cron,script-path=jd_cash.js, cronexpr="11 1,20 * * *", timeout=3600, enable=true */ const $ = new Env('签到领现金_Panda'); const notify = $.isNode() ? require('./sendNotify') : ''; @@ -42,9 +43,9 @@ if ($.isNode()) { const JD_API_HOST = 'https://api.m.jd.com/client.action'; let allMessage = ''; let jdPandaToken = ''; -jdPandaToken = $.isNode() ? (process.env.gua_cleancart_PandaToken ? process.env.gua_cleancart_PandaToken : `${jdPandaToken}`) : ($.getdata('gua_cleancart_PandaToken') ? $.getdata('gua_cleancart_PandaToken') : `${jdPandaToken}`); +jdPandaToken = $.isNode() ? (process.env.PandaToken ? process.env.PandaToken : `${jdPandaToken}`) : ($.getdata('PandaToken') ? $.getdata('PandaToken') : `${jdPandaToken}`); if (!jdPandaToken) { - console.log('请填写Panda获取的Token,变量是gua_cleancart_PandaToken'); + console.log('请填写Panda获取的Token,变量是PandaToken'); return; } @@ -282,7 +283,7 @@ function getSignfromPanda(functionId, body) { } return new Promise((resolve) => { let url = { - url: "https://api.jds.codes/jd/sign", + url: "https://api.zhezhe.cf/jd/sign", body: JSON.stringify(data), followRedirect: false, headers: { @@ -440,39 +441,6 @@ function taskUrl(functionId, body = {}) { } } -function getAuthorShareCode(url) { - return new Promise(resolve => { - const options = { - url: `${url}?${new Date()}`, "timeout": 30000, headers: { - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" - } - }; - if ($.isNode() && process.env.TG_PROXY_HOST && process.env.TG_PROXY_PORT) { - const tunnel = require("tunnel"); - const agent = { - https: tunnel.httpsOverHttp({ - proxy: { - host: process.env.TG_PROXY_HOST, - port: process.env.TG_PROXY_PORT * 1 - } - }) - } - Object.assign(options, { agent }) - } - $.get(options, async (err, resp, data) => { - try { - if (err) { - } else { - if (data) data = JSON.parse(data) - } - } catch (e) { - // $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} function TotalBean() { return new Promise(async resolve => { const options = { diff --git a/jd_jinli_hongbao.ts b/jd_jinli_hongbao.ts index 3c0e43a..56b90b8 100644 --- a/jd_jinli_hongbao.ts +++ b/jd_jinli_hongbao.ts @@ -1,186 +1,199 @@ /** - * const $ = new Env('京东-锦鲤红包'); - * 做任务、助力、开红包 - * cron: 1 0,18 * * * - * 修改自HW大佬,自用,仅助力前7账号,纯内部互助 + * 京东-锦鲤红包 + * 6点后做全部CK + * cron: 2 0,1,6 * * * + * CK1 HW.ts -> 内部 + * CK2~n 内部 -> HW.ts */ -import axios from 'axios'; -import {logs} from './function/jinli_log'; -import {getRandomNumberByRange, getshareCodeHW, o2s, randomString, requireConfig, wait} from "./function/TS_USER_AGENTS"; +import axios from 'axios' +import {sendNotify} from './sendNotify' +import {get, getshareCodeHW, o2s, requireConfig, wait} from "./TS_USER_AGENTS" -let cookie: string = '', res: any = '', UserName: string, UA: string = '' -let shareCodesSelf: string[] = [], shareCodes: string[] = [], fullCode: string[] = [] -let min: number[] = [0.02, 0.12, 0.3, 0.6, 0.7, 0.8, 1, 2], log: string = '', logIndex: number = 10 +let cookie: string, cookiesArr: string[] = [], res: any, UserName: string +let shareCodesSelf: string[] = [], shareCodes: string[] = [], shareCodesHW: string[] = [], fullCode: string[] = [] +let min: number[] = [0.02, 0.12, 0.3, 0.4, 0.6, 0.7, 0.8, 1, 1.2, 2, 3.6], log: string !(async () => { - let cookiesArr: string[] = await requireConfig(false); - for (let [index, value] of cookiesArr.entries()) { - if(index < 7){ - try { - cookie = value; - UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) - console.log(`\n开始【京东账号${index + 1}】${UserName}\n`); - UA = `jdltapp;iPhone;3.1.0;${Math.ceil(Math.random() * 4 + 10)}.${Math.ceil(Math.random() * 4)};${randomString(40)}` - log = logs[getRandomNumberByRange(0, logs.length - 1)] - let random = log.match(/"random":"(\d+)"/)[1], log1 = log.match(/"log":"(.*)"/)[1] - res = await api('h5launch', {"followShop": 0, "random": random, "log": log1, "sceneid": "JLHBhPageh5"}) - console.log('活动初始化:', res.data.result.statusDesc) - await wait(1000) + cookiesArr = await requireConfig() + cookiesArr = cookiesArr.slice(0, 1) + await join() + await help() - res = await api('h5activityIndex', {"isjdapp": 1}) - console.log('红包ID:', res.data.result.redpacketInfo.id) - shareCodesSelf.push(res.data.result.redpacketInfo.id) - await wait(1000) - } catch (e) { - console.log(e) - } - } - } + cookiesArr = await requireConfig() + cookiesArr = cookiesArr.slice(0, 9) + if (new Date().getHours() === 0) + await join() + await getShareCodeSelf() + await help() + await open(0) +})() - await wait(2000) - - console.log('内部助力:', shareCodesSelf) +async function join() { for (let [index, value] of cookiesArr.entries()) { try { - cookie = value; + cookie = value UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) - shareCodes = Array.from(new Set([...shareCodesSelf])) - for (let code of shareCodes) { - if (!fullCode.includes(code)) { - UA = `jdltapp;iPhone;3.1.0;${Math.ceil(Math.random() * 4 + 10)}.${Math.ceil(Math.random() * 4)};${randomString(40)}` - log = logs[getRandomNumberByRange(0, logs.length - 1)] - let random = log.match(/"random":"(\d+)"/)[1], log1 = log.match(/"log":"(.*)"/)[1] - console.log(`账号${index + 1} ${UserName} 去助力 ${code} ${shareCodesSelf.includes(code) ? '*内部*' : ''}`) - - res = await api('jinli_h5assist', {"redPacketId": code, "followShop": 0, "random": random, "log": log1, "sceneid": "JLHBhPageh5"}) - o2s(res, 'jinli_h5assist') - - if (res.data.result.status === 0) { - console.log('助力成功:', parseFloat(res.data.result.assistReward.discount)) - await wait(1000) + console.log(`\n开始【京东账号${index + 1}】${UserName}\n`) + for (let i = 0; i < 5; i++) { + try { + log = await getLog() + res = await api('h5launch', {followShop: 0, random: log.match(/"random":"(\d+)"/)[1], log: log.match(/"log":"(.*)"/)[1], sceneid: 'JLHBhPageh5'}) + console.log('活动初始化:', res.data.result.statusDesc) + if (res.rtn_code !== 403) { break - } else if (res.data.result.status === 3) { - console.log('今日助力次数已满') - break - } else { - console.log('助力结果:', res.data.result.statusDesc) - if (res.data.result.statusDesc === '啊偶,TA的助力已满,开启自己的红包活动吧~') { - fullCode.push(code) - } } - await wait(1000) - } else { - console.log(`Code ${code} 已被助满`) + } catch (e) { + console.log('log error', e) + await wait(3000) } } } catch (e) { console.log(e) } + await wait(1000) } +} +async function getShareCodeSelf(one: boolean = false) { + if (one) { + res = await api('h5activityIndex', {"isjdapp": 1}) + return res?.data?.result?.redpacketInfo?.id + } else { + for (let [index, value] of cookiesArr.entries()) { + try { + cookie = value + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + console.log(`\n开始【京东账号${index + 1}】${UserName}\n`) + res = await api('h5activityIndex', {"isjdapp": 1}) + console.log('ID:', res.data.result.redpacketInfo.id) + shareCodesSelf.push(res.data.result.redpacketInfo.id) + } catch (e) { + console.log('getShareCodeSelf error', e) + } + await wait(1000) + } + o2s(shareCodesSelf) + } +} + +async function open(autoOpen: number) { for (let [index, value] of cookiesArr.entries()) { - if(index < 7){ - try { + try { cookie = value UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) - console.log(`\n开始【京东账号${index + 1}】${UserName}\n`); - UA = `jdltapp;iPhone;3.1.0;${Math.ceil(Math.random() * 4 + 10)}.${Math.ceil(Math.random() * 4)};${randomString(40)}` - log = logs[getRandomNumberByRange(0, logs.length - 1)] - let random = log.match(/"random":"(\d+)"/)[1], log1 = log.match(/"log":"(.*)"/)[1] - // 做任务 - /* - res = await api('taskHomePage', {}) - await wait(1000) - for (let t of res.data.result.taskInfos) { - if (!t.alreadyReceivedCount || t.alreadyReceivedCount < t.requireCount) { - if ([2, 3, 4, 5, 8].includes(t.taskType)) { - res = await api('startTask', {"taskType": t.taskType, "random": getRandomNumberByRange(36135846, 74613584), "log": `${Date.now()}~1orj8k3`, "sceneid": "JLHBhPageh5"}) - console.log(t.title, res.data.biz_msg) - await wait(1000) - res = await api('getTaskDetailForColor', {taskType: t.taskType}) - await wait(1000) - for (let tp of res.data.result.advertDetails) { - if (tp.status === 0) { - res = await api('taskReportForColor', {"taskType": t.taskType, "detailId": tp.id}) - console.log(t.title, tp.name, res.data.biz_msg) - await wait(1000) - } - } - } - } - if (t.innerStatus === 3) { - res = await api('h5receiveRedpacketAll', {"taskType": t.taskType, "random": getRandomNumberByRange(36135846, 74613584), "log": `${Date.now()}~138q6w6`, "sceneid": "JLHBhPageh5"}) - console.log(`${t.title} 打开成功,获得`, parseFloat(res.data.result.discount)) - if (!min.includes(parseFloat(res.data.result.discount))) - await sendNotify(`锦鲤红包`, `账号${index + 1} ${UserName}\n${res.data.result.discount}`) - await wait(1000) - } - } - await wait(1000) - - - // 打开任务红包 - res = await api('taskHomePage', {}) - await wait(1000) - for (let t of res.data.result.taskInfos) { - if (t.innerStatus === 3) { - res = await api('h5receiveRedpacketAll', {"taskType": t.taskType, "random": getRandomNumberByRange(36135846, 74613584), "log": `${Date.now()}~138q6w6`, "sceneid": "JLHBhPageh5"}) - console.log(`${t.title} 打开成功,获得`, parseFloat(res.data.result.discount)) - if (!min.includes(parseFloat(res.data.result.discount))) - await sendNotify(`锦鲤红包`, `账号${index + 1} ${UserName}\n${res.data.result.discount}`) - await wait(1000) - } - } - await wait(2000) - */ - - // 打开助力红包 + console.log(`\n开始【京东账号${index + 1}】${UserName}\n`) let j: number = 1 res = await api('h5activityIndex', {"isjdapp": 1}) for (let t of res.data.result.redpacketConfigFillRewardInfo) { - if (t.packetStatus === 2) { - console.log(`红包${j}已拆过,获得`, t.packetAmount) - } else if (t.packetStatus === 1) { - console.log(`红包${j}可拆`) - res = await api('h5receiveRedpacketAll', {"random": random, "log": log1, "sceneid": "JLHBhPageh5"}) - console.log(res.data.biz_msg, parseFloat(res.data.result.discount)) - await wait(1000) - } else { + if (t.packetStatus === 1) { + console.log(`${j} 可拆`) + } else if (t.packetStatus === 2) { + console.log(`${j} 已拆`) + } + j++ + } + console.log('') + + j = 1 + for (let t of res.data.result.redpacketConfigFillRewardInfo) { + if (t.packetStatus === 1) { + if (autoOpen) { + log = await getLog() + res = await api('h5receiveRedpacketAll', {random: log.match(/"random":"(\d+)"/)[1], log: log.match(/"log":"(.*)"/)[1], sceneid: 'JLHBhPageh5'}) + console.log('打开成功', parseFloat(res.data.result.discount)) + if (!min.includes(parseFloat(res.data.result.discount))) { + await sendNotify('锦鲤红包', `账号${index + 1} ${UserName}\n${t.packetAmount}`) + } + await wait(6000) + } + } else if (![1, 2].includes(t.packetStatus)) { console.log(`${j}`, t.hasAssistNum, '/', t.requireAssistNum) } j++ } - } - - catch (e) { + } catch (e) { console.log(e) } - await wait(1000) + await wait(3000) } - } -})() +} -async function api(fn: string, body: object, retry: number = 0) { +async function help() { + for (let [index, value] of cookiesArr.entries()) { + try { + cookie = value + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + if (shareCodesHW.length === 0) { + shareCodesHW = await getshareCodeHW('jlhb') + } + if (index === 0) { + shareCodes = Array.from(new Set([...shareCodesHW, ...shareCodesSelf])) + } else { + shareCodes = Array.from(new Set([...shareCodesSelf, ...shareCodesHW])) + } + + let me: string = await getShareCodeSelf(true) + let success: boolean = false + for (let code of shareCodes) { + if (success) break + if (!fullCode.includes(code) && code !== me) { + console.log(`账号${index + 1} ${UserName} 去助力 ${code} ${shareCodesSelf.includes(code) ? '*内部*' : ''}`) + for (let i = 0; i < 5; i++) { + log = await getLog() + res = await api('jinli_h5assist', {"redPacketId": code, "followShop": 0, random: log.match(/"random":"(\d+)"/)[1], log: log.match(/"log":"(.*)"/)[1], sceneid: 'JLHBhPageh5'}) + if (res.rtn_code === 403) { + console.log('log error') + await wait(5000) + } else { + if (res.data.result.status === 0) { + console.log('助力成功:', parseFloat(res.data.result.assistReward.discount)) + success = true + await wait(45000) + break + } else if (res.data.result.status === 3) { + console.log('今日助力次数已满') + success = true + await wait(45000) + break + } else { + console.log('助力结果:', res.data.result.statusDesc) + if (res.data.result.statusDesc === '啊偶,TA的助力已满,开启自己的红包活动吧~') { + fullCode.push(code) + } + await wait(45000) + } + } + } + } + } + } catch (e) { + console.log(e) + } + await wait(6000) + } +} + +async function api(fn: string, body: object) { let {data} = await axios.post(`https://api.m.jd.com/api?appid=jinlihongbao&functionId=${fn}&loginType=2&client=jinlihongbao&clientVersion=10.2.4&osVersion=AndroidOS&d_brand=Xiaomi&d_model=Xiaomi`, `body=${encodeURIComponent(JSON.stringify(body))}`, { headers: { - "Cookie": cookie, "origin": "https://h5.m.jd.com", "referer": "https://h5.m.jd.com/babelDiy/Zeus/2NUvze9e1uWf4amBhe1AV6ynmSuH/index.html", 'Content-Type': 'application/x-www-form-urlencoded', "X-Requested-With": "com.jingdong.app.mall", - "User-Agent": UA, + "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", + "Cookie": cookie, } }) - await wait(5000) - if (data.rtn_code === 403 && retry < 3) { - console.log('retry...') - await wait(1000) - log = logs[getRandomNumberByRange(0, logs.length - 1)] - body['random'] = log.match(/"random":"(\d+)"/)[1] - body['log'] = log.match(/"log":"(.*)"/)[1] - await wait(5000) - await api(fn, body, ++retry) - } return data } + +async function getLog() { + let data = await get(`https://api.jdsharecode.xyz/api/jlhb`) + if (data !== 1 && data !== '1') { + return data + } else { + console.log('No log') + process.exit(0) + } +} \ No newline at end of file