Update jd_jinli_hongbao.ts

This commit is contained in:
Faker 2022-05-10 15:12:11 +08:00
parent 0f58b8f56b
commit 8525162c12

View File

@ -6,31 +6,27 @@
* CK2n -> HW.ts
*/
import {sendNotify} from './sendNotify'
import * as dotenv from 'dotenv'
import {get, post, getshareCodeHW, o2s, requireConfig, wait} from "./TS_USER_AGENTS"
import {get, post, getshareCodeHW, o2s, getCookie, wait} from "./TS_USER_AGENTS"
let rabbitToken: string = process.env.RABBIT_TOKEN || '', tg_id: string = process.env.TG_ID || ''
let cookie: string, cookiesArr: string[] = [], res: any, UserName: string
let ua: string = "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"
let shareCodesSelf: string[] = [], shareCodes: string[] = [], shareCodesHW: string[] = [], fullCode: string[] = []
let min: number[] = [0.02, 0.03, 0.12, 0.3, 0.4, 0.6, 0.7, 0.8, 1, 1.2, 2, 3.6], log: string
let shareCodesSelf: string[] = [], shareCodes: string[] = [], shareCodesHW: string[] = [], fullCode: string[] = [], log: string
!(async () => {
dotenv.config()
cookiesArr = await requireConfig(false)
cookiesArr = await getCookie()
cookiesArr = cookiesArr.slice(0, 1)
await join()
await help()
cookiesArr = await requireConfig(false)
cookiesArr = await getCookie()
cookiesArr = cookiesArr.slice(0, 9)
if ([0, 1].includes(new Date().getHours())) {
await join()
}
await getShareCodeSelf()
await help()
await open(0)
})()
async function join() {
@ -49,13 +45,13 @@ async function join() {
}
} catch (e) {
console.log('join error', res.rtn_code)
await wait(3000)
await wait(5000)
}
}
} catch (e) {
console.log(e)
}
await wait(1000)
await wait(5000)
}
}
@ -81,48 +77,6 @@ async function getShareCodeSelf(one: boolean = false) {
}
}
async function open(autoOpen: number) {
for (let [index, value] of cookiesArr.entries()) {
try {
cookie = value
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
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 === 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) {
console.log(e)
}
await wait(3000)
}
}
async function help() {
for (let [index, value] of cookiesArr.entries()) {
try {
@ -176,7 +130,7 @@ async function help() {
} catch (e) {
console.log(e)
}
await wait(6000)
await wait(5000)
}
}
@ -186,15 +140,16 @@ async function api(fn: string, body: object) {
"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,
"Cookie": cookie,
"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",
"MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
][Math.floor(Math.random() * 2)], "Cookie": cookie,
})
}
async function getLog() {
if (!rabbitToken && !tg_id) {
let pwd: string = '/', github: string = ''
let data = await get(`https://api.jdsharecode.xyz/api/jlhb?pwd=${pwd}&github=${github}`)
let data = await get(`https://api.jdsharecode.xyz/api/jlhb?pwd=${__dirname}&t=${Date.now()}`)
if (data !== 1 && data !== '1') {
return data
} else {