jd_bean_change.js添加今日将过期京豆提醒功能(如今日没将要过期的京豆则不显示)

This commit is contained in:
lxk0301
2020-12-22 10:05:58 +08:00
parent e59d5f9a8a
commit 0b1f1a1145

View File

@ -2,7 +2,7 @@
* @Author: lxk0301 https://github.com/lxk0301
* @Date: 2020-11-01 16:25:41
* @Last Modified by: lxk0301
* @Last Modified time: 2020-11-03 16:25:41
* @Last Modified time: 2020-12-22 10:25:41
*/
/*
京豆变动通知脚本https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_change.js
@ -56,6 +56,7 @@ if ($.isNode()) {
$.errorMsg = '';
$.isLogin = true;
$.nickName = '';
$.message = '';
await TotalBean();
console.log(`\n开始【京东账号${$.index}${$.nickName || $.UserName}\n`);
if (!$.isLogin) {
@ -82,9 +83,9 @@ if ($.isNode()) {
async function showMsg() {
if ($.errorMsg) return
if ($.isNode()) {
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `账号${$.index}${$.nickName || $.UserName}\n昨日收入:${$.incomeBean}京豆 🐶\n昨日支出:${$.expenseBean}京豆 🐶\n当前京豆:${$.beanCount}京豆 🐶`, { url: `https://bean.m.jd.com/beanDetail/index.action?resourceValue=bean` })
await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `账号${$.index}${$.nickName || $.UserName}\n昨日收入:${$.incomeBean}京豆 🐶\n昨日支出:${$.expenseBean}京豆 🐶\n当前京豆:${$.beanCount}京豆 🐶${$.message}`, { url: `https://bean.m.jd.com/beanDetail/index.action?resourceValue=bean` })
}
$.msg($.name, '', `账号${$.index}${$.nickName || $.UserName}\n昨日收入:${$.incomeBean}京豆 🐶\n昨日支出:${$.expenseBean}京豆 🐶\n当前京豆:${$.beanCount}京豆 🐶`, {"open-url": "https://bean.m.jd.com/beanDetail/index.action?resourceValue=bean"});
$.msg($.name, '', `账号${$.index}${$.nickName || $.UserName}\n昨日收入:${$.incomeBean}京豆 🐶\n昨日支出:${$.expenseBean}京豆 🐶\n当前京豆:${$.beanCount}京豆 🐶${$.message}`, {"open-url": "https://bean.m.jd.com/beanDetail/index.action?resourceValue=bean"});
}
async function bean() {
//前一天的0:0:0时间戳
@ -206,6 +207,49 @@ function getJingBeanBalanceDetail(page) {
})
})
}
function queryexpirejingdou() {
return new Promise(async resolve => {
const options = {
"url": `https://wq.jd.com/activep3/singjd/queryexpirejingdou?_=${Date.now()}&g_login_type=1&sceneval=2`,
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-cn",
"Connection": "keep-alive",
"Cookie": cookie,
"Host": "wq.jd.com",
"Referer": "https://wqs.jd.com/promote/201801/bean/mybean.html",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Mobile/15E148 Safari/604.1"
}
}
$.get(options, (err, resp, data) => {
try {
if (err) {
console.log(`${JSON.stringify(err)}`)
console.log(`${$.name} API请求失败请检查网路重试`)
} else {
if (data) {
console.log(data)
data = JSON.parse(data.slice(23, -13));
// console.log(data)
if (data.ret === 0) {
const expirejingdou = data['expirejingdou'][0]['expireamount'];
if (expirejingdou > 0) {
$.message += `\n今日将过期:${expirejingdou}京豆 🐶`;
}
}
} else {
console.log(`京东服务器返回空数据`)
}
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve();
}
})
})
}
function jsonParse(str) {
if (typeof str == "string") {
try {