├── .prettierrc ├── QuantumultX.cookie.conf ├── QuantumultX.task.json ├── README.md └── script ├── bilibili ├── bilibili.task.json ├── icon │ └── manga.png ├── manga.vip.reward.js ├── manga.vip.reward2.js └── rewrite │ ├── bilibili.manga.conf │ └── bilibili.manga.cookie.js ├── jd ├── icon │ ├── choujd.png │ ├── jd.png │ ├── jddj.png │ ├── jdjr.png │ ├── jdyjd.png │ ├── jx.png │ └── yaojd.png ├── jd.jr.doubleSign.task.js ├── jd.jx.cfd.task.js ├── jd.jx.doubleSign.task.js ├── jd.lottery.task.js ├── jd.plantBean.help.task.js ├── jd.plantBean.task.js ├── jd.sharkBean.task.js ├── jd.sign.task.js ├── jd.task.json └── rewrite │ ├── jd.cookie.conf │ ├── jd.cookie.js │ ├── jd.cookies.conf │ ├── jd.cookies.js │ ├── jddj.checkin.conf │ ├── jdjr.sign.conf │ ├── jdjr.sign.js │ ├── jdjx.cfd.sign.conf │ └── jdjx.cfd.sign.js ├── meituan ├── icon │ ├── mall.meituan.png │ └── meituan.png ├── mall.meituan.cookie.js ├── mall.meituan.mallcoin.task.js ├── meituan.task.json └── rewrite │ ├── mall.meituan.conf │ └── meituan.checkin.conf └── ximalaya ├── icon └── ximalaya.png ├── rewrite └── ximalaya.checkin.conf └── ximalaya.task.json /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "always", 3 | "bracketSpacing": true, 4 | "endOfLine": "lf", 5 | "htmlWhitespaceSensitivity": "css", 6 | "insertPragma": false, 7 | "jsxBracketSameLine": false, 8 | "jsxSingleQuote": false, 9 | "printWidth": 120, 10 | "proseWrap": "preserve", 11 | "quoteProps": "as-needed", 12 | "requirePragma": false, 13 | "semi": true, 14 | "singleQuote": true, 15 | "tabWidth": 2, 16 | "trailingComma": "es5", 17 | "useTabs": false, 18 | "vueIndentScriptAndStyle": false, 19 | "parser": "babel" 20 | } 21 | -------------------------------------------------------------------------------- /QuantumultX.cookie.conf: -------------------------------------------------------------------------------- 1 | # 此远程订阅用于解决QX任务脚本的cookie获取,仅适用于QX 1.0.10及更高版本,您可在使用后手动将其禁用,以避免无意义的MITM。 2 | 3 | hostname = passport.iqiyi.com, api.m.jd.com, ms.jr.jd.com, me-api.jd.com, daojia.jd.com, passport.biligame.com, *.bilibili.com, *.ximalaya.com, music.163.com, sf-integral-sign-in.weixinjia.net, mcs-mimp-web.sf-express.com, m.client.10010.com, act.10010.com, wx.10086.cn, i.meituan.com, promotion.waimai.meituan.com, maicai.api.ddxq.mobi, mall.meituan.com 4 | 5 | ######## @NobyDa ######### 6 | 7 | # 爱奇艺 cookie 8 | # hostname = passport.iqiyi.com 9 | ^https:\/\/passport\.iqiyi\.com\/apis\/user\/info\.action url script-request-header https://raw.githubusercontent.com/NobyDa/Script/master/iQIYI-DailyBonus/iQIYI.js 10 | 11 | # 京东 cookie 12 | # hostname = api.m.jd.com, ms.jr.jd.com, me-api.jd.com 13 | ^https:\/\/(api\.m|me-api)\.jd\.com\/(client\.action\?functionId=signBean|user_new\/info\/GetJDUserInfoUnion\?) url script-request-header https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js 14 | ^https:\/\/ms\.jr\.jd\.com\/gw\/generic\/hy\/h5\/m\/appSign\? url script-request-body https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js 15 | 16 | # 哔哩哔哩漫画 Get cookie 17 | # hostname = passport.biligame.com 18 | ^https:\/\/passport\.biligame\.com\/api\/login\/sso.+?version%22%3A%22(3|4|5) url script-request-header https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js 19 | 20 | 21 | ######## @chavyleung ######### 22 | 23 | # Bilibili cookie 24 | # hostname = *.bilibili.com 25 | ^https:\/\/(www|live)\.bilibili\.com\/?.? url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/bilibili/bilibili.cookie.js 26 | 27 | # 喜马拉雅 28 | # hostname = *.ximalaya.com 29 | # @chavyleung的重写触发不了 30 | # ^https?:\/\/.*\/mobile\-user\/(v1\/)?homePage\/.* url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/ximalaya/ximalaya.cookie.js 31 | # @JoJoJotarou 2022-04-22 这个规则不好的一点就是每次进入app就会触发,切换app也会触发,获取cookie后需要立即到QX禁止该规则 32 | ^https?:\/\/passport.ximalaya.com\/user-http-app\/v1\/token\/refresh url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/ximalaya/ximalaya.cookie.js 33 | 34 | # 网易云音乐 35 | # hostname = music.163.com 36 | ^https:\/\/music.163.com\/weapi\/user\/level url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/quanx/neteasemusic.cookie.js 37 | 38 | # 顺丰速运 39 | # hostname = sf-integral-sign-in.weixinjia.net, mcs-mimp-web.sf-express.com 40 | ^https:\/\/sf-integral-sign-in.weixinjia.net\/app\/index url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/sfexpress/sfexpress.cookie.js 41 | ^https:\/\/mcs-mimp-web.sf-express.com\/mcs-mimp\/share\/(.*?)Redirect url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/sfexpress/sfexpress.cookie.js 42 | 43 | # 中国联通 44 | # hostname = m.client.10010.com, act.10010.com 45 | ^https:\/\/act.10010.com\/SigninApp\/signin\/querySigninActivity.htm url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.cookie.js 46 | ^https:\/\/act.10010.com\/SigninApp(.*?)\/signin\/daySign url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.cookie.js 47 | ^https:\/\/m.client.10010.com\/dailylottery\/static\/(textdl\/userLogin|active\/findActivityInfo) url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.cookie.js 48 | 49 | # 中国移动 50 | # hostname = wx.10086.cn 51 | ^http:\/\/wx.10086.cn\/website\/taskCenter\/index\? url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.cookie.js 52 | ^http:\/\/wx.10086.cn\/website\/taskCenter\/sign\? url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.cookie.js 53 | 54 | # 美团外卖 55 | # hostname = promotion.waimai.meituan.com 56 | ^https:\/\/promotion.waimai.meituan.com\/playcenter\/signIn\/entry url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/wmmeituan/wmmeituan.cookie.js 57 | ^https:\/\/promotion.waimai.meituan.com\/playcenter\/signIn\/doaction url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/wmmeituan/wmmeituan.cookie.js 58 | 59 | # 美团 60 | # hostname = i.meituan.com 61 | ^https:\/\/i.meituan.com\/evolve\/signin\/signpost\/ url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/meituan/meituan.cookie.js 62 | 63 | # 叮咚买菜 64 | # hostname = maicai.api.ddxq.mobi 65 | ^https:\/\/maicai.api.ddxq.mobi\/point\/home url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/mcdd/mcdd.cookie.js 66 | 67 | # 京东到家 68 | # hostname = daojia.jd.com 69 | ^https:\/\/daojia.jd.com/client(.*?)functionId=signin(.*?)userSigninNew url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/jddj/jddj.cookie.js 70 | 71 | 72 | ######## @blackmatrix7 ######### 73 | 74 | 75 | # 美团买菜 76 | # 打开美团App,选择“美团买菜” - “我的” - “天天领钱” 77 | # Check:✅❌❓ 78 | ^https?:\/\/mall\.meituan\.com\/api\/c\/mallcoin\/checkIn\/getWeekCheckInProgressBar\? url script-request-header https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/meituan/maicai_checkin.js 79 | -------------------------------------------------------------------------------- /QuantumultX.task.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "JoJoJotarou 脚本收集", 3 | "description": "Task collect by @JoJoJotarou.", 4 | "task": [ 5 | { 6 | "config": "5 8 * * * https://raw.githubusercontent.com/NobyDa/Script/master/iQIYI-DailyBonus/iQIYI.js, tag=爱奇艺签到, img-url=https://raw.githubusercontent.com/NobyDa/mini/master/Color/iQIYI.png, enabled=true" 7 | }, 8 | { 9 | "config": "10 8 * * * https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js, tag=哔哩漫画签到, img-url=https://raw.githubusercontent.com/NobyDa/mini/master/Color/manga.png, enabled=true" 10 | }, 11 | { 12 | "config": "10,20,30 0 12 * * * https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/ExchangePoints.js, tag=哔哩漫画抢券, img-url=https://raw.githubusercontent.com/NobyDa/mini/master/Color/manga.png, enabled=true" 13 | }, 14 | { 15 | "config": "2 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/bilibili/bilibili.js , img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=bilibili签到, enabled=true" 16 | }, 17 | { 18 | "config": "1 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/bilibili/bilibili.silver2coin.js , img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=bilibili银瓜子转硬币, enabled=true" 19 | }, 20 | { 21 | "config": "6 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/ximalaya/ximalaya.js , img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=喜马拉雅, enabled=true" 22 | }, 23 | { 24 | "config": "3 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/quanx/neteasemusic.js , img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=网易云音乐, enabled=true" 25 | }, 26 | { 27 | "config": "10 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/sfexpress/sfexpress.js , img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=顺丰速运, enabled=true" 28 | }, 29 | { 30 | "config": "8 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.js , img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=中国联通, enabled=true" 31 | }, 32 | { 33 | "config": "9 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.js , img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=中国移动, enabled=true" 34 | }, 35 | { 36 | "config": "9 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/wmmeituan/wmmeituan.js , img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=美团外卖, enabled=true" 37 | }, 38 | { 39 | "config": "10 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/meituan/meituan.js , img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=美团, enabled=true" 40 | }, 41 | { 42 | "config": "10 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/mcdd/mcdd.js , img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=叮咚买菜, enabled=true" 43 | }, 44 | { 45 | "config": "11 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/jddj/jddj.js , img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=京东到家, enabled=true" 46 | }, 47 | { 48 | "config": "30 0 * * * https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/meituan/maicai_checkin.js, img-url=https://raw.githubusercontent.com/crossutility/Quantumult-X/master/quantumult-x.png, tag=美团买菜_每日签到, enabled=true" 49 | } 50 | ] 51 | } 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # myScript 2 | 3 | 获取Cookie后, 请将Cookie脚本禁用并移除主机名,以免产生不必要的MITM. 4 | 5 | ## iqiyi 6 | 7 | Safari浏览器打开 使用密码登录, 如通知成功获取cookie则可使用该脚本. 8 | 9 | ## jd 10 | 11 | Safari浏览器打开网址 点击签到并且出现签到日历 12 | 如果通知获取Cookie成功, 则可以使用此签到脚本. 注: 请勿在京东APP内获取!!! 13 | 获取京东金融签到Body说明: 正确添加脚本配置后, 进入"京东金融"APP, 在"首页"点击"签到"并签到一次, 待通知提示成功即可. 14 | 15 | ## bilibili漫画 16 | 17 | 打开 APP 后 (AppStore中国区),单击"我的", 如果通知获取cookie成功, 则可以使用此脚本. 18 | 19 | ## bilibili 20 | 21 | 打开浏览器访问: 22 | 23 | ## 喜马拉雅 24 | 25 | 打开 APP, 访问下右下角`账号` 26 | 27 | ## 网易云音乐 28 | 29 | 浏览器访问并登录: 30 | 31 | ## 顺丰速运 32 | 33 | 打开 APP, 访问下`我的顺丰` > `去签到` (访问下`去签到`的页面即可, 不用点`签到`) 34 | 35 | ## 中国联通 36 | 37 | 打开 APP , 进入签到页面, 系统提示: `获取刷新链接: 成功`,然后手动签到 1 次 38 | 39 | ## 中国移动 40 | 41 | 打开 APP , 进入签到页面, 系统提示: `获取刷新链接: 成功`,然后手动签到 1 次 42 | 43 | ## 美团外卖 44 | 45 | 打开 APP , 进入签到页面, 系统提示: `获取刷新链接: 成功`,然后手动签到 1 次 46 | 47 | ## 美团 48 | 49 | 打开 APP , 然后手动签到 1 次, (`首页` > `红包签到`) 50 | 51 | ## 叮咚买菜 52 | 53 | 打开 APP, 访问下`我的`>`积分` 54 | 55 | ## 京东到家 56 | 57 | 打开 APP 手动签到一次: `首页` > `签到` 或者 手机浏览器打开 点击签到 58 | 59 | ✅:ok, ❌:no, ❓:unknown 60 | 61 | | APP | Cookie测试时间 | Cookie测试结果 | Task测试时间 | Task测试结果 | 62 | | ------------ | -------------- | -------------- | ------------ | ------------ | 63 | | jd | | | | | 64 | | 京东到家 | | | | | 65 | | bilibili | | | | | 66 | | bilibili漫画 | | | | | 67 | | 喜马拉雅 | | | | | 68 | | 网易云音乐 | | | | | 69 | | 顺丰速运 | | | | | 70 | | 中国联通 | | | | | 71 | | 叮咚买菜 | | | | | 72 | | 美团外卖 | | | | | 73 | | 美团 | | | | | 74 | | 美团买菜 | | | | | 75 | -------------------------------------------------------------------------------- /script/bilibili/bilibili.task.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "哔哩哔哩脚本集合", 3 | "description": "Script Gallery by @JoJoJotarou", 4 | "task": [ 5 | { 6 | "config": "10 8 * * * https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js, tag=哔哩漫画签到, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/bilibili/icon/manga.png, enabled=true", 7 | "addons":"https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/bilibili/rewrite/bilibili.manga.conf, tag=哔哩漫画CK" 8 | }, 9 | { 10 | "config": "10,20,30 0 12 * * * https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/ExchangePoints.js, tag=哔哩漫画抢券, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/bilibili/icon/manga.png, enabled=true", 11 | "addons":"https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/bilibili/rewrite/bilibili.manga.conf, tag=哔哩漫画CK" 12 | }, 13 | { 14 | "config": "0 8 1 * * https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/bilibili/manga.vip.reward.js, tag=哔漫年度会员特权, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/bilibili/icon/manga.png, enabled=true", 15 | "addons":"https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/bilibili/rewrite/bilibili.manga.conf, tag=哔哩漫画CK" 16 | }, 17 | { 18 | "config": "0 8 1 * * https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/bilibili/manga.vip.reward2.js, tag=哔漫会员特权, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/bilibili/icon/manga.png, enabled=true", 19 | "addons":"https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/bilibili/rewrite/bilibili.manga.conf, tag=哔哩漫画CK" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /script/bilibili/icon/manga.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoJoJotarou/myScript/4a79b2488c892a0723e152aeb4931dff23d295bb/script/bilibili/icon/manga.png -------------------------------------------------------------------------------- /script/bilibili/manga.vip.reward.js: -------------------------------------------------------------------------------- 1 | /** 2 | * B漫大会员特权(年度大会员10张福利券和10元漫画商城优惠券,非年度只有5张福利券,会员时长大于31天,每31天领取一次) 3 | * 🚨Cookie 有效期是否有一个月待验证 4 | * 🌟本脚本适用于年度大会员 5 | */ 6 | const $ = Env('哔漫大会员特权'); 7 | const BILI_MANGA_COOKIE = $.getdata('CookieBM'); 8 | 9 | let _log = []; 10 | let _desc = []; 11 | 12 | function getVipReward(eventName, url) { 13 | let csrf = BILI_MANGA_COOKIE.match(/bili_jct=(\w+)/)[1]; 14 | let option = { 15 | url: url, 16 | headers: { 17 | Host: 'manga.bilibili.com', 18 | Accept: '*/*', 19 | native_api_from: 'h5', 20 | 'Accept-Language': 'zh-cn', 21 | 'Accept-Encoding': 'gzip, deflate, br', 22 | 'User-Agent': 23 | 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/611.2.7.0.4 (KHTML, like Gecko) Mobile/18F72 BiliApp/6791 os/ios model/iPhone 11 mobi_app/iphone_comic build/1400 osVer/14.6 network/2 channel/AppStore Buvid/Z042DA07830C491342CDAB412721528A68F5 c_locale/zh-Hans_CN s_locale/zh-Hans_TW sessionID/d6e4099d disable_rcmd/0 BiliComic/1400 VersionName/4.15.0 comic-universal/1400 CFNetwork/1240.0.4 Darwin/20.5.0 os/ios model/iPhone 11 mobi_app/iphone_comic build/1400 osVer/14.6 network/2 channel/AppStore', 24 | Connection: 'keep-alive', 25 | Referer: 'https://manga.bilibili.com/eden/membership-rewards.html?flutterReqCode=0&-F.pEncoded=1&from=0', 26 | 'X-CSRF-TOKEN': csrf, 27 | Cookie: BILI_MANGA_COOKIE, 28 | }, 29 | body: `access_key=6c2bee60c69fb82836d6bd6607601551&actionKey=appkey&appkey=da44a5d9227fa9ef&build=1400&csrf=${csrf}&device=phone&mobi_app=iphone_comic&platform=ios&reason_id=0&statistics=%7B%22appId%22%3A17%2C%22version%22%3A%224.15.0%22%2C%22abtest%22%3A%22%22%2C%22platform%22%3A1%7D&ts=${ 30 | Date.parse(new Date()) / 1000 31 | }&type=0`, 32 | }; 33 | 34 | return new Promise((resolve, reject) => { 35 | $.post(option, (error, response, data) => { 36 | try { 37 | if (response.statusCode === 200 && JSON.parse(data).code === 0) { 38 | _log.push(`🟢${eventName}: ${data}`); 39 | _desc.push(`🟢${eventName}成功领取`); 40 | } else if (response.statusCode === 200 && JSON.parse(data).code === 1) { 41 | _log.push(`🟡${eventName}: ${JSON.parse(data).msg}`); 42 | _desc.push(`🟡${eventName}${JSON.parse(data).msg}`); 43 | } else { 44 | throw error || data; 45 | } 46 | } catch (error) { 47 | _log.push(`🔴${eventName}: ${error}`); 48 | _desc.push(`🔴${eventName}领取失败`); 49 | } finally { 50 | resolve(); 51 | } 52 | }); 53 | }); 54 | } 55 | 56 | !(async () => { 57 | if (!BILI_MANGA_COOKIE) { 58 | _desc.push(`🔴请先获取哔漫Cookie`); 59 | } else { 60 | await getVipReward('【福利券】', 'https://manga.bilibili.com/twirp/user.v1.User/GetVipReward'); 61 | await getVipReward('【商城券】', 'https://manga.bilibili.com/twirp/activity.v1.Activity/TakeShopCoupon'); 62 | } 63 | 64 | $.log(..._log); 65 | $.desc = _desc.join(''); 66 | $.msg($.name, '', $.desc); 67 | })() 68 | .catch((e) => $.logErr(e)) 69 | .finally(() => $.done()); 70 | 71 | // prettier-ignore 72 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 73 | -------------------------------------------------------------------------------- /script/bilibili/manga.vip.reward2.js: -------------------------------------------------------------------------------- 1 | /** 2 | * B漫大会员特权(年度大会员10张福利券和10元漫画商城优惠券,非年度只有5张福利券,会员时长大于31天,每31天领取一次) 3 | * 🚨Cookie 有效期是否有一个月待验证 4 | * 🌟本脚本适用于非年度大会员 5 | */ 6 | const $ = Env('哔漫大会员特权'); 7 | const BILI_MANGA_COOKIE = $.getdata('CookieBM'); 8 | 9 | let _log = []; 10 | let _desc = []; 11 | 12 | function getVipReward(eventName, url) { 13 | let csrf = BILI_MANGA_COOKIE.match(/bili_jct=(\w+)/)[1]; 14 | let option = { 15 | url: url, 16 | headers: { 17 | Host: 'manga.bilibili.com', 18 | Accept: '*/*', 19 | native_api_from: 'h5', 20 | 'Accept-Language': 'zh-cn', 21 | 'Accept-Encoding': 'gzip, deflate, br', 22 | 'User-Agent': 23 | 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/611.2.7.0.4 (KHTML, like Gecko) Mobile/18F72 BiliApp/6791 os/ios model/iPhone 11 mobi_app/iphone_comic build/1400 osVer/14.6 network/2 channel/AppStore Buvid/Z042DA07830C491342CDAB412721528A68F5 c_locale/zh-Hans_CN s_locale/zh-Hans_TW sessionID/d6e4099d disable_rcmd/0 BiliComic/1400 VersionName/4.15.0 comic-universal/1400 CFNetwork/1240.0.4 Darwin/20.5.0 os/ios model/iPhone 11 mobi_app/iphone_comic build/1400 osVer/14.6 network/2 channel/AppStore', 24 | Connection: 'keep-alive', 25 | Referer: 'https://manga.bilibili.com/eden/membership-rewards.html?flutterReqCode=0&-F.pEncoded=1&from=0', 26 | 'X-CSRF-TOKEN': csrf, 27 | Cookie: BILI_MANGA_COOKIE, 28 | }, 29 | body: `access_key=6c2bee60c69fb82836d6bd6607601551&actionKey=appkey&appkey=da44a5d9227fa9ef&build=1400&csrf=${csrf}&device=phone&mobi_app=iphone_comic&platform=ios&reason_id=0&statistics=%7B%22appId%22%3A17%2C%22version%22%3A%224.15.0%22%2C%22abtest%22%3A%22%22%2C%22platform%22%3A1%7D&ts=${ 30 | Date.parse(new Date()) / 1000 31 | }&type=0`, 32 | }; 33 | 34 | return new Promise((resolve, reject) => { 35 | $.post(option, (error, response, data) => { 36 | try { 37 | if (response.statusCode === 200 && JSON.parse(data).code === 0) { 38 | _log.push(`🟢${eventName}: ${data}`); 39 | _desc.push(`🟢${eventName}成功领取`); 40 | } else if (response.statusCode === 200 && JSON.parse(data).code === 1) { 41 | _log.push(`🟡${eventName}: ${JSON.parse(data).msg}`); 42 | _desc.push(`🟡${eventName}${JSON.parse(data).msg}`); 43 | } else { 44 | throw error || data; 45 | } 46 | } catch (error) { 47 | _log.push(`🔴${eventName}: ${error}`); 48 | _desc.push(`🔴${eventName}领取失败`); 49 | } finally { 50 | resolve(); 51 | } 52 | }); 53 | }); 54 | } 55 | 56 | !(async () => { 57 | if (!BILI_MANGA_COOKIE) { 58 | _desc.push(`🔴Cookie获取失败`); 59 | } else { 60 | await getVipReward('【商城券】', 'https://manga.bilibili.com/twirp/user.v1.User/GetVipReward'); 61 | } 62 | 63 | $.log(..._log); 64 | $.desc = _desc.join(''); 65 | $.msg($.name, '', $.desc); 66 | })() 67 | .catch((e) => $.logErr(e)) 68 | .finally(() => $.done()); 69 | 70 | // prettier-ignore 71 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 72 | -------------------------------------------------------------------------------- /script/bilibili/rewrite/bilibili.manga.conf: -------------------------------------------------------------------------------- 1 | # 使用说明:打开哔哩哔哩漫画后 (AppStore中国区),单击"我的", 如果通知获取cookie成功, 则可以使用此脚本, 若一直不提示可尝试退出登录重新B站授权. 2 | hostname = passport.biligame.com 3 | ^https:\/\/passport\.biligame\.com\/api\/login\/sso.+?version%22%3A%22(3|4|5) url script-request-header https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/bilibili/rewrite/bilibili.manga.cookie.js 4 | -------------------------------------------------------------------------------- /script/bilibili/rewrite/bilibili.manga.cookie.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @description: 原脚本作者:@NobyDa 3 | * @description: 原脚本链接:https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js 4 | * @description: 修改作者:@ZhouStarStar9527 5 | * @description: 修改内容:(cookie 变量的名称依旧为CookieBM)脚本仅留下GetCookie函数并去除对匹配 “SESSDATA=”, 保留所有 cookie 值,兑换大会员特权需要 cookie 中 bili_jct 值 6 | * @description: 使用说明:打开哔哩哔哩漫画后 (AppStore中国区),单击"我的", 如果通知获取cookie成功, 则可以使用此脚本, 若一直不提示可尝试退出登录重新B站授权. 7 | */ 8 | const $ = Env('哔哩哔哩漫画'); 9 | 10 | if (typeof $request !== 'undefined') { 11 | GetCookie(); 12 | } 13 | 14 | function GetCookie() { 15 | var CookieName = 'B站漫画'; 16 | var CookieKey = 'CookieBM'; 17 | // var regex = /SESSDATA=.+?;/; 18 | if ($request.headers) { 19 | var header = $request.headers['Cookie'] ? $request.headers['Cookie'] : ''; 20 | if (header.indexOf('SESSDATA=') != -1) { 21 | var CookieValue = header; 22 | // var CookieValue = regex.exec(header)[0]; 23 | if ($.getdata(CookieKey)) { 24 | if ($.getdata(CookieKey) != CookieValue) { 25 | var cookie = $.setdata(CookieValue, CookieKey); 26 | if (!cookie) { 27 | $.msg('更新' + CookieName + 'Cookie失败‼️', '', ''); 28 | } else { 29 | $.msg('更新' + CookieName + 'Cookie成功 🎉', '', ''); 30 | } 31 | } 32 | } else { 33 | var cookie = $.setdata(CookieValue, CookieKey); 34 | if (!cookie) { 35 | $.msg('首次写入' + CookieName + 'Cookie失败‼️', '', ''); 36 | } else { 37 | $.msg('首次写入' + CookieName + 'Cookie成功 🎉', '', ''); 38 | } 39 | } 40 | } else { 41 | $.msg('写入' + CookieName + 'Cookie失败‼️', '', 'Cookie关键值缺失'); 42 | } 43 | } else { 44 | $.msg('写入' + CookieName + 'Cookie失败‼️', '', '配置错误, 无法读取请求头,'); 45 | } 46 | $.done(); 47 | } 48 | 49 | // prettier-ignore 50 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 51 | -------------------------------------------------------------------------------- /script/jd/icon/choujd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoJoJotarou/myScript/4a79b2488c892a0723e152aeb4931dff23d295bb/script/jd/icon/choujd.png -------------------------------------------------------------------------------- /script/jd/icon/jd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoJoJotarou/myScript/4a79b2488c892a0723e152aeb4931dff23d295bb/script/jd/icon/jd.png -------------------------------------------------------------------------------- /script/jd/icon/jddj.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoJoJotarou/myScript/4a79b2488c892a0723e152aeb4931dff23d295bb/script/jd/icon/jddj.png -------------------------------------------------------------------------------- /script/jd/icon/jdjr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoJoJotarou/myScript/4a79b2488c892a0723e152aeb4931dff23d295bb/script/jd/icon/jdjr.png -------------------------------------------------------------------------------- /script/jd/icon/jdyjd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoJoJotarou/myScript/4a79b2488c892a0723e152aeb4931dff23d295bb/script/jd/icon/jdyjd.png -------------------------------------------------------------------------------- /script/jd/icon/jx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoJoJotarou/myScript/4a79b2488c892a0723e152aeb4931dff23d295bb/script/jd/icon/jx.png -------------------------------------------------------------------------------- /script/jd/icon/yaojd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoJoJotarou/myScript/4a79b2488c892a0723e152aeb4931dff23d295bb/script/jd/icon/yaojd.png -------------------------------------------------------------------------------- /script/jd/jd.jr.doubleSign.task.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @ZhouStarStar9527 3 | * @description 支持多账号 4 | * @description 入口:京东APP -> 首页 -> 领京豆 -> 双签领豆 5 | * @description 必须添加重写规则,并手动签到一次,否则无法签到成功 6 | */ 7 | const $ = Env('京东金融双签'); 8 | 9 | let _log, _desc; 10 | let _beans; 11 | 12 | function jdSignIn(cookie) { 13 | const eventName = '【京东签到】'; 14 | const option = getOption('https://api.m.jd.com/client.action?functionId=signBeanAct&appid=ld', { 15 | Cookie: cookie, 16 | Referer: 'https://wqs.jd.com/', 17 | }); 18 | 19 | return new Promise((resolve, reject) => { 20 | $.get(option, (err, resp, data) => { 21 | try { 22 | if (resp.statusCode === 200 && JSON.parse(data).data) { 23 | if (JSON.parse(data).data.status === '1') { 24 | const award = JSON.parse(data).data.dailyAward || JSON.parse(data).data.continuityAward; 25 | _beans += Number(award.beanAward.beanCount) || 0; 26 | _log.push(`🟢${eventName}: 获得${award.beanAward.beanCount}个京豆`); 27 | _desc.push(`🟢${eventName}`); 28 | } else if (_data.status === '2') { 29 | _log.push(`🟡${eventName}: 今天已签到`); 30 | } 31 | } else { 32 | throw err || data; 33 | } 34 | } catch (error) { 35 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 36 | _desc.push(`🔴${eventName}`); 37 | } finally { 38 | resolve(); 39 | } 40 | }); 41 | }); 42 | } 43 | 44 | function jrSignIn(cookie, signBody) { 45 | const eventName = '【金融签到】'; 46 | const option = getOption(`https://ms.jr.jd.com/gw/generic/hy/h5/m/jrSign?_=${ts()}&${signBody}`, { 47 | Cookie: cookie, 48 | 'User-Agent': userAgent('jr'), 49 | Accept: 'application/json', 50 | Origin: 'https://member.jr.jd.com', 51 | Referer: 52 | 'https://member.jr.jd.com/activity/sign/v5/indexV2.html?channelLv=shuangqian&sid=dace0970cf046301400564834161022w', 53 | }); 54 | 55 | return new Promise((resolve, reject) => { 56 | $.get(option, (err, resp, data) => { 57 | try { 58 | if ( 59 | resp.statusCode === 200 && 60 | JSON.parse(data).resultCode === 0 && 61 | JSON.parse(data).resultData.resBusiCode === 0 62 | ) { 63 | _log.push(`🟢${eventName}: 数据加密,故这里不知道具体获取多少金贴,请到京东金融App查看`); 64 | _desc.push(`🟢${eventName}`); 65 | } else { 66 | throw err || data; 67 | } 68 | } catch (error) { 69 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 70 | _desc.push(`🔴${eventName}`); 71 | } finally { 72 | resolve(); 73 | } 74 | }); 75 | }); 76 | } 77 | 78 | function jdJrDoubleSignReward(cookie) { 79 | const eventName = '【京融双签领奖】'; 80 | const option = getOption( 81 | // `https://nu.jr.jd.com/gw/generic/jrm/h5/m/process?_=${ts()}&reqData=%7B%22actCode%22%3A%22F68B2C3E71%22%2C%22type%22%3A4%2C%22frontParam%22%3A%7B%22belong%22%3A%22jingdou%22%7D%2C%22riskDeviceParam%22%3A%22%7B%5C%22fp%5C%22%3A%5C%229847ae780d67b91a200f87e5b0307ead%5C%22%2C%5C%22eid%5C%22%3A%5C%22PK7BGV22IJOGPW3RIR37RVVQAOL5MA5WG546B63HZIG7QIRJM4XZZHFT2UYT57ZL5EOKRLPDA3F6NWU2HIGXIVDUFY%5C%22%2C%5C%22sdkToken%5C%22%3A%5C%22%5C%22%2C%5C%22sid%5C%22%3A%5C%22%5C%22%7D%22%7D`, 82 | `https://nu.jr.jd.com/gw/generic/jrm/h5/m/process?_=${ts()}&reqData=%7B%22actCode%22%3A%22F68B2C3E71%22%2C%22type%22%3A4%2C%22frontParam%22%3A%7B%22belong%22%3A%22jingdou%22%7D%7D`, 83 | { 84 | Cookie: cookie, 85 | Referer: 'https://m.jr.jd.com/integrate/signin/index.html', 86 | Origin: 'https://m.jr.jd.com', 87 | Accept: 'application/json', 88 | } 89 | ); 90 | 91 | return new Promise((resolve, reject) => { 92 | $.post(option, (err, resp, data) => { 93 | try { 94 | if ( 95 | resp.statusCode === 200 && 96 | JSON.parse(data).resultData && 97 | JSON.parse(data).resultData.data && 98 | JSON.parse(data).resultData.data.businessMsg === '成功' 99 | ) { 100 | bean = JSON.parse(data).resultData.data.businessData.businessData.awardListVo[0].count; 101 | _beans += bean; 102 | _log.push(`🟢${eventName}: 获得${bean}个京豆`); 103 | _desc.push(`🟢${eventName}`); 104 | } else { 105 | throw err || data; 106 | } 107 | } catch (error) { 108 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 109 | _desc.push(`🔴${eventName}`); 110 | } finally { 111 | resolve(); 112 | } 113 | }); 114 | }); 115 | } 116 | 117 | function jdJrDoubleSignInfo(cookie) { 118 | const eventName = '【京融双签状态】'; 119 | const option = getOption( 120 | `https://nu.jr.jd.com/gw/generic/jrm/h5/m/process?_=${ts()}&reqData=%7B%22actCode%22%3A%22F68B2C3E71%22%2C%22type%22%3A9%2C%22frontParam%22%3A%7B%22channel%22%3A%22JD%22%2C%22belong%22%3A%22jingdou%22%7D%7D`, 121 | { 122 | Cookie: cookie, 123 | Referer: 'https://m.jr.jd.com/integrate/signin/index.html', 124 | Origin: 'https://m.jr.jd.com', 125 | Accept: 'application/json', 126 | } 127 | ); 128 | 129 | return new Promise((resolve, reject) => { 130 | $.post(option, (err, resp, data) => { 131 | try { 132 | if (resp.statusCode === 200 && JSON.parse(data).resultData && JSON.parse(data).resultData.code === 200) { 133 | signStatus = JSON.parse(data).resultData.data.businessData; 134 | _log.push( 135 | `🟢${eventName}: ${signStatus.signInJd ? '✓ 京东签到完成' : '⨉ 京东签到未完成'} ${ 136 | signStatus.signInJr ? '✓ 金融签到完成' : '⨉ 金融签到未完成' 137 | } ${signStatus.get ? '✓ 双签礼包已领' : '⨉ 双签礼包未领'} ` 138 | ); 139 | resolve(signStatus); 140 | } else { 141 | throw err || data; 142 | } 143 | } catch (error) { 144 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 145 | _desc.push(`🔴${eventName}`); 146 | resolve(); 147 | } 148 | }); 149 | }); 150 | } 151 | 152 | async function main(cookieObj) { 153 | _beans = 0; 154 | _log = [`\n++++++++++${cookieObj.nickname}++++++++++\n`]; 155 | _desc = []; 156 | 157 | if (!cookieObj.jrSignBody) { 158 | throw '请按照重写规则说明手动完成一次京东金融中签到'; 159 | } 160 | 161 | const signStatus = await jdJrDoubleSignInfo(cookieObj.cookie); 162 | 163 | if (signStatus) { 164 | if (!signStatus.get) { 165 | await randomWait(); 166 | if (signStatus.signInJd && signStatus.signInJr && !signStatus.double_sign_status) { 167 | await jdJrDoubleSignReward(cookieObj.cookie); 168 | await randomWait(); 169 | } else { 170 | if (!signStatus.signInJd) { 171 | await jdSignIn(cookieObj.cookie); 172 | await randomWait(); 173 | } 174 | if (!signStatus.signInJr) { 175 | await jrSignIn(cookieObj.cookie, cookieObj.jrSignBody); 176 | await randomWait(); 177 | } 178 | await jdJrDoubleSignReward(cookieObj.cookie); 179 | await randomWait(); 180 | } 181 | 182 | const [nickname, totalBeans] = await getUserInfo(cookieObj.cookie); 183 | $.subt = `${nickname}, 京豆: ${totalBeans}(+${_beans})`; 184 | } else { 185 | $.subt = `${cookieObj.nickname},今日已完成 ~`; 186 | } 187 | } else { 188 | throw '获取京融双签状态失败'; 189 | } 190 | } 191 | 192 | !(async () => { 193 | let cookieObjs = $.getdata('GLOBAL_JD_COOKIES'); 194 | const specifyUserId = $.getdata('GLOBAL_SPECIFY_USER_ID'); 195 | 196 | if (cookieObjs && JSON.parse(cookieObjs).length > 0) { 197 | cookieObjs = JSON.parse(cookieObjs); 198 | if (specifyUserId && specifyUserId.indexOf('jd_') !== -1) { 199 | // 实现一次执行一个账号 200 | cookieObjs = cookieObjs.filter((cookie) => cookie.userId === specifyUserId); 201 | } 202 | let i = 1; 203 | for (const cookieObj of cookieObjs) { 204 | try { 205 | await main(cookieObj); 206 | } catch (error) { 207 | _log.push(`🔴 ${error}`); 208 | _desc.push(`🔴 ${error}`); 209 | $.subt = `${cookieObj.nickname}`; 210 | } finally { 211 | $.log(..._log); 212 | $.desc = _desc.join(''); 213 | $.msg($.name, $.subt || '', $.desc); 214 | } 215 | 216 | // 切换账号等待至少5秒 217 | if (i < cookieObjs.length) { 218 | await randomWait(5000); 219 | } 220 | i++; 221 | } 222 | } else { 223 | throw '请先获取会话'; 224 | } 225 | })() 226 | .catch((e) => { 227 | $.subt = '脚本执行异常'; 228 | $.msg($.name, $.subt, `🔴 ${String(e)}`); 229 | $.logErr(e); 230 | }) 231 | .finally(() => { 232 | $.done(); 233 | }); 234 | 235 | function getOption(url, headers, body = '') { 236 | // 默认的option 237 | let _headers = { 238 | Accept: '*/*', 239 | 'Accept-Encoding': 'gzip, deflate, br', 240 | 'Accept-Language': 'zh-cn', 241 | Connection: 'keep-alive', 242 | Host: url.match(/\/\/([\w\.]*)/)[1], 243 | 'User-Agent': userAgent('jd'), 244 | }; 245 | 246 | return { 247 | url: url + (body ? `&body=${encodeURIComponent(JSON.stringify(body))}` : ''), 248 | headers: Object.assign({}, _headers, headers), 249 | }; 250 | } 251 | 252 | function userAgent(app) { 253 | // 获取不同app的user-agent 254 | return { 255 | jd: 'jdapp;iPhone;10.5.2;;;M/5.0;JDEbook/openapp.jdreader;appBuild/168069;jdSupportDarkMode/0;ef/1;ep/%7B%22ciphertype%22%3A5%2C%22cipher%22%3A%7B%22ud%22%3A%22CQZwZtO3CzGzYtC0DtG1YJG1DJGmY2HuYWHsDzdrENVwDJGyZNvwEK%3D%3D%22%2C%22sv%22%3A%22CJGkDq%3D%3D%22%2C%22iad%22%3A%22%22%7D%2C%22ts%22%3A1651124892%2C%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22version%22%3A%221.0.3%22%2C%22appname%22%3A%22com.360buy.jdmobile%22%2C%22ridx%22%3A-1%7D;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;', 256 | jx: 'jdpingou;iPhone;5.25.0;appBuild/100934;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/4;pap/JA2019_3111789;supportJDSHWK/1;ef/1;ep/%7B%22ciphertype%22:5,%22cipher%22:%7B%22ud%22:%22ENO0ZNunDtc0CwPtCtHwZQPtDtU2DWUnYtO0Dzu5DwDsZWGyYzTsZq==%22,%22bd%22:%22YXLmbQU=%22,%22iad%22:%22%22,%22sv%22:%22CJGkDq==%22%7D,%22ts%22:1651399595,%22hdid%22:%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=%22,%22version%22:%221.0.3%22,%22appname%22:%22com.360buy.jdpingou%22,%22ridx%22:-1%7D;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148', 257 | safari: 258 | 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1', 259 | jr: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148/application=JDJR-App&deviceId=5383333424033364d243836433d243643373-d293831473d2938334544313542464145403&eufv=1&clientType=ios&iosType=iphone&clientVersion=6.3.40&HiClVersion=6.3.40&isUpdate=0&osVersion=14.6&osName=iOS&screen=896*414&src=App Store&netWork=1&netWorkType=1&CpayJS=UnionPay/1.0 JDJR&stockSDK=stocksdk-iphone_4.1.0&sPoint=MTAwMDcjI2RpYW9xaTQwMDI%3D&jdPay=(*#@jdPaySDK*#@jdPayChannel=jdfinance&jdPayChannelVersion=6.3.40&jdPaySdkVersion=4.00.35.01&jdPayClientName=iOS*#@jdPaySDK*#@)', 260 | }[app]; 261 | } 262 | 263 | // prettier-ignore 264 | function ts(){return new Date().getTime()} 265 | // prettier-ignore 266 | function randomWait(min) { randomTime = ((Math.random() / 5) * 10000 + (min || 1000)).toFixed(0); _log.push(`⏳休息${randomTime}ms`); return new Promise((resolve) => setTimeout(resolve, randomTime)) } 267 | // prettier-ignore 268 | function getUserInfo(cookie){const eventName='【用户信息】';const option={url:'https://wq.jd.com/user/info/QueryJDUserInfo?g_login_type=1&sceneval=2',headers:{Accept:'*/*','Accept-Encoding':'gzip, deflate, br','Accept-Language':'zh-cn',Host:'wq.jd.com',Cookie:cookie,Connection:'keep-alive',Referer:'https://wqs.jd.com/','User-Agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1',},};return new Promise((resolve,reject)=>{$.get(option,(err,resp,data)=>{try{if(resp.statusCode===200&&JSON.parse(data).retcode===0&&JSON.parse(data).base){const nickname=JSON.parse(data).base.nickname;const totalBeans=JSON.parse(data).base.jdNum;_log.push(`🟢${eventName}:${nickname}当前有${totalBeans}个京豆`);resolve([nickname,totalBeans])}else{throw err||data;}}catch(error){error!==data?_log.push(`🔴${eventName}:${error}\n${data}`):_log.push(`🔴${eventName}:${error}`);_desc.push(`🔴${eventName}`);resolve([])}})})} 269 | // prettier-ignore 270 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 271 | -------------------------------------------------------------------------------- /script/jd/jd.lottery.task.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @ZhouStarStar9527 3 | * @description 支持多账号 4 | * @description 入口:京东APP -> 首页 -> 领京豆 -> 抽京豆 5 | */ 6 | const $ = Env('京东抽京豆'); 7 | 8 | let _log, _beans, _desc; 9 | 10 | function getChances(cookie) { 11 | const eventName = '【抽奖机会】'; 12 | const option = { 13 | url: 'https://pro.m.jd.com/mall/active/2xoBJwC5D1Q3okksMUFHcJQhFq8j/index.html?tttparams=%3DI0iMfliQeyJncHNfYXJlYSI6IjJfMjgzMF81MTgxMV8wIiwicHJzdGF0ZSI6IjAiLCJ1bl9hcmVhIjoiMl8yODMwXzUxODExXzAiLCJkTGF0IjoiIiwiZ0xhdCI6IjMxLjEyMzI2NCIsImdMbmciOiIxMjEuNTA5MjQ3IiwibG5nIjoiMTIxLjUxMDMwNyIsImxhdCI6IjMxLjEyMjkzOCIsImRMbmciOiIiLCJtb2RlbCI6ImlQaG9uZTEyLDEifQ9%3D%3D', 14 | headers: { 15 | Cookie: cookie, 16 | Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 17 | 'Accept-Encoding': 'gzip, deflate, br', 18 | 'Accept-Language': 'zh-cn', 19 | Connection: 'keep-alive', 20 | Host: 'pro.m.jd.com', 21 | Referer: 'https://wqs.jd.com/', 22 | 'User-Agent': 23 | 'jdapp;iPhone;10.5.2;;;M/5.0;JDEbook/openapp.jdreader;appBuild/168069;jdSupportDarkMode/0;ef/1;ep/%7B%22ciphertype%22%3A5%2C%22cipher%22%3A%7B%22ud%22%3A%22CQZwZtO3CzGzYtC0DtG1YJG1DJGmY2HuYWHsDzdrENVwDJGyZNvwEK%3D%3D%22%2C%22sv%22%3A%22CJGkDq%3D%3D%22%2C%22iad%22%3A%22%22%7D%2C%22ts%22%3A1651124892%2C%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22version%22%3A%221.0.3%22%2C%22appname%22%3A%22com.360buy.jdmobile%22%2C%22ridx%22%3A-1%7D;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;', 24 | }, 25 | }; 26 | 27 | return new Promise((resolve, reject) => { 28 | $.get(option, (err, resp, data) => { 29 | try { 30 | if (resp.statusCode === 200 && data) { 31 | const chances = data.match(/>([0-9])<\/span>次抽奖机会/)[1]; 32 | _log.push(`🟢${eventName}: 当前有${chances}次抽奖机会`); 33 | if (Number(chances) > 0) { 34 | resolve(Number(chances)); 35 | } else { 36 | resolve(0); 37 | } 38 | } else { 39 | throw err || data; 40 | } 41 | } catch (error) { 42 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 43 | _desc.push(`🔴${eventName}`); 44 | resolve(); 45 | } 46 | }); 47 | }); 48 | } 49 | 50 | function getLottery(cookie) { 51 | const eventName = '【抽奖】'; 52 | const body = { 53 | enAwardK: 54 | 'ltvTJ/WYFPZcuWIWHCAjRz/NdrezuUkmfR0ulrrxUVAaqi8FPY5ILAsnodr3lNauuItMTCtt2Dmy\ny4p8d6/bK/bwdZK6Aw80mPSE7ShF/0r28HWSugMPNPm5JQ8b9nflgkMfDwDJiaqThDW7a9IYpL8z\n7mu4l56kMNsaMgLecghsgTYjv+RZ8bosQ6kKx+PNAP61OWarrOeJ2rhtFmhQncw6DQFeBryeMUM1\nw9SpK5iag4uLvHGIZstZMKOALjB/r9TIJDYxHs/sFMU4vtb2jX9DEwleHSLTLeRpLM1w+RakAk8s\nfC4gHoKM/1zPHJXq1xfwXKFh5wKt4jr5hEqddxiI8N28vWT05HuOdPqtP+0EbGMDdSPdisoPmlru\n+CyHR5Kt0js9JUM=_babel', 55 | encryptProjectId: '3u4fVy1c75fAdDN6XRYDzAbkXz1E', 56 | encryptAssignmentId: '2x5WEhFsDhmf8JohWQJFYfURTh9w', 57 | }; 58 | const option = { 59 | url: `https://api.m.jd.com/client.action?functionId=babelGetLottery&body=${encodeURIComponent( 60 | JSON.stringify(body) 61 | )}&client=wh5`, 62 | headers: { 63 | Cookie: cookie, 64 | Accept: '*/*', 65 | Connection: 'keep-alive', 66 | 'Accept-Encoding': 'gzip, deflate, br', 67 | 'Accept-Language': 'zh-cn', 68 | Referer: 69 | 'https://pro.m.jd.com/mall/active/2xoBJwC5D1Q3okksMUFHcJQhFq8j/index.html?tttparams=fC86MMeyJncHNfYXJlYSI6IjJfMjgzMF81MTgxMV8wIiwicHJzdGF0ZSI6IjAiLCJ1bl9hcmVhIjoiMl8yODMwXzUxODExXzAiLCJkTGF0IjoiIiwiZ0xhdCI6IjMxLjEyMzI2NCIsImdMbmciOiIxMjEuNTA5MjQ3IiwibG5nIjoiMTIxLjUxMDMyMyIsImxhdCI6IjMxLjEyMzA0OCIsImRMbmciOiIiLCJtb2RlbCI6ImlQaG9uZTEyLDEifQ6%3D%3D', 70 | Origin: 'https://pro.m.jd.com', 71 | Host: 'api.m.jd.com', 72 | 'User-Agent': 73 | 'jdapp;iPhone;10.5.2;;;M/5.0;JDEbook/openapp.jdreader;appBuild/168069;jdSupportDarkMode/0;ef/1;ep/%7B%22ciphertype%22%3A5%2C%22cipher%22%3A%7B%22ud%22%3A%22CQZwZtO3CzGzYtC0DtG1YJG1DJGmY2HuYWHsDzdrENVwDJGyZNvwEK%3D%3D%22%2C%22sv%22%3A%22CJGkDq%3D%3D%22%2C%22iad%22%3A%22%22%7D%2C%22ts%22%3A1651124892%2C%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22version%22%3A%221.0.3%22%2C%22appname%22%3A%22com.360buy.jdmobile%22%2C%22ridx%22%3A-1%7D;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;', 74 | 'Content-Type': 'application/x-www-form-urlencoded', 75 | }, 76 | }; 77 | 78 | return new Promise((resolve, reject) => { 79 | $.post(option, (err, resp, data) => { 80 | try { 81 | const _data = JSON.parse(data); 82 | if (resp.statusCode === 200 && _data) { 83 | if (_data.winner && _data.winner === 'true') { 84 | const bean = _data.prizeName.match(/([0-9]+)京豆/)[1]; 85 | _beans += Number(bean); 86 | _log.push(`🟢${eventName}: 获得${bean}个京豆`); 87 | } else if (_data.winner && _data.winner === 'false') { 88 | _log.push(`🟢${eventName}: 与大奖擦肩而过哦~`); 89 | } 90 | } else { 91 | throw err || data; 92 | } 93 | } catch (error) { 94 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 95 | _desc.push(`🔴${eventName}`); 96 | } finally { 97 | resolve(); 98 | } 99 | }); 100 | }); 101 | } 102 | 103 | async function main(cookieObj) { 104 | // 先检查是否有机会,避免非必要请求 105 | const chances = await getChances(cookieObj.cookie); 106 | if (chances && chances > 0) { 107 | // 每天应该就一次机会 108 | await getLottery(cookieObj.cookie); 109 | const [nickname, totalBeans] = await getUserInfo(cookieObj.cookie); 110 | $.subt = `${nickname}, 京豆: ${totalBeans}(+${_beans})`; 111 | } else if (chances === 0) { 112 | $.subt = `${cookieObj.nickname}, 没有抽奖机会 ~`; 113 | } 114 | } 115 | 116 | !(async () => { 117 | let cookieObjs = $.getdata('GLOBAL_JD_COOKIES'); 118 | const specifyUserId = $.getdata('GLOBAL_SPECIFY_USER_ID'); 119 | 120 | if (cookieObjs && JSON.parse(cookieObjs).length > 0) { 121 | cookieObjs = JSON.parse(cookieObjs); 122 | if (specifyUserId && specifyUserId.indexOf('jd_') !== -1) { 123 | // 实现一次执行一个账号 124 | cookieObjs = cookieObjs.filter((cookie) => cookie.userId === specifyUserId); 125 | } 126 | let i = 1; 127 | for (const cookieObj of cookieObjs) { 128 | try { 129 | _beans = 0; 130 | _log = [`\n++++++++++${cookieObj.nickname}++++++++++\n`]; 131 | _desc = []; 132 | await main(cookieObj); 133 | } catch (error) { 134 | _log.push(`🔴 ${error}`); 135 | _desc.push(`🔴 ${error}`); 136 | $.subt = `${cookieObj.nickname}`; 137 | } finally { 138 | $.log(..._log); 139 | $.desc = _desc.join(''); 140 | $.msg($.name, $.subt || '', $.desc); 141 | } 142 | 143 | // 切换账号等待至少5秒 144 | if (i < cookieObjs.length) { 145 | await randomWait(5000); 146 | } 147 | i++; 148 | } 149 | } else { 150 | throw '请先获取会话'; 151 | } 152 | })() 153 | .catch((e) => { 154 | $.subt = '脚本执行异常'; 155 | $.msg($.name, $.subt, `🔴 ${String(e)}`); 156 | $.logErr(e); 157 | }) 158 | .finally(() => { 159 | $.done(); 160 | }); 161 | 162 | // prettier-ignore 163 | function randomWait(min) { randomTime = ((Math.random() / 5) * 10000 + (min || 1000)).toFixed(0); _log.push(`⏳休息${randomTime}ms`); return new Promise((resolve) => setTimeout(resolve, randomTime)) } 164 | // prettier-ignore 165 | function getUserInfo(cookie){const eventName='【用户信息】';const option={url:'https://wq.jd.com/user/info/QueryJDUserInfo?g_login_type=1&sceneval=2',headers:{Accept:'*/*','Accept-Encoding':'gzip, deflate, br','Accept-Language':'zh-cn',Host:'wq.jd.com',Cookie:cookie,Connection:'keep-alive',Referer:'https://wqs.jd.com/','User-Agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1',},};return new Promise((resolve,reject)=>{$.get(option,(err,resp,data)=>{try{if(resp.statusCode===200&&JSON.parse(data).retcode===0&&JSON.parse(data).base){const nickname=JSON.parse(data).base.nickname;const totalBeans=JSON.parse(data).base.jdNum;_log.push(`🟢${eventName}:${nickname}当前有${totalBeans}个京豆`);resolve([nickname,totalBeans])}else{throw err||data;}}catch(error){error!==data?_log.push(`🔴${eventName}:${error}\n${data}`):_log.push(`🔴${eventName}:${error}`);_desc.push(`🔴${eventName}`);resolve([])}})})} 166 | // prettier-ignore 167 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 168 | -------------------------------------------------------------------------------- /script/jd/jd.plantBean.help.task.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @description 本脚本是对faker2仓库jd_plantBean.js脚本的修改 3 | * @description 支持多账号,种豆得豆内部互助(默认帮助author, 通过BoxJS设置变量zss_jd_help_author关闭), 支持获取/更新互助码(需手动运行一次获取互助码) 4 | */ 5 | const $ = Env('京东种豆得豆互助'); 6 | 7 | let _log, _errEvents, _desc; 8 | let jdPlantBeanShareArr = []; 9 | let successHelp = 0; 10 | 11 | async function plantBeanIndex(cookie) { 12 | const eventName = '【种豆得豆首页】'; 13 | return await request(eventName, cookie, 'plantBeanIndex', {}, 'post'); 14 | // let retryTimes = 3; 15 | 16 | // for (let i = 0; i < retryTimes; i++) { 17 | // await randomWait(i * 10 * 1000); 18 | // const indexInfo = await request(eventName, cookie, 'plantBeanIndex', {}, 'post'); 19 | // if (indexInfo) { 20 | // return indexInfo; 21 | // } else { 22 | // _log.push(`🔴${eventName}: 第${i + 1}次获取首页信息失败\n ${JSON.stringify(indexInfo, null, 2)}`); 23 | // } 24 | // } 25 | // _errEvents.push(`🔴${eventName}`); 26 | } 27 | 28 | async function doHelp(cookie) { 29 | const eventName = '【助力好友】'; 30 | let runTimes = 0; 31 | 32 | for (let plantUuid of jdPlantBeanShareArr) { 33 | if (!plantUuid) continue; 34 | runTimes++; 35 | let helpRes = await helpShare(cookie, plantUuid); 36 | if (helpRes) { 37 | if (helpRes.data.helpShareRes) { 38 | if (helpRes.data.helpShareRes.state === '1') { 39 | _log.push(`🟢${eventName}: 助力好友${plantUuid}成功, ${helpRes.data.helpShareRes.promptText}`); 40 | successHelp++; 41 | } else if (helpRes.data.helpShareRes.state === '2') { 42 | _log.push(`🟡${eventName}: 您今日助力的机会已耗尽,已不能再帮助好友助力了`); 43 | break; 44 | } else if (helpRes.data.helpShareRes.state === '3') { 45 | _log.push(`🟡${eventName}: 该好友今日已满9人助力/20瓶营养液,明天再来为Ta助力吧`); 46 | } else if (helpRes.data.helpShareRes.state === '4') { 47 | _log.push(`🟡${eventName}: ${helpRes.data.helpShareRes.promptText}`); 48 | } else { 49 | _log.push(`🔴${eventName}: 未知数据, 助力好友${plantUuid}失败, ${JSON.stringify(helpRes, null, 2)}`); 50 | _errEvents.push(`🔴${eventName}`); 51 | } 52 | } 53 | } 54 | if (/(^[1-9]\d*$)/.test(runTimes / 5)) { 55 | _log.push(`🟡${eventName}: 访问接口次数达到5次,休息半分钟`); 56 | await randomWait(30 * 1000); 57 | runTimes = 0; 58 | } else { 59 | if (runTimes !== jdPlantBeanShareArr.length) { 60 | await randomWait(3000); 61 | } 62 | } 63 | } 64 | } 65 | 66 | async function helpShare(cookie, plantUuid) { 67 | const eventName = `【助力好友】`; 68 | const body = { 69 | plantUuid: plantUuid, 70 | wxHeadImgUrl: '', 71 | shareUuid: '', 72 | followType: '1', 73 | }; 74 | return await request(eventName, cookie, `plantBeanIndex`, body, 'post'); 75 | } 76 | 77 | function getParam(url, name) { 78 | const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); 79 | const r = url.match(reg); 80 | if (r != null) return unescape(r[2]); 81 | return null; 82 | } 83 | 84 | function myShareCode(shareUrl, cookieObj) { 85 | const eventName = '【我的互助码】'; 86 | let myPlantUuid = getParam(shareUrl, 'plantUuid'); 87 | 88 | if (myPlantUuid.length === 0) { 89 | _log.push(`🟡${eventName}: 暂无互助码`); 90 | return; 91 | } 92 | 93 | if (!cookieObj.shareCode) { 94 | cookieObj['shareCode'] = { plantBean: myPlantUuid }; 95 | _log.push(`🟢${eventName}: 获取到互助码: ${myPlantUuid}`); 96 | $.setdata(JSON.stringify(cookieObjs), 'GLOBAL_JD_COOKIES'); 97 | } else { 98 | if (!cookieObj.shareCode.plantBean) { 99 | cookieObj.shareCode['plantBean'] = myPlantUuid; 100 | _log.push(`🟢${eventName}: 获取到互助码: ${myPlantUuid}`); 101 | $.setdata(JSON.stringify(cookieObjs), 'GLOBAL_JD_COOKIES'); 102 | } else if (cookieObj.shareCode.plantBean && cookieObj.shareCode.plantBean !== myPlantUuid) { 103 | cookieObj.shareCode['plantBean'] = myPlantUuid; 104 | _log.push(`🟢${eventName}: 更新互助码: ${myPlantUuid}`); 105 | $.setdata(JSON.stringify(cookieObjs), 'GLOBAL_JD_COOKIES'); 106 | } else { 107 | _log.push(`🟢${eventName}: 互助码已存在`); 108 | } 109 | } 110 | return myPlantUuid; 111 | } 112 | 113 | async function main(cookieObj) { 114 | _nutrients = successHelp = 0; 115 | _log = [`\n++++++++++⭐${cookieObj.nickname}⭐++++++++++\n`]; 116 | _errEvents = ['\n++++++++++🔻事件提醒🔻++++++++++\n']; 117 | _desc = []; 118 | 119 | let indexInfo = await plantBeanIndex(cookieObj.cookie); 120 | if (indexInfo) { 121 | const shareUrl = indexInfo.data.jwordShareInfo.shareUrl; 122 | let myPlantUuid = myShareCode(shareUrl, cookieObj); 123 | 124 | if ( 125 | $.getdata('zss_jd_help_author') === 'true' && 126 | myPlantUuid != 'e7lhibzb3zek3wcj57kt7pjocmlfjvrhpn266uq' && 127 | jdPlantBeanShareArr.indexOf('e7lhibzb3zek3wcj57kt7pjocmlfjvrhpn266uq') === -1 128 | ) { 129 | jdPlantBeanShareArr.push('e7lhibzb3zek3wcj57kt7pjocmlfjvrhpn266uq'); 130 | } 131 | _log.push(`🟢【获取互助码】: 获取到${jdPlantBeanShareArr.length}个好友的互助码`); 132 | 133 | if (jdPlantBeanShareArr.length > 0) { 134 | await randomWait(); 135 | await doHelp(cookieObj.cookie); 136 | _desc.push(`助力${successHelp}个好友, 查看日志了解详情>>`); 137 | } else { 138 | _desc.push(`暂无需要助力的好友 ~`); 139 | } 140 | } 141 | } 142 | 143 | function getShareCodes(cookieObjs, currentUserId) { 144 | const eventName = '【获取互助码】'; 145 | jdPlantBeanShareArr = []; 146 | cookieObjs.forEach((item) => { 147 | if (item.userId !== currentUserId && item.shareCode && item.shareCode.plantBean) { 148 | jdPlantBeanShareArr.push(item.shareCode.plantBean); 149 | } 150 | }); 151 | } 152 | 153 | let cookieObjs = $.getdata('GLOBAL_JD_COOKIES'); 154 | 155 | !(async () => { 156 | const specifyUserId = $.getdata('GLOBAL_SPECIFY_USER_ID'); 157 | 158 | if (cookieObjs && JSON.parse(cookieObjs).length > 0) { 159 | cookieObjs = JSON.parse(cookieObjs); 160 | let specifyCookieObjs; 161 | if (specifyUserId && specifyUserId.indexOf('jd_') !== -1) { 162 | // 实现一次执行一个账号 163 | specifyCookieObjs = cookieObjs.filter((cookie) => cookie.userId === specifyUserId); 164 | } 165 | let i = 1; 166 | for (let cookieObj of specifyCookieObjs || cookieObjs) { 167 | try { 168 | $.subt = `${cookieObj.nickname}`; 169 | getShareCodes(cookieObjs, cookieObj.userId); 170 | await main(cookieObj); 171 | } catch (error) { 172 | _log.push(`🔴 ${error}`); 173 | _desc.push(`🔴 ${error}`); 174 | } finally { 175 | $.log(..._log); 176 | $.log(..._errEvents); 177 | $.desc = _desc.join('\n'); 178 | $.msg($.name, $.subt || '', $.desc); 179 | } 180 | 181 | // 切换账号等待至少5秒 182 | if (i < (specifyCookieObjs ? specifyCookieObjs.length : cookieObjs.length)) { 183 | await randomWait(5000); 184 | } 185 | i++; 186 | } 187 | } else { 188 | throw '请先获取会话'; 189 | } 190 | })() 191 | .catch((e) => { 192 | $.subt = '脚本执行异常'; 193 | $.msg($.name, $.subt, `🔴 ${String(e)}`); 194 | $.logErr(e); 195 | }) 196 | .finally(() => { 197 | $.done(); 198 | }); 199 | 200 | function request(eventName, cookie, function_id, body = {}, method = 'get') { 201 | let _body = { 202 | version: '9.2.4.1', 203 | monitor_source: 'plant_m_plant_index', 204 | monitor_refer: '', 205 | }; 206 | let option = { 207 | headers: { 208 | Cookie: cookie, 209 | Host: 'api.m.jd.com', 210 | Accept: '*/*', 211 | Connection: 'keep-alive', 212 | 'User-Agent': userAgent('jd'), 213 | 'Accept-Language': 'zh-cn', 214 | 'Accept-Encoding': 'gzip, deflate, br', 215 | Referer: 216 | 'https://plantearth.m.jd.com/plantBean/index?source=wojinghd&sid=06eb567bdb0c9abecb298ab48172115w&un_area=2_2830_51811_0', 217 | 'request-from': 'native', 218 | }, 219 | timeout: 10000, 220 | }; 221 | if (method === 'post') { 222 | option.url = 'https://api.m.jd.com/client.action'; 223 | option.body = `functionId=${function_id}&body=${encodeURIComponent( 224 | JSON.stringify(Object.assign(_body, body)) 225 | )}&appid=ld&client=apple&clientVersion=10.5.2&networkType=wifi&osVersion=14.6`; 226 | } else { 227 | option.url = `https://api.m.jd.com/client.action?functionId=${function_id}&body=${encodeURIComponent( 228 | JSON.stringify(Object.assign(_body, body)) 229 | )}&appid=ld&client=apple&clientVersion=10.5.2&networkType=wifi&osVersion=14.6`; 230 | } 231 | return new Promise((resolve, reject) => { 232 | if (method === 'post') { 233 | $.post(option, (err, resp, data) => { 234 | try { 235 | if (resp.statusCode === 200 && JSON.parse(data) && JSON.parse(data).code === '0') { 236 | _log.push(`🟢${eventName}: 请求成功`); 237 | resolve(JSON.parse(data)); 238 | } else { 239 | throw err || data; 240 | } 241 | } catch (error) { 242 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 243 | _errEvents.push(`🔴${eventName}`); 244 | resolve(); 245 | } 246 | }); 247 | } else { 248 | $.get(option, (err, resp, data) => { 249 | try { 250 | if (resp.statusCode === 200 && JSON.parse(data) && JSON.parse(data).code === '0') { 251 | _log.push(`🟢${eventName}: 请求成功`); 252 | resolve(JSON.parse(data)); 253 | } else { 254 | throw err || data; 255 | } 256 | } catch (error) { 257 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 258 | _errEvents.push(`🔴${eventName}`); 259 | resolve(); 260 | } 261 | }); 262 | } 263 | }); 264 | } 265 | 266 | function userAgent(app) { 267 | // 获取不同app的user-agent 268 | return { 269 | jd: 'jdapp;iPhone;10.5.2;;;M/5.0;JDEbook/openapp.jdreader;appBuild/168069;jdSupportDarkMode/0;ef/1;ep/%7B%22ciphertype%22%3A5%2C%22cipher%22%3A%7B%22ud%22%3A%22CQZwZtO3CzGzYtC0DtG1YJG1DJGmY2HuYWHsDzdrENVwDJGyZNvwEK%3D%3D%22%2C%22sv%22%3A%22CJGkDq%3D%3D%22%2C%22iad%22%3A%22%22%7D%2C%22ts%22%3A1651124892%2C%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22version%22%3A%221.0.3%22%2C%22appname%22%3A%22com.360buy.jdmobile%22%2C%22ridx%22%3A-1%7D;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;', 270 | jx: 'jdpingou;iPhone;5.25.0;appBuild/100934;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/4;pap/JA2019_3111789;supportJDSHWK/1;ef/1;ep/%7B%22ciphertype%22:5,%22cipher%22:%7B%22ud%22:%22ENO0ZNunDtc0CwPtCtHwZQPtDtU2DWUnYtO0Dzu5DwDsZWGyYzTsZq==%22,%22bd%22:%22YXLmbQU=%22,%22iad%22:%22%22,%22sv%22:%22CJGkDq==%22%7D,%22ts%22:1651399595,%22hdid%22:%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=%22,%22version%22:%221.0.3%22,%22appname%22:%22com.360buy.jdpingou%22,%22ridx%22:-1%7D;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148', 271 | safari: 272 | 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1', 273 | }[app]; 274 | } 275 | 276 | // prettier-ignore 277 | function ts(){return new Date().getTime()} 278 | // prettier-ignore 279 | function randomWait(min) { randomTime = ((Math.random() / 5) * 10000 + (min || 1000)).toFixed(0); _log.push(`⏳休息${randomTime}ms`); return new Promise((resolve) => setTimeout(resolve, randomTime)) } 280 | // prettier-ignore 281 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 282 | -------------------------------------------------------------------------------- /script/jd/jd.sharkBean.task.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @ZhouStarStar9527 3 | * @name 京东新版摇京豆 2021/03/02~2023/12/31 4 | * @description 支持多账号, 执行一个账号大约需要30s~60s(🚨这是包括做任务的时间,感觉只有优惠价,默认注释掉了,需要的在 main 函数打开 doneTasks 的注释) 5 | * @description 入口:京东首页→领京豆→点击页面中的【摇京豆】”,进入摇京豆游戏页面参与活动。 6 | */ 7 | 8 | const $ = Env('京东新版摇京豆'); 9 | let _log, _beans, _desc, indexPageInfoList; 10 | 11 | function getOption(cookie, appid, functionId, body) { 12 | let option = { 13 | url: `https://api.m.jd.com/?t=${ts()}&appid=${appid}&functionId=${functionId}&body=${encodeURIComponent( 14 | JSON.stringify(body) 15 | )}`, 16 | headers: { 17 | Accept: 'application/json', 18 | 'Accept-Encoding': 'gzip, deflate, br', 19 | 'Accept-Language': 'zh-cn', 20 | Connection: 'keep-alive', 21 | Host: 'api.m.jd.com', 22 | Cookie: cookie, 23 | Origin: 'https://spa.jd.com', 24 | Referer: 'https://spa.jd.com/home', 25 | 'User-Agent': 26 | 'jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', 27 | }, 28 | }; 29 | return option; 30 | } 31 | 32 | function indexPage(cookie) { 33 | const eventName = '【获取摇京豆首页】'; 34 | const body = { paramData: { token: 'dd2fb032-9fa3-493b-8cd0-0d57cd51812d' } }; 35 | option = getOption(cookie, 'sharkBean', 'pg_channel_page_data', body); 36 | 37 | return new Promise((resolve, reject) => { 38 | $.get(option, (err, resp, data) => { 39 | try { 40 | const _data = JSON.parse(data).data; 41 | if (resp.statusCode === 200 && _data) { 42 | indexPageInfoList = _data.floorInfoList; 43 | _log.push(`🟢${eventName}`); 44 | } else { 45 | throw err || data; 46 | } 47 | } catch (error) { 48 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 49 | _desc.push(`🔴${eventName}`); 50 | } finally { 51 | resolve(); 52 | } 53 | }); 54 | }); 55 | } 56 | 57 | async function checkIn(cookie) { 58 | const eventName = '【签到】'; 59 | try { 60 | if (!indexPageInfoList) { 61 | throw '未获取到首页信息'; 62 | } 63 | const signInfo = indexPageInfoList.filter((item) => !!item && item.code === 'SIGN_ACT_INFO')[0]; 64 | const singToken = signInfo.token; 65 | // 当前签到次数 66 | const currSignCursor = signInfo.floorData.signActInfo.currSignCursor; 67 | // 签到累积奖励信息 68 | const cursorBeanNum = signInfo.floorData.signActInfo.cursorBeanNum; 69 | const signStatus = signInfo.floorData.signActInfo.signActCycles.filter( 70 | (item) => !!item && item.signCursor === currSignCursor 71 | )[0].signStatus; 72 | 73 | if (signStatus === -1) { 74 | // 未签到 75 | await _checkIn(cookie, singToken, currSignCursor, cursorBeanNum); 76 | } else { 77 | _log.push(`🟡${eventName}: 本轮第${currSignCursor}次签到已完成`); 78 | } 79 | } catch (error) { 80 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 81 | _desc.push(`🔴${eventName}`); 82 | } 83 | } 84 | 85 | function _checkIn(cookie, singToken, currSignCursor, cursorBeanNum) { 86 | const eventName = '【签到】'; 87 | const body = { floorToken: singToken, dataSourceCode: 'signIn', argMap: { currSignCursor: currSignCursor } }; 88 | const option = getOption(cookie, 'sharkBean', 'pg_interact_interface_invoke', body); 89 | 90 | return new Promise((resolve, reject) => { 91 | $.post(option, (err, resp, data) => { 92 | try { 93 | const _data = JSON.parse(data).data; 94 | if (resp.statusCode === 200 && _data) { 95 | const bean = 96 | _data.rewardVos[0].jingBeanVo.beanNum + 97 | (cursorBeanNum && cursorBeanNum[currSignCursor] ? Number(cursorBeanNum[currSignCursor]) : 0); 98 | _beans += bean; 99 | _log.push(`🟢${eventName}: 本轮第${currSignCursor}次签到成功, 获得${bean}个京豆`); 100 | _desc.push(`🟢${eventName}`); 101 | } else { 102 | throw err || data; 103 | } 104 | } catch (error) { 105 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 106 | _desc.push(`🔴${eventName}`); 107 | } finally { 108 | resolve(); 109 | } 110 | }); 111 | }); 112 | } 113 | 114 | async function doneTasks(cookie) { 115 | const eventName = '【浏览活动】'; 116 | let s = 0; 117 | let i = 1; 118 | const tasks = await getTasks(cookie); 119 | if (tasks.length > 0) { 120 | for (const task of tasks) { 121 | const res = await browse(cookie, task.id, task.title); 122 | if (res) { 123 | s++; 124 | } 125 | if (i !== tasks.length) { 126 | await randomWait(500); 127 | } 128 | i++; 129 | } 130 | _desc.push(`🟢${eventName} ${s}/${tasks.length}`); 131 | } 132 | } 133 | 134 | function getTasks(cookie) { 135 | const eventName = '【任务列表】'; 136 | const option = getOption(cookie, 'vip_h5', 'vvipclub_lotteryTask', { info: 'browseTask', withItem: true }); 137 | 138 | return new Promise((resolve, reject) => { 139 | $.get(option, (err, resp, data) => { 140 | try { 141 | if (resp.statusCode === 200 && JSON.parse(data).success) { 142 | const tasks = JSON.parse(data).data[0].taskItems.filter((task) => task.finish !== true); 143 | if (tasks.length > 0) { 144 | _log.push(`🟢${eventName}: 当前共有${tasks.length}个任务未完成`); 145 | } else { 146 | _log.push(`🟡${eventName}: 所有任务已完成`); 147 | } 148 | resolve(tasks); 149 | } else { 150 | throw err || data; 151 | } 152 | } catch (error) { 153 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 154 | _desc.push(`🔴${eventName}`); 155 | resolve([]); 156 | } 157 | }); 158 | }); 159 | } 160 | 161 | function browse(cookie, taskId, taskName) { 162 | let eventName = `【浏览-${taskName}】`; 163 | let body = { taskName: 'browseTask', taskItemId: taskId }; 164 | const option = getOption(cookie, 'vip_h5', 'vvipclub_doTask', body); 165 | 166 | return new Promise((resolve, reject) => { 167 | $.get(option, (err, resp, data) => { 168 | try { 169 | if (resp.statusCode === 200 && JSON.parse(data).success && JSON.parse(data).data.isFinish) { 170 | _log.push(`🟢${eventName}: 浏览完成`); 171 | resolve(true); 172 | } else { 173 | throw err || data; 174 | } 175 | } catch (error) { 176 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 177 | _desc.push(`🔴${eventName}`); 178 | resolve(false); 179 | } 180 | }); 181 | }); 182 | } 183 | 184 | async function shake(cookie) { 185 | const eventName = '【摇奖】'; 186 | try { 187 | if (!indexPageInfoList) { 188 | throw '未获取到首页信息'; 189 | } 190 | const shakingInfo = indexPageInfoList.filter((item) => !!item && item.code === 'SHAKING_BOX_INFO')[0]; 191 | // 获取摇奖次数 192 | let remainLotteryTimes = shakingInfo.floorData.shakingBoxInfo.remainLotteryTimes; 193 | 194 | if (remainLotteryTimes === 0) { 195 | _log.push(`🟡${eventName}: 摇奖次数已用完`); 196 | return; 197 | } 198 | 199 | let s = 0; 200 | for (let index = 0; index < remainLotteryTimes; index++) { 201 | const res = await _shake(cookie); 202 | if (res) { 203 | s++; 204 | } 205 | if (index < remainLotteryTimes) { 206 | await randomWait(500); 207 | } 208 | } 209 | let icon = s === remainLotteryTimes ? '🟢' : '🟡'; 210 | _desc.push(`${icon}${eventName} ${s}/${remainLotteryTimes}`); 211 | } catch (error) { 212 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 213 | _desc.push(`🔴${eventName}`); 214 | } 215 | } 216 | 217 | function _shake(cookie) { 218 | const eventName = '【摇奖】'; 219 | let option = getOption(cookie, 'sharkBean', 'vvipclub_shaking_lottery', {}); 220 | option.url += `&h5st=${geth5st()}`; 221 | 222 | return new Promise((resolve, reject) => { 223 | $.post(option, (err, resp, data) => { 224 | try { 225 | if (resp.statusCode === 200 && JSON.parse(data).success) { 226 | if (JSON.parse(data).data.lotteryType === 5) { 227 | _log.push(`🟢${eventName}: 收到一则广告`); 228 | } else if (JSON.parse(data).data.lotteryType === 2) { 229 | const couponInfo = JSON.parse(data).data.couponInfo; 230 | if (couponInfo.couponType === 1) { 231 | _log.push( 232 | `🟢${eventName}: 获得优惠券: 满${couponInfo.couponQuota}减${couponInfo.couponDiscount}, ${couponInfo.limitStr}, ${couponInfo.endTime}失效` 233 | ); 234 | } else { 235 | // 摇奖得京豆的概率很低,导致不知道怎么写 236 | _desc.push(`🔥${eventName} 解锁新奖励,查看日志并反馈给作者`); 237 | _log.push(`🟢${eventName}: ${data}`); 238 | } 239 | } else { 240 | // 摇奖得京豆的概率很低,导致不知道怎么写 241 | _log.push(`🟢${eventName}: ${data}`); 242 | } 243 | resolve(true); 244 | } else { 245 | throw err | data; 246 | } 247 | } catch (error) { 248 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 249 | resolve(false); 250 | } 251 | }); 252 | }); 253 | } 254 | 255 | async function main(cookieObj) { 256 | await indexPage(cookieObj.cookie); 257 | await checkIn(cookieObj.cookie); 258 | // await doneTasks(cookieObj.cookie); 259 | await randomWait(); 260 | await indexPage(cookieObj.cookie); 261 | await shake(cookieObj.cookie); 262 | if (_desc.length > 0) { 263 | const [nickname, totalBeans] = await getUserInfo(cookieObj.cookie); 264 | $.subt = `${nickname}, 京豆: ${totalBeans}(+${_beans})`; 265 | } else { 266 | $.subt = `${cookieObj.nickname}, Nothing to do ~`; 267 | } 268 | } 269 | 270 | !(async () => { 271 | let cookieObjs = $.getdata('GLOBAL_JD_COOKIES'); 272 | const specifyUserId = $.getdata('GLOBAL_SPECIFY_USER_ID'); 273 | 274 | if (cookieObjs && JSON.parse(cookieObjs).length > 0) { 275 | cookieObjs = JSON.parse(cookieObjs); 276 | if (specifyUserId && specifyUserId.indexOf('jd_') !== -1) { 277 | // 实现一次执行一个账号 278 | cookieObjs = cookieObjs.filter((cookie) => cookie.userId === specifyUserId); 279 | } 280 | let i = 1; 281 | for (const cookieObj of cookieObjs) { 282 | try { 283 | _beans = 0; 284 | _log = [`\n++++++++++${cookieObj.nickname}++++++++++\n`]; 285 | _desc = []; 286 | await main(cookieObj); 287 | } catch (error) { 288 | _log.push(`🔴 ${error}`); 289 | _desc.push(`🔴 ${error}`); 290 | $.subt = `${cookieObj.nickname}`; 291 | } finally { 292 | $.log(..._log); 293 | $.desc = _desc.join(''); 294 | $.msg($.name, $.subt || '', $.desc); 295 | } 296 | 297 | // 切换账号等待至少5秒 298 | if (i < cookieObjs.length) { 299 | await randomWait(5000); 300 | } 301 | i++; 302 | } 303 | } else { 304 | throw '请先获取会话'; 305 | } 306 | })() 307 | .catch((e) => { 308 | $.subt = '脚本执行异常'; 309 | $.msg($.name, $.subt, `🔴 ${String(e)}`); 310 | $.logErr(e); 311 | }) 312 | .finally(() => { 313 | $.done(); 314 | }); 315 | 316 | function ts() { 317 | // 获取时间戳 318 | return new Date().getTime(); 319 | } 320 | 321 | function geth5st() { 322 | const timestamp = ts(); 323 | return encodeURIComponent( 324 | [ 325 | $.time('yyyyMMddHHmmssS'), 326 | '7810563172488273', 327 | 'ae692', 328 | 'tk02wee691d8118nws6sRJuqo6QXnqpgjgHklwsMZEIqKjb1gKlkx/4JX5OP/0kwGEhmbdOiuOYY3YycmRIAjHvyjg5H', 329 | '830d177a7f231a848ee9a58f182b455c77e2a256785af07466b46b797eb34c5b', 330 | '3.0', 331 | String(timestamp), 332 | ].join(';') 333 | ); 334 | } 335 | 336 | // prettier-ignore 337 | function randomWait(min) { randomTime = ((Math.random() / 5) * 10000 + (min || 1000)).toFixed(0); _log.push(`⏳休息${randomTime}ms`); return new Promise((resolve) => setTimeout(resolve, randomTime)) } 338 | // prettier-ignore 339 | function getUserInfo(cookie){const eventName='【用户信息】';const option={url:'https://wq.jd.com/user/info/QueryJDUserInfo?g_login_type=1&sceneval=2',headers:{Accept:'*/*','Accept-Encoding':'gzip, deflate, br','Accept-Language':'zh-cn',Host:'wq.jd.com',Cookie:cookie,Connection:'keep-alive',Referer:'https://wqs.jd.com/','User-Agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1',},};return new Promise((resolve,reject)=>{$.get(option,(err,resp,data)=>{try{if(resp.statusCode===200&&JSON.parse(data).retcode===0&&JSON.parse(data).base){const nickname=JSON.parse(data).base.nickname;const totalBeans=JSON.parse(data).base.jdNum;_log.push(`🟢${eventName}:${nickname}当前有${totalBeans}个京豆`);resolve([nickname,totalBeans])}else{throw err||data;}}catch(error){error!==data?_log.push(`🔴${eventName}:${error}\n${data}`):_log.push(`🔴${eventName}:${error}`);_desc.push(`🔴${eventName}`);resolve([])}})})} 340 | // prettier-ignore 341 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 342 | -------------------------------------------------------------------------------- /script/jd/jd.sign.task.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @ZhouStarStar9527 3 | * @description 支持多账号 4 | * @description 入口:京东APP -> 首页 -> 领京豆 -> 签到 5 | */ 6 | const $ = Env('京东签到'); 7 | 8 | let _log, _beans, _desc; 9 | 10 | function jdSignInfo(cookie) { 11 | const eventName = '【京东签到信息】'; 12 | const option = getOption( 13 | 'https://api.m.jd.com/client.action?functionId=signBeanIndex&body=%7B%22monitor_refer%22%3A%22%22%2C%22rnVersion%22%3A%223.9%22%2C%22fp%22%3A%22-1%22%2C%22shshshfp%22%3A%22-1%22%2C%22shshshfpa%22%3A%22-1%22%2C%22referUrl%22%3A%22-1%22%2C%22userAgent%22%3A%22-1%22%2C%22jda%22%3A%22-1%22%2C%22monitor_source%22%3A%22bean_m_bean_index%22%7D&appid=ld&client=android&osVersion=14.6', 14 | { 15 | Cookie: cookie, 16 | Referer: 'https://bean.m.jd.com/', 17 | 'User-Agent': userAgent('safari'), 18 | } 19 | ); 20 | 21 | return new Promise((resolve, reject) => { 22 | $.get(option, (err, resp, data) => { 23 | try { 24 | if (resp.statusCode === 200 && JSON.parse(data).code === '0') { 25 | if (JSON.parse(data).data.status === '2') { 26 | _log.push(`🟢${eventName}: 今天已签到`); 27 | resolve(true); 28 | } else { 29 | resolve(false); 30 | } 31 | } else { 32 | throw err || data; 33 | } 34 | } catch (error) { 35 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 36 | _desc.push(`🔴${eventName}`); 37 | resolve(); 38 | } 39 | }); 40 | }); 41 | } 42 | 43 | function jdSignIn(cookie) { 44 | const eventName = '【京东签到】'; 45 | const option = getOption('https://api.m.jd.com/client.action?functionId=signBeanAct&appid=ld', { 46 | Cookie: cookie, 47 | Referer: 'https://wqs.jd.com/', 48 | }); 49 | 50 | return new Promise((resolve, reject) => { 51 | $.get(option, (err, resp, data) => { 52 | try { 53 | if (resp.statusCode === 200 && JSON.parse(data).data) { 54 | if (JSON.parse(data).data.status === '1') { 55 | const award = JSON.parse(data).data.dailyAward || JSON.parse(data).data.continuityAward; 56 | _beans += Number(award.beanAward.beanCount) || 0; 57 | _log.push(`🟢${eventName}: 获得${award.beanAward.beanCount}个京豆`); 58 | _desc.push(`🟢${eventName}`); 59 | } else if (JSON.parse(data).data.status === '2') { 60 | _log.push(`🟡${eventName}: 今天已签到`); 61 | } 62 | } else { 63 | throw err || data; 64 | } 65 | } catch (error) { 66 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 67 | _desc.push(`🔴${eventName}`); 68 | } finally { 69 | resolve(); 70 | } 71 | }); 72 | }); 73 | } 74 | 75 | async function main(cookie) { 76 | _beans = 0; 77 | _log = [`\n++++++++++${cookie.nickname}++++++++++\n`]; 78 | _desc = []; 79 | 80 | const isSignIn = await jdSignInfo(cookie.cookie); 81 | if (isSignIn === false) { 82 | await jdSignIn(cookie.cookie); 83 | const [nickname, totalBeans] = await getUserInfo(cookie.cookie); 84 | $.subt = `${nickname}, 京豆: ${totalBeans}(+${_beans})`; 85 | } else { 86 | $.subt = `${cookie.nickname}, 今日已签到 ~`; 87 | } 88 | } 89 | 90 | !(async () => { 91 | let cookieObjs = $.getdata('GLOBAL_JD_COOKIES'); 92 | const specifyUserId = $.getdata('GLOBAL_SPECIFY_USER_ID'); 93 | 94 | if (cookieObjs && JSON.parse(cookieObjs).length > 0) { 95 | cookieObjs = JSON.parse(cookieObjs); 96 | if (specifyUserId && specifyUserId.indexOf('jd_') !== -1) { 97 | // 实现一次执行一个账号 98 | cookieObjs = cookieObjs.filter((cookie) => cookie.userId === specifyUserId); 99 | } 100 | let i = 1; 101 | for (const cookieObj of cookieObjs) { 102 | try { 103 | await main(cookieObj); 104 | } catch (error) { 105 | _log.push(`🔴 ${error}`); 106 | _desc.push(`🔴 ${error}`); 107 | $.subt = `${cookieObj.nickname}`; 108 | } finally { 109 | $.log(..._log); 110 | $.desc = _desc.join(''); 111 | $.msg($.name, $.subt || '', $.desc); 112 | } 113 | 114 | // 切换账号等待至少5秒 115 | if (i < cookieObjs.length) { 116 | await randomWait(5000); 117 | } 118 | i++; 119 | } 120 | } else { 121 | throw '请先获取会话'; 122 | } 123 | })() 124 | .catch((e) => { 125 | $.subt = '脚本执行异常'; 126 | $.msg($.name, $.subt, `🔴 ${String(e)}`); 127 | $.logErr(e); 128 | }) 129 | .finally(() => { 130 | $.done(); 131 | }); 132 | 133 | function getOption(url, headers, body = '') { 134 | // 默认的option 135 | let _headers = { 136 | Accept: '*/*', 137 | 'Accept-Encoding': 'gzip, deflate, br', 138 | 'Accept-Language': 'zh-cn', 139 | Connection: 'keep-alive', 140 | Host: url.match(/\/\/([\w\.]*)/)[1], 141 | 'User-Agent': userAgent('jd'), 142 | }; 143 | 144 | return { 145 | url: url + (body ? `&body=${encodeURIComponent(JSON.stringify(body))}` : ''), 146 | headers: Object.assign({}, _headers, headers), 147 | }; 148 | } 149 | 150 | function userAgent(app) { 151 | // 获取不同app的user-agent 152 | return { 153 | jd: 'jdapp;iPhone;10.5.2;;;M/5.0;JDEbook/openapp.jdreader;appBuild/168069;jdSupportDarkMode/0;ef/1;ep/%7B%22ciphertype%22%3A5%2C%22cipher%22%3A%7B%22ud%22%3A%22CQZwZtO3CzGzYtC0DtG1YJG1DJGmY2HuYWHsDzdrENVwDJGyZNvwEK%3D%3D%22%2C%22sv%22%3A%22CJGkDq%3D%3D%22%2C%22iad%22%3A%22%22%7D%2C%22ts%22%3A1651124892%2C%22hdid%22%3A%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw%3D%22%2C%22version%22%3A%221.0.3%22%2C%22appname%22%3A%22com.360buy.jdmobile%22%2C%22ridx%22%3A-1%7D;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;', 154 | jx: 'jdpingou;iPhone;5.25.0;appBuild/100934;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/4;pap/JA2019_3111789;supportJDSHWK/1;ef/1;ep/%7B%22ciphertype%22:5,%22cipher%22:%7B%22ud%22:%22ENO0ZNunDtc0CwPtCtHwZQPtDtU2DWUnYtO0Dzu5DwDsZWGyYzTsZq==%22,%22bd%22:%22YXLmbQU=%22,%22iad%22:%22%22,%22sv%22:%22CJGkDq==%22%7D,%22ts%22:1651399595,%22hdid%22:%22JM9F1ywUPwflvMIpYPok0tt5k9kW4ArJEU3lfLhxBqw=%22,%22version%22:%221.0.3%22,%22appname%22:%22com.360buy.jdpingou%22,%22ridx%22:-1%7D;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148', 155 | safari: 156 | 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1', 157 | }[app]; 158 | } 159 | 160 | // prettier-ignore 161 | function ts(){return new Date().getTime()} 162 | // prettier-ignore 163 | function randomWait(min) { randomTime = ((Math.random() / 5) * 10000 + (min || 1000)).toFixed(0); _log.push(`⏳休息${randomTime}ms`); return new Promise((resolve) => setTimeout(resolve, randomTime)) } 164 | // prettier-ignore 165 | function getUserInfo(cookie){const eventName='【用户信息】';const option={url:'https://wq.jd.com/user/info/QueryJDUserInfo?g_login_type=1&sceneval=2',headers:{Accept:'*/*','Accept-Encoding':'gzip, deflate, br','Accept-Language':'zh-cn',Host:'wq.jd.com',Cookie:cookie,Connection:'keep-alive',Referer:'https://wqs.jd.com/','User-Agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1',},};return new Promise((resolve,reject)=>{$.get(option,(err,resp,data)=>{try{if(resp.statusCode===200&&JSON.parse(data).retcode===0&&JSON.parse(data).base){const nickname=JSON.parse(data).base.nickname;const totalBeans=JSON.parse(data).base.jdNum;_log.push(`🟢${eventName}:${nickname}当前有${totalBeans}个京豆`);resolve([nickname,totalBeans])}else{throw err||data;}}catch(error){error!==data?_log.push(`🔴${eventName}:${error}\n${data}`):_log.push(`🔴${eventName}:${error}`);_desc.push(`🔴${eventName}`);resolve([])}})})} 166 | // prettier-ignore 167 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 168 | -------------------------------------------------------------------------------- /script/jd/jd.task.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "京东脚本集合", 3 | "description": "Script Gallery (仅支持QuanX订阅, BoxJS订阅该脚本可管理环境变量)", 4 | "apps": [ 5 | { 6 | "id": "JDScriptEnvManager", 7 | "name": "JD Script Env Manager", 8 | "keys": [ 9 | "GLOBAL_JD_COOKIES" 10 | ], 11 | "descs_html": [ 12 | "

⚠️ 该订阅仅用于管理京东脚本环境变量 ⚠️

" 13 | ], 14 | "icons": [ 15 | "https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/icon/jd.png" 16 | ], 17 | "settings": [ 18 | { 19 | "id": "GLOBAL_SPECIFY_USER_ID", 20 | "name": "指定执行账户", 21 | "val": "", 22 | "type": "text", 23 | "placeholder": "默认不指定,为所有用户执行脚本", 24 | "desc": "指定执行用户,请填写以'jd_'开头的唯一用户名,脚本执行将作用于指定的的用户,一般为了测试使用,避免修改CK的麻烦 ~" 25 | }, 26 | { 27 | "id": "zss_jd_help_author", 28 | "name": "帮助作者", 29 | "val": true, 30 | "type": "boolean", 31 | "placeholder": "是否帮助作者", 32 | "desc": "在好友助力环节是否帮助作者, 例如种豆种得豆好友助力(默认开启)" 33 | } 34 | ] 35 | }, 36 | { 37 | "id": "JDJXCFD", 38 | "name": "京喜财富岛", 39 | "keys": [ 40 | "GLOBAL_JX_CFD_OPEN_PICKSHELL", 41 | "GLOBAL_JX_CFD_OPEN_BUILD", 42 | "GLOBAL_JX_CFD_OPEN_ZCF", 43 | "GLOBAL_JX_CFD_OPEN_ZJB_SIGN", 44 | "GLOBAL_JX_CFD_OPEN_ZJB_TASK", 45 | "GLOBAL_JX_CFD_OPEN_ZJB_ACHIEVE_REWARD" 46 | ], 47 | "descs_html": [ 48 | "

⚠️ 该订阅仅用于控制京喜财富岛相关变量 ⚠️

", 49 | "

⚠️ 若要启用“赚京币”相关脚本, 必须先获取phoneID, 如何获取请查看重写规则注释 ⚠️

" 50 | ], 51 | "icons": [ 52 | "https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/icon/jx.png" 53 | ], 54 | "settings": [ 55 | { 56 | "id": "GLOBAL_JX_CFD_OPEN_PICKSHELL", 57 | "name": "去海边捡贝壳", 58 | "val": true, 59 | "type": "boolean", 60 | "desc": "是否开启去海边捡贝壳(20个贝壳)脚本(默认开启,当成就任务“去海边捡贝壳”完成后重复执行不会捡贝壳)" 61 | }, 62 | { 63 | "id": "GLOBAL_JX_CFD_OPEN_BUILD", 64 | "name": "升级建筑", 65 | "val": false, 66 | "type": "boolean", 67 | "desc": "是否开启升级建筑脚本(默认关闭,每次执行会将4种建筑各升级一次,不开启但是启用“赚财富”会升级一次,仅能升级才会升级!!!)" 68 | }, 69 | { 70 | "id": "GLOBAL_JX_CFD_OPEN_ZCF", 71 | "name": "赚财富", 72 | "val": true, 73 | "type": "boolean", 74 | "desc": "是否开启赚财富脚本(默认开启)" 75 | }, 76 | { 77 | "id": "GLOBAL_JX_CFD_OPEN_ZJB_SIGN", 78 | "name": "连续营业赢红包", 79 | "val": true, 80 | "type": "boolean", 81 | "desc": "是否开启赚京币-连续营业赢红包(京喜App&微信小程序)脚本(默认开启,需要获取phoneID)" 82 | }, 83 | { 84 | "id": "GLOBAL_JX_CFD_OPEN_ZJB_TASK", 85 | "name": "营业赚京币", 86 | "val": true, 87 | "type": "boolean", 88 | "desc": "是否开启赚京币-营业赚京币脚本(默认开启,购物任务自动跳过)" 89 | }, 90 | { 91 | "id": "GLOBAL_JX_CFD_OPEN_ZJB_ACHIEVE_REWARD", 92 | "name": "成就赚财富(领)", 93 | "val": true, 94 | "type": "boolean", 95 | "desc": "是否开启赚京币-成就赚财富(领)脚本(默认开启)" 96 | } 97 | ] 98 | } 99 | ], 100 | "task": [ 101 | { 102 | "config": "11 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/jddj/jddj.js, tag=签到领鲜豆, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/icon/jddj.png, enabled=true", 103 | "addons": "https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jddj.checkin.conf,tag=京东到家CK" 104 | }, 105 | { 106 | "config": "1 0 * * * https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/jd.sign.task.js, tag=京东签到, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/icon/jd.png, enabled=true", 107 | "addons": "https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jd.cookies.conf,tag=京东CK" 108 | }, 109 | { 110 | "config": "3 0 * * * https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/jd.jr.doubleSign.task.js, tag=京融双签, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/icon/jdjr.png, enabled=true", 111 | "addons": "https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jdjr.sign.conf,tag=京东金融SignBody", 112 | "description": "添加重写规则addons中的重写规则,并手动签到一次" 113 | }, 114 | { 115 | "config": "5 0 * * * https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/jd.jx.doubleSign.task.js, tag=京喜双签, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/icon/jx.png, enabled=true", 116 | "addons": "https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jd.cookies.conf,tag=京东CK" 117 | }, 118 | { 119 | "config": "7 0 * * * https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/jd.lottery.task.js, tag=抽京豆, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/icon/choujd.png, enabled=true", 120 | "addons": "https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jd.cookies.conf,tag=京东CK" 121 | }, 122 | { 123 | "config": "30 7 * * * https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/jd.sharkBean.task.js, tag=摇京豆, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/icon/jdyjd.png, enabled=true", 124 | "addons": "https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jd.cookies.conf,tag=京东CK" 125 | }, 126 | { 127 | "config": "10 0 * * * https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/jd.jx.cfd.task.js, tag=京喜财富岛, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/icon/jx.png, enabled=true", 128 | "addons": "https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jdjx.cfd.sign.conf,tag=京喜PhoneId" 129 | },{ 130 | "config": "1 7-21/2 * * * https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/jd.plantBean.task.js, tag=京东种豆得豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdzd.png, enabled=true", 131 | "addons": "https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jd.cookies.conf,tag=京东CK" 132 | },{ 133 | "config": "50 7 * * * https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/jd.plantBean.help.task.js, tag=京东种豆得豆内部互助, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdzd.png, enabled=true", 134 | "addons": "https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jd.cookies.conf,tag=京东CK" 135 | } 136 | ] 137 | } 138 | -------------------------------------------------------------------------------- /script/jd/rewrite/jd.cookie.conf: -------------------------------------------------------------------------------- 1 | # 开关重写方法: QuanX -> 构造HTTP请求 -> 订阅仓库 -> 点击应用图标 -> 添加/移除/查看附件组件 2 | # 食用方法: 浏览器访问 `https://plogin.m.jd.com/login/login` 登录后,点击"我的",QX提示成功即可 3 | hostname = home.m.jd.com 4 | ^https:\/\/home\.m\.jd\.com\/myJd\/newhome\.action url script-request-header https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jd.cookie.js 5 | -------------------------------------------------------------------------------- /script/jd/rewrite/jd.cookie.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @description: 浏览器访问 `https://plogin.m.jd.com/login/login` 登录后,点击"我的",QX提示成功即可 3 | * 4 | */ 5 | const $ = Env('京东'); 6 | 7 | !(async () => { 8 | const JD_COOKIE = $request.headers['Cookie'] || $request.headers['cookie']; 9 | if ( 10 | JD_COOKIE && 11 | JD_COOKIE.toLocaleLowerCase().indexOf('pt_key') !== -1 && 12 | JD_COOKIE.toLocaleLowerCase().indexOf('pt_pin') !== -1 13 | ) { 14 | $.setdata(JD_COOKIE, 'GLOBAL_JD_COOKIE'); 15 | $.subt = '🟢 获取会话成功'; 16 | } else { 17 | throw '无法获取用户信息'; 18 | } 19 | })() 20 | .catch((e) => { 21 | $.subt = '🔴 获取会话失败'; 22 | $.log(`🔴 获取会话失败: ${e}`); 23 | }) 24 | .finally(() => { 25 | $.msg($.name, $.subt, ''); 26 | $.done(); 27 | }); 28 | 29 | // prettier-ignore 30 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 31 | -------------------------------------------------------------------------------- /script/jd/rewrite/jd.cookies.conf: -------------------------------------------------------------------------------- 1 | # 开关重写方法: QuanX -> 构造HTTP请求 -> 订阅仓库 -> 点击应用图标 -> 添加/移除/查看附件组件 2 | # 食用方法: 浏览器访问 `https://plogin.m.jd.com/login/login` 登录后,点击"我的",QX提示成功即可 3 | hostname = home.m.jd.com 4 | ^https:\/\/home\.m\.jd\.com\/myJd\/newhome\.action url script-request-header https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jd.cookies.js 5 | -------------------------------------------------------------------------------- /script/jd/rewrite/jd.cookies.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @description: 浏览器访问 `https://plogin.m.jd.com/login/login` 登录后,点击"我的",QX提示成功即可 3 | * @description: 支持多账号 4 | * @description: cookieObjs = [ {userId: 'xxx', nickname: 'yyy', cookie: 'zzz', ...}, ...] 5 | * @description: 对于已存在的cookieObj务必更新,不是删除新增,避免导致其他的key-value丢失(例如:京东金融的 signBody) 6 | */ 7 | const $ = Env('京东 CK'); 8 | 9 | let _log = []; 10 | let _desc = []; 11 | 12 | function getNickname(cookie) { 13 | const eventName = '【用户昵称】'; 14 | const option = { 15 | url: 'https://wq.jd.com/user/info/QueryJDUserInfo?g_login_type=1&sceneval=2', 16 | headers: { 17 | Accept: '*/*', 18 | 'Accept-Encoding': 'gzip, deflate, br', 19 | 'Accept-Language': 'zh-cn', 20 | Host: 'wq.jd.com', 21 | Cookie: cookie, 22 | Connection: 'keep-alive', 23 | Referer: 'https://wqs.jd.com/', 24 | 'User-Agent': 25 | 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1', 26 | }, 27 | }; 28 | return new Promise((resolve, reject) => { 29 | $.get(option, (err, resp, data) => { 30 | try { 31 | if (resp.statusCode === 200 && JSON.parse(data).retcode === 0 && JSON.parse(data).base) { 32 | const nickname = JSON.parse(data).base.nickname; 33 | resolve(nickname); 34 | } else { 35 | throw err || data; 36 | } 37 | } catch (error) { 38 | error !== data ? _log.push(`🔴${eventName}: ${error}\n${data}`) : _log.push(`🔴${eventName}: ${error}`); 39 | _desc.push(`🔴${eventName}`); 40 | resolve(); 41 | } 42 | }); 43 | }); 44 | } 45 | 46 | !(async () => { 47 | const cookie = $request.headers['Cookie'] || $request.headers['cookie']; 48 | if ( 49 | cookie && 50 | cookie.toLocaleLowerCase().indexOf('pt_key') !== -1 && 51 | cookie.toLocaleLowerCase().indexOf('pt_pin') !== -1 52 | ) { 53 | let currentUserId = cookie.match(/pt_pin=(\w+)/)[1]; 54 | let cookieObjs = []; 55 | let currentCookieObj; 56 | // 获取昵称好分辨 57 | const nickname = await getNickname(cookie); 58 | 59 | if ($.getdata('GLOBAL_JD_COOKIES') && JSON.parse($.getdata('GLOBAL_JD_COOKIES')).length > 0) { 60 | cookieObjs = JSON.parse($.getdata('GLOBAL_JD_COOKIES')); 61 | currentCookieObj = cookieObjs.filter((cookie) => cookie.userId === currentUserId)[0]; 62 | // 去除当前用户的旧cookie 63 | cookieObjs = cookieObjs.filter((cookie) => cookie.userId !== currentUserId); 64 | } 65 | 66 | if (currentCookieObj) { 67 | currentCookieObj.cookie = cookie; 68 | currentCookieObj.nickname = nickname; 69 | } else { 70 | currentCookieObj = { userId: currentUserId, nickname: nickname || currentUserId, cookie: cookie }; 71 | } 72 | 73 | cookieObjs.push(currentCookieObj); 74 | $.setdata(JSON.stringify(cookieObjs), 'GLOBAL_JD_COOKIES'); 75 | $.subt = `获取成功, 当前共有${cookieObjs.length}个用户`; 76 | 77 | for (const cookieObj of cookieObjs) { 78 | if (cookieObj.userId !== currentUserId) { 79 | _desc.push(`${cookieObj.nickname}`); 80 | } else { 81 | _desc.push(`${nickname} ◀`); 82 | } 83 | } 84 | $.desc = _desc.join('\n'); 85 | } else { 86 | throw '无法获取用户信息'; 87 | } 88 | })() 89 | .catch((e) => { 90 | $.subt = '获取失败'; 91 | $.desc = `🔴 ${String(e)}`; 92 | _log.push(`🔴 获取会话失败: ${e}`); 93 | }) 94 | .finally(() => { 95 | $.log(..._log); 96 | $.msg($.name, $.subt, $.desc); 97 | $.done(); 98 | }); 99 | 100 | // prettier-ignore 101 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 102 | -------------------------------------------------------------------------------- /script/jd/rewrite/jddj.checkin.conf: -------------------------------------------------------------------------------- 1 | hostname = daojia.jd.com 2 | ^https:\/\/daojia.jd.com/client(.*?)functionId=signin(.*?)userSigninNew url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/jddj/jddj.cookie.js 3 | -------------------------------------------------------------------------------- /script/jd/rewrite/jdjr.sign.conf: -------------------------------------------------------------------------------- 1 | # 开关重写方法: QuanX -> 构造HTTP请求 -> 订阅仓库 -> 点击应用图标 -> 添加/移除/查看附件组件 2 | # 食用方法: 京东APP首页 - 领京豆 -> 双签领豆 -> 去京东金融App签到 -> 等待跳转到签到页面后签到 3 | hostname = ms.jr.jd.com 4 | ^https:\/\/ms.jr.jd.com\/gw\/generic\/hy\/h5\/m\/jrSign url script-request-body https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jdjr.sign.js 5 | -------------------------------------------------------------------------------- /script/jd/rewrite/jdjr.sign.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @description: 京东APP首页 - 领京豆 -> 双签领豆 -> 去京东金融App签到 -> 等待跳转到签到页面后签到 3 | * @description: 支持多账号 4 | */ 5 | const $ = Env('京东金融 Sign Body'); 6 | 7 | let _log = []; 8 | let _desc = []; 9 | 10 | !(async () => { 11 | const cookie = $request.headers['Cookie'] || $request.headers['cookie']; 12 | const signBody = $request.body; 13 | if ( 14 | cookie && 15 | cookie.toLocaleLowerCase().indexOf('pt_key') !== -1 && 16 | cookie.toLocaleLowerCase().indexOf('pt_pin') !== -1 17 | ) { 18 | let currentUserId = cookie.match(/pt_pin=(\w+)/)[1]; 19 | let cookieObjs = []; 20 | let currentCookieObj; 21 | if ($.getdata('GLOBAL_JD_COOKIES') && JSON.parse($.getdata('GLOBAL_JD_COOKIES')).length > 0) { 22 | cookieObjs = JSON.parse($.getdata('GLOBAL_JD_COOKIES')); 23 | // 获取当前用户 24 | currentCookieObj = cookieObjs.filter((cookie) => cookie.userId === currentUserId)[0]; 25 | if (!currentCookieObj) { 26 | _desc.push('浏览器访问 https://plogin.m.jd.com/login/login 登录后,点击"我的"更新京东CK'); 27 | currentCookieObj = { userId: currentUserId, nickname: currentUserId, cookie: cookie, jrSignBody: signBody }; 28 | cookieObjs.push(currentCookieObj); 29 | } else { 30 | currentCookieObj['jrSignBody'] = signBody; 31 | } 32 | } else { 33 | _desc.push('浏览器访问 https://plogin.m.jd.com/login/login 登录后,点击"我的"更新京东CK'); 34 | currentCookieObj = { userId: currentUserId, nickname: currentUserId, cookie: cookie, jrSignBody: signBody }; 35 | cookieObjs.push(currentCookieObj); 36 | } 37 | $.setdata(JSON.stringify(cookieObjs), 'GLOBAL_JD_COOKIES'); 38 | $.subt = `获取成功, 当前用户: ${currentCookieObj.nickname}`; 39 | $.desc = _desc.join('\n'); 40 | } else { 41 | throw '无法获取用户信息'; 42 | } 43 | })() 44 | .catch((e) => { 45 | $.subt = '获取失败'; 46 | $.desc = `🔴 ${String(e)}`; 47 | _log.push(`🔴 获取失败: ${e}`); 48 | }) 49 | .finally(() => { 50 | $.log(..._log); 51 | $.msg($.name, $.subt, $.desc); 52 | $.done(); 53 | }); 54 | 55 | // prettier-ignore 56 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 57 | -------------------------------------------------------------------------------- /script/jd/rewrite/jdjx.cfd.sign.conf: -------------------------------------------------------------------------------- 1 | # 开关重写方法: QuanX -> 构造HTTP请求 -> 订阅仓库 -> 点击应用图标 -> 添加/移除/查看附件组件 2 | # 食用方法: 京喜APP首页 -> 财富小岛 -> QuanX提示成功即可 (🚨 高频触发,成功获取后立即移除附件组件) 3 | hostname = m.jingxi.com 4 | ^https:\/\/m.jingxi.com\/jxbfd\/user\/QueryUserInfo(.*) url script-request-header https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/jd/rewrite/jdjx.cfd.sign.js 5 | -------------------------------------------------------------------------------- /script/jd/rewrite/jdjx.cfd.sign.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @description: 京喜APP首页 -> 财富小岛 -> QuanX提示成功即可 (🚨 高频触发,成功获取后立即移除附件组件) 3 | * @description: 支持多账号 4 | */ 5 | const $ = Env('京喜 PhoneId'); 6 | 7 | let _log = []; 8 | let _desc = []; 9 | 10 | !(async () => { 11 | const cookie = $request.headers['Cookie'] || $request.headers['cookie']; 12 | const strPhoneID = $request.url.match(/strPhoneID=(\w+)/)[1]; 13 | const strPgUUNum = $request.url.match(/strPgUUNum=(\w+)/)[1]; 14 | const h5st = $request.url.match(/h5st=([\d|%|\w|.]*)/)[1]; 15 | if ( 16 | cookie && 17 | cookie.toLocaleLowerCase().indexOf('pt_key') !== -1 && 18 | cookie.toLocaleLowerCase().indexOf('pt_pin') !== -1 19 | ) { 20 | let currentUserId = cookie.match(/pt_pin=(\w+)/)[1]; 21 | let cookieObjs = []; 22 | let currentCookieObj; 23 | if ($.getdata('GLOBAL_JD_COOKIES') && JSON.parse($.getdata('GLOBAL_JD_COOKIES')).length > 0) { 24 | cookieObjs = JSON.parse($.getdata('GLOBAL_JD_COOKIES')); 25 | // 获取当前用户 26 | currentCookieObj = cookieObjs.filter((cookie) => cookie.userId === currentUserId)[0]; 27 | if (!currentCookieObj) { 28 | _desc.push('浏览器访问 https://plogin.m.jd.com/login/login 登录后,点击"我的"更新京东CK'); 29 | currentCookieObj = { 30 | userId: currentUserId, 31 | nickname: currentUserId, 32 | cookie: cookie, 33 | jx: { cfd: { strPhoneID: strPhoneID, strPgUUNum: strPgUUNum, h5st: h5st } }, 34 | }; 35 | cookieObjs.push(currentCookieObj); 36 | } else { 37 | currentCookieObj['jx'] = { cfd: { strPhoneID: strPhoneID, strPgUUNum: strPgUUNum, h5st: h5st } }; 38 | } 39 | } else { 40 | _desc.push('浏览器访问 https://plogin.m.jd.com/login/login 登录后,点击"我的"更新京东CK'); 41 | currentCookieObj = { 42 | userId: currentUserId, 43 | nickname: currentUserId, 44 | cookie: cookie, 45 | jx: { cfd: { strPhoneID: strPhoneID, strPgUUNum: strPgUUNum, h5st: h5st } }, 46 | }; 47 | cookieObjs.push(currentCookieObj); 48 | } 49 | $.setdata(JSON.stringify(cookieObjs), 'GLOBAL_JD_COOKIES'); 50 | $.subt = `获取成功, 当前用户: ${currentCookieObj.nickname}`; 51 | $.desc = _desc.join('\n'); 52 | } else { 53 | throw '无法获取用户信息'; 54 | } 55 | })() 56 | .catch((e) => { 57 | $.subt = '获取失败'; 58 | $.desc = `🔴 ${String(e)}`; 59 | _log.push(`🔴 获取失败: ${e}`); 60 | }) 61 | .finally(() => { 62 | $.log(..._log); 63 | $.msg($.name, $.subt, $.desc); 64 | $.done(); 65 | }); 66 | 67 | // prettier-ignore 68 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 69 | -------------------------------------------------------------------------------- /script/meituan/icon/mall.meituan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoJoJotarou/myScript/4a79b2488c892a0723e152aeb4931dff23d295bb/script/meituan/icon/mall.meituan.png -------------------------------------------------------------------------------- /script/meituan/icon/meituan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoJoJotarou/myScript/4a79b2488c892a0723e152aeb4931dff23d295bb/script/meituan/icon/meituan.png -------------------------------------------------------------------------------- /script/meituan/mall.meituan.cookie.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author: @JoJoJotarou 3 | * @description: 方式1:美团APP -> 美团买菜 -> 我的 -> 买菜币 -> 去使用 -> 在退回上一级,QX提示成功即可 4 | * @description: 方式2:美团APP -> 美团买菜 -> 我的 -> 买菜币 -> 左滑一半做推出手势再松手(不要真的左滑退出) -> QX提示成功即可 5 | * 6 | */ 7 | const $ = Env('美团买菜Token'); 8 | const generalQueryParams = ['tenantId', 'poiId', 'poi', 'bizId', 'utm_medium', 'utm_term', 'uuid', 'app_tag', 'userid']; 9 | 10 | !(async () => { 11 | const cookie = $request.headers['Cookie'] || $request.headers['cookie']; 12 | const queryStr = $request.url 13 | .match(/queryTaskListInfoV.\?(.*)/)[1] 14 | .split('&') 15 | .filter((param) => generalQueryParams.includes(param.split('=')[0])) 16 | .join('&'); 17 | const xuuid = 18 | $request.url 19 | .match(/queryTaskListInfoV.\?(.*)/)[1] 20 | .split('&') 21 | .filter((param) => 'xuuid' === param.split('=')[0])[0] || ''; 22 | 23 | if (cookie.toLocaleLowerCase().indexOf('token=') !== -1) { 24 | $.setdata( 25 | JSON.stringify({ 26 | queryStr: queryStr, 27 | xuuid: xuuid, 28 | headers: { 29 | 'X-Titans-User': $request.headers['X-Titans-User'] || $request.headers['x-titans-user'], 30 | T: $request.headers['T'] || $request.headers['t'], 31 | Cookie: cookie, 32 | 'User-Agent': $request.headers['User-Agent'] || $request.headers['user-agent'], 33 | }, 34 | }), 35 | 'jojo_mall_meituan' 36 | ); 37 | $.subt = '🟢 获取会话成功'; 38 | } else { 39 | throw '无法获取token信息'; 40 | } 41 | })() 42 | .catch((e) => { 43 | $.subt = '🔴 获取会话失败'; 44 | $.log(`🔴 获取会话失败: ${e}`); 45 | }) 46 | .finally(() => { 47 | $.msg($.name, $.subt, ''); 48 | $.done(); 49 | }); 50 | 51 | // prettier-ignore 52 | 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.encoding = "utf-8", 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 } isShadowrocket() { return "undefined" != typeof $rocket } isStash() { return "undefined" != typeof $environment && $environment["stash-version"] } 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("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (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 = (() => { })) { if (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) }); else if (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)); else if (this.isNode()) { let s = require("iconv-lite"); 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: i, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: i, statusCode: r, headers: o, rawBody: h }, s.decode(h, this.encoding)) }, t => { const { message: i, response: r } = t; e(i, r, r && s.decode(r.rawBody, this.encoding)) }) } } post(t, e = (() => { })) { const s = t.method ? t.method.toLocaleLowerCase() : "post"; 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[s](t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = s, 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()) { let i = require("iconv-lite"); this.initGotEnv(t); const { url: r, ...o } = t; this.got[s](r, o).then(t => { const { statusCode: s, statusCode: r, headers: o, rawBody: h } = t; e(null, { status: s, statusCode: r, headers: o, rawBody: h }, i.decode(h, this.encoding)) }, t => { const { message: s, response: r } = t; e(s, r, r && i.decode(r.rawBody, this.encoding)) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).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, i = t["update-pasteboard"] || t.updatePasteboard; return { "open-url": e, "media-url": s, "update-pasteboard": i } } 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) } 53 | -------------------------------------------------------------------------------- /script/meituan/meituan.task.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "美团脚本集合", 3 | "description": "Script Gallery", 4 | "task": [ 5 | { 6 | "config": "0 6,8 * * * https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/meituan/mall.meituan.mallcoin.task.js, img-url=https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/script/meituan/maicai.png, tag=买菜币, enabled=true", 7 | "addons":"https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/meituan/rewrite/mall.meituan.conf,tag=美团买菜CK" 8 | }, 9 | { 10 | "config": "10 0 * * * https://raw.githubusercontent.com/chavyleung/scripts/master/meituan/meituan.js, img-url=https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/meituan/icon/meituan.png, tag=签到领红包, enabled=true", 11 | "addons":"https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/meituan/rewrite/meituan.checkin.conf, tag=美团签到领红包CK" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /script/meituan/rewrite/mall.meituan.conf: -------------------------------------------------------------------------------- 1 | hostname = mall.meituan.com 2 | # 美团买菜 - 买菜币 3 | # 使用说明:方式1:美团APP -> 美团买菜 -> 我的 -> 买菜币 -> QX提示成功即可 (若此方式不行尝试下面2种方法) 4 | # 使用说明:方式2:美团APP -> 美团买菜 -> 我的 -> 买菜币 -> 去使用 -> 在退回上一级,QX提示成功即可 5 | # 使用说明:方式3:美团APP -> 美团买菜 -> 我的 -> 买菜币 -> 左滑一半做退出手势再松手(不要真的退出了)-> QX提示成功即可 6 | ^https?:\/\/mall\.meituan\.com\/api\/c\/mallcoin\/checkIn\/queryTaskListInfoV.\? url script-request-header https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/meituan/mall.meituan.cookie.js 7 | -------------------------------------------------------------------------------- /script/meituan/rewrite/meituan.checkin.conf: -------------------------------------------------------------------------------- 1 | hostname = i.meituan.com 2 | 3 | # 美团签到领红包 4 | # 使用方法1:美团APP -> 我的 -> 福利中心 -> 领红包 -> 手动签到一次 5 | # 使用方法2:美团APP -> 首页 -> 红包签到 -> 手动签到一次 6 | ^https:\/\/i.meituan.com\/evolve\/signin\/signpost\/ url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/meituan/meituan.cookie.js 7 | -------------------------------------------------------------------------------- /script/ximalaya/icon/ximalaya.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JoJoJotarou/myScript/4a79b2488c892a0723e152aeb4931dff23d295bb/script/ximalaya/icon/ximalaya.png -------------------------------------------------------------------------------- /script/ximalaya/rewrite/ximalaya.checkin.conf: -------------------------------------------------------------------------------- 1 | hostname = *.ximalaya.com 2 | # @JoJoJotarou 2022-07-28 必须开启QX的HTTP数据抓取能匹配到请求URL(估计是请求被隐藏) 3 | # @JoJoJotarou 2022-04-22 这个规则不好的一点就是每次进入app就会触发,切换app也会触发,获取cookie后需要立即到QX禁止该规则 4 | # @chavyleung的重写触发不了: ^https?:\/\/.*\/mobile\-user\/(v1\/)?homePage\/.* url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/ximalaya/ximalaya.cookie.js 5 | # ^https?:\/\/passport.ximalaya.com\/user-http-app\/v1\/token\/refresh url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/ximalaya/ximalaya.cookie.js 6 | 7 | # new !2022-11-15 8 | # 喜马拉雅 cookie 9 | ^https?:\/\/(mobile|mobilehera|mobwsa)\.ximalaya\.com\/app-skin-service\/skin\/ url script-request-header https://raw.githubusercontent.com/ClydeTime/Quantumult/main/Script/Task/xmlySign.js 10 | -------------------------------------------------------------------------------- /script/ximalaya/ximalaya.task.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "喜马拉雅脚本集合", 3 | "description": "Script Gallery", 4 | "task": [ 5 | { 6 | "config":"35 8 * * * https://raw.githubusercontent.com/ClydeTime/Quantumult/main/Script/Task/xmlySign.js, tag=喜马拉雅签到任务, img-url=https://raw.githubusercontent.com/HuiDoY/Icon/main/mini/Color/ximalaya.png, enabled=true", 7 | "addons":"https://raw.githubusercontent.com/JoJoJotarou/myScript/master/script/ximalaya/rewrite/ximalaya.checkin.conf, tag=喜马拉雅CK" 8 | } 9 | ] 10 | } 11 | --------------------------------------------------------------------------------