mirror of https://github.com/KingRan/KR.git
更新农场
parent
6038e701b0
commit
cd6c1069a1
|
@ -10,19 +10,17 @@
|
|||
==========================Quantumultx=========================
|
||||
[task_local]
|
||||
#jd免费水果
|
||||
10 5,17 * * * jd_fruit_friend.js, tag=东东农场好友删减奖励, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdnc.png, enabled=true
|
||||
10 2 * * * jd_fruit_friend.js, tag=东东农场好友删减奖励, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdnc.png, enabled=true
|
||||
=========================Loon=============================
|
||||
[Script]
|
||||
cron "10 5,17 * * *" script-path=jd_fruit_friend.js,tag=东东农场好友删减奖励
|
||||
cron "10 2 * * *" script-path=jd_fruit_friend.js,tag=东东农场好友删减奖励
|
||||
|
||||
=========================Surge============================
|
||||
东东农场好友删减奖励 = type=cron,cronexp="10 5,17 * * *",wake-system=1,timeout=3600,script-path=jd_fruit_friend.js
|
||||
东东农场好友删减奖励 = type=cron,cronexp="10 2 * * *",wake-system=1,timeout=3600,script-path=jd_fruit_friend.js
|
||||
|
||||
=========================小火箭===========================
|
||||
东东农场好友删减奖励 = type=cron,script-path=jd_fruit_friend.js, cronexpr="10 5,17 * * *", timeout=3600, enable=true
|
||||
东东农场好友删减奖励 = type=cron,script-path=jd_fruit_friend.js, cronexpr="10 2 * * *", timeout=3600, enable=true
|
||||
|
||||
每号间隔(毫秒),默认0毫秒(0分钟)
|
||||
export fruit_sleep=20000
|
||||
|
||||
*/
|
||||
const $ = new Env('东东农场好友删减奖励');
|
||||
|
@ -36,6 +34,21 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action';
|
|||
const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html%22%20%7D`;
|
||||
let NowHour = new Date().getHours();
|
||||
let llhelp = true;
|
||||
const fs = require('fs');
|
||||
let boolneedUpdate = false;
|
||||
let strShare = './Fruit_ShareCache.json';
|
||||
let Fileexists = fs.existsSync(strShare);
|
||||
let TempShareCache = [];
|
||||
if (Fileexists) {
|
||||
console.log("检测到东东农场缓存文件Fruit_ShareCache.json,载入...");
|
||||
TempShareCache = fs.readFileSync(strShare, 'utf-8');
|
||||
if (TempShareCache) {
|
||||
TempShareCache = TempShareCache.toString();
|
||||
TempShareCache = JSON.parse(TempShareCache);
|
||||
}
|
||||
}
|
||||
let lnrun = 0;
|
||||
let llgetshare = false;
|
||||
!(async () => {
|
||||
await requireConfig();
|
||||
if (!cookiesArr[0]) {
|
||||
|
@ -43,7 +56,7 @@ let llhelp=true;
|
|||
return;
|
||||
}
|
||||
if(llhelp){
|
||||
console.log('开始收集您的互助码,用于好友删除与加好友操作');
|
||||
console.log('\n【开始收集您的互助码,用于好友删除与加好友操作】\n');
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
if (cookiesArr[i]) {
|
||||
cookie = cookiesArr[i];
|
||||
|
@ -64,11 +77,32 @@ let llhelp=true;
|
|||
subTitle = '';
|
||||
option = {};
|
||||
$.retry = 0;
|
||||
llgetshare = false;
|
||||
await GetCollect();
|
||||
await $.wait(1500);
|
||||
if(llgetshare){
|
||||
await $.wait(5000);
|
||||
lnrun++;
|
||||
}
|
||||
if(lnrun == 10){
|
||||
console.log(`\n【访问接口次数达到10次,休息一分钟.....】\n`);
|
||||
await $.wait(60*1000);
|
||||
lnrun = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (boolneedUpdate) {
|
||||
var str = JSON.stringify(TempShareCache, null, 2);
|
||||
fs.writeFile(strShare, str, function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
console.log("\n【缓存文件Fruit_ShareCache.json更新失败!】\n");
|
||||
} else {
|
||||
console.log("\n【缓存文件Fruit_ShareCache.json更新成功!】\n");
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
console.log('\n【互助码已经收集完毕,现在开始账号内部互助,请稍等...】\n');
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
if (cookiesArr[i]) {
|
||||
cookie = cookiesArr[i];
|
||||
|
@ -90,11 +124,13 @@ let llhelp=true;
|
|||
subTitle = '';
|
||||
option = {};
|
||||
$.retry = 0;
|
||||
lnrun++;
|
||||
await jdFruit();
|
||||
await $.wait(30 * 1000);
|
||||
if (lnrun == 5) {
|
||||
console.log(`\n【访问接口次数达到5次,休息一分钟.....】\n`);
|
||||
await $.wait(60 * 1000);
|
||||
lnrun = 0;
|
||||
}
|
||||
if ($.isNode()) {
|
||||
process.env.fruit_sleep ? await $.wait(Number(process.env.fruit_sleep)) : ''
|
||||
}
|
||||
}
|
||||
if ($.isNode() && allMessage && $.ctrTemp) {
|
||||
|
@ -173,13 +209,39 @@ async function receiveFriendInvite() {
|
|||
}
|
||||
async function GetCollect() {
|
||||
try {
|
||||
console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】`);
|
||||
var llfound = false;
|
||||
var strShareCode = "";
|
||||
if (TempShareCache) {
|
||||
for (let j = 0; j < TempShareCache.length; j++) {
|
||||
if (TempShareCache[j].pt_pin == $.UserName) {
|
||||
llfound = true;
|
||||
strShareCode = TempShareCache[j].ShareCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!llfound) {
|
||||
console.log($.UserName + "该账号无缓存,尝试联网获取互助码.....");
|
||||
llgetshare=true;
|
||||
await initForFarm();
|
||||
if ($.farmInfo.farmUserPro) {
|
||||
console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}互助码】${$.farmInfo.farmUserPro.shareCode}`);
|
||||
newShareCodes.push($.farmInfo.farmUserPro.shareCode)
|
||||
var tempAddCK = {};
|
||||
strShareCode=$.farmInfo.farmUserPro.shareCode;
|
||||
tempAddCK = {
|
||||
"pt_pin": $.UserName,
|
||||
"ShareCode": strShareCode
|
||||
};
|
||||
TempShareCache.push(tempAddCK);
|
||||
//标识,需要更新缓存文件
|
||||
boolneedUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (strShareCode) {
|
||||
console.log(`\n`+strShareCode);
|
||||
newShareCodes.push(strShareCode)
|
||||
} else {
|
||||
console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}互助码】\n数据异常,使用作者的互助码:94f3ba0769b04c94bbfca26139108702`);
|
||||
newShareCodes.push("94f3ba0769b04c94bbfca26139108702");
|
||||
console.log(`\n数据异常`);
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e);
|
||||
|
@ -572,7 +634,7 @@ function TotalBean() {
|
|||
})
|
||||
})
|
||||
}
|
||||
function request(function_id, body = {}, timeout = 1000) {
|
||||
function request(function_id, body = {}, timeout = 2000) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
$.get(taskUrl(function_id, body), (err, resp, data) => {
|
||||
|
|
|
@ -23,9 +23,6 @@ cron "20 4,16 * * *" script-path=jd_fruit_help.js,tag=东东农场内部互助
|
|||
|
||||
export DO_TEN_WATER_AGAIN="" 默认再次浇水
|
||||
|
||||
每号间隔(毫秒),默认0毫秒(0分钟)
|
||||
export fruit_sleep=20000
|
||||
|
||||
*/
|
||||
const $ = new Env('东东农场内部水滴互助');
|
||||
let cookiesArr = [],
|
||||
|
@ -55,6 +52,21 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action';
|
|||
const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html%22%20%7D`;
|
||||
let NowHour = new Date().getHours();
|
||||
let llhelp = true;
|
||||
const fs = require('fs');
|
||||
let boolneedUpdate = false;
|
||||
let strShare = './Fruit_ShareCache.json';
|
||||
let Fileexists = fs.existsSync(strShare);
|
||||
let TempShareCache = [];
|
||||
if (Fileexists) {
|
||||
console.log("检测到东东农场缓存文件Fruit_ShareCache.json,载入...");
|
||||
TempShareCache = fs.readFileSync(strShare, 'utf-8');
|
||||
if (TempShareCache) {
|
||||
TempShareCache = TempShareCache.toString();
|
||||
TempShareCache = JSON.parse(TempShareCache);
|
||||
}
|
||||
}
|
||||
let lnrun = 0;
|
||||
let llgetshare = false;
|
||||
!(async() => {
|
||||
await requireConfig();
|
||||
if (!cookiesArr[0]) {
|
||||
|
@ -62,7 +74,7 @@ let llhelp=true;
|
|||
return;
|
||||
}
|
||||
if(llhelp){
|
||||
console.log('开始收集您的互助码,用于账号内部互助,请稍等...');
|
||||
console.log('\n【开始收集您的互助码,用于账号内部互助,请稍等...】\n');
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
if (cookiesArr[i]) {
|
||||
cookie = cookiesArr[i];
|
||||
|
@ -83,11 +95,32 @@ let llhelp=true;
|
|||
subTitle = '';
|
||||
option = {};
|
||||
$.retry = 0;
|
||||
llgetshare = false;
|
||||
await GetCollect();
|
||||
await $.wait(1500);
|
||||
if(llgetshare){
|
||||
await $.wait(5000);
|
||||
lnrun++;
|
||||
}
|
||||
if(lnrun == 10){
|
||||
console.log(`\n【访问接口次数达到10次,休息一分钟.....】\n`);
|
||||
await $.wait(60*1000);
|
||||
lnrun = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (boolneedUpdate) {
|
||||
var str = JSON.stringify(TempShareCache, null, 2);
|
||||
fs.writeFile(strShare, str, function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
console.log("\n【缓存文件Fruit_ShareCache.json更新失败!】\n");
|
||||
} else {
|
||||
console.log("\n【缓存文件Fruit_ShareCache.json更新成功!】\n");
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
console.log('\n【互助码已经收集完毕,现在开始账号内部互助,请稍等...】\n');
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
if (cookiesArr[i]) {
|
||||
cookie = cookiesArr[i];
|
||||
|
@ -109,11 +142,13 @@ let llhelp=true;
|
|||
subTitle = '';
|
||||
option = {};
|
||||
$.retry = 0;
|
||||
lnrun++;
|
||||
await jdFruit();
|
||||
await $.wait(20 * 1000);
|
||||
if (lnrun == 5) {
|
||||
console.log(`\n【访问接口次数达到5次,休息一分钟.....】\n`);
|
||||
await $.wait(60 * 1000);
|
||||
lnrun = 0;
|
||||
}
|
||||
if ($.isNode()) {
|
||||
process.env.fruit_sleep ? await $.wait(Number(process.env.fruit_sleep)) : ''
|
||||
}
|
||||
}
|
||||
if ($.isNode() && allMessage && $.ctrTemp) {
|
||||
|
@ -231,7 +266,7 @@ async function turntableFarm() {
|
|||
}
|
||||
//助力好友
|
||||
async function masterHelpShare() {
|
||||
|
||||
await $.wait(2000);
|
||||
await initForFarm();
|
||||
let salveHelpAddWater = 0;
|
||||
let remainTimes = 3;//今日剩余助力次数,默认3次(京东农场每人每天3次助力机会)。
|
||||
|
@ -250,7 +285,6 @@ async function masterHelpShare() {
|
|||
continue
|
||||
}
|
||||
await masterHelp(code);
|
||||
await $.wait(2000);
|
||||
if ($.helpResult.code === '0') {
|
||||
if ($.helpResult.helpResult.code === '0') {
|
||||
//助力成功
|
||||
|
@ -307,17 +341,45 @@ async function masterHelpShare() {
|
|||
|
||||
async function GetCollect() {
|
||||
try {
|
||||
console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】`);
|
||||
var llfound = false;
|
||||
var strShareCode = "";
|
||||
if (TempShareCache) {
|
||||
for (let j = 0; j < TempShareCache.length; j++) {
|
||||
if (TempShareCache[j].pt_pin == $.UserName) {
|
||||
llfound = true;
|
||||
strShareCode = TempShareCache[j].ShareCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!llfound) {
|
||||
console.log($.UserName + "该账号无缓存,尝试联网获取互助码.....");
|
||||
llgetshare=true;
|
||||
await initForFarm();
|
||||
if ($.farmInfo.farmUserPro) {
|
||||
console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.farmInfo.farmUserPro.shareCode}`);
|
||||
newShareCodes.push($.farmInfo.farmUserPro.shareCode)
|
||||
var tempAddCK = {};
|
||||
strShareCode=$.farmInfo.farmUserPro.shareCode;
|
||||
tempAddCK = {
|
||||
"pt_pin": $.UserName,
|
||||
"ShareCode": strShareCode
|
||||
};
|
||||
TempShareCache.push(tempAddCK);
|
||||
//标识,需要更新缓存文件
|
||||
boolneedUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (strShareCode) {
|
||||
console.log(`\n`+strShareCode);
|
||||
newShareCodes.push(strShareCode)
|
||||
} else {
|
||||
console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】\n数据异常`);
|
||||
console.log(`\n数据异常`);
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e);
|
||||
}
|
||||
}
|
||||
|
||||
// ========================API调用接口========================
|
||||
//鸭子,点我有惊喜
|
||||
async function getFullCollectionReward() {
|
||||
|
@ -708,7 +770,7 @@ function TotalBean() {
|
|||
})
|
||||
}
|
||||
|
||||
function request(function_id, body = {}, timeout = 1000) {
|
||||
function request(function_id, body = {}, timeout = 2000) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
$.get(taskUrl(function_id, body), (err, resp, data) => {
|
||||
|
|
|
@ -23,9 +23,6 @@ cron "5 6-18/6 * * *" script-path=jd_fruit_task.js,tag=东东农场日常任务
|
|||
|
||||
export DO_TEN_WATER_AGAIN="" 默认再次浇水
|
||||
|
||||
每号间隔(毫秒),默认0毫秒(0分钟)
|
||||
export fruit_sleep=20000
|
||||
|
||||
*/
|
||||
const $ = new Env('东东农场日常任务');
|
||||
let cookiesArr = [],
|
||||
|
@ -52,6 +49,7 @@ let jdFruitBeanCard = false; //农场使用水滴换豆卡(如果出现限时活
|
|||
let randomCount = $.isNode() ? 20 : 5;
|
||||
const JD_API_HOST = 'https://api.m.jd.com/client.action';
|
||||
const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html%22%20%7D`;
|
||||
let lnrun = 0;
|
||||
!(async() => {
|
||||
await requireConfig();
|
||||
if (!cookiesArr[0]) {
|
||||
|
@ -79,12 +77,14 @@ const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%2
|
|||
subTitle = '';
|
||||
option = {};
|
||||
$.retry = 0;
|
||||
//await shareCodesFormat();
|
||||
lnrun++;
|
||||
await jdFruit();
|
||||
await $.wait(30 * 1000);
|
||||
if (lnrun == 3) {
|
||||
console.log(`\n【访问接口次数达到3次,休息一分钟.....】\n`);
|
||||
await $.wait(60 * 1000);
|
||||
lnrun = 0;
|
||||
}
|
||||
if ($.isNode()) {
|
||||
process.env.fruit_sleep ? await $.wait(Number(process.env.fruit_sleep)) : ''
|
||||
await $.wait(30 * 1000);
|
||||
}
|
||||
}
|
||||
if ($.isNode() && allMessage && $.ctrTemp) {
|
||||
|
@ -1207,14 +1207,12 @@ function timeFormat(time) {
|
|||
}
|
||||
return date.getFullYear() + '-' + ((date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)) + '-' + (date.getDate() >= 10 ? date.getDate() : '0' + date.getDate());
|
||||
}
|
||||
|
||||
function requireConfig() {
|
||||
return new Promise(resolve => {
|
||||
console.log('开始获取配置文件\n')
|
||||
notify = $.isNode() ? require('./sendNotify') : '';
|
||||
//Node.js用户请在jdCookie.js处填写京东ck;
|
||||
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
|
||||
const jdFruitShareCodes = $.isNode() ? require('./jdFruitShareCodes.js') : '';
|
||||
//IOS等用户直接用NobyDa的jd cookie
|
||||
if ($.isNode()) {
|
||||
Object.keys(jdCookieNode).forEach((item) => {
|
||||
|
@ -1228,19 +1226,6 @@ function requireConfig() {
|
|||
}
|
||||
console.log(`共${cookiesArr.length}个京东账号\n`)
|
||||
$.shareCodesArr = [];
|
||||
if ($.isNode()) {
|
||||
Object.keys(jdFruitShareCodes).forEach((item) => {
|
||||
if (jdFruitShareCodes[item]) {
|
||||
$.shareCodesArr.push(jdFruitShareCodes[item])
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if ($.getdata('jd_fruit_inviter')) $.shareCodesArr = $.getdata('jd_fruit_inviter').split('\n').filter(item => !!item);
|
||||
console.log(`\nBoxJs设置的${$.name}好友邀请码:${$.getdata('jd_fruit_inviter') ? $.getdata('jd_fruit_inviter') : '暂无'}\n`);
|
||||
}
|
||||
// console.log(`$.shareCodesArr::${JSON.stringify($.shareCodesArr)}`)
|
||||
// console.log(`jdFruitShareArr账号长度::${$.shareCodesArr.length}`)
|
||||
// console.log(`您提供了${$.shareCodesArr.length}个账号的农场助力码\n`);
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue