优化代码

This commit is contained in:
黄志军
2021-11-09 14:13:03 +08:00
parent 2458118998
commit a4a738ef0d
2 changed files with 1406 additions and 1339 deletions
+51 -51
View File
@@ -4,7 +4,7 @@ let cookiesArr = [], cookie = '', jdFruitShareArr = [], isBox = false, notify, n
//下面给出两个账号的填写示例(iOS只支持2个动动账号) //下面给出两个账号的填写示例(iOS只支持2个动动账号)
let shareCodes = let shareCodes =
[ // 这个列表填入你要助力的好友的shareCode [ // 这个列表填入你要助力的好友的shareCode
] ]
let message = '', subTitle = '', option = {}, isFruitFinished = false; let message = '', subTitle = '', option = {}, isFruitFinished = false;
let dingtalk = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38f0df63e20797c002208d2710104750c18a1dc84d54106a859a3f0" let dingtalk = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38f0df63e20797c002208d2710104750c18a1dc84d54106a859a3f0"
const retainWater = 100;//保留水滴大于多少g,默认100g; const retainWater = 100;//保留水滴大于多少g,默认100g;
@@ -17,7 +17,7 @@ const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%2
await requireConfig(); await requireConfig();
message += "<font color=\'#FFA500\'>[通知] </font><font color=\'#006400\' size='3'>动动农场</font> \n\n --- \n\n" message += "<font color=\'#FFA500\'>[通知] </font><font color=\'#006400\' size='3'>动动农场</font> \n\n --- \n\n"
if (!cookiesArr[0]) { if (!cookiesArr[0]) {
$.msg($.name, '【提示】请先获取动动账号一cookie\n直接使用NobyDa的动动签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); $.msg($.name, '【提示】请先获取动动账号一cookie\n直接使用NobyDa的动动签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" });
return; return;
} }
for (let i = 0; i < cookiesArr.length; i++) { for (let i = 0; i < cookiesArr.length; i++) {
@@ -30,13 +30,13 @@ const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%2
$.nickName = ''; $.nickName = '';
await TotalBean(); await TotalBean();
username = $.UserName username = $.UserName
if ($.UserName == "jd_66ea783827d30"){ if ($.UserName == "jd_66ea783827d30") {
username = "跑腿小弟" username = "跑腿小弟"
} }
if ($.UserName == "jd_4521b375ebb5d"){ if ($.UserName == "jd_4521b375ebb5d") {
username = "锟锟" username = "锟锟"
} }
if ($.UserName == "jd_542c10c0222bc"){ if ($.UserName == "jd_542c10c0222bc") {
username = "康康" username = "康康"
} }
@@ -45,7 +45,7 @@ const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%2
message = message + "<font color=\'#778899\' size=2>【羊毛姐妹】<font color=\'#FFA500\' size=3>" + username + " </font> </font> \n\n " message = message + "<font color=\'#778899\' size=2>【羊毛姐妹】<font color=\'#FFA500\' size=3>" + username + " </font> </font> \n\n "
that.log(`\n开始【动动账号${$.index}${$.nickName || $.UserName}\n`); that.log(`\n开始【动动账号${$.index}${$.nickName || $.UserName}\n`);
if (!$.isLogin) { if (!$.isLogin) {
$.msg($.name, `【提示】cookie已失效`, `动动账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); $.msg($.name, `【提示】cookie已失效`, `动动账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" });
if ($.isNode()) { if ($.isNode()) {
await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `动动账号${$.index} ${$.UserName}\n请重新登录获取cookie`); await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `动动账号${$.index} ${$.UserName}\n请重新登录获取cookie`);
@@ -236,9 +236,9 @@ async function predictionFruit() {
message += "<font color=\'#778899\' size=2>【今日共浇水】" + `${waterEveryDayT}` + "次 </font>\n\n" message += "<font color=\'#778899\' size=2>【今日共浇水】" + `${waterEveryDayT}` + "次 </font>\n\n"
message += "<font color=\'#778899\' size=2>【剩余 水滴】" + `${$.farmInfo.farmUserPro.totalEnergy}` + "g💧 </font> \n\n" message += "<font color=\'#778899\' size=2>【剩余 水滴】" + `${$.farmInfo.farmUserPro.totalEnergy}` + "g💧 </font> \n\n"
message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `${(($.farmInfo.farmUserPro.treeEnergy / message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `${(($.farmInfo.farmUserPro.treeEnergy /
$.farmInfo.farmUserPro.treeTotalEnergy) * 100).toFixed(2)}` + "%,已浇水" +`${$.farmInfo.farmUserPro.treeEnergy / 10}` + "次,还需"+`${($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy) / 10}` +"次 </font> \n\n" $.farmInfo.farmUserPro.treeTotalEnergy) * 100).toFixed(2)}` + "%,已浇水" + `${$.farmInfo.farmUserPro.treeEnergy / 10}` + "次,还需" + `${($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy) / 10}` + "次 </font> \n\n"
if ($.farmInfo.toFlowTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) { if ($.farmInfo.toFlowTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) {
message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `【开花进度】再浇水${$.farmInfo.toFlowTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次开花\n\n` +"</font>\n\n" message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `【开花进度】再浇水${$.farmInfo.toFlowTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次开花\n\n` + "</font>\n\n"
} else if ($.farmInfo.toFruitTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) { } else if ($.farmInfo.toFruitTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) {
message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `【结果进度】再浇水${$.farmInfo.toFruitTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次结果\n\n` + "</font>\n\n" message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `【结果进度】再浇水${$.farmInfo.toFruitTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次结果\n\n` + "</font>\n\n"
} }
@@ -247,7 +247,7 @@ async function predictionFruit() {
let waterD = Math.ceil(waterTotalT / waterEveryDayT); let waterD = Math.ceil(waterTotalT / waterEveryDayT);
message = message + "<font color=\'#BA55D3\' size=2>" + `【预测】${waterD === 1 ? '明天' : waterD === 2 ? '后天' : waterD + '天之后'}(${timeFormat(24 * 60 * 60 * 1000 * waterD + Date.now())}日)可兑换水果🍉` +"</font>\n\n"; message = message + "<font color=\'#BA55D3\' size=2>" + `【预测】${waterD === 1 ? '明天' : waterD === 2 ? '后天' : waterD + '天之后'}(${timeFormat(24 * 60 * 60 * 1000 * waterD + Date.now())}日)可兑换水果🍉` + "</font>\n\n";
} }
//浇水十次 //浇水十次
async function doTenWater() { async function doTenWater() {
@@ -342,7 +342,7 @@ async function doTenWaterAgain() {
that.log(`剩余水滴${totalEnergy}g\n`); that.log(`剩余水滴${totalEnergy}g\n`);
await myCardInfoForFarm(); await myCardInfoForFarm();
const { fastCard, doubleCard, beanCard, signCard } = $.myCardInfoRes; const { fastCard, doubleCard, beanCard, signCard } = $.myCardInfoRes;
that.log(`背包已有道具:\n快速浇水卡:${fastCard === -1 ? '未解锁': fastCard + '张'}\n水滴翻倍卡:${doubleCard === -1 ? '未解锁': doubleCard + '张'}\n水滴换京豆卡:${beanCard === -1 ? '未解锁' : beanCard + '张'}\n加签卡:${signCard === -1 ? '未解锁' : signCard + '张'}\n`) that.log(`背包已有道具:\n快速浇水卡:${fastCard === -1 ? '未解锁' : fastCard + '张'}\n水滴翻倍卡:${doubleCard === -1 ? '未解锁' : doubleCard + '张'}\n水滴换京豆卡:${beanCard === -1 ? '未解锁' : beanCard + '张'}\n加签卡:${signCard === -1 ? '未解锁' : signCard + '张'}\n`)
if (totalEnergy >= 100 && doubleCard > 0) { if (totalEnergy >= 100 && doubleCard > 0) {
//使用翻倍水滴卡 //使用翻倍水滴卡
for (let i = 0; i < new Array(doubleCard).fill('').length; i++) { for (let i = 0; i < new Array(doubleCard).fill('').length; i++) {
@@ -372,7 +372,7 @@ async function doTenWaterAgain() {
await userMyCardForFarm('beanCard'); await userMyCardForFarm('beanCard');
that.log(`使用水滴换豆卡结果:${JSON.stringify($.userMyCardRes)}`); that.log(`使用水滴换豆卡结果:${JSON.stringify($.userMyCardRes)}`);
if ($.userMyCardRes.code === '0') { if ($.userMyCardRes.code === '0') {
message +="<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `【水滴换豆卡】获得${$.userMyCardRes.beanCount}个京豆\n` + "</font>\n\n"; message += "<font color=\'#BA55D3\' size=2>【水果🍉进度】" + `【水滴换豆卡】获得${$.userMyCardRes.beanCount}个京豆\n` + "</font>\n\n";
return return
} }
} else { } else {
@@ -487,11 +487,11 @@ async function turntableFarm() {
await initForTurntableFarm(); await initForTurntableFarm();
if ($.initForTurntableFarmRes.code === '0') { if ($.initForTurntableFarmRes.code === '0') {
//领取定时奖励 //4小时一次 //领取定时奖励 //4小时一次
let {timingIntervalHours, timingLastSysTime, sysTime, timingGotStatus, remainLotteryTimes, turntableInfos} = $.initForTurntableFarmRes; let { timingIntervalHours, timingLastSysTime, sysTime, timingGotStatus, remainLotteryTimes, turntableInfos } = $.initForTurntableFarmRes;
if (!timingGotStatus) { if (!timingGotStatus) {
that.log(`是否到了领取免费赠送的抽奖机会----${sysTime > (timingLastSysTime + 60*60*timingIntervalHours*1000)}`) that.log(`是否到了领取免费赠送的抽奖机会----${sysTime > (timingLastSysTime + 60 * 60 * timingIntervalHours * 1000)}`)
if (sysTime > (timingLastSysTime + 60*60*timingIntervalHours*1000)) { if (sysTime > (timingLastSysTime + 60 * 60 * timingIntervalHours * 1000)) {
await timingAwardForTurntableFarm(); await timingAwardForTurntableFarm();
that.log(`领取定时奖励结果${JSON.stringify($.timingAwardRes)}`); that.log(`领取定时奖励结果${JSON.stringify($.timingAwardRes)}`);
await initForTurntableFarm(); await initForTurntableFarm();
@@ -643,9 +643,9 @@ function getHelp() {
} }
}) })
}); });
} }
function setHelp() { function setHelp() {
return new Promise(resolve => { return new Promise(resolve => {
if ($.farmInfo.farmUserPro.shareCode) { if ($.farmInfo.farmUserPro.shareCode) {
$.get({ $.get({
@@ -671,7 +671,7 @@ function getHelp() {
} }
}); });
} }
//助力好友 //助力好友
async function masterHelpShare() { async function masterHelpShare() {
@@ -831,7 +831,7 @@ async function getAwardInviteFriend() {
if ($.friendList.friends && $.friendList.friends.length > 0) { if ($.friendList.friends && $.friendList.friends.length > 0) {
for (let friend of $.friendList.friends) { for (let friend of $.friendList.friends) {
that.log(`\n开始删除好友 [${friend.shareCode}]`); that.log(`\n开始删除好友 [${friend.shareCode}]`);
const deleteFriendForFarm = await request('deleteFriendForFarm', { "shareCode": `${friend.shareCode}`,"version":8,"channel":1 }); const deleteFriendForFarm = await request('deleteFriendForFarm', { "shareCode": `${friend.shareCode}`, "version": 8, "channel": 1 });
if (deleteFriendForFarm && deleteFriendForFarm.code === '0') { if (deleteFriendForFarm && deleteFriendForFarm.code === '0') {
that.log(`删除好友 [${friend.shareCode}] 成功\n`); that.log(`删除好友 [${friend.shareCode}] 成功\n`);
} }
@@ -871,11 +871,11 @@ async function doFriendsWater() {
//TODO ,发现bug,github action运行发现有些账号第一次没有给3个好友浇水 //TODO ,发现bug,github action运行发现有些账号第一次没有给3个好友浇水
that.log(`需要浇水的好友列表shareCodes:${JSON.stringify(needWaterFriends)}`); that.log(`需要浇水的好友列表shareCodes:${JSON.stringify(needWaterFriends)}`);
let waterFriendsCount = 0, cardInfoStr = ''; let waterFriendsCount = 0, cardInfoStr = '';
for (let index = 0; index < needWaterFriends.length; index ++) { for (let index = 0; index < needWaterFriends.length; index++) {
await waterFriendForFarm(needWaterFriends[index]); await waterFriendForFarm(needWaterFriends[index]);
that.log(`为第${index+1}个好友浇水结果:${JSON.stringify($.waterFriendForFarmRes)}\n`) that.log(`为第${index + 1}个好友浇水结果:${JSON.stringify($.waterFriendForFarmRes)}\n`)
if ($.waterFriendForFarmRes.code === '0') { if ($.waterFriendForFarmRes.code === '0') {
waterFriendsCount ++; waterFriendsCount++;
if ($.waterFriendForFarmRes.cardInfo) { if ($.waterFriendForFarmRes.cardInfo) {
that.log('为好友浇水获得道具了'); that.log('为好友浇水获得道具了');
if ($.waterFriendForFarmRes.cardInfo.type === 'beanCard') { if ($.waterFriendForFarmRes.cardInfo.type === 'beanCard') {
@@ -982,7 +982,7 @@ async function duck() {
//鸭子,点我有惊喜 //鸭子,点我有惊喜
async function getFullCollectionReward() { async function getFullCollectionReward() {
return new Promise(resolve => { return new Promise(resolve => {
const body = {"type": 2, "version": 6, "channel": 2}; const body = { "type": 2, "version": 6, "channel": 2 };
$.post(taskUrl("getFullCollectionReward", body), (err, resp, data) => { $.post(taskUrl("getFullCollectionReward", body), (err, resp, data) => {
try { try {
if (err) { if (err) {
@@ -1018,17 +1018,17 @@ async function firstWaterTaskForFarm() {
//领取给3个好友浇水后的奖励水滴API //领取给3个好友浇水后的奖励水滴API
async function waterFriendGotAwardForFarm() { async function waterFriendGotAwardForFarm() {
const functionId = 'waterFriendGotAwardForFarm'; const functionId = 'waterFriendGotAwardForFarm';
$.waterFriendGotAwardRes = await request(functionId, {"version": 4, "channel": 1}); $.waterFriendGotAwardRes = await request(functionId, { "version": 4, "channel": 1 });
} }
// 查询背包道具卡API // 查询背包道具卡API
async function myCardInfoForFarm() { async function myCardInfoForFarm() {
const functionId = 'myCardInfoForFarm'; const functionId = 'myCardInfoForFarm';
$.myCardInfoRes = await request(functionId, {"version": 5, "channel": 1}); $.myCardInfoRes = await request(functionId, { "version": 5, "channel": 1 });
} }
//使用道具卡API //使用道具卡API
async function userMyCardForFarm(cardType) { async function userMyCardForFarm(cardType) {
const functionId = 'userMyCardForFarm'; const functionId = 'userMyCardForFarm';
$.userMyCardRes = await request(functionId, {"cardType": cardType}); $.userMyCardRes = await request(functionId, { "cardType": cardType });
} }
/** /**
* 领取浇水过程中的阶段性奖励 * 领取浇水过程中的阶段性奖励
@@ -1036,7 +1036,7 @@ async function userMyCardForFarm(cardType) {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async function gotStageAwardForFarm(type) { async function gotStageAwardForFarm(type) {
$.gotStageAwardForFarmRes = await request('gotStageAwardForFarm', {'type': type}); $.gotStageAwardForFarmRes = await request('gotStageAwardForFarm', { 'type': type });
} }
//浇水API //浇水API
async function waterGoodForFarm() { async function waterGoodForFarm() {
@@ -1048,16 +1048,16 @@ async function waterGoodForFarm() {
} }
// 初始化集卡抽奖活动数据API // 初始化集卡抽奖活动数据API
async function initForTurntableFarm() { async function initForTurntableFarm() {
$.initForTurntableFarmRes = await request('initForTurntableFarm', {version: 4, channel: 1}); $.initForTurntableFarmRes = await request('initForTurntableFarm', { version: 4, channel: 1 });
} }
async function lotteryForTurntableFarm() { async function lotteryForTurntableFarm() {
await $.wait(2000); await $.wait(2000);
that.log('等待了2秒'); that.log('等待了2秒');
$.lotteryRes = await request('lotteryForTurntableFarm', {type: 1, version: 4, channel: 1}); $.lotteryRes = await request('lotteryForTurntableFarm', { type: 1, version: 4, channel: 1 });
} }
async function timingAwardForTurntableFarm() { async function timingAwardForTurntableFarm() {
$.timingAwardRes = await request('timingAwardForTurntableFarm', {version: 4, channel: 1}); $.timingAwardRes = await request('timingAwardForTurntableFarm', { version: 4, channel: 1 });
} }
async function browserForTurntableFarm(type, adId) { async function browserForTurntableFarm(type, adId) {
@@ -1067,13 +1067,13 @@ async function browserForTurntableFarm(type, adId) {
if (type === 2) { if (type === 2) {
that.log('天天抽奖浏览任务领取水滴'); that.log('天天抽奖浏览任务领取水滴');
} }
const body = {"type": type,"adId": adId,"version":4,"channel":1}; const body = { "type": type, "adId": adId, "version": 4, "channel": 1 };
$.browserForTurntableFarmRes = await request('browserForTurntableFarm', body); $.browserForTurntableFarmRes = await request('browserForTurntableFarm', body);
// 浏览爆品会场8秒 // 浏览爆品会场8秒
} }
//天天抽奖浏览任务领取水滴API //天天抽奖浏览任务领取水滴API
async function browserForTurntableFarm2(type) { async function browserForTurntableFarm2(type) {
const body = {"type":2,"adId": type,"version":4,"channel":1}; const body = { "type": 2, "adId": type, "version": 4, "channel": 1 };
$.browserForTurntableFarm2Res = await request('browserForTurntableFarm', body); $.browserForTurntableFarm2Res = await request('browserForTurntableFarm', body);
} }
/** /**
@@ -1126,7 +1126,7 @@ async function masterHelp() {
*/ */
async function waterRainForFarm() { async function waterRainForFarm() {
const functionId = 'waterRainForFarm'; const functionId = 'waterRainForFarm';
const body = {"type": 1, "hongBaoTimes": 100, "version": 3}; const body = { "type": 1, "hongBaoTimes": 100, "version": 3 };
$.waterRain = await request(functionId, body); $.waterRain = await request(functionId, body);
} }
/** /**
@@ -1140,7 +1140,7 @@ async function clockInInitForFarm() {
// 连续签到API // 连续签到API
async function clockInForFarm() { async function clockInForFarm() {
const functionId = 'clockInForFarm'; const functionId = 'clockInForFarm';
$.clockInForFarmRes = await request(functionId, {"type": 1}); $.clockInForFarmRes = await request(functionId, { "type": 1 });
} }
//关注,领券等API //关注,领券等API
@@ -1168,12 +1168,12 @@ async function clockInFollowForFarm(id, type, step) {
// 领取连续签到7天的惊喜礼包API // 领取连续签到7天的惊喜礼包API
async function gotClockInGift() { async function gotClockInGift() {
$.gotClockInGiftRes = await request('clockInForFarm', {"type": 2}) $.gotClockInGiftRes = await request('clockInForFarm', { "type": 2 })
} }
//定时领水API //定时领水API
async function gotThreeMealForFarm() { async function gotThreeMealForFarm() {
const functionId ='gotThreeMealForFarm'; const functionId = 'gotThreeMealForFarm';
$.threeMeal = await request(functionId); $.threeMeal = await request(functionId);
} }
/** /**
@@ -1184,14 +1184,14 @@ async function gotThreeMealForFarm() {
async function browseAdTaskForFarm(advertId, type) { async function browseAdTaskForFarm(advertId, type) {
const functionId = 'browseAdTaskForFarm'; const functionId = 'browseAdTaskForFarm';
if (type === 0) { if (type === 0) {
$.browseResult = await request(functionId, {advertId, type}); $.browseResult = await request(functionId, { advertId, type });
} else if (type === 1) { } else if (type === 1) {
$.browseRwardResult = await request(functionId, {advertId, type}); $.browseRwardResult = await request(functionId, { advertId, type });
} }
} }
// 被水滴砸中API // 被水滴砸中API
async function gotWaterGoalTaskForFarm() { async function gotWaterGoalTaskForFarm() {
$.goalResult = await request('gotWaterGoalTaskForFarm', {type: 3}); $.goalResult = await request('gotWaterGoalTaskForFarm', { type: 3 });
} }
//签到API //签到API
async function signForFarm() { async function signForFarm() {
@@ -1205,7 +1205,7 @@ async function initForFarm() {
return new Promise(resolve => { return new Promise(resolve => {
const option = { const option = {
url: `${JD_API_HOST}?functionId=initForFarm`, url: `${JD_API_HOST}?functionId=initForFarm`,
body: `body=${escape(JSON.stringify({"version":4}))}&appid=wh5&clientVersion=9.1.0`, body: `body=${escape(JSON.stringify({ "version": 4 }))}&appid=wh5&clientVersion=9.1.0`,
headers: { headers: {
"accept": "*/*", "accept": "*/*",
"accept-encoding": "gzip, deflate, br", "accept-encoding": "gzip, deflate, br",
@@ -1251,7 +1251,7 @@ async function taskInitForFarm() {
} }
//获取好友列表API //获取好友列表API
async function friendListInitForFarm() { async function friendListInitForFarm() {
$.friendList = await request('friendListInitForFarm', {"version": 4, "channel": 1}); $.friendList = await request('friendListInitForFarm', { "version": 4, "channel": 1 });
// that.log('aa', aa); // that.log('aa', aa);
} }
// 领取邀请好友的奖励API // 领取邀请好友的奖励API
@@ -1260,7 +1260,7 @@ async function awardInviteFriendForFarm() {
} }
//为好友浇水API //为好友浇水API
async function waterFriendForFarm(shareCode) { async function waterFriendForFarm(shareCode) {
const body = {"shareCode": shareCode, "version": 6, "channel": 1} const body = { "shareCode": shareCode, "version": 6, "channel": 1 }
$.waterFriendForFarmRes = await request('waterFriendForFarm', body); $.waterFriendForFarmRes = await request('waterFriendForFarm', body);
} }
async function showMsg() { async function showMsg() {
@@ -1293,7 +1293,7 @@ function timeFormat(time) {
} }
function readShareCode() { function readShareCode() {
return new Promise(async resolve => { return new Promise(async resolve => {
$.get({url: `http://jd.turinglabs.net/api/v2/jd/farm/read/${randomCount}/`, timeout: 10000,}, (err, resp, data) => { $.get({ url: `http://jd.turinglabs.net/api/v2/jd/farm/read/${randomCount}/`, timeout: 10000, }, (err, resp, data) => {
try { try {
if (err) { if (err) {
that.log(`${JSON.stringify(err)}`) that.log(`${JSON.stringify(err)}`)
@@ -1348,7 +1348,7 @@ function requireConfig() {
cookiesArr.push(jdCookieNode[item]) cookiesArr.push(jdCookieNode[item])
} }
}) })
if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') that.log = () => {}; if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') that.log = () => { };
} else { } else {
let cookiesData = $.getdata('CookiesJD') || "[]"; let cookiesData = $.getdata('CookiesJD') || "[]";
cookiesData = jsonParse(cookiesData); cookiesData = jsonParse(cookiesData);
@@ -1403,7 +1403,7 @@ function TotalBean() {
}) })
}) })
} }
function request(function_id, body = {}, timeout = 1000){ function request(function_id, body = {}, timeout = 1000) {
return new Promise(resolve => { return new Promise(resolve => {
setTimeout(() => { setTimeout(() => {
$.get(taskUrl(function_id, body), (err, resp, data) => { $.get(taskUrl(function_id, body), (err, resp, data) => {
@@ -1468,7 +1468,7 @@ function postToDingTalk(messgae) {
const body = { const body = {
"msgtype": "markdown", "msgtype": "markdown",
"markdown": { "markdown": {
"title":"动动农场", "title": "动动农场",
"text": message1 "text": message1
}, },
"at": { "at": {
@@ -1478,7 +1478,7 @@ function postToDingTalk(messgae) {
} }
$.post(toDingtalk(dingtalk,JSON.stringify(body)), (data,status,xhr)=>{ $.post(toDingtalk(dingtalk, JSON.stringify(body)), (data, status, xhr) => {
try { try {
that.log(resp) that.log(resp)
that.log(data) that.log(data)
@@ -1495,24 +1495,24 @@ function postToDingTalk(messgae) {
} finally { } finally {
resolve(); resolve();
} }
},"json") }, "json")
} }
function toDingtalk(urlmain, bodyMain) { function toDingtalk(urlmain, bodyMain) {
return { return {
url: urlmain, url: urlmain,
body:bodyMain, body: bodyMain,
headers: { 'Content-Type': 'application/json;charset=utf-8' }, headers: { 'Content-Type': 'application/json;charset=utf-8' },
timeout: 10000, timeout: 10000,
} }
} }
function getPic(){ function getPic() {
let code = ["1.gif","2.png","3.png","4.png","5.gif","6.gif","7.gif","8.gif","9.gif","10.png","11.png"] let code = ["1.gif", "2.png", "3.png", "4.png", "5.gif", "6.gif", "7.gif", "8.gif", "9.gif", "10.png", "11.png"]
let address = "\n\n ![screenshot](https://cdn.jsdelivr.net/gh/selfImprHuang/Go-Tool@v1.2/test/emptyDirTest/3/" let address = "\n\n ![screenshot](https://cdn.jsdelivr.net/gh/selfImprHuang/Go-Tool@v1.2/test/emptyDirTest/3/"
pos = parseInt(11*Math.random()) pos = parseInt(11 * Math.random())
address = address + code[pos] + ")" address = address + code[pos] + ")"
return address return address
} }
File diff suppressed because one or more lines are too long