This commit is contained in:
lxk0301
2021-01-17 12:22:41 +08:00
parent 7660df8116
commit a2e8d9936c

View File

@@ -20,7 +20,7 @@ const $ = new Env('宠汪汪偷好友积分与狗粮');
const notify = $.isNode() ? require('./sendNotify') : ''; const notify = $.isNode() ? require('./sendNotify') : '';
//Node.js用户请在jdCookie.js处填写京东ck; //Node.js用户请在jdCookie.js处填写京东ck;
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000);
//IOS等用户直接用NobyDa的jd cookie //IOS等用户直接用NobyDa的jd cookie
let cookiesArr = [], cookie = ''; let cookiesArr = [], cookie = '';
if ($.isNode()) { if ($.isNode()) {
@@ -42,7 +42,6 @@ let message = '', subTitle = '';
let jdNotify = false;//是否开启静默运行false关闭静默运行(即通知)true打开静默运行(即不通知) let jdNotify = false;//是否开启静默运行false关闭静默运行(即通知)true打开静默运行(即不通知)
let jdJoyHelpFeed = false;//是否给好友喂食false为不给喂食true为给好友喂食默认不给好友喂食 let jdJoyHelpFeed = false;//是否给好友喂食false为不给喂食true为给好友喂食默认不给好友喂食
let jdJoyStealCoin = true;//是否偷好友积分与狗粮false为否true为是默认是偷 let jdJoyStealCoin = true;//是否偷好友积分与狗粮false为否true为是默认是偷
const weAppUrl = 'https://draw.jdfcloud.com//pet';
const JD_API_HOST = 'https://jdjoy.jd.com/pet' const JD_API_HOST = 'https://jdjoy.jd.com/pet'
!(async () => { !(async () => {
if (!cookiesArr[0]) { if (!cookiesArr[0]) {
@@ -80,40 +79,46 @@ const JD_API_HOST = 'https://jdjoy.jd.com/pet'
$.done(); $.done();
}) })
async function jdJoySteal() { async function jdJoySteal() {
await getFriends(); try {
if ($.getFriendsData && $.getFriendsData.success) { $.helpFood = 0;
message += `【京东账号${$.index}${$.nickName}\n`; $.stealFriendCoin = 0;
await getCoinChanges(); $.stealFood = 0;
if ($.getFriendsData && $.getFriendsData.datas && $.getFriendsData.datas.length > 0) { await getFriends();
const { lastPage } = $.getFriendsData.page; // $.log('data', JSON.stringify($.getFriendsData.datas))
console.log('lastPage', lastPage) if ($.getFriendsData && $.getFriendsData.success) {
$.allFriends = []; message += `【京东账号${$.index}${$.nickName}\n`;
for (let i = 1; i <= new Array(lastPage).fill('').length; i++) { await getCoinChanges();//查询喂食好友和偷好友积分是否已达上限
console.log(`开始查询第${i}页好友\n`); if ($.getFriendsData && $.getFriendsData.datas && $.getFriendsData.datas.length > 0) {
await getFriends(i); const { lastPage } = $.getFriendsData.page;
$.allFriends = $.allFriends.concat($.getFriendsData.datas); console.log('lastPage', lastPage)
} $.allFriends = [];
for (let index = 0; index < $.allFriends.length; index ++) { for (let i = 1; i <= new Array(lastPage).fill('').length; i++) {
//剔除自己 console.log(`开始查询第${i}页好友\n`);
if (!$.allFriends[index].stealStatus) { await getFriends(i);
$.allFriends.splice(index, 1); $.allFriends = $.allFriends.concat($.getFriendsData.datas);
} }
for (let index = 0; index < $.allFriends.length; index ++) {
//剔除自己
if (!$.allFriends[index].stealStatus) {
$.allFriends.splice(index, 1);
}
}
console.log(`${$.allFriends.length}个好友`);
await Promise.all([
stealFriendCoinFun(),//偷积分
stealFriendsFood(),//偷好友狗粮
helpFriendsFeed()//给好友喂食
])
} }
console.log(`${$.allFriends.length}个好友`); } else {
$.helpFood = 0; message += `${$.getFriendsData && $.getFriendsData.errorMessage}\n`;
$.stealFriendCoin = 0;
$.stealFood = 0;
await Promise.all([
stealFriendCoinFun(),//偷积分
stealFriendsFood(),//偷好友狗粮
helpFriendsFeed()//给好友喂食
])
} }
} else { } catch (e) {
message += `${$.getFriendsData && $.getFriendsData.errorMessage}\n`; $.logErr(e)
} }
} }
async function stealFriendsFood() { async function stealFriendsFood() {
if (nowTimes.getHours() < 6) return
let jdJoyStealCoinTemp; let jdJoyStealCoinTemp;
if ($.isNode() && process.env.jdJoyStealCoin) { if ($.isNode() && process.env.jdJoyStealCoin) {
jdJoyStealCoinTemp = `${process.env.jdJoyStealCoin}` === 'true'; jdJoyStealCoinTemp = `${process.env.jdJoyStealCoin}` === 'true';