1
0
mirror of https://github.com/okyyds/yyds.git synced 2026-07-13 23:31:18 +08:00

Update jd_pigPet.js

This commit is contained in:
YYDS
2022-02-17 17:40:37 +08:00
parent e8fe13369b
commit 5fa8f899ab

View File

@@ -1,23 +1,26 @@
/*
*
京东金融养猪猪
活动入口:京东金融养猪猪,
脚本更新地址https://github.com/zero205/JD_tencent_scf
加了个邀新助力不过应该没啥用。邀请码变量PIGPETSHARECODE变量仅支持单账号邀请码
活动入口:京东金融养猪猪
一键开完所有的宝箱功能。耗时70秒
大转盘抽奖
喂食
每日签到
完成分享任务得猪粮
已支持IOS双京东账号,Node.js支持N个京东账号
脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js
============Quantumultx===============
脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js
===============Quantumultx===============
[task_local]
京东金融养猪猪
12 0-23/6 * * * https://raw.githubusercontent.com/zero205/JD_tencent_scf/main/jd_pigPet.js, tag=京东金融养猪猪, enabled=true
#京东金融养猪猪
12 0-23/6 * * * https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_pigPet.js, tag=京东金融养猪猪, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdyz.png, enabled=true
================Loon==============
[Script]
cron "12 0-23/6 * * *" script-path=https://raw.githubusercontent.com/zero205/JD_tencent_scf/main/jd_pigPet.js,tag=摇钱树助力
cron "12 0-23/6 * * *" script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_pigPet.js, tag=京东金融养猪猪
===============Surge=================
京东金融养猪猪 = type=cron,cronexp="12 0-23/6 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/zero205/JD_tencent_scf/main/jd_pigPet.js
京东金融养猪猪 = type=cron,cronexp="12 0-23/6 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_pigPet.js
============小火箭=========
京东金融养猪猪 = type=cron,script-path=https://raw.githubusercontent.com/zero205/JD_tencent_scf/main/jd_pigPet.js, cronexpr="12 0-23/6 * * *", timeout=3600, enable=true
*
京东金融养猪猪 = type=cron,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_pigPet.js, cronexpr="12 0-23/6 * * *", timeout=3600, enable=true
*/
const $ = new Env('金融养猪');
const url = require('url');
@@ -27,15 +30,13 @@ const MISSION_BASE_API = `https://ms.jr.jd.com/gw/generic/mission/h5/m`;
const notify = $.isNode() ? require('./sendNotify') : '';
//Node.js用户请在jdCookie.js处填写京东ck;
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
let UA = $.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")
let shareId = 'KMnydTyM9ezAduo1QsTZZsAdoUJQ3Dik'
let shareId = "hRYQeeaVYXQBX1Mguan2kA"
$.shareCodes = [];
if ($.isNode()) {
Object.keys(jdCookieNode).forEach((item) => {
cookiesArr.push(jdCookieNode[item])
})
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {};
if (process.env.JR_USER_AGENT) UA = process.env.JR_USER_AGENT;
} else {
cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item);
}
@@ -47,15 +48,14 @@ if ($.isNode()) {
if (process.env.PIGPETSHARECODE) {
shareId = process.env.PIGPETSHARECODE
} else {
let res = await getAuthorShareCode('https://raw.githubusercontent.com/zero205/updateTeam/main/shareCodes/pigPet.json')
let res = await getAuthorShareCode('https://raw.githubusercontent.com/Aaron-lv/updateTeam/master/shareCodes/pigPet.json')
if (!res) {
res = await getAuthorShareCode('https://raw.fastgit.org/zero205/updateTeam/main/shareCodes/pigPet.json')
$.http.get({url: 'https://purge.jsdelivr.net/gh/Aaron-lv/updateTeam@master/shareCodes/pigPet.json'}).then((resp) => {}).catch((e) => console.log('刷新CDN异常', e));
await $.wait(2000)
res = await getAuthorShareCode('https://cdn.jsdelivr.net/gh/Aaron-lv/updateTeam@master/shareCodes/pigPet.json')
}
if (res){
shareId = res[Math.floor((Math.random() * res.length))];
if (res && res.length) shareId = res[Math.floor((Math.random() * res.length))]
}
}
console.log(`\n【原作者LXK大佬】\n\nByzero205\n添加:邀请新用户,大转盘助力,抢粮食\n修改:优化日志输出,自动喂食\n\n默认不抢粮食成功机率小需要的请添加变量JD_PIGPET_PK值填true\nTodo领取成就奖励\n`);
for (let i = 0; i < cookiesArr.length; i++) {
if (cookiesArr[i]) {
cookie = cookiesArr[i];
@@ -63,7 +63,6 @@ if ($.isNode()) {
$.index = i + 1;
$.isLogin = true;
$.nickName = '';
$.finish = false;
await TotalBean();
console.log(`\n开始【京东账号${$.index}${$.nickName || $.UserName}\n`);
if (!$.isLogin) {
@@ -76,13 +75,19 @@ if ($.isNode()) {
await jdPigPet();
}
}
let res2 = await getAuthorShareCode('https://raw.githubusercontent.com/Aaron-lv/updateTeam/master/shareCodes/pig.json')
if (!res2) {
$.http.get({url: 'https://purge.jsdelivr.net/gh/Aaron-lv/updateTeam@master/shareCodes/pig.json'}).then((resp) => {}).catch((e) => console.log('刷新CDN异常', e));
await $.wait(2000)
res2 = await getAuthorShareCode('https://cdn.jsdelivr.net/gh/Aaron-lv/updateTeam@master/shareCodes/pig.json')
}
$.shareCodes = [...new Set([...$.shareCodes, ...(res2 || [])])]
console.log($.shareCodes)
console.log(`\n======开始大转盘助力======\n`);
$.helpId = await getAuthorShareCode('https://raw.fastgit.org/zero205/updateTeam/main/shareCodes/pig.json');
$.shareCodes = [...$.shareCodes, ...($.helpId || [])]
for (let j = 0; j < cookiesArr.length; j++) {
cookie = cookiesArr[j];
if ($.shareCodes && $.shareCodes.length) {
console.log(`\n自己账号内部循环互助有剩余次数再帮【zero205】助力\n`);
console.log(`\n自己账号内部循环互助\n`);
for (let item of $.shareCodes) {
await pigPetLotteryHelpFriend(item)
await $.wait(1000)
@@ -90,7 +95,7 @@ if ($.isNode()) {
}
}
}
if (process.env.PIGNF != 'false' && allMessage) {
if (allMessage && new Date().getHours() % 6 === 0) {
if ($.isNode()) await notify.sendNotify($.name, allMessage);
$.msg($.name, '', allMessage);
}
@@ -103,6 +108,7 @@ if ($.isNode()) {
})
async function jdPigPet() {
try {
$.notAddFood = false;
await pigPetLogin();
if (!$.hasPig) return
await pigPetSignIndex();
@@ -115,8 +121,11 @@ async function jdPigPet() {
}
await pigPetMissionList();
await missions();
if ($.finish) return
if ($.notAddFood) {
console.log(`\n猪猪已成熟,跳过喂食`)
} else {
await pigPetUserBag();
}
} catch (e) {
$.logErr(e)
}
@@ -125,7 +134,7 @@ async function pigPetLottery() {
if ($.currentCount > 0) {
for (let i = 0; i < $.currentCount; i++) {
await pigPetLotteryPlay();
await $.wait(6000)
await $.wait(5000);
}
}
}
@@ -197,17 +206,16 @@ function pigPetUserBag() {
}
for (let item of data.resultData.resultData.goods) {
if (item.count >= 20) {
let i = parseInt(process.env.PIG_FEED_LIMIT || 50)
console.log(`\n每次运行最多喂食${i}次(环境变量PIG_FEED_LIMIT)`)
let num = 50;
$.finish = false;
$.remain = item.count
do {
console.log(`\n10秒后开始喂食${item.goodsName},当前数量为${item.count}g`)
console.log(`10秒后开始喂食${item.goodsName},当前数量为${$.remain}g`)
await $.wait(10000);
await pigPetAddFood(item.sku);
if ($.finish) break
item.count = item.count - 20
i--
} while (item.count >= 20 && i > 0)
if ($.finish) break
$.remain = $.remain - 20
num--
} while (num > 0 && !$.finish && $.remain >= 20)
}
}
} else {
@@ -288,14 +296,14 @@ function pigPetLogin() {
if (data.resultData.resultCode === 0) {
$.hasPig = data.resultData.resultData.hasPig;
if (!$.hasPig) {
console.log(`\n京东账号${$.index} ${$.nickName} 未开启养猪活动,请手动去京东金融APP开启此活动或复制口令直达:\n29.0复制整段话 Https:/JWHOjEv6wgo0BQ 我的5斤百香果能领取啦来养猪一起赚#0E4EfAMIKuyDlW%打kai>【ぺ京倲金融ぺ App】\n`)
console.log(`\n京东账号${$.index} ${$.nickName} 未开启养猪活动,请手动去京东金融APP开启此活动\n`)
return
}
if (data.resultData.resultData.wished) {
if (data.resultData.resultData.wishAward) {
allMessage += `京东账号${$.index} ${$.nickName || $.UserName}\n${data.resultData.resultData.wishAward.name}已可兑换${$.index !== cookiesArr.length ? '\n\n' : ''}`
console.log(`【京东账号${$.index}${$.nickName || $.UserName} ${data.resultData.resultData.wishAward.name}已可兑换请及时去京东金融APP领取`)
$.finish = true
$.notAddFood = true;
}
}
console.log(`\n【京东账号${$.index}${$.nickName || $.UserName} 的邀请码为${data.resultData.resultData.user.shareId}\n`)
@@ -772,7 +780,7 @@ function getJumpInfo(juid) {
'Connection': 'keep-alive',
'Accept': 'application/json',
"Cookie": cookie,
'User-Agent': UA,
'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://u1.jr.jd.com/uc-fe-wxgrowing/cloudpig/index/',
'Accept-Encoding': 'gzip, deflate, br'
@@ -812,7 +820,7 @@ function queryMissionReceiveAfterStatus(missionId) {
"Cookie": cookie,
"Origin": "https://jdjoy.jd.com",
"Referer": "https://jdjoy.jd.com/",
"User-Agent": UA
"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")
}
}
$.get(options, (err, resp, data) => {
@@ -850,7 +858,7 @@ function finishReadMission(missionId, readTime) {
"Cookie": cookie,
"Origin": "https://jdjoy.jd.com",
"Referer": "https://jdjoy.jd.com/",
"User-Agent": UA
"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")
}
}
$.get(options, (err, resp, data) => {
@@ -881,6 +889,18 @@ function getAuthorShareCode(url) {
"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 {
resolve(JSON.parse(data))
@@ -951,7 +971,7 @@ function taskUrl(function_id, body) {
'Content-Type': `application/x-www-form-urlencoded;charset=UTF-8`,
'Host': `ms.jr.jd.com`,
'Connection': `keep-alive`,
'User-Agent': UA,
'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://u.jr.jd.com/`,
'Accept-Language': `zh-cn`
}