diff --git a/README.md b/README.md index 8783d737..68c4d189 100644 --- a/README.md +++ b/README.md @@ -66,10 +66,13 @@ **脚本兼容: [QuantumultX](https://apps.apple.com/us/app/quantumult-x/id1443988620), [Surge](https://apps.apple.com/us/app/surge-4/id1442620678), [Loon](https://apps.apple.com/us/app/loon/id1373567447), 小火箭, JSBox, Node.js** **TODO** -- [ ] 所有活动互助码在一个脚本打印 - -## [邀请码互助入口](https://github.com/lxk0301/jd_scripts/discussions) +- [x] 所有活动互助码在一个脚本打印 +- [ ] 京喜工厂添加预测N天后可兑换功能 +## 邀请码互助 + - [邀请码互助入口](https://github.com/lxk0301/jd_scripts/discussions) + - [获取各类活动互助码脚本 jd_get_share_code.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_get_share_code.js) + - [邀请码使用规范](githubAction.md#互助码类环境变量)(仅限云端) ## 食用方法 ### 方法一:本地安装Node.js,下载本库脚本 @@ -85,9 +88,9 @@ ### 方法二:云服务器、腾讯云函数等等 - 需自行有云服务器,云函数等 - - 腾讯云云函数 [快速部署教程](tencentscf.md)(免费) - - 腾讯云云函数控制台使用 [教程说明](iCloud.md) - - 腾讯云云函数 [GitHub Action部署教程](tencentscf.md#github-action-部署) + - 腾讯云云函数 [快速部署教程](./backUp/tencentscf.md)(免费) + - 腾讯云云函数控制台使用 [教程说明](./backUp/iCloud.md) + - 腾讯云云函数 [GitHub Action部署教程](./backUp/tencentscf.md#github-action-部署) ### 方法三:Docker(NAS或VPS用户) @@ -107,7 +110,7 @@ ### 方法四:iOS系统的代理软件(QuantumultX, Surge, Loon, 小火箭) -#### [京东cookie获取脚本](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/JD_extra_cookie.js) + - [京东cookie获取脚本 JD_extra_cookie.js](https://raw.githubusercontent.com/lxk0301/jd_scripts/master/JD_extra_cookie.js) ### 赞赏码(开发维护不易,请赏杯茶水费)
diff --git a/jd_ds.js b/activity/jd_ds.js similarity index 100% rename from jd_ds.js rename to activity/jd_ds.js diff --git a/jd_jdh.js b/activity/jd_jdh.js similarity index 100% rename from jd_jdh.js rename to activity/jd_jdh.js diff --git a/jd_live_redrain.js b/activity/jd_live_redrain.js similarity index 100% rename from jd_live_redrain.js rename to activity/jd_live_redrain.js diff --git a/jd_ms_redrain.js b/activity/jd_ms_redrain.js similarity index 100% rename from jd_ms_redrain.js rename to activity/jd_ms_redrain.js diff --git a/jd_watch.js b/activity/jd_watch.js similarity index 100% rename from jd_watch.js rename to activity/jd_watch.js diff --git a/jr_sign.js b/activity/jr_sign.js similarity index 100% rename from jr_sign.js rename to activity/jr_sign.js diff --git a/iCloud.md b/backUp/iCloud.md similarity index 98% rename from iCloud.md rename to backUp/iCloud.md index 9eb86134..22696205 100644 --- a/iCloud.md +++ b/backUp/iCloud.md @@ -108,21 +108,21 @@ let CookieJDs = [ 单击左侧导航栏**函数服务**,进入“函数服务”页面。 在页面上方选择一个地域,最好选择离你常用地区近点的,不至于导致账号异常。单击**新建**。如下图所示: -![iCloud1](./icon/iCloud1.png) +![iCloud1](../icon/iCloud1.png) 在“新建函数”页面填写函数基础信息,单击**下一步**。如下图所示: -![iCloud2](./icon/iCloud2.png) +![iCloud2](../icon/iCloud2.png) **函数名称**:可以自定义,比如为jd。
**运行环境**:选择 “Nodejs 12.16”。
**创建方式**:选择 “空白函数”。 确保环境为Nodejs 12.16,执行方法改为:index.main_handler,提交方式建议选本地文件夹,然后从GitHub项目克隆Zip压缩包,解压成文件夹,然后点击这个上传把文件夹上传进来(记得node_modules文件夹一并上传或者将node_modules文件夹上传到“层”,之后选择“函数管理”-“层管理”绑定上传好的层),完了后点击下面的高级设置。 -![iCloud3](./icon/iCloud3.png) +![iCloud3](../icon/iCloud3.png) 内存用不了太大,64MB就够了(64M内存,免费时长6,400,000秒,内存与免费时长大致关系可以参看云函数官方说明),超时时间改为最大的900秒,然后点击最下面的完成。 -![iCloud4](./icon/iCloud4.png) +![iCloud4](../icon/iCloud4.png) ## 5.设置触发器 @@ -136,7 +136,7 @@ let CookieJDs = [ 创建触发器 -![iCloud6](./icon/iCloud6.png) +![iCloud6](../icon/iCloud6.png) 触发方式默认“**定时触发**”,定时任务名称随便起个名字,触发周期根据自己需要自行设置。 diff --git a/backUp/qqread.js b/backUp/qqread.js index f72fe1f4..e1e2639b 100644 --- a/backUp/qqread.js +++ b/backUp/qqread.js @@ -14,27 +14,6 @@ ziye 本人github地址 https://github.com/ziye12/JavaScript 转载请备注个名字,谢谢 -11.25 增加 阅读时长上传,阅读金币,阅读随机金币 -11.25 修复翻倍宝箱不同时领取的问题.增加阅读金币判定 -11.25 修复阅读时长问题,阅读金币问题,请重新获取时长cookie -11.26 随机金币只有一次,故去除,调整修复阅读金币问题,增加时长上传限制 -11.26 增加领取周时长奖励 -11.26 增加结束命令 -11.27 调整通知为,成功开启宝箱再通知 -11.28 修复错误 -12.1 调整通知为15次宝箱通知一次 -12.1 优化通知 - -⚠️cookie获取方法: - -进 https://m.q.qq.com/a/s/d3eacc70120b9a37e46bad408c0c4c2a 点我的 获取cookie - -进一本书 看 10秒以下 然后退出,获取阅读时长cookie,看书一定不能超过10秒 - -可能某些页面会卡住,但是能获取到cookie,再注释cookie重写就行了! - - - ⚠️宝箱奖励为20分钟一次,自己根据情况设置定时,建议设置11分钟一次 hostname=mqqapi.reader.qq.com @@ -62,7 +41,9 @@ const jsname = '企鹅读书' const $ = Env(jsname) let task = '', config, ssr2 = '', wktime, day = 0; console.log(`\n========= 脚本执行时间(TM):${new Date(new Date().getTime() + 0 * 60 * 60 * 1000).toLocaleString('zh', {hour12: false})} =========\n`) -const notify = require('../sendNotify'); + +const notify = $.isNode() ? require('../sendNotify') : ''; + const logs = 1; //0为关闭日志,1为开启 const TIME = 30//单次时长上传限制,默认5分钟 @@ -78,6 +59,7 @@ let qqreadtimeurlVal = $.getdata(qqreadtimeurlKey) const qqreadtimeheaderKey = 'qqreadtimehd' let qqreadtimeheaderVal = $.getdata(qqreadtimeheaderKey) +let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); //云函数使用在下面填写 let QQ_READ_COOKIES = [ { @@ -177,7 +159,7 @@ function GetCookie() { async function QQ_READ() { for (let i = 0; i < QQ_READ_COOKIES.length; i++) { $.log(`\n*************开始QQ账号${i + 1}**************\n`); - tz = ''; + $.isLogin = true; if (!QQ_READ_COOKIES[i]["qqreadbodyVal"] || !QQ_READ_COOKIES[i]['qqreadtimeurlVal'] || !QQ_READ_COOKIES[i]['qqreadtimeheaderVal']) { $.log(`账号${i + 1}暂未提供脚本执行所需的cookie`); continue @@ -186,6 +168,13 @@ async function QQ_READ() { qqreadtimeurlVal = QQ_READ_COOKIES[i]['qqreadtimeurlVal']; qqreadtimeheaderVal = QQ_READ_COOKIES[i]['qqreadtimeheaderVal']; await qqreadinfo();//用户名 + if (!$.isLogin) { + $.log(`企鹅阅读账号${i + 1} cookie过期`); + if (nowTimes.getHours() % 12 === 0 && (nowTimes.getMinutes() > 0 && nowTimes.getMinutes() <= 15)) { + await notify.sendNotify(`企鹅阅读账号${i + 1} cookie过期`, '请及时更新 QQ_READ_TIME_HEADER_VAL') + } + continue + } await qqreadwktime();//周时长查询 await qqreadtrack(); await qqreadconfig();//时长查询 @@ -234,8 +223,7 @@ async function QQ_READ() { } function showmsg() { return new Promise(async resolve => { - let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); - if (nowTimes.getHours() === 22 && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 15)) { + if (nowTimes.getHours() === 22 && (nowTimes.getMinutes() > 0 && nowTimes.getMinutes() <= 15)) { await notify.sendNotify(jsname, tz); } $.msg(jsname, "", tz); @@ -326,6 +314,13 @@ function qqreadinfo() { $.get(toqqreadinfourl, (error, response, data) => { if (logs) $.log(`${jsname}, 用户名: ${data}`); let info = JSON.parse(data); + if (info.code === 0) { + $.isLogin = info.data['isLogin']; + if (!$.isLogin) { + resolve(); + return + } + } kz += `\n========== 【${info.data.user.nickName}】 ==========\n`; tz += `\n========== 【${info.data.user.nickName}】 ==========\n`; diff --git a/backUp/qqreadOpenBox.js b/backUp/qqreadOpenBox.js new file mode 100644 index 00000000..5182b6e5 --- /dev/null +++ b/backUp/qqreadOpenBox.js @@ -0,0 +1,293 @@ +/* +lxk0301修改自用,单独开宝箱 +****************************************************************************** +本人github地址 https://github.com/ziye12/JavaScript +转载请备注个名字,谢谢 + +1.5 调整宝箱策略,20分钟运行一次就行 +*/ +const $ = Env(`企鹅读书开宝箱`) +const notify = $.isNode() ? require("../sendNotify") : ""; +const logs = 1; //0为关闭日志,1为开启 + +let task, tz = '', kz, config = '', CASH = '', COOKIES_SPLIT = '' ; +let dk,ljyd,sp,ydrw,wktime; + +let qqreadbodyVal = ``; +let qqreadtimeurlVal = ``; +let qqreadtimeheaderVal = ``; +let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); +//云函数使用在下面填写 +let QQ_READ_COOKIES = [ + { + "qqreadbodyVal": ``, + "qqreadtimeurlVal": ``, + "qqreadtimeheaderVal": `` + } +] + +!(async () => { + await getNodeCookie(); + await open_box(); +})() +.catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') +}) +.finally(() => { + $.done(); +}) + +async function open_box() { + for (let i = 0; i < QQ_READ_COOKIES.length; i++) { + $.log(`\n*************开始QQ账号${i + 1}**************\n`); + // tz = ''; + $.isLogin = true; + if (!QQ_READ_COOKIES[i]["qqreadbodyVal"] || !QQ_READ_COOKIES[i]['qqreadtimeurlVal'] || !QQ_READ_COOKIES[i]['qqreadtimeheaderVal']) { + $.log(`账号${i + 1}暂未提供脚本执行所需的cookie`); + continue + } + qqreadbodyVal = QQ_READ_COOKIES[i]['qqreadbodyVal']; + qqreadtimeurlVal = QQ_READ_COOKIES[i]['qqreadtimeurlVal']; + qqreadtimeheaderVal = QQ_READ_COOKIES[i]['qqreadtimeheaderVal']; + await qqreadinfo();//用户名 + if (!$.isLogin) { + $.log(`企鹅阅读账号${i + 1} cookie过期`); + if (nowTimes.getHours() % 12 === 0 && (nowTimes.getMinutes() > 0 && nowTimes.getMinutes() <= 15)) { + await notify.sendNotify(`企鹅阅读账号${i + 1} cookie过期`, '请及时更新 QQ_READ_TIME_HEADER_VAL') + } + continue + } + //单独开宝箱 + if (nowTimes.getHours() === 0 && (nowTimes.getMinutes() >= 0 && nowTimes.getMinutes() <= 59)) { + await qqreadtrack();//更新 + } + await qqreadtask();//任务列表 + if (task.data && ljyd.doneFlag == 0) { + await qqreaddayread();//阅读任务 + } + if (task.data && task.data.treasureBox.timeInterval <= 10000) { + await $.wait(task.data.treasureBox.timeInterval) + await qqreadbox();//宝箱 + } + if (task.data && task.data.treasureBox.timeInterval - 600000 <= 10000) { + await $.wait(task.data.treasureBox.timeInterval - 600000) + await qqreadbox2();//宝箱翻倍 + } + } + await showmsg();//通知 +} + + +function showmsg() { + return new Promise(async resolve => { + if (nowTimes.getHours() === 23 && (nowTimes.getMinutes() > 0 && nowTimes.getMinutes() <= 15)) { + await notify.sendNotify($.name, tz); + } + $.msg($.name, "", tz); + resolve() + }) +} + + +// 更新 +function qqreadtrack() { + return new Promise((resolve, reject) => { + const body = qqreadbodyVal.replace(new RegExp(/"dis":[0-9]{13}/), `"dis":${new Date().getTime()}`) + const toqqreadtrackurl = { + url: "https://mqqapi.reader.qq.com/log/v4/mqq/track", + headers: JSON.parse(qqreadtimeheaderVal), + body: body, + timeout: 60000, + }; + $.post(toqqreadtrackurl, (error, response, data) => { + if (logs) $.log(`更新: ${data}`); + let track = JSON.parse(data); + const date = new Date(JSON.parse(qqreadbodyVal).dataList[0].dis) + let Y = date.getFullYear() + '-'; + let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'; + let D = date.getDate() + ' '; + let h = date.getHours() + ':'; + let m = date.getMinutes() + ':'; + let s = date.getSeconds(); + let time = Y + M + D + h + m + s; + tz += `【数据更新】:更新${track.msg},\n【cookie获取时间】${time}\n`; + kz += `【数据更新】:更新${track.msg},\n【cookie获取时间】${time}\n`; + resolve(); + }); + }); +} +// 用户名 +function qqreadinfo() { + return new Promise((resolve, reject) => { + const toqqreadinfourl = { + url: "https://mqqapi.reader.qq.com/mqq/user/init", + headers: JSON.parse(qqreadtimeheaderVal), + timeout: 60000, + }; + $.get(toqqreadinfourl, (error, response, data) => { + if (logs) $.log(`用户名: ${data}`); + const info = JSON.parse(data); + if (info.code === 0) { + $.isLogin = info.data['isLogin']; + if (!$.isLogin) { + resolve(); + return + } + } + kz += `\n========== 【${info.data.user.nickName}】 ==========\n`; + tz += `\n========== 【${info.data.user.nickName}】 ==========\n`; + + resolve(); + }); + }); +} +// 任务列表 +function qqreadtask() { + return new Promise((resolve, reject) => { + const toqqreadtaskurl = { + url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/page?fromGuid=", + headers: JSON.parse(qqreadtimeheaderVal), + timeout: 60000, + }; + $.get(toqqreadtaskurl, (error, response, data) => { + if (logs) $.log(`任务列表: ${data}`); + task = JSON.parse(data); + dk = task.data.taskList.find(item => item.type === 200); + ljyd = task.data.taskList.find(item => item.type === 210); + ydrw = task.data.taskList.find(item => item.type === 220); + sp = task.data.taskList.find(item => item.type === 230); + + if (task.data.invite.nextInviteConfig) { + tz += + `【现金余额】:${(task.data.user.amount / 10000).toFixed(2)}元\n` + + `【第${task.data.invite.issue}期】:时间${task.data.invite.dayRange}\n` + + ` 已邀请${task.data.invite.inviteCount}人,再邀请${task.data.invite.nextInviteConfig.count}人获得${task.data.invite.nextInviteConfig.amount}金币\n` + + `【${dk.title}】:${dk.amount}金币,${dk.actionText}\n` + + `【${ljyd.title}】:${ljyd.amount}金币,${ljyd.actionText}\n` + + `【${ydrw.title}】:${ydrw.amount}金币,${ydrw.actionText}\n` + + `【${sp.title}】:${sp.amount}金币,${sp.actionText}\n` + + `【宝箱任务${task.data.treasureBox.count + 1}】:${task.data.treasureBox.timeInterval / 1000 + }秒后领取\n` + + `【${task.data.fans.title}】:${task.data.fans.fansCount}个好友,${task.data.fans.todayAmount}金币\n`; + } + + kz += + `【现金余额】:${(task.data.user.amount / 10000).toFixed(2)}元\n` + + `【宝箱任务${task.data.treasureBox.count + 1}】:${task.data.treasureBox.timeInterval / 1000 + }秒后领取\n` + + `【已开宝箱】:${task.data.treasureBox.count}个\n`; + + resolve(); + }); + }); +} +// 每日阅读 +function qqreaddayread() { + return new Promise((resolve, reject) => { + const toqqreaddayreadurl = { + url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/read_book", + headers: JSON.parse(qqreadtimeheaderVal), + timeout: 60000, + }; + $.get(toqqreaddayreadurl, (error, response, data) => { + if (logs) $.log(`每日阅读: ${data}`); + let dayread = JSON.parse(data); + if (dayread.code == 0) { + tz += `【每日阅读】:获得${dayread.data.amount}金币\n`; + kz += `【每日阅读】:获得${dayread.data.amount}金币\n`; + } + resolve(); + }); + }); +} +// 宝箱奖励 +function qqreadbox() { + return new Promise((resolve, reject) => { + const toqqreadboxurl = { + url: "https://mqqapi.reader.qq.com/mqq/red_packet/user/treasure_box", + headers: JSON.parse(qqreadtimeheaderVal), + timeout: 60000, + }; + $.get(toqqreadboxurl, (error, response, data) => { + if (logs) $.log(`宝箱奖励: ${data}`); + let box = JSON.parse(data); + if (box.code == 0 && box.data.amount) { + tz += `【宝箱奖励${box.data.count}】:获得${box.data.amount}金币\n`; + kz += `【宝箱奖励${box.data.count}】:获得${box.data.amount}金币\n`; + } + + resolve(); + }); + }); +} +// 宝箱奖励翻倍 +function qqreadbox2() { + return new Promise((resolve, reject) => { + const toqqreadbox2url = { + url: + "https://mqqapi.reader.qq.com/mqq/red_packet/user/treasure_box_video", + headers: JSON.parse(qqreadtimeheaderVal), + timeout: 60000, + }; + $.get(toqqreadbox2url, (error, response, data) => { + if (logs) $.log(`宝箱奖励翻倍: ${data}`); + let box2 = JSON.parse(data); + if (box2.code == 0 && box2.data.amount) { + tz += `【宝箱翻倍】:获得${box2.data.amount}金币\n`; + kz += `【宝箱翻倍】:获得${box2.data.amount}金币\n`; + } + resolve(); + }); + }); +} +function getNodeCookie() { + if ($.isNode()) { + let QQ_READ_BODY_VAL = [], QQ_READ_TIME_URL_VAL = [], QQ_READ_TIME_HEADER_VAL = []; + if (process.env.QQ_READ_HEADER_VAL) { + if (process.env.QQ_READ_HEADER_VAL.indexOf('@') > -1) { + console.log(`您的QQ_READ_HEADER_VAL选择的是用@隔开\n`) + QQ_READ_BODY_VAL = process.env.QQ_READ_HEADER_VAL.split('@'); + } else if (process.env.QQ_READ_HEADER_VAL.indexOf('\n') > -1) { + console.log(`您的QQ_READ_HEADER_VAL选择的是用换行隔开\n`) + QQ_READ_BODY_VAL = process.env.QQ_READ_HEADER_VAL.split('\n'); + } else { + QQ_READ_BODY_VAL = [process.env.QQ_READ_HEADER_VAL]; + } + } + if (process.env.QQ_READ_TIME_URL_VAL) { + if (process.env.QQ_READ_TIME_URL_VAL.indexOf('@') > -1) { + console.log(`您的QQ_READ_TIME_URL_VAL选择的是用@隔开\n`) + QQ_READ_TIME_URL_VAL = process.env.QQ_READ_TIME_URL_VAL.split('@'); + } else if (process.env.QQ_READ_HEADER_VAL.indexOf('\n') > -1) { + console.log(`您的QQ_READ_TIME_URL_VAL选择的是用换行隔开\n`) + QQ_READ_TIME_URL_VAL = process.env.QQ_READ_TIME_URL_VAL.split('\n'); + } else { + QQ_READ_TIME_URL_VAL = [process.env.QQ_READ_TIME_URL_VAL]; + } + // QQ_READ_TIME_URL_VAL = [...new Set(QQ_READ_TIME_URL_VAL)] + } + if (process.env.QQ_READ_TIME_HEADER_VAL) { + if (process.env.QQ_READ_TIME_HEADER_VAL.indexOf('@') > -1) { + console.log(`您的QQ_READ_TIME_HEADER_VAL选择的是用@隔开\n`) + QQ_READ_TIME_HEADER_VAL = process.env.QQ_READ_TIME_HEADER_VAL.split('@'); + } else if (process.env.QQ_READ_TIME_HEADER_VAL.indexOf('\n') > -1) { + console.log(`您的QQ_READ_TIME_HEADER_VAL选择的是用换行隔开\n`) + QQ_READ_TIME_HEADER_VAL = process.env.QQ_READ_TIME_HEADER_VAL.split('\n'); + } else { + QQ_READ_TIME_HEADER_VAL = [process.env.QQ_READ_TIME_HEADER_VAL]; + } + // QQ_READ_TIME_HEADER_VAL = [...new Set(QQ_READ_TIME_HEADER_VAL)] + } + if (QQ_READ_BODY_VAL && QQ_READ_BODY_VAL.length > 0) QQ_READ_COOKIES = []; + for (let i = 0; i < QQ_READ_BODY_VAL.length; i ++) { + QQ_READ_COOKIES.push({ + "qqreadbodyVal": QQ_READ_BODY_VAL[i] || "", + "qqreadtimeurlVal": QQ_READ_TIME_URL_VAL[i] || "", + "qqreadtimeheaderVal": QQ_READ_TIME_HEADER_VAL[i] || "" + }) + } + // console.log(`${JSON.stringify(QQ_READ_COOKIES)}`) + } +} +// prettier-ignore +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(); 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 } } } }; this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))); let h = ["", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="]; h.push(e), s && h.push(s), i && h.push(i), console.log(h.join("\n")), this.logs = this.logs.concat(h) } 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 diff --git a/tencentscf.md b/backUp/tencentscf.md similarity index 100% rename from tencentscf.md rename to backUp/tencentscf.md diff --git a/jdCookie.js b/jdCookie.js index f24b3983..0dcadb23 100644 --- a/jdCookie.js +++ b/jdCookie.js @@ -24,5 +24,5 @@ console.log(`\n====================共有${CookieJDs.length}个京东账号Cooki console.log(`==================脚本执行- 北京时间(UTC+8):${new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString()}=====================\n`) for (let i = 0; i < CookieJDs.length; i++) { const index = (i + 1 === 1) ? '' : (i + 1); - exports['CookieJD' + index] = CookieJDs[i]; + exports['CookieJD' + index] = CookieJDs[i].trim(); } diff --git a/jd_crazy_joy_coin.js b/jd_crazy_joy_coin.js index 669bf766..8824b85a 100644 --- a/jd_crazy_joy_coin.js +++ b/jd_crazy_joy_coin.js @@ -287,9 +287,9 @@ function getJoyShop() { 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;//可购买的最大等级 - if ($.isNode() && process.env.BUY_JPY_LEVEL) { + if ($.isNode() && process.env.BUY_JOY_LEVEL) { $.log(`当前可购买的最高JOY等级为${$.buyJoyLevel}级\n`) - $.buyJoyLevel = (process.env.BUY_JPY_LEVEL * 1) > $.buyJoyLevel ? $.buyJoyLevel : process.env.BUY_JPY_LEVEL * 1; + $.buyJoyLevel = (process.env.BUY_JOY_LEVEL * 1) > $.buyJoyLevel ? $.buyJoyLevel : process.env.BUY_JOY_LEVEL * 1; $.cost = shop[$.buyJoyLevel - 1]['coins'] } else { $.cost = shop.length ? shop[shop.length - 1]['coins'] : Infinity diff --git a/jd_fruit.js b/jd_fruit.js index 2cb8ec94..0b4b3ba2 100644 --- a/jd_fruit.js +++ b/jd_fruit.js @@ -1,6 +1,6 @@ /* 东东水果:脚本更新地址 https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_fruit.js -更新时间:2020-12-25 +更新时间:2021-1-5 东东农场活动链接:https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html 已支持IOS双京东账号,Node.js支持N个京东账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js @@ -29,9 +29,9 @@ let cookiesArr = [], cookie = '', jdFruitShareArr = [], isBox = false, notify, n //下面给出两个账号的填写示例(iOS只支持2个京东账号) let shareCodes = [ // 这个列表填入你要助力的好友的shareCode //账号一的好友shareCode,不同好友的shareCode中间用@符号隔开 - '0a74407df5df4fa99672a037eec61f7e@dbb21614667246fabcfd9685b6f448f3@6fbd26cc27ac44d6a7fed34092453f77@61ff5c624949454aa88561f2cd721bf6@56db8e7bc5874668ba7d5195230d067a', + '0a74407df5df4fa99672a037eec61f7e@dbb21614667246fabcfd9685b6f448f3@6fbd26cc27ac44d6a7fed34092453f77@61ff5c624949454aa88561f2cd721bf6@56db8e7bc5874668ba7d5195230d067a@', //账号二的好友shareCode,不同好友的shareCode中间用@符号隔开 - 'b1638a774d054a05a30a17d3b4d364b8@f92cb56c6a1349f5a35f0372aa041ea0@9c52670d52ad4e1a812f894563c746ea@8175509d82504e96828afc8b1bbb9cb3', + 'b1638a774d054a05a30a17d3b4d364b8@f92cb56c6a1349f5a35f0372aa041ea0@9c52670d52ad4e1a812f894563c746ea@8175509d82504e96828afc8b1bbb9cb3@2673c3777d4443829b2a635059953a28', ] let message = '', subTitle = '', option = {}, isFruitFinished = false; const retainWater = 100;//保留水滴大于多少g,默认100g; @@ -771,24 +771,31 @@ async function clockInIn() { // async function getAwardInviteFriend() { await friendListInitForFarm();//查询好友列表 - console.log(`\n今日已邀请好友${$.friendList.inviteFriendCount}个 / 每日邀请上限${$.friendList.inviteFriendMax}个`); - console.log(`开始删除${$.friendList.friends.length}个好友,可拿每天的邀请奖励`); - for (let friend of $.friendList.friends) { - console.log(`\n开始删除好友 [${friend.shareCode}]`); - const deleteFriendForFarm = await request('deleteFriendForFarm', { "shareCode": `${friend.shareCode}`,"version":8,"channel":1 }); - if (deleteFriendForFarm && deleteFriendForFarm.code === '0') { - console.log(`删除好友 [${friend.shareCode}] 成功\n`); + console.log(`查询好友列表数据:${JSON.stringify($.friendList)}\n`) + if ($.friendList) { + console.log(`\n今日已邀请好友${$.friendList.inviteFriendCount}个 / 每日邀请上限${$.friendList.inviteFriendMax}个`); + console.log(`开始删除${$.friendList.friends && $.friendList.friends.length}个好友,可拿每天的邀请奖励`); + if ($.friendList.friends && $.friendList.friends.length > 0) { + for (let friend of $.friendList.friends) { + console.log(`\n开始删除好友 [${friend.shareCode}]`); + const deleteFriendForFarm = await request('deleteFriendForFarm', { "shareCode": `${friend.shareCode}`,"version":8,"channel":1 }); + if (deleteFriendForFarm && deleteFriendForFarm.code === '0') { + console.log(`删除好友 [${friend.shareCode}] 成功\n`); + } + } } - } - await receiveFriendInvite();//为他人助力,接受邀请成为别人的好友 - if ($.friendList.inviteFriendCount > 0) { - if ($.friendList.inviteFriendCount > $.friendList.inviteFriendGotAwardCount) { - console.log('开始领取邀请好友的奖励'); - await awardInviteFriendForFarm(); - console.log(`领取邀请好友的奖励结果::${JSON.stringify($.awardInviteFriendRes)}`); + await receiveFriendInvite();//为他人助力,接受邀请成为别人的好友 + if ($.friendList.inviteFriendCount > 0) { + if ($.friendList.inviteFriendCount > $.friendList.inviteFriendGotAwardCount) { + console.log('开始领取邀请好友的奖励'); + await awardInviteFriendForFarm(); + console.log(`领取邀请好友的奖励结果::${JSON.stringify($.awardInviteFriendRes)}`); + } + } else { + console.log('今日未邀请过好友') } } else { - console.log('今日未邀请过好友') + console.log(`查询好友列表失败\n`); } } //给好友浇水 diff --git a/jd_get_share_code.js b/jd_get_share_code.js index 46357d5b..a23754d1 100644 --- a/jd_get_share_code.js +++ b/jd_get_share_code.js @@ -144,11 +144,14 @@ if ($.isNode()) { $.isLogin = true; $.nickName = ''; message = ''; + await TotalBean(); + if (!$.isLogin) { + continue + } console.log(`======账号${$.index}开始======`) await getShareCode() - console.log(`======账号${$.index}结束======`) + console.log(`======账号${$.index}结束======\n`) } - } })() .catch((e) => { @@ -174,7 +177,7 @@ function getJdFactory() { $.taskVos.map((item) => { if (item.taskType === 14) { console.log( - `【东东工厂】${item.assistTaskDetailVo.taskToken}` + `【账号${$.index}(${$.nickName || $.UserName})东东工厂】${item.assistTaskDetailVo.taskToken}` ); } }); @@ -238,7 +241,7 @@ function getJxFactory(){ $.commodityDimId = production.commodityDimId; $.encryptPin = data.user.encryptPin; // subTitle = data.user.pin; - console.log(`【惊喜工厂】${data.user.encryptPin}`); + console.log(`【账号${$.index}(${$.nickName || $.UserName})惊喜工厂】${data.user.encryptPin}`); } } else { $.unActive = false; //标记是否开启了京喜活动或者选购了商品进行生产 @@ -317,7 +320,7 @@ function getJdPet(){ } console.log( - `【京东萌宠】${$.petInfo.shareCode}` + `【账号${$.index}(${$.nickName || $.UserName})京东萌宠】${$.petInfo.shareCode}` ); } else if (initPetTownRes.code === "0") { @@ -348,7 +351,7 @@ async function getJdZZ() { if (safeGet(data)) { data = JSON.parse(data); if (data.data.shareTaskRes) { - console.log(`【京东赚赚】${data.data.shareTaskRes.itemId}`); + console.log(`【账号${$.index}(${$.nickName || $.UserName})京东赚赚】${data.data.shareTaskRes.itemId}`); } else { //console.log(`已满5人助力,暂时看不到您的京东赚赚好友助力码`) } @@ -449,7 +452,7 @@ async function getPlantBean() { if ($.plantBeanIndexResult.code === "0") { const shareUrl = $.plantBeanIndexResult.data.jwordShareInfo.shareUrl; $.myPlantUuid = getParam(shareUrl, "plantUuid"); - console.log(`【种豆得豆】${$.myPlantUuid}`); + console.log(`【账号${$.index}(${$.nickName || $.UserName})种豆得豆】${$.myPlantUuid}`); } else { console.log( @@ -513,11 +516,8 @@ async function getJDFruit() { async function jdFruit() { await initForFarm(); if ($.farmInfo.farmUserPro) { - // option['media-url'] = $.farmInfo.farmUserPro.goodsImage; - subTitle = `【京东账号${$.index}】${$.nickName}`; - message = `【水果名称】${$.farmInfo.farmUserPro.name}`; console.log( - `【京东农场】${$.farmInfo.farmUserPro.shareCode}` + `【账号${$.index}(${$.nickName || $.UserName})京东农场】${$.farmInfo.farmUserPro.shareCode}` ); } else { @@ -563,7 +563,7 @@ async function getJoy(){ if (safeGet(data)) { data = JSON.parse(data); if (data.success && data.data && data.data.userInviteCode) { - console.log(`【crazyJoy】${data.data.userInviteCode}`) + console.log(`【账号${$.index}(${$.nickName || $.UserName})crazyJoy】${data.data.userInviteCode}`) } } } @@ -596,7 +596,46 @@ function safeGet(data) { return false; } } - +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + $.nickName = data['base'].nickname; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} function taskPostUrl(function_id, body = {}, function_id2) { let url = `${JD_API_HOST}`; if (function_id2) { @@ -622,5 +661,16 @@ function taskPostUrl(function_id, body = {}, function_id2) { }, }; } +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie') + return []; + } + } +} // prettier-ignore 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();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}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}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)} diff --git a/jd_joy_reward.js b/jd_joy_reward.js index 2eaf482d..76ed0fe4 100644 --- a/jd_joy_reward.js +++ b/jd_joy_reward.js @@ -1,6 +1,6 @@ /* 宠汪汪积分兑换奖品脚本, 目前脚本只兑换京豆,兑换京豆成功,才会发出通知提示,其他情况不通知。 -更新时间:2020-12-23 +更新时间:2021-1-6 兑换规则:一个账号一天只能兑换一次京豆。 兑换奖品成功后才会有系统弹窗通知 每日京豆库存会在0:00、8:00、16:00更新,经测试发现中午12:00也会有补发京豆。 @@ -127,9 +127,9 @@ async function joyReward() { ctrTemp = `${jdNotify}` === 'false'; } if (ctrTemp) { - $.msg($.name, `兑换${giftValue}京豆成功`, `【京东账号${$.index}】${$.nickName}\n【宠物等级】${data.level}\n【积分详情】消耗积分 ${salePrice}, 剩余积分 ${data.coin - salePrice}`); + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【${giftValue}京豆】兑换成功\n【宠物等级】${data.level}\n【积分详情】消耗积分 ${salePrice}, 剩余积分 ${data.coin - salePrice}`); if ($.isNode()) { - await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】 ${$.nickName}\n【兑换${giftValue}京豆】成功\n【宠物等级】${data.level}\n【积分详情】消耗积分 ${salePrice}, 剩余积分 ${data.coin - salePrice}`); + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】 ${$.nickName}\n【${giftValue}京豆】兑换成功\n【宠物等级】${data.level}\n【积分详情】消耗积分 ${salePrice}, 剩余积分 ${data.coin - salePrice}`); } } // if ($.isNode()) { diff --git a/jd_joy_run.js b/jd_joy_run.js index 2b18c1e0..a8f414d7 100644 --- a/jd_joy_run.js +++ b/jd_joy_run.js @@ -1,6 +1,6 @@ /** 宠汪汪邀请助力与赛跑助力脚本,感谢github@Zero-S1提供帮助 -更新时间:2020-12-16(宠汪汪助力更新Token的配置正则表达式已改) +更新时间:2021-1-6(宠汪汪助力更新Token的配置正则表达式已改) token时效很短,几个小时就失效了,闲麻烦的放弃就行 每天拿到token后,可一次性运行完毕即可。 @@ -245,37 +245,41 @@ async function invite(invite_pins) { for (let item of invite_pins.map(item => item.trim())) { console.log(`\n账号${$.index} [${UserName}] 开始给好友 [${item}] 进行邀请助力`) const data = await enterRoom(item); - if (!data.success && data.errorCode === 'B0001') { - console.log('京东Cookie失效'); - $.msg($.name, `【提示】京东cookie已失效`, `京东账号${$.index} ${UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); - $.jdLogin = false; - break - } else { - const { helpStatus } = data.data; - console.log(`helpStatus ${helpStatus}`) - if (helpStatus=== 'help_full') { - console.log(`您的邀请助力机会已耗尽\n`) - break; - } else if (helpStatus=== 'cannot_help') { - console.log(`已给该好友 ${item} 助力过或者此friendPin是你自己\n`) - continue; - } else if (helpStatus=== 'invite_full') { - console.log(`助力失败,该好友 ${item} 已经满3人给他助力了,无需您再次助力\n`) - continue; - } else if (helpStatus=== 'can_help') { - console.log(`开始给好友 ${item} 助力\n`) - const LKYL_DATA = await helpInviteFriend(item); - if (LKYL_DATA.errorCode === 'L0001' && !LKYL_DATA.success) { - console.log('来客有礼宠汪汪token失效'); - $.setdata('', 'jdJoyRunToken'); - $.msg($.name, '【提示】来客有礼token失效,请重新获取', "微信搜索'来客有礼'小程序\n点击底部的'发现'Tab\n即可获取Token") - $.LKYLLogin = false; + if (data) { + if (data.success) { + const { helpStatus } = data.data; + console.log(`helpStatus ${helpStatus}`) + if (helpStatus=== 'help_full') { + console.log(`您的邀请助力机会已耗尽\n`) + break; + } else if (helpStatus=== 'cannot_help') { + console.log(`已给该好友 ${item} 助力过或者此friendPin是你自己\n`) + continue; + } else if (helpStatus=== 'invite_full') { + console.log(`助力失败,该好友 ${item} 已经满3人给他助力了,无需您再次助力\n`) + continue; + } else if (helpStatus=== 'can_help') { + console.log(`开始给好友 ${item} 助力\n`) + const LKYL_DATA = await helpInviteFriend(item); + if (LKYL_DATA.errorCode === 'L0001' && !LKYL_DATA.success) { + console.log('来客有礼宠汪汪token失效'); + $.setdata('', 'jdJoyRunToken'); + $.msg($.name, '【提示】来客有礼token失效,请重新获取', "微信搜索'来客有礼'小程序\n点击底部的'发现'Tab\n即可获取Token") + $.LKYLLogin = false; + break + } else { + $.LKYLLogin = true; + } + } + $.jdLogin = true; + } else { + if (data.errorCode === 'B0001') { + console.log('京东Cookie失效'); + $.msg($.name, `【提示】京东cookie已失效`, `京东账号${$.index} ${UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + $.jdLogin = false; break - } else { - $.LKYLLogin = true; } } - $.jdLogin = true; } } // if ($.inviteReward > 0) { @@ -287,14 +291,15 @@ function enterRoom(invitePin) { headers.Cookie = cookie; headers.LKYLToken = $.LKYLToken; const options = { - url: `${JD_BASE_API}/enterRoom?reqSource=weapp&invitePin=${encodeURI(invitePin)}`, + url: `${JD_BASE_API}/enterRoom/h5?reqSource=weapp&invitePin=${encodeURI(invitePin)}&inviteSource=task_invite&shareSource=weapp&inviteTimeStamp=${Date.now()}`, + body: '{}', headers } - $.get(options, (err, resp, data) => { + $.post(options, (err, resp, data) => { try { if (err) { - $.log('API请求失败') - $.logErr(JSON.stringify(err)); + $.log(`${$.name} API请求失败`) + $.log(JSON.stringify(err)) } else { data = JSON.parse(data); // console.log('进入房间', data) diff --git a/jd_pet.js b/jd_pet.js index cde3fd7f..3586c920 100644 --- a/jd_pet.js +++ b/jd_pet.js @@ -1,6 +1,6 @@ /* 东东萌宠 更新地址: https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_pet.js -更新时间:2020-12-26 +更新时间:2021-01-06 已支持IOS双京东账号,Node.js支持N个京东账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js @@ -231,8 +231,10 @@ async function masterHelpInit() { if(!res.result.addedBonusFlag) { console.log("开始领取额外奖励"); let getHelpAddedBonusResult = await request('getHelpAddedBonus'); + if (getHelpAddedBonusResult.resultCode === '0') { + message += `【额外奖励${getHelpAddedBonusResult.result.reward}领取】${getHelpAddedBonusResult.message}\n`; + } console.log(`领取30g额外奖励结果:【${getHelpAddedBonusResult.message}】`); - message += `【额外奖励${getHelpAddedBonusResult.result.reward}领取】${getHelpAddedBonusResult.message}\n`; } else { console.log("已经领取过5好友助力额外奖励"); message += `【额外奖励】已领取\n`; @@ -261,6 +263,8 @@ async function masterHelpInit() { * 运行脚本时你自己的shareCode会在控制台输出, 可以将其分享给他人 */ async function slaveHelp() { + $.log(`\n因1.6日好友助力功能下线。故暂时屏蔽\n`) + return let helpPeoples = ''; for (let code of newShareCodes) { console.log(`开始助力京东账号${$.index} - ${$.nickName}的好友: ${code}`); @@ -281,7 +285,7 @@ async function slaveHelp() { console.log(`助力其他情况:${JSON.stringify(response)}`); } } else { - console.log(`助理好友结果: ${response.message}`); + console.log(`助力好友结果: ${response.message}`); } } if (helpPeoples && helpPeoples.length > 0) { @@ -467,7 +471,9 @@ function shareCodesFormat() { const tempIndex = $.index > shareCodes.length ? (shareCodes.length - 1) : ($.index - 1); newShareCodes = shareCodes[tempIndex].split('@'); } - const readShareCodeRes = await readShareCode(); + //因好友助力功能下线。故暂时屏蔽 + // const readShareCodeRes = await readShareCode(); + const readShareCodeRes = null; if (readShareCodeRes && readShareCodeRes.code === 200) { newShareCodes = [...new Set([...newShareCodes, ...(readShareCodeRes.data || [])])]; } diff --git a/sendNotify.js b/sendNotify.js index 262e5e97..df0be539 100644 --- a/sendNotify.js +++ b/sendNotify.js @@ -2,7 +2,7 @@ * @Author: lxk0301 https://github.com/lxk0301 * @Date: 2020-08-19 16:12:40 * @Last Modified by: lxk0301 - * @Last Modified time: 2020-12-21 13:52:54 + * @Last Modified time: 2021-1-5 17:52:54 */ const querystring = require("querystring"); const $ = new Env(); @@ -49,7 +49,8 @@ let DD_BOT_SECRET = ''; let QYWX_KEY = ''; // =======================================企业微信应用消息通知设置区域=========================================== -//此处填你企业微信应用消息的 值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236),依次填上corpid的值,corpsecret的值,touser的值,agentid的值,素材库图片id(见https://work.weixin.qq.com/api/doc/90000/90135/90253) 注意用,号隔开,例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat +//此处填你企业微信应用消息的 值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236),依次填上corpid的值,corpsecret的值,touser的值,agentid的值,素材库图片id(见https://github.com/lxk0301/jd_scripts/issues/519) 注意用,号隔开,例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat +//增加一个选择推送消息类型,用图文消息直接填写素材库图片id的值,用卡片消息就填写0(就是数字零) //注:此处设置github action用户填写到Settings-Secrets里面(Name输入QYWX_AM) let QYWX_AM = ''; @@ -132,17 +133,21 @@ if (process.env.PUSH_PLUS_USER) { async function sendNotify(text, desp, params = {}) { //提供7种通知 - await serverNotify(text, desp);//微信server酱 - await pushPlusNotify(text, desp);//pushplus(推送加) + await Promise.all([ + serverNotify(text, desp),//微信server酱 + pushPlusNotify(text, desp)//pushplus(推送加) + ]) //由于上述两种微信通知需点击进去才能查看到详情,故text(标题内容)携带了账号序号以及昵称信息,方便不点击也可知道是哪个京东哪个活动 text = text.match(/.*?(?=\s?-)/g) ? text.match(/.*?(?=\s?-)/g)[0] : text; - await BarkNotify(text, desp, params);//iOS Bark APP - await tgBotNotify(text, desp);//telegram 机器人 - await ddBotNotify(text, desp);//钉钉机器人 - await qywxBotNotify(text, desp); //企业微信机器人 - await qywxamNotify(text, desp); //企业微信应用消息推送 - await iGotNotify(text, desp, params);//iGot - await CoolPush(text, desp);//QQ酷推 + await Promise.all([ + BarkNotify(text, desp, params),//iOS Bark APP + tgBotNotify(text, desp),//telegram 机器人 + ddBotNotify(text, desp),//钉钉机器人 + qywxBotNotify(text, desp), //企业微信机器人 + qywxamNotify(text, desp), //企业微信应用消息推送 + iGotNotify(text, desp, params),//iGot + CoolPush(text, desp)//QQ酷推 + ]) } function serverNotify(text, desp, timeout = 2100) { @@ -419,45 +424,64 @@ function qywxBotNotify(text, desp) { function qywxamNotify(text, desp) { return new Promise(resolve => { if (QYWX_AM) { - var QYWX_AM_AY = QYWX_AM.split(','); - const options_accesstoken = { - url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`, - json: { - corpid:`${QYWX_AM_AY[0]}`, - corpsecret:`${QYWX_AM_AY[1]}`, - }, - headers: { - 'Content-Type': 'application/json', - }, - }; - $.post(options_accesstoken, (err, resp, data) => { + var QYWX_AM_AY = QYWX_AM.split(','); + const options_accesstoken = { + url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`, + json: { + corpid:`${QYWX_AM_AY[0]}`, + corpsecret:`${QYWX_AM_AY[1]}`, + }, + headers: { + 'Content-Type': 'application/json', + }, + }; + $.post(options_accesstoken, (err, resp, data) => { + html=desp.replace(/\n/g,"
") var json = JSON.parse(data); accesstoken = json.access_token; - const options = { - url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`, - json: { - touser:`${QYWX_AM_AY[2]}`, - agentid:`${QYWX_AM_AY[3]}`, - msgtype: 'mpnews', - mpnews: { + const options_textcard = { + url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`, + json: { + touser:`${QYWX_AM_AY[2]}`, + agentid:`${QYWX_AM_AY[3]}`, + msgtype: 'textcard', + textcard: { + title: `${text}`, + description: `${desp}`, + url: '127.0.0.1', + btntxt: '更多' + }, + safe:'0', + }, + headers: { + 'Content-Type': 'application/json', + }, + }; + const options_mpnews = { + url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`, + json: { + touser:`${QYWX_AM_AY[2]}`, + agentid:`${QYWX_AM_AY[3]}`, + msgtype: 'mpnews', + mpnews: { articles: [ { - title: `${text}`, + title: `${text}`, thumb_media_id: `${QYWX_AM_AY[4]}`, author : `智能助手` , content_source_url: ``, - content : `${desp}`, //暂时直接设置成了desp + content : `${html}`, digest: `${desp}` } ] - }, - safe:'0', - }, - headers: { - 'Content-Type': 'application/json', - }, - }; - $.post(options, (err, resp, data) => { + }, + safe:'0', + }, + headers: { + 'Content-Type': 'application/json', + }, + }; + $.post((QYWX_AM_AY[4]==0)?options_textcard:options_mpnews, (err, resp, data) => { try { if (err) { console.log('企业微信应用消息发送通知消息失败!!\n'); @@ -564,7 +588,7 @@ function pushPlusNotify(text, desp) { } }) } else { - console.log('\n您未提供push+推送所需的PUSH_PLUS_TOKEN,取消push+推送消息通知\n'); + console.log('您未提供push+推送所需的PUSH_PLUS_TOKEN,取消push+推送消息通知\n'); resolve() } })