This commit is contained in:
Faker 2022-05-12 11:29:27 +08:00
parent dcf2092e93
commit c7e8a9a9f5
8 changed files with 0 additions and 482 deletions

21
TS_JDHelloWorld.d.ts vendored
View File

@ -1,21 +0,0 @@
interface User {
i: number;
UserName: string;
cookie: string;
UserAgent: string;
}
declare class JDHelloWorld {
scriptName: string;
constructor(scriptName?: string);
getCookie(check?: boolean): Promise<string[]>;
checkCookie(cookie: string): Promise<boolean>;
exceptCookie(filename?: string): any;
get(url: string, headers?: any): Promise<unknown>;
post(url: string, data: any, headers?: any): Promise<object>;
wait(ms?: number): Promise<unknown>;
o2s(obj: object, title?: string): void;
run(son: {
main: Function;
}): Promise<void>;
}
export { User, JDHelloWorld };

File diff suppressed because one or more lines are too long

View File

@ -1,77 +0,0 @@
/**
* -
* panda api和本地sign
*
* 使panda sign
* export PANDA_TOKEN=""
* sign算法 import {getSign} from './test/sign'
*/
import {User, JDHelloWorld} from "./TS_JDHelloWorld";
import {getSign} from "./test/sign";
class CASH extends JDHelloWorld {
cookie: string
constructor() {
super();
}
async init() {
await this.run(new CASH())
}
async api(fn: string, body: object) {
let sign = getSign(fn, body)
return await this.post(`https://api.m.jd.com/client.action?functionId=${fn}`, sign, {
'Host': 'api.m.jd.com',
'Cookie': this.cookie,
'user-agent': 'jdapp;',
})
}
async main(user: User) {
this.cookie = user.cookie
let res: any = await this.api('cash_homePage', {})
if (res.data.result.signedStatus !== 1) {
console.log('今日未签到')
await this.api('cash_sign', {"remind": 0, "inviteCode": "", "type": 0, "breakReward": 0})
await this.wait(1000)
console.log('签到成功')
} else {
console.log('今日已签到')
}
res = await this.api('cash_homePage', {})
let type: number[] = [2, 4, 31, 16, 3, 5, 17, 21], data: any
let otherTaskNum = res.data.result.taskInfos.filter(item => !type.includes(item.type)).length
let taskNum = res.data.result.taskInfos.filter(item => type.includes(item.type)).length
console.log(taskNum, otherTaskNum)
for (let i = 0; i < 10; i++) {
res = await this.api('cash_homePage', {})
if (res.data.result.taskInfos.filter(item => type.includes(item.type) && item.doTimes === item.times).length === taskNum) {
console.log('任务全部完成')
break
}
for (let t of res?.data?.result?.taskInfos || []) {
if (t.doTimes < t.times && t.type !== 7) {
console.log(t.name)
data = await this.api('cash_doTask', {"type": t.type, "taskInfo": t.desc})
await this.wait(t.duration * 1000 || 1000)
if (data.data.bizCode === 0) {
console.log('任务完成', data.data.result.totalMoney ?? '')
break
} else {
console.log('任务失败', JSON.stringify(data))
break
}
}
}
await this.wait(2000)
}
}
}
new CASH().init().then().catch()

View File

@ -1,12 +0,0 @@
import {getCookie} from "./TS_USER_AGENTS"
let cookie: string = '', UserName: string
!(async () => {
let cookiesArr: string[] = await getCookie(true)
for (let [index, value] of cookiesArr.entries()) {
cookie = value
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
console.log(index + 1, UserName)
}
})()

View File

@ -1,63 +0,0 @@
import {User, JDHelloWorld} from "./TS_JDHelloWorld";
class TEST extends JDHelloWorld {
user: User
constructor() {
super();
}
async init() {
await this.run(new TEST)
}
async api(fn: string, body: object) {
return await this.post('https://api.m.jd.com/', `functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&uuid=`, {
'Host': 'api.m.jd.com',
'Origin': 'https://h5.m.jd.com',
'User-Agent': this.user.UserAgent,
'Referer': 'https://h5.m.jd.com/',
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': this.user.cookie
})
}
async main(user: User) {
this.user = user
let res: any = await this.api('jdhealth_getTaskDetail', {"buildingId": "", "taskId": "", "channelId": 1})
try {
for (let t of res.data.result.taskVos) {
if (t.status === 1 || t.status === 3) {
console.log(t.taskName)
for (let tp of t.productInfoVos || t.followShopVo || t.shoppingActivityVos || []) {
if (tp.status === 1) {
console.log('\t', tp.skuName || tp.shopName || tp.title)
if (t.taskName.includes('早睡打卡') && t.taskBeginTime < Date.now() && t.taskEndTime > Date.now()) {
res = await this.api('jdhealth_collectScore', {"taskToken": tp.taskToken, "taskId": t.taskId, "actionType": 1})
await this.wait(2000)
console.log('\t', res.data.bizMsg)
}
if (t.waitDuration) {
res = await this.api('jdhealth_collectScore', {"taskToken": tp.taskToken, "taskId": t.taskId, "actionType": 1})
console.log('\t', res.data.bizMsg)
await this.wait(t.waitDuration * 1000)
}
res = await this.api('jdhealth_collectScore', {"taskToken": tp.taskToken, "taskId": t.taskId, "actionType": 0})
if (res.data.bizMsg.includes('做完')) {
console.log(res.data.bizMsg)
break
} else {
console.log(res.data.bizMsg, parseInt(res.data.result.score))
await this.wait(1500)
}
}
}
}
}
} catch (e) {
console.log('Error', e)
}
}
}
new TEST().init().then()

View File

@ -1,41 +0,0 @@
import {User, JDHelloWorld} from "./TS_JDHelloWorld";
class Joy_Park extends JDHelloWorld {
user: User
constructor() {
super();
}
async init() {
await this.run(new Joy_Park())
}
async api(fn: string, body: Object): Promise<object> {
return await this.post('https://api.m.jd.com/', `functionId=${fn}&body=${JSON.stringify(body)}&_t=${Date.now()}&appid=activities_platform`, {
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': this.user.UserAgent,
'Host': 'api.m.jd.com',
'Referer': 'https://joypark.jd.com/',
'Origin': 'https://joypark.jd.com',
'Cookie': this.user.cookie
});
}
async main(user: User) {
this.user = user;
let res: any = await this.api('apTaskList', {"linkId": "L-sOanK_5RJCz7I314FpnQ"});
let t: any = res.data[2]
for (let i = t.taskDoTimes; i < t.taskLimitTimes; i++) {
let res: any = await this.api('apTaskTimeRecord', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "taskId": t.id})
console.log(res.success)
await this.wait(31000)
let url: any = "https://pro.m.jd.com/jdlite/active/3qRAXpNehcsUpToARD9ekP4g6Jhi/index.html?babelChannel=ttt6"
await this.api('apDoTask', {"channel": "4", "checkVersion": true, "itemId": encodeURIComponent(url), "linkId": "L-sOanK_5RJCz7I314FpnQ", "taskId": t.id, "taskType": t.taskType})
console.log(res.success)
await this.wait(1000)
}
}
}
new Joy_Park().init().then()

View File

@ -1,221 +0,0 @@
/**
* -+
* cron: 20 * * * *
* export FP_448DE="" // url: runningMyPrize => h5st.split(';')[1]
* export FP_B6AC3="" // url: runningOpenBox => h5st.split(';')[1]
*/
import {H5ST} from "./utils/h5st"
import {getDate} from "date-fns";
import {JDHelloWorld, User} from "./TS_JDHelloWorld";
class Joy_Park_Run extends JDHelloWorld {
teamTool: H5ST
apiTool: H5ST
user: User
captainId: string | number
constructor() {
super()
}
async init() {
await this.run(new Joy_Park_Run())
}
// 秒转时分秒
secondsToMinutes(seconds: number) {
let minutes: number = Math.floor(seconds / 60)
let second: number = Math.floor(seconds % 60)
return `${minutes}${second}`
}
// 小数加法
add(num1: number, num2: number) {
let r1: number, r2: number
try {
r1 = num1.toString().split('.')[1].length
} catch (e) {
r1 = 0
}
try {
r2 = num2.toString().split('.')[1].length
} catch (e) {
r2 = 0
}
let m: number = Math.pow(10, Math.max(r1, r2))
return (num1 * m + num2 * m) / m
}
async team(fn: string, body: object) {
let timestamp: number = Date.now(), h5st: string
h5st = this.teamTool.__genH5st({
appid: "activities_platform",
body: JSON.stringify(body),
client: "ios",
clientVersion: "3.1.0",
functionId: fn,
t: timestamp.toString()
})
return await this.get(`https://api.m.jd.com/?functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&t=${timestamp}&appid=activities_platform&client=ios&clientVersion=3.1.0&cthr=1&h5st=${h5st}`, {
'Host': 'api.m.jd.com',
'User-Agent': 'jdltapp;',
'Origin': 'https://h5platform.jd.com',
'X-Requested-With': 'com.jd.jdlite',
'Referer': 'https://h5platform.jd.com/',
'Cookie': this.user.cookie
})
}
async api(fn: string, body: object) {
let timestamp: number = Date.now(), h5st: string = ''
if (fn === 'runningOpenBox') {
h5st = this.apiTool.__genH5st({
appid: "activities_platform",
body: JSON.stringify(body),
client: "ios",
clientVersion: "3.1.0",
functionId: fn,
t: timestamp.toString()
})
}
let params: string = `functionId=${fn}&body=${JSON.stringify(body)}&t=${timestamp}&appid=activities_platform&client=ios&clientVersion=3.1.0&cthr=1`
h5st && (params += `&h5st=${h5st}`)
return await this.post('https://api.m.jd.com/', params, {
'authority': 'api.m.jd.com',
'content-type': 'application/x-www-form-urlencoded',
'cookie': this.user.cookie,
'origin': 'https://h5platform.jd.com',
'referer': 'https://h5platform.jd.com/',
'user-agent': 'jdltapp;iPhone;3.1.0;'
})
}
async runningPageHome() {
return this.get(`https://api.m.jd.com/?functionId=runningPageHome&body=%7B%22linkId%22:%22L-sOanK_5RJCz7I314FpnQ%22,%22isFromJoyPark%22:true,%22joyLinkId%22:%22LsQNxL7iWDlXUs6cFl-AAg%22%7D&t=${Date.now()}&appid=activities_platform&client=ios&clientVersion=3.1.0`, {
'Host': 'api.m.jd.com',
'Origin': 'https://h5platform.jd.com',
'User-Agent': 'jdltapp;',
'Referer': 'https://h5platform.jd.com/',
'Cookie': this.user.cookie
})
}
async main(user: User) {
this.user = user
let assets: number = parseFloat(process.env.JD_JOY_PARK_RUN_ASSETS || '0.08')
let rewardAmount: number = 0
try {
this.teamTool = new H5ST('448de', 'jdltapp;', process.env.FP_448DE || '')
await this.teamTool.__genAlgo()
let res: any = await this.team('runningMyPrize', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "pageSize": 20, "time": null, "ids": null})
let sum: number = 0, success: number = 0
rewardAmount = res.data.rewardAmount
if (res.data.runningCashStatus.currentEndTime && res.data.runningCashStatus.status === 0) {
console.log('可提现', rewardAmount)
res = await this.api('runningPrizeDraw', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "type": 2})
await this.wait(2000)
console.log(res.data.message)
}
for (let t of res?.data?.detailVos || []) {
if (getDate(new Date(t.createTime)) === new Date().getDate()) {
sum = this.add(sum, t.amount)
success++
} else {
break
}
}
console.log('成功', success)
console.log('收益', parseFloat(sum.toFixed(2)))
res = await this.team('runningTeamInfo', {"linkId": "L-sOanK_5RJCz7I314FpnQ"})
if (!this.captainId) {
if (res.data.members.length === 0) {
console.log('成为队长')
this.captainId = res.data.captainId
} else if (res.data.members.length !== 6) {
console.log('队伍未满', res.data.members.length)
this.captainId = res.data.captainId
} else {
console.log('队伍已满')
}
} else if (this.captainId && res.data.members.length === 0) {
console.log('已有组队ID未加入队伍')
res = await this.team('runningJoinTeam', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "captainId": this.captainId})
if (res.code === 0) {
console.log('组队成功')
for (let member of res.data.members) {
if (member.captain) {
console.log('队长', member.nickName)
break
}
}
if (res.data.members.length === 6) {
console.log('队伍已满')
this.captainId = ''
}
} else {
this.o2s(res, '组队失败')
}
} else {
console.log('已组队', res.data.members.length)
console.log('战队收益', res.data.teamSumPrize)
}
this.apiTool = new H5ST('b6ac3', 'jdltapp;', process.env.FP_B6AC3 || '')
await this.apiTool.__genAlgo()
res = await this.runningPageHome()
console.log('🧧', res.data.runningHomeInfo.prizeValue)
console.log('💊', res.data.runningHomeInfo.energy)
await this.wait(2000)
console.log('⏳', this.secondsToMinutes(res.data.runningHomeInfo.nextRunningTime / 1000))
if (res.data.runningHomeInfo.nextRunningTime && res.data.runningHomeInfo.nextRunningTime / 1000 < 300) {
console.log('⏳')
await this.wait(res.data.runningHomeInfo.nextRunningTime + 3000)
res = await this.runningPageHome()
await this.wait(1000)
} else if (res.data.runningHomeInfo.nextRunningTime && res.data.runningHomeInfo.nextRunningTime / 1000 > 3000 && res.data.runningHomeInfo.energy !== 0) {
console.log('💉')
res = await this.api('runningUseEnergyBar', {"linkId": "L-sOanK_5RJCz7I314FpnQ"})
console.log(res.errMsg)
res = await this.runningPageHome()
await this.wait(1000)
}
if (!res.data.runningHomeInfo.nextRunningTime) {
console.log('终点目标', assets)
for (let i = 0; i < 10; i++) {
res = await this.api('runningOpenBox', {"linkId": "L-sOanK_5RJCz7I314FpnQ"})
if (parseFloat(res.data.assets) >= assets) {
let assets: number = parseFloat(res.data.assets)
res = await this.api('runningPreserveAssets', {"linkId": "L-sOanK_5RJCz7I314FpnQ"})
console.log('领取成功', assets)
break
} else {
if (res.data.doubleSuccess) {
console.log('翻倍成功', parseFloat(res.data.assets))
await this.wait(5000)
} else if (!res.data.doubleSuccess && !res.data.runningHomeInfo.runningFinish) {
console.log('开始跑步', parseFloat(res.data.assets))
await this.wait(5000)
} else {
console.log('翻倍失败')
break
}
}
await this.wait(5000)
}
}
res = await this.runningPageHome()
console.log('🧧', res.data.runningHomeInfo.prizeValue)
await this.wait(2000)
} catch (e) {
console.log('Error', e)
await this.wait(3000)
}
}
}
new Joy_Park_Run().init().then()

View File

@ -1,46 +0,0 @@
/**
*
* FP_9A38A
* cron: 8 0 * * *
*/
import {H5ST} from "./utils/h5st"
import {User, JDHelloWorld} from "./TS_JDHelloWorld";
class Wechat_sign extends JDHelloWorld {
constructor() {
super("微信小程序签到红包");
}
async init() {
await this.run(new Wechat_sign())
}
async main(user: User) {
let h5stTool = new H5ST("9a38a", 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79 MicroMessenger/8.0.15(0x18000f2e) NetType/WIFI Language/zh_CN', process.env.FP_9A38A || "");
await h5stTool.__genAlgo()
let timestamp: number = Date.now()
let h5st: string = h5stTool.__genH5st({
appid: 'hot_channel',
body: JSON.stringify({"activityId": "10002"}),
client: 'android',
clientVersion: '7.16.250',
functionId: 'SignComponent_doSignTask',
t: timestamp.toString(),
})
let res: any = await this.post(`https://api.m.jd.com/signTask/doSignTask?functionId=SignComponent_doSignTask&appid=hot_channel&body={"activityId":"10002"}&client=android&clientVersion=7.16.250&t=${timestamp}&h5st=${h5st}`, '', {
'content-type': 'application/json',
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79 MicroMessenger/8.0.15(0x18000f2e) NetType/WIFI Language/zh_CN',
'referer': 'https://servicewechat.com/wx91d27dbf599dff74/581/page-frame.html',
'cookie': user.cookie
})
if (res.data) {
console.log('已签到', res.data.signDays, '天,奖励', res.data.rewardValue, '元')
return {msg: `【京东账号${user.i + 1}${user.UserName}\n已签到 ${res.data.signDays}\n奖励 ${res.data.rewardValue}\n\n`}
} else {
console.log(res.message)
}
}
}
new Wechat_sign().init().then()