From 8087da0867c05372c67c5d3f61d37fbf7a92f27c Mon Sep 17 00:00:00 2001 From: DoveBoy <393366046@qq.com> Date: Fri, 1 Jan 2021 10:33:55 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E4=BA=91=E5=87=BD=E6=95=B0=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E8=BF=87=E6=9C=9F=E7=9A=84=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 云函数去除过期的活动 --- serverless.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/serverless.yml b/serverless.yml index 98a0be6..1309762 100644 --- a/serverless.yml +++ b/serverless.yml @@ -46,12 +46,12 @@ inputs: cronExpression: "0 0 0-16/8,20 * * * *" enable: true argument: jd_joy_reward&jd_joy_steal&jd_necklace&jd_live - - timer: #京东全民开红包 #进店领豆 #取关京东店铺商品 #注销京东会员卡 #京东抽奖机 #东东小窝 #秒杀红包雨 #健康抽奖机 + - timer: #京东全民开红包 #进店领豆 #取关京东店铺商品 #注销京东会员卡 #京东抽奖机 #东东小窝 #健康抽奖机 parameters: - name: redPacket_shop_unsubscribe_unbind_lotteryMachine_small_home_ms_redrain_health + name: redPacket_shop_unsubscribe_unbind_lotteryMachine_small_home_health cronExpression: "0 10 0 * * * *" enable: true - argument: jd_redPacket&jd_shop&jd_unsubscribe&jd_unbind&jd_lotteryMachine&jd_small_home&jd_ms_redrain&jd_health + argument: jd_redPacket&jd_shop&jd_unsubscribe&jd_unbind&jd_lotteryMachine&jd_small_home&jd_health - timer: # 京东天天加速# 天天提鹅 parameters: name: jd_speed_jd_daily_egg @@ -64,18 +64,18 @@ inputs: cronExpression: "0 15 * * * * *" enable: true argument: jd_superMarket - - timer: #京豆变动通知 #疯狂的joy #京东排行榜 #领京豆额外奖励 #京东健康APP + - timer: #京豆变动通知 #疯狂的joy #京东排行榜 #领京豆额外奖励 parameters: - name: bean_change_crazy_joy_rankingList_bean_home_jdh + name: bean_change_crazy_joy_rankingList_bean_home cronExpression: "0 30 7 * * * *" enable: true - argument: jd_bean_change&jd_crazy_joy&jd_rankingList&jd_bean_home&jd_car&jd_jdh - - timer: #金融养猪 #十元街 #京东快递 #发现-看一看 #京东赚赚 #金融打卡领年终奖 + argument: jd_bean_change&jd_crazy_joy&jd_rankingList&jd_bean_home&jd_car + - timer: #金融养猪 #京东快递 #京东赚赚 parameters: - name: pigPet_syj_kd_watch_jdzz_jr_sign + name: pigPet_kd_jdzz cronExpression: "0 3 1 * * * *" enable: true - argument: jd_pigPet&jd_syj&jd_kd&jd_watch&jd_jdzz&jr_sign + argument: jd_pigPet&jd_kd&jd_jdzz environment: # 环境变量 variables: # 环境变量对象 AAA: BBB # 不要删除,用来格式化对齐追加的变量的 -- Gitee From 0192937145de1d3aa3df8bd2f23e7c7c0a08cfd5 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 1 Jan 2021 15:10:21 +0800 Subject: [PATCH 02/16] Update crontab_list.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 清除过期活动 --- docker/crontab_list.sh | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/docker/crontab_list.sh b/docker/crontab_list.sh index dd5a341..186c148 100644 --- a/docker/crontab_list.sh +++ b/docker/crontab_list.sh @@ -4,18 +4,6 @@ 50 23 */3 * * rm -rf /scripts/logs/*.log ##############短期活动############## -# 秒杀红包雨(2020.12.31活动过期) -40 8 1-31 12 * node /scripts/jd_ms_redrain.js >> /scripts/logs/jd_ms_redrain.log 2>&1 -# 健康抽奖机(2020.12.31活动过期) -10 0 1-31 12 * node /scripts/jd_health.js >> /scripts/logs/jd_health.log 2>&1 -# 直播红包雨(2020.12.31活动过期) -1 0,20,9-23/2 15-31 12 * node /scripts/jd_live_redrain.js >> /scripts/logs/jd_live_redrain.log 2>&1 -# 京东金融打卡领年终奖(2020.12.31活动过期) -10 6 1-31 12 * node /scripts/jr_sign.js >> /scripts/logs/jr_sign.log 2>&1 -# 京东健康APP集汪汪卡瓜分百万红包(2021.1.6活动过期) -10 8 * * * node /scripts/jd_jdh.js >> /scripts/logs/jd_jdh.log 2>&1 -# crazyJoy自动每日任务 -10 7 * * * node /scripts/jd_crazy_joy.js >> /scripts/logs/jd_crazy_joy.log 2>&1 ##############长期活动############## # 签到 @@ -84,7 +72,7 @@ 10 11 * * * node /scripts/jd_jdzz.js >> /scripts/logs/jd_jdzz.log 2>&1 # 宠汪汪邀请助力 10 10,11 * * * node /scripts/jd_joy_run.js >> /scripts/logs/jd_joy_run.log 2>&1 -# 京东发现-看一看,看40个视频领80京豆(非常耗时) -13 11,14 * * * node /scripts/jd_watch.js >> /scripts/logs/jd_watch.log 2>&1 # 注销京东已开的店铺会员,不是注销京东plus会员,个别店铺无法注销 44 4 * * 6 node /scripts/jd_unbind.js >> /scripts/logs/jd_unbind.log 2>&1 +# crazyJoy自动每日任务 +10 7 * * * node /scripts/jd_crazy_joy.js >> /scripts/logs/jd_crazy_joy.log 2>&1 -- Gitee From 249c3e8cdd205256299476941a63a7f0c8c90654 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 1 Jan 2021 15:57:39 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E5=81=A5=E5=BA=B7=E6=8A=BD=E5=A5=96?= =?UTF-8?q?=E6=9C=BA=E8=BF=98=E8=83=BD=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/crontab_list.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/crontab_list.sh b/docker/crontab_list.sh index 186c148..15540fe 100644 --- a/docker/crontab_list.sh +++ b/docker/crontab_list.sh @@ -4,7 +4,8 @@ 50 23 */3 * * rm -rf /scripts/logs/*.log ##############短期活动############## - +# 健康抽奖机(2020.12.31活动过期) +10 0 1-31 12 * node /scripts/jd_health.js >> /scripts/logs/jd_health.log 2>&1 ##############长期活动############## # 签到 0 0,18 * * * cd /scripts && node jd_bean_sign.js >> /scripts/logs/jd_bean_sign.log 2>&1 -- Gitee From a8b6c2e4b5e4f6f9e10d5a7fe749d2470a23288a Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 1 Jan 2021 16:30:51 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E5=AF=B9=E4=BA=8E=E5=B7=B2=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=B4=BB=E5=8A=A8=E7=9A=84=E8=84=9A=E6=9C=AC,?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=80=9A=E7=9F=A5=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Loon/lxk0301_LoonTask.conf | 10 +++++----- Surge/lxk0301_Task.sgmodule.sgmodule | 8 -------- docker/crontab_list.sh | 2 +- jd_ds.js | 11 +++++++++-- jd_ms_redrain.js | 10 ++++++++-- jd_watch.js | 18 ++++++++++++++---- jr_sign.js | 11 +++++++++-- 7 files changed, 46 insertions(+), 24 deletions(-) diff --git a/Loon/lxk0301_LoonTask.conf b/Loon/lxk0301_LoonTask.conf index 181904f..63977d1 100644 --- a/Loon/lxk0301_LoonTask.conf +++ b/Loon/lxk0301_LoonTask.conf @@ -91,7 +91,7 @@ http-response ^https:\/\/jdjoy\.jd\.com\/pet\/getPetTreasureBox|^https:\/\/draw\ http-response ^https:\/\/account\.huami\.com\/v2\/client\/login script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/backUp/xmSports.js, requires-body=true, timeout=10, tag=小米运动获取Token # 京东代属 -cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js, tag=京东代属 +# cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js, tag=京东代属 # 京东快递 cron "10 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js, tag=京东快递签到 @@ -107,18 +107,18 @@ cron "3 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_script # 京东赚赚 cron "10 11 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdzz.js, tag=京东赚赚 # 京东秒杀红包雨 -cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js, tag=秒杀红包雨 +# cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js, tag=秒杀红包雨 #注销京东店铺会员卡 cron "23 12 * * 6" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_unbind.js, tag=注销京东店铺会员卡 # 京东直播 cron "10-20/5 12 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live.js, tag=京东直播 # 京东看一看 -cron "40 9,10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_watch.js, tag=京东看一看 +# cron "40 9,10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_watch.js, tag=京东看一看 #直播红包雨 -cron "1 0,20,9-23/2 15-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, tag=直播红包雨 +# cron "1 0,20,9-23/2 15-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, tag=直播红包雨 # 金融打卡领年终奖 -cron "10 6 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jr_sign.js, tag=金融打卡领年终奖 +# cron "10 6 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jr_sign.js, tag=金融打卡领年终奖 # 健康抽奖机 cron "10 0 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js,tag=健康抽奖机 # 疯狂的joy日常任务 diff --git a/Surge/lxk0301_Task.sgmodule.sgmodule b/Surge/lxk0301_Task.sgmodule.sgmodule index 72656fc..ac72205 100644 --- a/Surge/lxk0301_Task.sgmodule.sgmodule +++ b/Surge/lxk0301_Task.sgmodule.sgmodule @@ -53,8 +53,6 @@ cron "40 * * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scrip cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_small_home.js, timeout=650, wake-system=1, tag=东东小窝 #十元街 cron "40 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_syj.js, timeout=650, wake-system=1, tag=十元街 -#京东代属(仅京东学生认证用户可用) -cron "30 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ds.js, timeout=650, wake-system=1, tag=京东代属 #领京豆额外奖励 cron "30 10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_home.js, timeout=750, wake-system=1, tag=领京豆额外奖励 #京东汽车 @@ -74,12 +72,6 @@ cron "20 12 * * 6" script-path=https://raw.githubusercontent.com/lxk0301/jd_scri #疯狂的joy日常任务 cron "30 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js, timeout=1750, wake-system=1, tag=疯狂的joy日常任务 #以下为短期活动 -#金融打卡领年终奖 -cron "30 7 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jr_sign.js, timeout=750, wake-system=1, tag=金融打卡领年终奖 #健康抽奖机 cron "30 2 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js, timeout=750, wake-system=1, tag=健康抽奖机 -#直播红包雨(2020-12-31活动结束) -cron "1 0,20,9-23/2 15-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, timeout=750, wake-system=1, tag=直播红包雨 -#秒杀红包雨(2020-12-31活动结束) -cron "20 9 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_ms_redrain.js, timeout=750, wake-system=1, tag=秒杀红包雨 diff --git a/docker/crontab_list.sh b/docker/crontab_list.sh index 15540fe..2994511 100644 --- a/docker/crontab_list.sh +++ b/docker/crontab_list.sh @@ -60,7 +60,7 @@ # 十元街 36 8,18 * * * node /scripts/jd_syj.js >> /scripts/logs/jd_syj.log 2>&1 # 京东代属(注:限校园用户可使用) -36 9 * * * node /scripts/jd_ds.js >> /scripts/logs/jd_ds.log 2>&1 +# 36 9 * * * node /scripts/jd_ds.js >> /scripts/logs/jd_ds.log 2>&1 # 京东快递签到 23 1 * * * node /scripts/jd_kd.js >> /scripts/logs/jd_kd.log 2>&1 # 京东汽车(签到满500赛点可兑换500京豆) diff --git a/jd_ds.js b/jd_ds.js index aa5bac6..46381bf 100644 --- a/jd_ds.js +++ b/jd_ds.js @@ -87,8 +87,15 @@ const JD_API_HOST = 'https://api.m.jd.com/'; }) function showMsg() { - return new Promise(resolve => { - $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + return new Promise(async resolve => { + // $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; + if (nowTime > new Date('2020/12/31 23:59:59+08:00').getTime()) { + $.msg($.name, '活动已结束', `咱江湖再见\nhttps://github.com/lxk0301/jd_scripts`, {"open-url": "https://github.com/lxk0301/jd_scripts"}); + if ($.isNode()) await notify.sendNotify($.name + '活动已结束', `咱江湖再见\n https://github.com/lxk0301/jd_scripts`) + } else { + $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`); + } resolve() }) } diff --git a/jd_ms_redrain.js b/jd_ms_redrain.js index c0e8258..c2ea858 100644 --- a/jd_ms_redrain.js +++ b/jd_ms_redrain.js @@ -83,8 +83,14 @@ const JD_API_HOST = 'https://api.m.jd.com/api'; }) function showMsg() { - return new Promise(resolve => { - $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + return new Promise(async resolve => { + let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; + if (nowTime > new Date('2020/12/31 23:59:59+08:00').getTime()) { + $.msg($.name, '活动已结束', `咱江湖再见\nhttps://github.com/lxk0301/jd_scripts`, {"open-url": "https://github.com/lxk0301/jd_scripts"}); + if ($.isNode()) await notify.sendNotify($.name + '活动已结束', `咱江湖再见\n https://github.com/lxk0301/jd_scripts`) + } else { + $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`); + } resolve() }) } diff --git a/jd_watch.js b/jd_watch.js index 499a2fe..f1f9f25 100644 --- a/jd_watch.js +++ b/jd_watch.js @@ -188,6 +188,7 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action'; continue } await jdHealth() + await showMsg(); } } })() @@ -200,8 +201,8 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action'; async function jdHealth() { $.bean = 0 await getTaskList() - console.log(`${$.name}浏览次数:${$.task.times}/${$.task.maxTimes}`) if($.task) { + console.log(`${$.name}浏览次数:${$.task.times}/${$.task.maxTimes}`) let i = 0, j = $.task.times while(j < $.task.maxTimes) { if (!acceptBody[i]) break @@ -220,8 +221,15 @@ async function jdHealth() { } function showMsg() { - return new Promise(resolve => { - $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`); + return new Promise(async resolve => { + // $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`); + let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; + if (nowTime > new Date('2020/12/31 23:59:59+08:00').getTime()) { + $.msg($.name, '活动已结束', `咱江湖再见\nhttps://github.com/lxk0301/jd_scripts`, {"open-url": "https://github.com/lxk0301/jd_scripts"}); + if ($.isNode()) await notify.sendNotify($.name + '活动已结束', `咱江湖再见\n https://github.com/lxk0301/jd_scripts`) + } else { + $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`); + } resolve() }) } @@ -237,7 +245,9 @@ function getTaskList() { } else { if (safeGet(data)) { data = JSON.parse(data); - $.task = data['data']['discTasks'][1] + if (data.busiCode === '0') { + $.task = data['data']['discTasks'][1] + } } } } catch (e) { diff --git a/jr_sign.js b/jr_sign.js index b7e6089..40c9a01 100644 --- a/jr_sign.js +++ b/jr_sign.js @@ -78,8 +78,14 @@ const JD_API_HOST = 'https://api.m.jd.com/api'; }) function showMsg() { - return new Promise(resolve => { - $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + return new Promise(async resolve => { + let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; + if (nowTime > new Date('2020/12/31 23:59:59+08:00').getTime()) { + $.msg($.name, '活动已结束', `咱江湖再见\nhttps://github.com/lxk0301/jd_scripts`, {"open-url": "https://github.com/lxk0301/jd_scripts"}); + if ($.isNode()) await notify.sendNotify($.name + '活动已结束', `咱江湖再见\n https://github.com/lxk0301/jd_scripts`) + } else { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + } resolve() }) } @@ -96,6 +102,7 @@ function sign() { if (safeGet(data)) { data = JSON.parse(data); console.log(data.resultData.message) + message += `${data.resultData.message}` } } } catch (e) { -- Gitee From 75012ed001b9763d789dc7e88f37cc6914512fef Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 1 Jan 2021 16:59:35 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=81=E5=85=83?= =?UTF-8?q?=E8=A1=97=E7=AD=BE=E5=88=B0=E5=BE=97=E4=BA=AC=E8=B1=86=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_syj.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jd_syj.js b/jd_syj.js index cd6dabf..ea75fc2 100644 --- a/jd_syj.js +++ b/jd_syj.js @@ -2,7 +2,7 @@ * @Author: lxk0301 https://github.com/lxk0301 * @Date: 2020-11-27 09:19:21 * @Last Modified by: lxk0301 - * @Last Modified time: 2020-11-27 09:58:02 + * @Last Modified time: 2021-1-1 16:58:02 */ /* 十元街脚本,一周签到下来可获得30京豆,一天任意时刻运行一次即可 @@ -93,7 +93,7 @@ function showMsg() { let signFlag = 0; function userSignIn() { return new Promise(resolve => { - const body = {"activityId":"8d6845fe2e77425c82d5078d314d33c5","inviterId":"VMIQlLQqjQyjZokQmv5bIDgq011L0Ov8","channel":"MiniProgram"}; + const body = {"activityId":"ccd8067defcd4787871b7f0c96fcbf5c","inviterId":"","channel":"MiniProgram"}; $.get(taskUrl('userSignIn', body), async (err, resp, data) => { try { if (err) { @@ -122,6 +122,10 @@ function userSignIn() { signFlag ++; await userSignIn(); } + } else if (data.code === 66) { + //此处有时会遇到 服务器繁忙 导致签到失败,故重复三次签到 + $.log(`${$.name}签到失败:${data.msg}`); + message += `【签到】失败,${data.msg}`; } else { console.log(`异常:${JSON.stringify(data)}`) } -- Gitee From fa2caf7442c21f8e190c1b305345deee794261ed Mon Sep 17 00:00:00 2001 From: DoveBoy <393366046@qq.com> Date: Fri, 1 Jan 2021 17:12:32 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E4=BA=91=E5=87=BD=E6=95=B0=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E6=B7=BB=E5=8A=A0=E6=9C=89=E6=95=88=E7=9A=84=E5=8D=81?= =?UTF-8?q?=E5=85=83=E8=A1=97=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 云函数重新添加有效的十元街活动 --- serverless.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/serverless.yml b/serverless.yml index 1309762..d78fe00 100644 --- a/serverless.yml +++ b/serverless.yml @@ -70,12 +70,12 @@ inputs: cronExpression: "0 30 7 * * * *" enable: true argument: jd_bean_change&jd_crazy_joy&jd_rankingList&jd_bean_home&jd_car - - timer: #金融养猪 #京东快递 #京东赚赚 + - timer: #金融养猪 #十元街 #京东快递 #京东赚赚 parameters: - name: pigPet_kd_jdzz + name: pigPet_syj_kd_jdzz cronExpression: "0 3 1 * * * *" enable: true - argument: jd_pigPet&jd_kd&jd_jdzz + argument: jd_pigPet&jd_syj&jd_kd&jd_jdzz environment: # 环境变量 variables: # 环境变量对象 AAA: BBB # 不要删除,用来格式化对齐追加的变量的 -- Gitee From daa176d3f8b503b0a84edd36864c897420eb0dbb Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 1 Jan 2021 17:17:34 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E4=B8=9C=E4=B8=9C=E5=B7=A5=E5=8E=82=20?= =?UTF-8?q?=20=E5=81=9A=E4=BB=BB=E5=8A=A1=E5=A2=9E=E5=8A=A0=E5=BB=B6?= =?UTF-8?q?=E8=BF=9F=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_jdfactory.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jd_jdfactory.js b/jd_jdfactory.js index 5f16249..b756da1 100644 --- a/jd_jdfactory.js +++ b/jd_jdfactory.js @@ -355,7 +355,8 @@ async function doTask() { //领取做完任务的奖励 function jdfactory_collectScore(taskToken) { - return new Promise(resolve => { + return new Promise(async resolve => { + await $.wait(1000); $.post(taskPostUrl("jdfactory_collectScore", { taskToken }, "jdfactory_collectScore"), async (err, resp, data) => { try { if (err) { -- Gitee From 089fc421efae06014d2a373ca0553e0b68790782 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 1 Jan 2021 18:10:12 +0800 Subject: [PATCH 08/16] =?UTF-8?q?jd=5Fcrazy=5Fjoy=5Fcoin.js=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89=E8=B4=AD=E4=B9=B0=E7=AD=89?= =?UTF-8?q?=E7=BA=A7=E5=8A=9F=E8=83=BD=EF=BC=8C=E7=8E=AF=E5=A2=83=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E4=B8=BA=20BUY=5FJPY=5FLEVEL=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E8=AE=BE=E7=BD=AE=E7=9A=84=E8=B4=AD=E4=B9=B0=E7=AD=89?= =?UTF-8?q?=E7=BA=A7=E5=A4=A7=E4=BA=8E=E6=9C=80=E9=AB=98=E5=8F=AF=E8=B4=AD?= =?UTF-8?q?=E4=B9=B0=E7=AD=89=E7=BA=A7=EF=BC=8C=E5=88=99=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_crazy_joy_coin.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/jd_crazy_joy_coin.js b/jd_crazy_joy_coin.js index 4e4a5a3..8bf51c4 100644 --- a/jd_crazy_joy_coin.js +++ b/jd_crazy_joy_coin.js @@ -204,6 +204,10 @@ async function jdJxStory() { await $.wait(1000) await getJoyShop() await $.wait(1000) + $.log('当前JOY分布情况') + $.log(`\n${$.joyIds[0]} ${$.joyIds[1]} ${$.joyIds[2]} ${$.joyIds[3]}`) + $.log(`${$.joyIds[4]} ${$.joyIds[5]} ${$.joyIds[6]} ${$.joyIds[7]}`) + $.log(`${$.joyIds[8]} ${$.joyIds[9]} ${$.joyIds[10]} ${$.joyIds[11]}\n`) for (let i = 0; i < $.joyIds.length; ++i) { if (!$.canBuy) { $.log(`金币不足,跳过购买`) @@ -280,8 +284,14 @@ function getJoyShop() { data = JSON.parse(data); if (data.success && data.data && data.data.shop) { const shop = data.data.shop.filter(vo => vo.status === 1) || [] - $.buyJoyLevel = shop.length ? shop[shop.length - 1]['joyId'] : 1 - $.cost = shop.length ? shop[shop.length - 1]['coins'] : Infinity + $.buyJoyLevel = shop.length ? shop[shop.length - 1]['joyId'] : 1;//可购买的最大等级 + if ($.isNode() && process.env.BUY_JPY_LEVEL) { + $.log(`当前可购买的最高JOY等级为${$.buyJoyLevel}级\n`) + $.buyJoyLevel = (process.env.BUY_JPY_LEVEL * 1) > $.buyJoyLevel ? $.buyJoyLevel : process.env.BUY_JPY_LEVEL * 1; + $.cost = shop[$.buyJoyLevel - 1]['coins'] + } else { + $.cost = shop.length ? shop[shop.length - 1]['coins'] : Infinity + } } } } catch (e) { -- Gitee From 58c005a6c38cb65ea146bde719f09d4df83cfcf8 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 1 Jan 2021 18:11:12 +0800 Subject: [PATCH 09/16] fix --- jd_crazy_joy_coin.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jd_crazy_joy_coin.js b/jd_crazy_joy_coin.js index 8bf51c4..669bf76 100644 --- a/jd_crazy_joy_coin.js +++ b/jd_crazy_joy_coin.js @@ -204,10 +204,12 @@ async function jdJxStory() { await $.wait(1000) await getJoyShop() await $.wait(1000) - $.log('当前JOY分布情况') - $.log(`\n${$.joyIds[0]} ${$.joyIds[1]} ${$.joyIds[2]} ${$.joyIds[3]}`) - $.log(`${$.joyIds[4]} ${$.joyIds[5]} ${$.joyIds[6]} ${$.joyIds[7]}`) - $.log(`${$.joyIds[8]} ${$.joyIds[9]} ${$.joyIds[10]} ${$.joyIds[11]}\n`) + if ($.joyIds && $.joyIds.length > 0) { + $.log('当前JOY分布情况') + $.log(`\n${$.joyIds[0]} ${$.joyIds[1]} ${$.joyIds[2]} ${$.joyIds[3]}`) + $.log(`${$.joyIds[4]} ${$.joyIds[5]} ${$.joyIds[6]} ${$.joyIds[7]}`) + $.log(`${$.joyIds[8]} ${$.joyIds[9]} ${$.joyIds[10]} ${$.joyIds[11]}\n`) + } for (let i = 0; i < $.joyIds.length; ++i) { if (!$.canBuy) { $.log(`金币不足,跳过购买`) -- Gitee From a3cdaa120e86d11747c1f6b0e38f1e88ae97222c Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 1 Jan 2021 18:46:08 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E4=B8=8E=E4=BA=AC=E4=B8=9C=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E6=97=B6=E9=97=B4=E4=B9=8B=E5=B7=AE=E7=9A=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_joy_reward.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/jd_joy_reward.js b/jd_joy_reward.js index 6878e76..d12d1c4 100644 --- a/jd_joy_reward.js +++ b/jd_joy_reward.js @@ -60,6 +60,7 @@ const JD_API_HOST = 'https://jdjoy.jd.com'; } continue } + console.log(`本地时间与京东服务器时间差:${await get_diff_time()}`); await joyReward(); // $.msg($.name, '兑换脚本暂不能使用', `请停止使用,等待后期更新\n如果新版本兑换您有兑换机会,请抓包兑换\n再把抓包数据发送telegram用户@lxk0301`); } @@ -273,6 +274,35 @@ function TotalBean() { }) }) } +function getJDServerTime() { + return new Promise(resolve => { + // console.log(Date.now()) + $.get({url: "https://a.jd.com//ajax/queryServerData.html",headers:{ + "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" + }}, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} 获取京东服务器时间失败,请检查网路重试`) + } else { + data = JSON.parse(data); + $.jdTime = data['serverTime']; + // console.log(data['serverTime']); + // console.log(data['serverTime'] - Date.now()) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve($.jdTime); + } + }) + }) +} +async function get_diff_time() { + // console.log(await getJDServerTime()) + let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; + return nowTime - await getJDServerTime(); +} function jsonParse(str) { if (typeof str == "string") { try { -- Gitee From 12fd34b5c24f20059fe53739e0658ccfd3ba011c Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 1 Jan 2021 19:00:58 +0800 Subject: [PATCH 11/16] Update jd_joy_reward.js --- jd_joy_reward.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jd_joy_reward.js b/jd_joy_reward.js index d12d1c4..26bf0c0 100644 --- a/jd_joy_reward.js +++ b/jd_joy_reward.js @@ -60,7 +60,7 @@ const JD_API_HOST = 'https://jdjoy.jd.com'; } continue } - console.log(`本地时间与京东服务器时间差:${await get_diff_time()}`); + console.log(`本地时间与京东服务器时间差(毫秒):${await get_diff_time()}`); await joyReward(); // $.msg($.name, '兑换脚本暂不能使用', `请停止使用,等待后期更新\n如果新版本兑换您有兑换机会,请抓包兑换\n再把抓包数据发送telegram用户@lxk0301`); } -- Gitee From afe55c1d81a5ff1f72f8f651ce7fa8297a8572f1 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 1 Jan 2021 22:14:14 +0800 Subject: [PATCH 12/16] Update jd_dreamFactory.js --- jd_dreamFactory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jd_dreamFactory.js b/jd_dreamFactory.js index 2333f2f..11687c9 100644 --- a/jd_dreamFactory.js +++ b/jd_dreamFactory.js @@ -34,7 +34,7 @@ const randomCount = $.isNode() ? 20 : 5; let tuanActiveId = `6S9y4sJUfA2vPQP6TLdVIQ==`; const jxOpenUrl = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://wqsd.jd.com/pingou/dream_factory/index.html%22%20%7D`; let cookiesArr = [], cookie = '', message = ''; -const inviteCodes = ['V5LkjP4WRyjeCKR9VRwcRX0bBuTz7MEK0-E99EJ7u0k=', 'PDPM257r_KuQhil2Y7koNw==', "gB99tYLjvPcEFloDgamoBw==", '-OvElMzqeyeGBWazWYjI1Q==', 'GFwo6PntxDHH95ZRzZ5uAg==']; +const inviteCodes = ['V5LkjP4WRyjeCKR9VRwcRX0bBuTz7MEK0-E99EJ7u0k=@0WtCMPNq7jekehT6d3AbFw==', 'PDPM257r_KuQhil2Y7koNw==', "gB99tYLjvPcEFloDgamoBw==", '-OvElMzqeyeGBWazWYjI1Q==', 'GFwo6PntxDHH95ZRzZ5uAg==']; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; if ($.isNode()) { Object.keys(jdCookieNode).forEach((item) => { -- Gitee From 18fe344bf27467bad46ac83899dc09ab87f508d8 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Sat, 2 Jan 2021 10:41:57 +0800 Subject: [PATCH 13/16] Update lxk0301_Task.sgmodule.sgmodule --- Surge/lxk0301_Task.sgmodule.sgmodule | 2 -- 1 file changed, 2 deletions(-) diff --git a/Surge/lxk0301_Task.sgmodule.sgmodule b/Surge/lxk0301_Task.sgmodule.sgmodule index ac72205..0419fcb 100644 --- a/Surge/lxk0301_Task.sgmodule.sgmodule +++ b/Surge/lxk0301_Task.sgmodule.sgmodule @@ -61,8 +61,6 @@ cron "0 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_script cron "20 11 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js, timeout=750, wake-system=1, tag=京东快递签到 #京东直播(活动结束时间未知) cron "20 12 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live.js, timeout=750, wake-system=1, tag=京东直播 -#京东看一看 -cron "40 9,10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_watch.js, timeout=7750, wake-system=1, tag=京东看一看 #京东健康 cron "20 23 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdh.js, timeout=750, wake-system=1, tag=京东健康 #京东赚赚 -- Gitee From 25f60ac51f910c0e5425b3839e294e09f8fb1a9b Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Sat, 2 Jan 2021 10:46:09 +0800 Subject: [PATCH 14/16] Update lxk0301_Task.sgmodule.sgmodule --- Surge/lxk0301_Task.sgmodule.sgmodule | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Surge/lxk0301_Task.sgmodule.sgmodule b/Surge/lxk0301_Task.sgmodule.sgmodule index 0419fcb..f359b01 100644 --- a/Surge/lxk0301_Task.sgmodule.sgmodule +++ b/Surge/lxk0301_Task.sgmodule.sgmodule @@ -71,5 +71,5 @@ cron "20 12 * * 6" script-path=https://raw.githubusercontent.com/lxk0301/jd_scri cron "30 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js, timeout=1750, wake-system=1, tag=疯狂的joy日常任务 #以下为短期活动 #健康抽奖机 -cron "30 2 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js, timeout=750, wake-system=1, tag=健康抽奖机 +cron "30 2 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js, timeout=750, wake-system=1, tag=健康抽奖机 -- Gitee From aeae18876ee3c72707c193310a75b47b98b64104 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Sat, 2 Jan 2021 21:42:52 +0800 Subject: [PATCH 15/16] add --- backUp/iOS_Weather_AQI_Standard.js | 138 +++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 backUp/iOS_Weather_AQI_Standard.js diff --git a/backUp/iOS_Weather_AQI_Standard.js b/backUp/iOS_Weather_AQI_Standard.js new file mode 100644 index 0000000..dfb2294 --- /dev/null +++ b/backUp/iOS_Weather_AQI_Standard.js @@ -0,0 +1,138 @@ +// Developed by Hackl0us (https://github.com/hackl0us) + +// STEP 1: 前往 https://aqicn.org/data-platform/token/ 注册账户,将申请的 API Token 填入下方 +let aqicnToken = '' +// STEP 2: 参考下方配置片段,在代理工具的配置文件中添加对应的配置。注意:script-path 后应该替换为添加 apicnToken 值后的脚本路径 +/* +===============Surge================= +[Script] +AQI-US = type=http-response, pattern=https://weather-data.apple.com/v1/weather/[\w-]+/[0-9]+\.[0-9]+/[0-9]+\.[0-9]+\?, requires-body=true, script-path=/path/to/iOS_Weather_AQI_Standard.js + +[MITM] +hostname = weather-data.apple.com +*/ +const $ = new Env('牛逼天气'); +aqicnToken = $.getdata('hackl0us_aqi_token'); + +const AirQualityStandard = { + CN: 'HJ6332012.1', + US: 'EPA_NowCast.1' +} + +const AirQualityLevel = { + GOOD: 1, + MODERATE: 2, + UNHEALTHY_FOR_SENSITIVE: 3, + UNHEALTHY: 4, + VERY_UNHEALTHY: 5, + HAZARDOUS: 6 +} + +const coordRegex = /https:\/\/weather-data\.apple\.com\/v1\/weather\/[\w-]+\/([0-9]+\.[0-9]+)\/([0-9]+\.[0-9]+)\?/ +const [_, lat, lng] = $request.url.match(coordRegex) + +function classifyAirQualityLevel(aqiIndex) { + if (aqiIndex >= 0 && aqiIndex <= 50) { + return AirQualityLevel.GOOD; + } else if (aqiIndex >= 51 && aqiIndex <= 100) { + return AirQualityLevel.MODERATE; + } else if (aqiIndex >= 101 && aqiIndex <= 150) { + return AirQualityLevel.UNHEALTHY_FOR_SENSITIVE; + } else if (aqiIndex >= 151 && aqiIndex <= 200) { + return AirQualityLevel.UNHEALTHY; + } else if (aqiIndex >= 201 && aqiIndex <= 300) { + return AirQualityLevel.VERY_UNHEALTHY; + } else if (aqiIndex >= 301 && aqiIndex <= 500) { + return AirQualityLevel.HAZARDOUS; + } +} + +function modifyWeatherResp(weatherRespBody, aqicnRespBody) { + let weatherRespJson = JSON.parse(weatherRespBody) + let aqicnRespJson = JSON.parse(aqicnRespBody).data + weatherRespJson.air_quality = constructAirQuailityNode(aqicnRespJson) + return JSON.stringify(weatherRespJson) +} + +function getPrimaryPollutant(pollutant) { + switch (pollutant) { + case 'co': + return 'CO2'; + case 'so2': + return 'SO2'; + case 'no2': + return 'NO2'; + case 'pm25': + return 'PM2.5'; + case 'pm10': + return 'PM10'; + case 'o3': + return 'OZONE'; + default: + console.log('Unknown pollutant ' + pollutant); + } +} + +function constructAirQuailityNode(aqicnData) { + let airQualityNode = { "source": "", "learnMoreURL": "", "isSignificant": true, "airQualityCategoryIndex": 1, "airQualityScale": "", "airQualityIndex": 0, "pollutants": { "CO": { "name": "CO", "amount": 0, "unit": "μg/m3" }, "SO2": { "name": "SO2", "amount": 0, "unit": "μg/m3" }, "NO2": { "name": "NO2", "amount": 0, "unit": "μg/m3" }, "PM2.5": { "name": "PM2.5", "amount": 0, "unit": "μg/m3" }, "OZONE": { "name": "OZONE", "amount": 0, "unit": "μg/m3" }, "PM10": { "name": "PM10", "amount": 0, "unit": "μg/m3" } }, "metadata": { "reported_time": 0, "longitude": 0, "provider_name": "aqicn.org", "expire_time": 2, "provider_logo": "https://i.loli.net/2020/12/27/UqW23eZLFAIbxGV.png", "read_time": 2, "latitude": 0, "v": 1, "language": "", "data_source": 0 }, "name": "AirQuality", "primaryPollutant": "" } + const aqicnIndex = aqicnData.aqi + airQualityNode.source = aqicnData.city.name + airQualityNode.learnMoreURL = aqicnData.city.url + '/cn/m' + airQualityNode.airQualityCategoryIndex = classifyAirQualityLevel(aqicnIndex) + airQualityNode.airQualityScale = AirQualityStandard.US + airQualityNode.airQualityIndex = aqicnIndex + airQualityNode.pollutants.CO.amount = aqicnData.iaqi.co?.v || -1 + airQualityNode.pollutants.SO2.amount = aqicnData.iaqi.so2?.v || -1 + airQualityNode.pollutants.NO2.amount = aqicnData.iaqi.no2?.v || -1 + airQualityNode.pollutants["PM2.5"].amount = aqicnData.iaqi.pm25?.v || -1 + airQualityNode.pollutants.OZONE.amount = aqicnData.iaqi.o3?.v || -1 + airQualityNode.pollutants.PM10.amount = aqicnData.iaqi.pm10?.v || -1 + airQualityNode.metadata.latitude = aqicnData.city.geo[0] + airQualityNode.metadata.longitude = aqicnData.city.geo[1] + airQualityNode.metadata.read_time = roundHours(new Date(), 'down') + airQualityNode.metadata.expire_time = roundHours(new Date(), 'up') + airQualityNode.metadata.reported_time = aqicnData.time.v + //airQualityNode.metadata.language = $request.headers['Accept-Language'] + airQualityNode.primaryPollutant = getPrimaryPollutant(aqicnData.dominentpol) + return airQualityNode +} + +function roundHours(time, method) { + switch (method) { + case 'up': + time.setHours(time.getHours() + Math.ceil(time.getMinutes() / 60)); + break; + case 'down': + time.setHours(time.getHours() + Math.floor(time.getMinutes() / 60)); + break; + default: + console.log("Error rounding method"); + } + time.setMinutes(2, 0, 0); + return time; +} + +// $httpClient.get(`https://api.waqi.info/feed/geo:${lat};${lng}/?token=${aqicnToken}`, function (error, _response, data) { +// if (error) { +// let body = $response.body +// $done({ body }) +// } else { +// let body = modifyWeatherResp($response.body, data) +// $done({ body }) +// } +// }); +$.get({ url: `https://api.waqi.info/feed/geo:${lat};${lng}/?token=${aqicnToken}`, headers: $request.headers },(err, resp, data) => { + try { + if (err) { + $.logErr(err, resp); + } else { + console.log(`${JSON.stringify(resp.body)}`); + let body = modifyWeatherResp($response.body, resp.body); + $.done({body}); + } + } catch (e) { + $.logErr(e, resp); + $.done(); + } +}); +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file -- Gitee From 0be6ec39efaa060678d3c41ef49e72c22ca34f85 Mon Sep 17 00:00:00 2001 From: Akira Date: Sat, 2 Jan 2021 23:27:27 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89shell=E8=84=9A=E6=9C=AC=E8=87=AA=E5=8A=A8mod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/Readme.md | 26 ++++++++++++++++++++------ docker/default_task.sh | 23 ++++++++++++++++++++++- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/docker/Readme.md b/docker/Readme.md index beb0330..922a84a 100644 --- a/docker/Readme.md +++ b/docker/Readme.md @@ -1,4 +1,24 @@ ### Usage +```diff ++ 2021-01-03更新 增加 CUSTOM_SHELL_FILE 参数配置执行自定义shell脚本 ++ 例1:配置远程shell脚本, 我自己写了一个shell脚本https://raw.githubusercontent.com/iouAkira/someDockerfile/master/jd_scripts/shell_script_mod.sh 内容很简单下载惊喜农场并添加定时任务 ++ CUSTOM_SHELL_FILE=https://raw.githubusercontent.com/iouAkira/someDockerfile/master/jd_scripts/shell_script_mod.sh ++ ++ 例2:配置docker挂载本地自定义shell脚本,/scripts/docker/shell_script_mod.sh 为你在docker-compose.yml里面挂载到容器里面绝对路径 ++ CUSTOM_SHELL_FILE=/scripts/docker/shell_script_mod.sh ++ ++ tip:如果使用远程自定义,请保证网络畅通或者选择合适的国内仓库,例如有部分人的容器里面就下载不到github的raw文件,那就可以把自己的自定义shell写在gitee上,或者换本地挂载 ++ 如果是 docker 挂载本地,请保重文件挂载进去了,并且配置的是绝对路径。 ++ 自定义 shell 脚本里面如果要加 crontab 任务请使用 echo 追加到 /scripts/docker/merged_list_file.sh 里面否者不生效 ++ 注⚠️ 建议无shell能力的不要轻易使用,当然你可以找别人写好适配了这个docker镜像的脚本直接远程配置 ++ 上面写了这么多如果还看不懂,不建议使用该变量功能。 +_____ +! ⚠️⚠️⚠️2020-12-11更新镜像启动方式,虽然兼容旧版的运行启动方式,但是强烈建议更新镜像和配置后使用 +! 更新后`command:`指令配置不再需要 +! 更新后可以使用自定义任务文件追加在默任务文件之后,比以前的完全覆盖多一个选择 +! - 新的自定两个环境变量为 `CUSTOM_LIST_MERGE_TYPE`:自定文件的生效方式可选值为`append`,`overwrite`默认为`append` ; `CUSTOM_LIST_FILE`: 自定义文件的名字 +! 更新镜像增减镜像更新通知,以后镜像如果更新之后,会通知用户更新 +``` > 推荐使用`docker-compose`所以这里只介绍`docker-compose`使用方式 - `docker-compose` 安装(群晖nas docker自带安装了docker-compose) @@ -21,12 +41,6 @@ pip install docker-compose ### 如果需要使用 docker 多个账户独立并发执行定时任务,[参考这里](https://github.com/iouAkira/scripts/blob/patch-1/docker/docker%E5%A4%9A%E8%B4%A6%E6%88%B7%E4%BD%BF%E7%94%A8%E7%8B%AC%E7%AB%8B%E5%AE%B9%E5%99%A8%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.md#%E4%BD%BF%E7%94%A8%E6%AD%A4%E6%96%B9%E5%BC%8F%E8%AF%B7%E5%85%88%E7%90%86%E8%A7%A3%E5%AD%A6%E4%BC%9A%E4%BD%BF%E7%94%A8docker%E5%8A%9E%E6%B3%95%E4%B8%80%E7%9A%84%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F) -⚠️⚠️⚠️2020-12-11更新镜像启动方式,虽然兼容旧版的运行启动方式,但是强烈建议更新镜像和配置后使用 -- 更新后`command:`指令配置不再需要 -- 更新后可以使用自定义任务文件追加在默任务文件之后,比以前的完全覆盖多一个选择 -- - 新的自定两个环境变量为 `CUSTOM_LIST_MERGE_TYPE`:自定文件的生效方式可选值为`append`,`overwrite`默认为`append` ; `CUSTOM_LIST_FILE`: 自定义文件的名字 -- 更新镜像增减镜像更新通知,以后镜像如果更新之后,会通知用户更新 - > 注⚠️:前提先理解学会使用这下面的教程 ### 创建一个目录`jd_scripts`用于存放备份配置等数据,迁移重装的时候只需要备份整个jd_scripts目录即可 需要新建的目录文件结构参考如下: diff --git a/docker/default_task.sh b/docker/default_task.sh index caf4f6d..26da7f0 100644 --- a/docker/default_task.sh +++ b/docker/default_task.sh @@ -107,7 +107,7 @@ if [ $(grep -c "default_task.sh" $mergedListFile) -eq '0' ]; then echo "52 */1 * * * sh /scripts/docker/default_task.sh |ts >> /scripts/logs/default_task.log 2>&1" >>$mergedListFile fi -if [ $RANDOM_DELAY_MAX ];then +if [ $RANDOM_DELAY_MAX ]; then if [ $RANDOM_DELAY_MAX -ge 1 ]; then echo "已设置随机延迟为 $RANDOM_DELAY_MAX , 设置延迟任务中... " sed -i "/\(jd_bean_sign.js\|jd_blueCoin.js\|jd_joy_reward.js\|jd_joy_steal.js\|jd_joy_feedPets.js\)/!s/node/sleep \$((RANDOM % \$RANDOM_DELAY_MAX)); node/g" $mergedListFile @@ -116,6 +116,27 @@ else echo "未配置随即延迟对应的环境变量,故不设置延迟任务" fi +##增加自定义shell脚本 +if [ 0"$CUSTOM_SHELL_FILE" = "0" ]; then + echo "未配置自定shell脚本文件,跳过执行。" +else + if expr "$CUSTOM_SHELL_FILE" : 'http.*' &>/dev/null; then + echo "自定义shell脚本为远程脚本,开始下在自定义远程脚本。" + wget -O /scripts/docker/shell_script_mod.sh $CUSTOM_SHELL_FILE + echo "下载完成,开始执行..." + sh -x /scripts/docker/shell_script_mod.sh + echo "自定义远程shell脚本下载并执行结束。" + else + if [ !$CUSTOM_SHELL_FILE ]; then + echo "自定义shell脚本为docker挂载脚本文件,但是指定挂载文件不存在,跳过执行。" + else + echo "docker挂载的自定shell脚本,开始执行..." + sh -x $CUSTOM_SHELL_FILE + echo "docker挂载的自定shell脚本,执行结束。" + fi + fi +fi + echo "加载最新的定时任务文件..." crontab $mergedListFile -- Gitee