Merge pull request #331 from shylocks/master

更新直播红包雨
This commit is contained in:
lxk0301
2020-12-14 19:15:56 +08:00
committed by GitHub

View File

@@ -1,24 +1,24 @@
/* /*
直播红包雨 直播红包雨
每天0,9,11,13,15,17,19,20,21,23可领每日上限未知 每天0,9,11,13,15,17,19,20,21,23可领每日上限未知
活动时间2020-12-7 到 2020-12-12 活动时间2020-12-14 到 2020-12-31
更新地址https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js 更新地址https://raw.githubusercontent.com/lxk0301/jd_scripts/master/activity/jd_live_redrain.js
已支持IOS双京东账号, Node.js支持N个京东账号 已支持IOS双京东账号, Node.js支持N个京东账号
脚本兼容: QuantumultX, Surge, Loon, 小火箭JSBox, Node.js 脚本兼容: QuantumultX, Surge, Loon, 小火箭JSBox, Node.js
============Quantumultx=============== ============Quantumultx===============
[task_local] [task_local]
#直播红包雨 #直播红包雨
0 0,9,11,13,15,17,19,20,21,23 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, tag=直播红包雨, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true 0 0,9,11,13,15,17,19,20,21,23 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/activity/jd_live_redrain.js, tag=直播红包雨, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true
================Loon============== ================Loon==============
[Script] [Script]
cron "0 0,9,11,13,15,17,19,20,21,23 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, tag=直播红包雨 cron "0 0,9,11,13,15,17,19,20,21,23 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/activity/jd_live_redrain.js, tag=直播红包雨
===============Surge================= ===============Surge=================
直播红包雨 = type=cron,cronexp="0 0,9,11,13,15,17,19,20,21,23 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js 直播红包雨 = type=cron,cronexp="0 0,9,11,13,15,17,19,20,21,23 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/activity/jd_live_redrain.js
============小火箭========= ============小火箭=========
直播红包雨 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live_redrain.js, cronexpr="0 0,9,11,13,15,17,19,20,21,23 * * *", timeout=200, enable=true 直播红包雨 = type=cron,script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/activity/jd_live_redrain.js, cronexpr="0 0,9,11,13,15,17,19,20,21,23 * * *", timeout=200, enable=true
*/ */
const $ = new Env('直播红包雨'); const $ = new Env('直播红包雨');
@@ -26,7 +26,6 @@ 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 jdNotify = true;//是否关闭通知false打开通知推送true关闭通知推送 let jdNotify = true;//是否关闭通知false打开通知推送true关闭通知推送
const randomCount = $.isNode() ? 20 : 5;
//IOS等用户直接用NobyDa的jd cookie //IOS等用户直接用NobyDa的jd cookie
let cookiesArr = [], cookie = '', message; let cookiesArr = [], cookie = '', message;
if ($.isNode()) { if ($.isNode()) {
@@ -51,6 +50,12 @@ const JD_API_HOST = 'https://api.m.jd.com/api';
} }
await getRedRain(); await getRedRain();
if(!$.activityId) return if(!$.activityId) return
let nowTs = new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000
message = `${new Date($.st).getHours()}点红包雨】`
if (!($.st <= nowTs && nowTs < $.ed)) {
console.log(`不在红包雨时间之内`)
return
}
for (let i = 0; i < cookiesArr.length; i++) { for (let i = 0; i < cookiesArr.length; i++) {
if (cookiesArr[i]) { if (cookiesArr[i]) {
cookie = cookiesArr[i]; cookie = cookiesArr[i];
@@ -58,7 +63,6 @@ const JD_API_HOST = 'https://api.m.jd.com/api';
$.index = i + 1; $.index = i + 1;
$.isLogin = true; $.isLogin = true;
$.nickName = ''; $.nickName = '';
message = '';
await TotalBean(); await TotalBean();
console.log(`\n******开始【京东账号${$.index}${$.nickName || $.UserName}*********\n`); console.log(`\n******开始【京东账号${$.index}${$.nickName || $.UserName}*********\n`);
if (!$.isLogin) { if (!$.isLogin) {
@@ -71,14 +75,7 @@ const JD_API_HOST = 'https://api.m.jd.com/api';
} }
continue continue
} }
let nowTs = new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000 await receiveRedRain();
// console.log(nowTs, $.startTime, $.endTime)
if ($.startTime <= nowTs && nowTs < $.endTime) {
await receiveRedRain();
} else {
console.log(`不在红包雨时间之内`)
message += `不在红包雨时间之内`
}
await showMsg(); await showMsg();
} }
} }
@@ -90,7 +87,10 @@ const JD_API_HOST = 'https://api.m.jd.com/api';
$.done(); $.done();
}) })
function showMsg() { async function showMsg() {
if ($.isNode() && !jdNotify) {
await notify.sendNotify(`【京东账号${$.index}${$.nickName}`, message)
}
return new Promise(resolve => { return new Promise(resolve => {
$.msg($.name, '', `【京东账号${$.index}${$.nickName}\n${message}`); $.msg($.name, '', `【京东账号${$.index}${$.nickName}\n${message}`);
resolve() resolve()
@@ -100,10 +100,8 @@ function showMsg() {
function getRedRain() { function getRedRain() {
return new Promise(resolve => { return new Promise(resolve => {
$.get({ $.get({
url: "https://gitee.com/shylocks/updateTeam/raw/main/jd_live_redRain.json", url: "http://ql4kk90rw.hb-bkt.clouddn.com/jd_live_redRain.json",
headers:{ }, (err, resp, data) => {
"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"
}}, (err, resp, data) => {
try { try {
if (err) { if (err) {
console.log(`1111${JSON.stringify(err)}`) console.log(`1111${JSON.stringify(err)}`)
@@ -112,8 +110,8 @@ function getRedRain() {
if (safeGet(data)) { if (safeGet(data)) {
data = JSON.parse(data); data = JSON.parse(data);
$.activityId = data.activityId $.activityId = data.activityId
$.startTime = data.startTime $.st = data.startTime
$.endTime = data.endTime $.ed = data.endTime
console.log(`下一场红包雨开始时间:${new Date(data.startTime)}`) console.log(`下一场红包雨开始时间:${new Date(data.startTime)}`)
console.log(`下一场红包雨结束时间:${new Date(data.endTime)}`) console.log(`下一场红包雨结束时间:${new Date(data.endTime)}`)
} }
@@ -141,11 +139,11 @@ function receiveRedRain() {
if (data.subCode === '0') { if (data.subCode === '0') {
console.log(`领取成功,获得${JSON.stringify(data.lotteryResult)}`) console.log(`领取成功,获得${JSON.stringify(data.lotteryResult)}`)
// message+= `领取成功,获得${JSON.stringify(data.lotteryResult)}\n` // message+= `领取成功,获得${JSON.stringify(data.lotteryResult)}\n`
message += `${data.lotteryResult.jPeasList[0].ext}:${(data.lotteryResult.jPeasList[0].quantity)}京豆\n` message += `领取成功,获得 ${(data.lotteryResult.jPeasList[0].quantity)} 京豆\n`
} else if (data.subCode === '8') { } else if (data.subCode === '8') {
console.log(`今日次数已满`) console.log(`领取失败,已领过`)
message += `领取失败,今日已签到\n`; message += `领取失败,已领过\n`;
} else { } else {
console.log(`异常:${JSON.stringify(data)}`) console.log(`异常:${JSON.stringify(data)}`)
} }