├── README.md ├── USER_AGENTS.js ├── jdCookie.js ├── jd_bzbw.js ├── jd_dreamFactory-help.js ├── jd_fanli.js ├── jd_fcwb-help.js ├── jd_fruit-help.js ├── jd_fruit.js ├── jd_health-help.js ├── jd_health.js ├── jd_jdfactory-help.js ├── jd_jdfactory.js ├── jd_mofang.js ├── jd_ms.js ├── jd_pet-help.js ├── jd_pet.js ├── jd_planbean-help.js ├── jd_plantBean.js ├── jd_sgmh-help.js ├── jd_sgmh.js ├── jd_syj.js └── jd_tyt.js /README.md: -------------------------------------------------------------------------------- 1 | 👋 Hi, I’m @mrddddgggg 2 | 👀 I’m interested in ... 3 | 🌱 I’m currently learning ... 4 | 💞️ I’m looking to collaborate on ... 5 | 📫 How to reach me .. 6 | 7 | TG:https://t.me/gjds9 8 | 9 | The Qing Long Repo 10 | 11 | ql repo https://github.com/mrddddgggg/dongge.git "jd_" 12 | 13 | 14 | 15 | ![微信图片_20220123181004](https://user-images.githubusercontent.com/94060932/150673806-66451600-5419-47f4-998a-3b5ad579a3f1.jpg) 16 | -------------------------------------------------------------------------------- /USER_AGENTS.js: -------------------------------------------------------------------------------- 1 | const USER_AGENTS = [ 2 | "jdapp;android;10.1.0;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", 3 | "jdapp;iPhone;10.1.0;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", 4 | "jdapp;android;10.1.0;9;network/4g;Mozilla/5.0 (Linux; Android 9; Mi Note 3 Build/PKQ1.181007.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36", 5 | "jdapp;android;10.1.0;10;network/wifi;Mozilla/5.0 (Linux; Android 10; GM1910 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", 6 | "jdapp;android;10.1.0;9;network/wifi;Mozilla/5.0 (Linux; Android 9; 16T Build/PKQ1.190616.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", 7 | "jdapp;iPhone;10.1.0;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 8 | "jdapp;iPhone;10.1.0;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 9 | "jdapp;iPhone;10.1.0;13.5;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 10 | "jdapp;iPhone;10.1.0;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 11 | "jdapp;iPhone;10.1.0;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 12 | "jdapp;iPhone;10.1.0;13.7;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 13 | "jdapp;iPhone;10.1.0;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 14 | "jdapp;iPhone;10.1.0;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 15 | "jdapp;iPhone;10.1.0;13.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 16 | "jdapp;iPhone;10.1.0;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 17 | "jdapp;android;10.1.0;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MI 6 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", 18 | "jdapp;android;10.1.0;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045511 Mobile Safari/537.36", 19 | "jdapp;iPhone;10.1.0;11.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79", 20 | "jdapp;android;10.1.0;10;;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", 21 | "jdapp;android;10.1.0;10;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", 22 | "jdapp;android;10.1.0;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A6000 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045224 Mobile Safari/537.36", 23 | "jdapp;android;10.1.0;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MHA-AL00 Build/HUAWEIMHA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", 24 | "jdapp;android;10.1.0;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; 16 X Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", 25 | "jdapp;android;10.1.0;8.0.0;network/wifi;Mozilla/5.0 (Linux; Android 8.0.0; HTC U-3w Build/OPR6.170623.013; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", 26 | "jdapp;iPhone;10.1.0;14.0.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 27 | "jdapp;android;10.1.0;10;network/wifi;Mozilla/5.0 (Linux; Android 10; LYA-AL00 Build/HUAWEILYA-AL00L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", 28 | "jdapp;iPhone;10.1.0;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 29 | "jdapp;iPhone;10.1.0;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 30 | "jdapp;iPhone;10.1.0;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 31 | "jdapp;android;10.1.0;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; MI 8 Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36", 32 | "jdapp;android;10.1.0;10;network/wifi;Mozilla/5.0 (Linux; Android 10; Redmi K20 Pro Premium Edition Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36", 33 | "jdapp;iPhone;10.1.0;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 34 | "jdapp;iPhone;10.1.0;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", 35 | "jdapp;android;10.1.0;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K20 Pro Premium Edition Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045513 Mobile Safari/537.36", 36 | "jdapp;android;10.1.0;10;network/wifi;Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36", 37 | "jdapp;iPhone;10.1.0;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 38 | ] 39 | /** 40 | * 生成随机数字 41 | * @param {number} min 最小值(包含) 42 | * @param {number} max 最大值(不包含) 43 | */ 44 | function randomNumber(min = 0, max = 100) { 45 | return Math.min(Math.floor(min + Math.random() * (max - min)), max); 46 | } 47 | const USER_AGENT = USER_AGENTS[randomNumber(0, USER_AGENTS.length)]; 48 | 49 | module.exports = { 50 | USER_AGENT 51 | } 52 | -------------------------------------------------------------------------------- /jdCookie.js: -------------------------------------------------------------------------------- 1 | /* 2 | 此文件为Node.js专用。其他用户请忽略 3 | */ 4 | //此处填写京东账号cookie。 5 | let CookieJDs = [ 6 | '',//账号一ck,例:pt_key=XXX;pt_pin=XXX; 7 | '',//账号二ck,例:pt_key=XXX;pt_pin=XXX;如有更多,依次类推 8 | ] 9 | // 判断环境变量里面是否有京东ck 10 | if (process.env.JD_COOKIE) { 11 | if (process.env.JD_COOKIE.indexOf('&') > -1) { 12 | CookieJDs = process.env.JD_COOKIE.split('&'); 13 | } else if (process.env.JD_COOKIE.indexOf('\n') > -1) { 14 | CookieJDs = process.env.JD_COOKIE.split('\n'); 15 | } else { 16 | CookieJDs = [process.env.JD_COOKIE]; 17 | } 18 | } 19 | if (JSON.stringify(process.env).indexOf('GITHUB')>-1) { 20 | console.log(`请勿使用github action运行此脚本,无论你是从你自己的私库还是其他哪里拉取的源代码,都会导致我被封号\n`); 21 | !(async () => { 22 | await require('./sendNotify').sendNotify('提醒', `请勿使用github action、滥用github资源会封我仓库以及账号`) 23 | await process.exit(0); 24 | })() 25 | } 26 | CookieJDs = [...new Set(CookieJDs.filter(item => !!item))] 27 | console.log(`\n====================共${CookieJDs.length}个京东账号Cookie=========\n`); 28 | console.log(`==================脚本执行- 北京时间(UTC+8):${new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString()}=====================\n`) 29 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; 30 | for (let i = 0; i < CookieJDs.length; i++) { 31 | if (!CookieJDs[i].match(/pt_pin=(.+?);/) || !CookieJDs[i].match(/pt_key=(.+?);/)) console.log(`\n提示:京东cookie 【${CookieJDs[i]}】填写不规范,可能会影响部分脚本正常使用。正确格式为: pt_key=xxx;pt_pin=xxx;(分号;不可少)\n`); 32 | const index = (i + 1 === 1) ? '' : (i + 1); 33 | exports['CookieJD' + index] = CookieJDs[i].trim(); 34 | } 35 | -------------------------------------------------------------------------------- /jd_fanli.js: -------------------------------------------------------------------------------- 1 | const $ = new Env('搞基大神-饭粒'); 2 | const notify = $.isNode() ? require('./sendNotify') : ''; 3 | //Node.js用户请在jdCookie.js处填写京东ck; 4 | const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; 5 | const JD_API_HOST = 'https://ifanli.m.jd.com'; 6 | //IOS等用户直接用NobyDa的jd cookie 7 | let cookiesArr = [], cookie = '', message; 8 | var timestamp = Math.round(new Date().getTime()/1000).toString(); 9 | 10 | let insertCodes = [] 11 | let inviteCodes = [] 12 | 13 | if ($.isNode()) { 14 | Object.keys(jdCookieNode).forEach((item) => { 15 | cookiesArr.push(jdCookieNode[item]) 16 | }) 17 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; 18 | } else { 19 | cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); 20 | } 21 | 22 | !(async () => { 23 | if (!cookiesArr[0]) { 24 | $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 25 | return; 26 | } 27 | 28 | for (let i = 0; i < cookiesArr.length; i++) { 29 | if (cookiesArr[i]) { 30 | cookie = cookiesArr[i]; 31 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 32 | $.index = i + 1; 33 | $.isLogin = true; 34 | $.nickName = ''; 35 | message = ''; 36 | await TotalBean(); 37 | console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); 38 | if (!$.isLogin) { 39 | $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 40 | 41 | if ($.isNode()) { 42 | await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); 43 | } 44 | continue 45 | } 46 | 47 | 48 | 49 | } 50 | 51 | await getTaskFinishCount() 52 | 53 | 54 | } 55 | 56 | 57 | 58 | 59 | })() 60 | .catch((e) => { 61 | $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') 62 | }) 63 | .finally(() => { 64 | $.done(); 65 | }) 66 | 67 | function getTaskFinishCount() { 68 | return new Promise((resolve) => { 69 | 70 | $.get(taskurl('getTaskFinishCount'), async (err, resp, data) => { 71 | 72 | try { 73 | if (err) { 74 | console.log(`${JSON.stringify(err)}`) 75 | console.log(`${$.name} API请求失败,请检查网路重试`) 76 | } else { 77 | if (safeGet(data)) { 78 | data = JSON.parse(data); 79 | if(data.code==1){ 80 | 81 | 82 | 83 | console.log(`总任务:${data.content.maxTaskCount}`) 84 | console.log(`当前已做${data.content.finishCount}个`) 85 | if(data.content.finishCount==8){ 86 | console.log('今天任务已做完') 87 | }else 88 | var task=data.content.maxTaskCount-data.content.finishCount 89 | for(let i=0;i { 112 | 113 | $.get(taskurl('getTaskList'), async (err, resp, data) => { 114 | 115 | try { 116 | if (err) { 117 | console.log(`${JSON.stringify(err)}`) 118 | console.log(`${$.name} API请求失败,请检查网路重试`) 119 | } else { 120 | if (safeGet(data)) { 121 | data = JSON.parse(data); 122 | if(data.code==1){ 123 | list = data.content 124 | for(let i=0;i { 149 | let body = {"taskId":taskId,"taskType":taskType,"uid":uid,"tt":tt} 150 | 151 | $.post(taskposturl('saveTaskRecord',body), async (err, resp, data) => { 152 | //$.log(data) 153 | 154 | try { 155 | if (err) { 156 | console.log(`${JSON.stringify(err)}`) 157 | console.log(`${$.name} API请求失败,请检查网路重试`) 158 | } else { 159 | if (safeGet(data)) { 160 | data = JSON.parse(data); 161 | if(data.code==1){ 162 | 163 | 164 | 165 | console.log(`${data.content.msg}`) 166 | 167 | 168 | } 169 | else if(data.code==0){ 170 | console.log(`任务已做完`) 171 | 172 | } 173 | 174 | } 175 | } 176 | } catch (e) { 177 | $.logErr(e, resp) 178 | } finally { 179 | resolve(data); 180 | } 181 | }) 182 | }) 183 | } 184 | 185 | function saveTask(taskId,taskType) { 186 | return new Promise((resolve) => { 187 | 188 | let body = {taskId: taskId, taskType: taskType} 189 | $.post(taskposturl('saveTaskRecord',body), async (err, resp, data) => { 190 | 191 | 192 | try { 193 | if (err) { 194 | console.log(`${JSON.stringify(err)}`) 195 | console.log(`${$.name} API请求失败,请检查网路重试`) 196 | } else { 197 | if (safeGet(data)) { 198 | data = JSON.parse(data); 199 | if(data.code==1){ 200 | 201 | uid=data.content.uid 202 | tt=data.content.tt 203 | console.log(`等待10S`) 204 | 205 | 206 | } 207 | else if(data.code==0){ 208 | //console.log(`${data.content.msg}`) 209 | 210 | } 211 | 212 | } 213 | } 214 | } catch (e) { 215 | $.logErr(e, resp) 216 | } finally { 217 | resolve(data); 218 | } 219 | }) 220 | }) 221 | } 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | function TotalBean() { 234 | return new Promise(async resolve => { 235 | const options = { 236 | "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, 237 | "headers": { 238 | "Accept": "application/json,text/plain, */*", 239 | "Content-Type": "application/x-www-form-urlencoded", 240 | "Accept-Encoding": "gzip, deflate, br", 241 | "Accept-Language": "zh-cn", 242 | "Connection": "keep-alive", 243 | "Cookie": cookie, 244 | "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", 245 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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") 246 | } 247 | } 248 | $.post(options, (err, resp, data) => { 249 | try { 250 | if (err) { 251 | console.log(`${JSON.stringify(err)}`) 252 | console.log(`${$.name} API请求失败,请检查网路重试`) 253 | } else { 254 | if (data) { 255 | data = JSON.parse(data); 256 | if (data["retcode"] === 13) { 257 | $.isLogin = false; //cookie过期 258 | return; 259 | } 260 | if (data["retcode"] === 0) { 261 | $.nickName = (data["base"] && data["base"].nickname) || $.UserName; 262 | } else { 263 | $.nickName = $.UserName; 264 | } 265 | } else { 266 | console.log(`京东服务器返回空数据`) 267 | } 268 | } 269 | } catch (e) { 270 | $.logErr(e, resp) 271 | } finally { 272 | resolve(); 273 | } 274 | }) 275 | }) 276 | } 277 | function safeGet(data) { 278 | try { 279 | if (typeof JSON.parse(data) == "object") { 280 | return true; 281 | } 282 | } catch (e) { 283 | console.log(e); 284 | console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); 285 | return false; 286 | } 287 | } 288 | function jsonParse(str) { 289 | if (typeof str == "string") { 290 | try { 291 | return JSON.parse(str); 292 | } catch (e) { 293 | console.log(e); 294 | $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') 295 | return []; 296 | } 297 | } 298 | } 299 | 300 | 301 | function taskurl(functionId) { 302 | return { 303 | url: `${JD_API_HOST}/rebateapi/task/${functionId}`, 304 | 305 | headers: { 306 | 307 | "Cookie": cookie, 308 | "Origin": "https://ifanli.m.jd.com", 309 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36", 310 | 311 | } 312 | } 313 | } 314 | 315 | function taskposturl(functionId,body) { 316 | return { 317 | url: `${JD_API_HOST}/rebateapi/task/${functionId}`, 318 | body:`${unescape(JSON.stringify(body))}`, 319 | headers: { 320 | 'Host': 'ifanli.m.jd.com', 321 | 'Accept': 'application/json, text/plain, */*', 322 | 'Accept-Language': 'zh-cn', 323 | 'Accept-Encoding':' gzip, deflate, br', 324 | 'Cache-Control': 'no-cache', 325 | 'Content-Type': 'application/json;charset=utf-8', 326 | 'Origin': 'https://ifanli.m.jd.com', 327 | 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.16(0x1800102a) NetType/4G Language/zh_CN', 328 | 'Connection': 'keep-alive', 329 | 'Referer': 'https://ifanli.m.jd.com/rebate/earnBean.html?cu=true&utm_source=kong&utm_medium=jingfen&utm_campaign=t_1000126035_&utm_term=addceb25a70d4aa1ba19344b2577a850', 330 | cookie: cookie, 331 | 332 | } 333 | } 334 | } 335 | 336 | function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),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=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,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;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 337 | -------------------------------------------------------------------------------- /jd_health-help.js: -------------------------------------------------------------------------------- 1 | 2 | const $ = new Env("搞鸡玩家-健康社区互助"); 3 | const jdCookieNode = $.isNode() ? require("./jdCookie.js") : ""; 4 | const notify = $.isNode() ? require('./sendNotify') : ""; 5 | let cookiesArr = [], cookie = "", allMessage = "", message; 6 | const inviteCodes = [] 7 | let reward = $.isNode() ? (process.env.JD_HEALTH_REWARD_NAME ? process.env.JD_HEALTH_REWARD_NAME : '') : ($.getdata('JD_HEALTH_REWARD_NAME') ? $.getdata('JD_HEALTH_REWARD_NAME') : ''); 8 | const randomCount = $.isNode() ? 20 : 5; 9 | if ($.isNode()) { 10 | Object.keys(jdCookieNode).forEach((item) => { 11 | cookiesArr.push(jdCookieNode[item]); 12 | }); 13 | console.log(`如果出现提示 ?.data. 错误,请升级nodejs版本(进入容器后,apk add nodejs-current)`) 14 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === "false") console.log = () => {}; 15 | } else { 16 | cookiesArr = [$.getdata("CookieJD"), $.getdata("CookieJD2"), ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); 17 | } 18 | const JD_API_HOST = "https://api.m.jd.com/"; 19 | !(async () => { 20 | if (!cookiesArr[0]) { 21 | $.msg($.name, "【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取", "https://bean.m.jd.com/", {"open-url": "https://bean.m.jd.com/"}); 22 | return; 23 | } 24 | await requireConfig() 25 | for (let i = 0; i < cookiesArr.length; i++) { 26 | if (cookiesArr[i]) { 27 | cookie = cookiesArr[i]; 28 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); 29 | $.index = i + 1; 30 | message = ""; 31 | console.log(`\n******开始【京东账号${$.index}】${$.UserName}*********\n`); 32 | // await shareCodesFormat() 33 | await main() 34 | 35 | } 36 | } 37 | console.log(`\n开始账号内互助\n`); 38 | for (let i = 0; i < cookiesArr.length; i++) { 39 | cookie = cookiesArr[i]; 40 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 41 | 42 | console.log('开始助力好友') 43 | 44 | console.log(`格式化后的助力码::${JSON.stringify(inviteCodes)}\n`); 45 | await helpFriends() 46 | } 47 | })() 48 | .catch((e) => { 49 | $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); 50 | }) 51 | .finally(() => { 52 | $.done(); 53 | }); 54 | 55 | async function main() { 56 | try { 57 | $.score = 0 58 | $.earn = false 59 | await getTaskDetail(6) 60 | 61 | 62 | 63 | } catch (e) { 64 | $.logErr(e) 65 | } 66 | } 67 | 68 | async function helpFriends() { 69 | for (let code of inviteCodes) { 70 | if (!code) continue 71 | console.log(`去助力好友${code}`) 72 | let res = await doTask(code, 6) 73 | if([108,-1001].includes(res?.data?.bizCode)){ 74 | console.log(`助力次数已满,跳出`) 75 | break 76 | } 77 | await $.wait(1000) 78 | } 79 | } 80 | 81 | function doTask(taskToken, taskId, actionType = 0) { 82 | return new Promise(resolve => { 83 | const options = taskUrl('jdhealth_collectScore', {taskToken, taskId, actionType}) 84 | $.get(options, 85 | (err, resp, data) => { 86 | try { 87 | if (safeGet(data)) { 88 | data = $.toObj(data) 89 | if ([0, 1].includes(data?.data?.bizCode ?? -1)) { 90 | $.canDo = true 91 | if (data?.data?.result?.score) 92 | console.log(`任务完成成功,获得:${data?.data?.result?.score ?? '未知'}能量`) 93 | else 94 | console.log(`任务领取结果:${data?.data?.bizMsg ?? JSON.stringify(data)}`) 95 | } else { 96 | console.log(`任务完成失败:${data?.data?.bizMsg ?? JSON.stringify(data)}`) 97 | } 98 | } 99 | } catch (e) { 100 | console.log(e) 101 | } finally { 102 | resolve(data) 103 | } 104 | }) 105 | }) 106 | } 107 | 108 | function getTaskDetail(taskId = '') { 109 | return new Promise(resolve => { 110 | $.get(taskUrl('jdhealth_getTaskDetail', {"buildingId": "", taskId: taskId === -1 ? '' : taskId, "channelId": 1}), 111 | async (err, resp, data) => { 112 | try { 113 | if (safeGet(data)) { 114 | data = $.toObj(data) 115 | if (taskId === -1) { 116 | let tmp = parseInt(parseFloat(data?.data?.result?.userScore ?? '0')) 117 | if (!$.earn) { 118 | $.score = tmp 119 | $.earn = 1 120 | } else { 121 | $.earn = tmp - $.score 122 | $.score = tmp 123 | } 124 | } else if (taskId === 6) { 125 | if (data?.data?.result?.taskVos) { 126 | console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${data?.data?.result?.taskVos[0].assistTaskDetailVo.taskToken}\n`); 127 | console.log('收集助力码!!!') 128 | inviteCodes.push(data?.data?.result?.taskVos[0].assistTaskDetailVo.taskToken) 129 | 130 | 131 | } 132 | } 133 | } 134 | } catch (e) { 135 | console.log(e) 136 | } finally { 137 | resolve() 138 | } 139 | }) 140 | }) 141 | } 142 | 143 | 144 | 145 | 146 | 147 | 148 | function taskUrl(function_id, body = {}) { 149 | return { 150 | url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&uuid=`, 151 | headers: { 152 | "Cookie": cookie, 153 | "origin": "https://h5.m.jd.com", 154 | "referer": "https://h5.m.jd.com/", 155 | 'accept-language': 'zh-cn', 156 | 'accept-encoding': 'gzip, deflate, br', 157 | 'accept': 'application/json, text/plain, */*', 158 | 'Content-Type': 'application/x-www-form-urlencoded', 159 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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") 160 | } 161 | } 162 | } 163 | 164 | function safeGet(data) { 165 | try { 166 | if (typeof JSON.parse(data) == "object") { 167 | return true; 168 | } 169 | } catch (e) { 170 | console.log(e); 171 | console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); 172 | return false; 173 | } 174 | } 175 | 176 | 177 | 178 | 179 | function requireConfig() { 180 | return new Promise(resolve => { 181 | console.log(`开始获取${$.name}配置文件\n`); 182 | //Node.js用户请在jdCookie.js处填写京东ck; 183 | 184 | console.log(`共${cookiesArr.length}个京东账号\n`); 185 | 186 | resolve() 187 | }) 188 | } 189 | // prettier-ignore 190 | function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),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=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,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;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 191 | -------------------------------------------------------------------------------- /jd_health.js: -------------------------------------------------------------------------------- 1 | /* 2 | 东东健康社区 3 | 更新时间:2021-4-22 4 | 活动入口:京东APP首页搜索 "玩一玩"即可 5 | 6 | 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js 7 | ===================quantumultx================ 8 | [task_local] 9 | #东东健康社区 10 | 13 1,6,22 * * * https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_health.js, tag=东东健康社区, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true 11 | 12 | =====================Loon================ 13 | [Script] 14 | cron "13 1,6,22 * * *" script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_health.js, tag=东东健康社区 15 | 16 | ====================Surge================ 17 | 东东健康社区 = type=cron,cronexp="13 1,6,22 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_health.js 18 | 19 | ============小火箭========= 20 | 东东健康社区 = type=cron,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_health.js, cronexpr="13 1,6,22 * * *", timeout=3600, enable=true 21 | */ 22 | const $ = new Env("东东健康社区"); 23 | const jdCookieNode = $.isNode() ? require("./jdCookie.js") : ""; 24 | const notify = $.isNode() ? require('./sendNotify') : ""; 25 | let cookiesArr = [], cookie = "", allMessage = "", message; 26 | const inviteCodes = [] 27 | let reward = $.isNode() ? (process.env.JD_HEALTH_REWARD_NAME ? process.env.JD_HEALTH_REWARD_NAME : '') : ($.getdata('JD_HEALTH_REWARD_NAME') ? $.getdata('JD_HEALTH_REWARD_NAME') : ''); 28 | const randomCount = $.isNode() ? 20 : 5; 29 | if ($.isNode()) { 30 | Object.keys(jdCookieNode).forEach((item) => { 31 | cookiesArr.push(jdCookieNode[item]); 32 | }); 33 | console.log(`如果出现提示 ?.data. 错误,请升级nodejs版本(进入容器后,apk add nodejs-current)`) 34 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === "false") console.log = () => {}; 35 | } else { 36 | cookiesArr = [$.getdata("CookieJD"), $.getdata("CookieJD2"), ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); 37 | } 38 | const JD_API_HOST = "https://api.m.jd.com/"; 39 | !(async () => { 40 | if (!cookiesArr[0]) { 41 | $.msg($.name, "【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取", "https://bean.m.jd.com/", {"open-url": "https://bean.m.jd.com/"}); 42 | return; 43 | } 44 | await requireConfig() 45 | for (let i = 0; i < cookiesArr.length; i++) { 46 | if (cookiesArr[i]) { 47 | cookie = cookiesArr[i]; 48 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); 49 | $.index = i + 1; 50 | message = ""; 51 | console.log(`\n******开始【京东账号${$.index}】${$.UserName}*********\n`); 52 | // await shareCodesFormat() 53 | await main() 54 | await showMsg() 55 | //$.log(cookie+'\n') 56 | } 57 | } 58 | if ($.isNode() && allMessage) { 59 | await notify.sendNotify(`${$.name}`, `${allMessage}`) 60 | } 61 | })() 62 | .catch((e) => { 63 | $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); 64 | }) 65 | .finally(() => { 66 | $.done(); 67 | }); 68 | 69 | async function main() { 70 | try { 71 | $.score = 0 72 | $.earn = false 73 | await getTaskDetail(-1) 74 | await getTaskDetail(16) 75 | await getTaskDetail(6) 76 | for(let i = 0 ; i < 5; ++i){ 77 | $.canDo = false 78 | await getTaskDetail() 79 | if(!$.canDo) break 80 | await $.wait(1000) 81 | } 82 | await collectScore() 83 | 84 | await getTaskDetail(22); 85 | await getTaskDetail(-1) 86 | 87 | if (reward) { 88 | await getCommodities() 89 | } 90 | 91 | } catch (e) { 92 | $.logErr(e) 93 | } 94 | } 95 | 96 | async function helpFriends() { 97 | for (let code of inviteCodes) { 98 | if (!code) continue 99 | console.log(`去助力好友${code}`) 100 | let res = await doTask(code, 6) 101 | if([108,-1001].includes(res?.data?.bizCode)){ 102 | console.log(`助力次数已满,跳出`) 103 | break 104 | } 105 | await $.wait(1000) 106 | } 107 | } 108 | 109 | function showMsg() { 110 | return new Promise(async resolve => { 111 | message += `本次获得${$.earn}健康值,累计${$.score}健康值\n` 112 | $.msg($.name, '', `京东账号${$.index} ${$.UserName}\n${message}`); 113 | resolve(); 114 | }) 115 | } 116 | 117 | function getTaskDetail(taskId = '') { 118 | return new Promise(resolve => { 119 | $.get(taskUrl('jdhealth_getTaskDetail', {"buildingId": "", taskId: taskId === -1 ? '' : taskId, "channelId": 1}), 120 | async (err, resp, data) => { 121 | try { 122 | if (safeGet(data)) { 123 | data = $.toObj(data) 124 | if (taskId === -1) { 125 | let tmp = parseInt(parseFloat(data?.data?.result?.userScore ?? '0')) 126 | if (!$.earn) { 127 | $.score = tmp 128 | $.earn = 1 129 | } else { 130 | $.earn = tmp - $.score 131 | $.score = tmp 132 | } 133 | } else if (taskId === 6) { 134 | if (data?.data?.result?.taskVos) { 135 | console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${data?.data?.result?.taskVos[0].assistTaskDetailVo.taskToken}\n`); 136 | // console.log('好友助力码:' + data?.data?.result?.taskVos[0].assistTaskDetailVo.taskToken) 137 | 138 | // *************************** 139 | 140 | 141 | } 142 | } else if (taskId === 22) { 143 | console.log(`${data?.data?.result?.taskVos[0]?.taskName}任务,完成次数:${data?.data?.result?.taskVos[0]?.times}/${data?.data?.result?.taskVos[0]?.maxTimes}`) 144 | if (data?.data?.result?.taskVos[0]?.times === data?.data?.result?.taskVos[0]?.maxTimes) return 145 | await doTask(data?.data?.result?.taskVos[0].shoppingActivityVos[0]?.taskToken, 22, 1)//领取任务 146 | await $.wait(1000 * (data?.data?.result?.taskVos[0]?.waitDuration || 3)); 147 | await doTask(data?.data?.result?.taskVos[0].shoppingActivityVos[0]?.taskToken, 22, 0);//完成任务 148 | } else { 149 | for (let vo of data?.data?.result?.taskVos.filter(vo => vo.taskType !== 19 && vo.taskType !== 25) ?? []) { 150 | console.log(`${vo.taskName}任务,完成次数:${vo.times}/${vo.maxTimes}`) 151 | for (let i = vo.times; i < vo.maxTimes; i++) { 152 | console.log(`去完成${vo.taskName}任务`) 153 | if (vo.taskType === 13) { 154 | await doTask(vo.simpleRecordInfoVo?.taskToken, vo?.taskId) 155 | } else if (vo.taskType === 8) { 156 | await doTask(vo.productInfoVos[i]?.taskToken, vo?.taskId, 1) 157 | await $.wait(1000 * 10) 158 | await doTask(vo.productInfoVos[i]?.taskToken, vo?.taskId, 0) 159 | } else if (vo.taskType === 9) { 160 | await doTask(vo.shoppingActivityVos[0]?.taskToken, vo?.taskId, 1) 161 | await $.wait(1000 * 10) 162 | await doTask(vo.shoppingActivityVos[0]?.taskToken, vo?.taskId, 0) 163 | } else if (vo.taskType === 10) { 164 | await doTask(vo.threeMealInfoVos[0]?.taskToken, vo?.taskId) 165 | } else if (vo.taskType === 26 || vo.taskType === 3) { 166 | await doTask(vo.shoppingActivityVos[0]?.taskToken, vo?.taskId) 167 | } else if (vo.taskType === 1) { 168 | for (let key of Object.keys(vo.followShopVo)) { 169 | let taskFollow = vo.followShopVo[key] 170 | if (taskFollow.status !== 2) { 171 | await doTask(taskFollow.taskToken, vo.taskId, 0) 172 | break 173 | } 174 | } 175 | } 176 | await $.wait(2000) 177 | } 178 | } 179 | } 180 | } 181 | } catch (e) { 182 | console.log(e) 183 | } finally { 184 | resolve() 185 | } 186 | }) 187 | }) 188 | } 189 | 190 | async function getCommodities() { 191 | return new Promise(async resolve => { 192 | const options = taskUrl('jdhealth_getCommodities') 193 | $.post(options, async (err, resp, data) => { 194 | try { 195 | if (safeGet(data)) { 196 | data = $.toObj(data) 197 | let beans = data.data.result.jBeans.filter(x => x.status !== 1) 198 | if (beans.length !== 0) { 199 | for (let key of Object.keys(beans)) { 200 | let vo = beans[key] 201 | if (vo.title === reward && $.score >= vo.exchangePoints) { 202 | await $.wait(1000) 203 | await exchange(vo.type, vo.id) 204 | } 205 | } 206 | } else { 207 | console.log(`兑换京豆次数已达上限`) 208 | } 209 | } 210 | } catch (e) { 211 | console.log(e) 212 | } finally { 213 | resolve(data) 214 | } 215 | }) 216 | }) 217 | } 218 | function exchange(commodityType, commodityId) { 219 | return new Promise(resolve => { 220 | const options = taskUrl('jdhealth_exchange', {commodityType, commodityId}) 221 | $.post(options, (err, resp, data) => { 222 | try { 223 | if (safeGet(data)) { 224 | data = $.toObj(data) 225 | if (data.data.bizCode === 0 || data.data.bizMsg === "success") { 226 | $.score = data.data.result.userScore 227 | console.log(`兑换${data.data.result.jingBeanNum}京豆成功`) 228 | message += `兑换${data.data.result.jingBeanNum}京豆成功\n` 229 | if ($.isNode()) { 230 | allMessage += `【京东账号${$.index}】 ${$.UserName}\n兑换${data.data.result.jingBeanNum}京豆成功🎉${$.index !== cookiesArr.length ? '\n\n' : ''}` 231 | } 232 | } else { 233 | console.log(data.data.bizMsg) 234 | } 235 | } 236 | } catch (e) { 237 | console.log(e) 238 | } finally { 239 | resolve(data) 240 | } 241 | }) 242 | }) 243 | } 244 | 245 | function doTask(taskToken, taskId, actionType = 0) { 246 | return new Promise(resolve => { 247 | const options = taskUrl('jdhealth_collectScore', {taskToken, taskId, actionType}) 248 | $.get(options, 249 | (err, resp, data) => { 250 | try { 251 | if (safeGet(data)) { 252 | data = $.toObj(data) 253 | if ([0, 1].includes(data?.data?.bizCode ?? -1)) { 254 | $.canDo = true 255 | if (data?.data?.result?.score) 256 | console.log(`任务完成成功,获得:${data?.data?.result?.score ?? '未知'}能量`) 257 | else 258 | console.log(`任务领取结果:${data?.data?.bizMsg ?? JSON.stringify(data)}`) 259 | } else { 260 | console.log(`任务完成失败:${data?.data?.bizMsg ?? JSON.stringify(data)}`) 261 | } 262 | } 263 | } catch (e) { 264 | console.log(e) 265 | } finally { 266 | resolve(data) 267 | } 268 | }) 269 | }) 270 | } 271 | 272 | function collectScore() { 273 | return new Promise(resolve => { 274 | $.get(taskUrl('jdhealth_collectProduceScore', {}), 275 | (err, resp, data) => { 276 | try { 277 | if (safeGet(data)) { 278 | data = $.toObj(data) 279 | if (data?.data?.bizCode === 0) { 280 | if (data?.data?.result?.produceScore) 281 | console.log(`任务完成成功,获得:${data?.data?.result?.produceScore ?? '未知'}能量`) 282 | else 283 | console.log(`任务领取结果:${data?.data?.bizMsg ?? JSON.stringify(data)}`) 284 | } else { 285 | console.log(`任务完成失败:${data?.data?.bizMsg ?? JSON.stringify(data)}`) 286 | } 287 | } 288 | } catch (e) { 289 | console.log(e) 290 | } finally { 291 | resolve() 292 | } 293 | }) 294 | }) 295 | } 296 | 297 | function taskUrl(function_id, body = {}) { 298 | return { 299 | url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&uuid=`, 300 | headers: { 301 | "Cookie": cookie, 302 | "origin": "https://h5.m.jd.com", 303 | "referer": "https://h5.m.jd.com/", 304 | 'accept-language': 'zh-cn', 305 | 'accept-encoding': 'gzip, deflate, br', 306 | 'accept': 'application/json, text/plain, */*', 307 | 'Content-Type': 'application/x-www-form-urlencoded', 308 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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") 309 | } 310 | } 311 | } 312 | 313 | function safeGet(data) { 314 | try { 315 | if (typeof JSON.parse(data) == "object") { 316 | return true; 317 | } 318 | } catch (e) { 319 | console.log(e); 320 | console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); 321 | return false; 322 | } 323 | } 324 | 325 | 326 | 327 | 328 | function requireConfig() { 329 | return new Promise(resolve => { 330 | console.log(`开始获取${$.name}配置文件\n`); 331 | //Node.js用户请在jdCookie.js处填写京东ck; 332 | 333 | console.log(`共${cookiesArr.length}个京东账号\n`); 334 | 335 | resolve() 336 | }) 337 | } 338 | // prettier-ignore 339 | function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),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=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,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;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 340 | -------------------------------------------------------------------------------- /jd_jdfactory-help.js: -------------------------------------------------------------------------------- 1 | 2 | const $ = new Env('搞鸡玩家-东东工厂互助'); 3 | 4 | const notify = $.isNode() ? require('./sendNotify') : ''; 5 | //Node.js用户请在jdCookie.js处填写京东ck; 6 | const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; 7 | let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 8 | const randomCount = $.isNode() ? 20 : 5; 9 | //IOS等用户直接用NobyDa的jd cookie 10 | let cookiesArr = [], cookie = '', message; 11 | if ($.isNode()) { 12 | Object.keys(jdCookieNode).forEach((item) => { 13 | cookiesArr.push(jdCookieNode[item]) 14 | }) 15 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; 16 | if (process.env.JDFACTORY_FORBID_ACCOUNT) process.env.JDFACTORY_FORBID_ACCOUNT.split('&').map((item, index) => Number(item) === 0 ? cookiesArr = [] : cookiesArr.splice(Number(item) - 1 - index, 1)) 17 | } else { 18 | cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); 19 | } 20 | let wantProduct = ``;//心仪商品名称 21 | const JD_API_HOST = 'https://api.m.jd.com/client.action'; 22 | const inviteCodes = []; 23 | !(async () => { 24 | await requireConfig(); 25 | if (!cookiesArr[0]) { 26 | $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 27 | return; 28 | } 29 | for (let i = 0; i < cookiesArr.length; i++) { 30 | if (cookiesArr[i]) { 31 | cookie = cookiesArr[i]; 32 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 33 | $.index = i + 1; 34 | $.isLogin = true; 35 | $.nickName = ''; 36 | message = ''; 37 | await TotalBean(); 38 | console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); 39 | if (!$.isLogin) { 40 | $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 41 | 42 | if ($.isNode()) { 43 | await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); 44 | } 45 | continue 46 | } 47 | //await shareCodesFormat(); 48 | await jdFactory() 49 | } 50 | } 51 | console.log(`\n开始账号内互助\n`); 52 | for (let i = 0; i < cookiesArr.length; i++) { 53 | cookie = cookiesArr[i]; 54 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 55 | 56 | console.log('开始助力好友') 57 | 58 | console.log(`格式化后的助力码::${JSON.stringify(inviteCodes)}\n`); 59 | for (let code of inviteCodes) { 60 | if (!code) continue 61 | const helpRes = await jdfactory_collectScore(code); 62 | if (helpRes.code === 0 && helpRes.data.bizCode === -7) { 63 | console.log(`助力机会已耗尽,跳出`); 64 | break 65 | } 66 | } 67 | } 68 | })() 69 | .catch((e) => { 70 | $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') 71 | }) 72 | .finally(() => { 73 | $.done(); 74 | }) 75 | async function jdFactory() { 76 | try { 77 | 78 | await jdfactory_getTaskDetail(); 79 | 80 | } catch (e) { 81 | $.logErr(e) 82 | } 83 | } 84 | function showMsg() { 85 | return new Promise(resolve => { 86 | if (!jdNotify) { 87 | $.msg($.name, '', `${message}`); 88 | } else { 89 | $.log(`${message}`); 90 | } 91 | if (new Date().getHours() === 12) { 92 | $.msg($.name, '', `${message}`); 93 | } 94 | resolve() 95 | }) 96 | } 97 | function jdfactory_collectScore(taskToken) { 98 | return new Promise(async resolve => { 99 | await $.wait(1000); 100 | $.post(taskPostUrl("jdfactory_collectScore", { taskToken }, "jdfactory_collectScore"), async (err, resp, data) => { 101 | try { 102 | if (err) { 103 | console.log(`${JSON.stringify(err)}`) 104 | console.log(`${$.name} API请求失败,请检查网路重试`) 105 | } else { 106 | if (safeGet(data)) { 107 | data = JSON.parse(data); 108 | if (data.data.bizCode === 0) { 109 | $.taskVos = data.data.result.taskVos;//任务列表 110 | console.log(`领取做完任务的奖励:${JSON.stringify(data.data.result)}`); 111 | } else { 112 | console.log(JSON.stringify(data)) 113 | } 114 | } 115 | } 116 | } catch (e) { 117 | $.logErr(e, resp) 118 | } finally { 119 | resolve(data); 120 | } 121 | }) 122 | }) 123 | } 124 | 125 | 126 | //获取任务列表 127 | function jdfactory_getTaskDetail() { 128 | return new Promise(resolve => { 129 | $.post(taskPostUrl("jdfactory_getTaskDetail", {}, "jdfactory_getTaskDetail"), async (err, resp, data) => { 130 | try { 131 | if (err) { 132 | console.log(`${JSON.stringify(err)}`) 133 | console.log(`${$.name} API请求失败,请检查网路重试`) 134 | } else { 135 | if (safeGet(data)) { 136 | data = JSON.parse(data); 137 | if (data.data.bizCode === 0) { 138 | $.taskVos = data.data.result.taskVos;//任务列表 139 | $.taskVos.map(item => { 140 | if (item.taskType === 14) { 141 | console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${item.assistTaskDetailVo.taskToken}\n`) 142 | inviteCodes.push(item.assistTaskDetailVo.taskToken) 143 | console.log(`收集邀请码‼️`) 144 | } 145 | }) 146 | } 147 | } 148 | } 149 | } catch (e) { 150 | $.logErr(e, resp) 151 | } finally { 152 | resolve(); 153 | } 154 | }) 155 | }) 156 | } 157 | 158 | 159 | function requireConfig() { 160 | return new Promise(resolve => { 161 | console.log(`开始获取${$.name}配置文件\n`); 162 | //Node.js用户请在jdCookie.js处填写京东ck; 163 | 164 | console.log(`共${cookiesArr.length}个京东账号\n`); 165 | 166 | // console.log(`\n种豆得豆助力码::${JSON.stringify($.shareCodesArr)}`); 167 | //console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); 168 | resolve() 169 | }) 170 | } 171 | function taskPostUrl(function_id, body = {}, function_id2) { 172 | let url = `${JD_API_HOST}`; 173 | if (function_id2) { 174 | url += `?functionId=${function_id2}`; 175 | } 176 | return { 177 | url, 178 | body: `functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.1.0`, 179 | headers: { 180 | "Accept": "application/json, text/plain, */*", 181 | "Accept-Encoding": "gzip, deflate, br", 182 | "Accept-Language": "zh-cn", 183 | "Connection": "keep-alive", 184 | "Content-Type": "application/x-www-form-urlencoded", 185 | "Cookie": cookie, 186 | "Host": "api.m.jd.com", 187 | "Origin": "https://h5.m.jd.com", 188 | "Referer": "https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html", 189 | "User-Agent": "jdapp;iPhone;9.3.4;14.3;88732f840b77821b345bf07fd71f609e6ff12f43;network/4g;ADID/1C141FDD-C62F-425B-8033-9AAB7E4AE6A3;supportApplePay/0;hasUPPay/0;hasOCPay/0;model/iPhone11,8;addressid/2005183373;supportBestPay/0;appBuild/167502;jdSupportDarkMode/0;pv/414.19;apprpd/Babel_Native;ref/TTTChannelViewContoller;psq/5;ads/;psn/88732f840b77821b345bf07fd71f609e6ff12f43|1701;jdv/0|iosapp|t_335139774|appshare|CopyURL|1610885480412|1610885486;adk/;app_device/IOS;pap/JA2015_311210|9.3.4|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", 190 | }, 191 | timeout: 10000, 192 | } 193 | } 194 | function TotalBean() { 195 | return new Promise(async resolve => { 196 | const options = { 197 | "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, 198 | "headers": { 199 | "Accept": "application/json,text/plain, */*", 200 | "Content-Type": "application/x-www-form-urlencoded", 201 | "Accept-Encoding": "gzip, deflate, br", 202 | "Accept-Language": "zh-cn", 203 | "Connection": "keep-alive", 204 | "Cookie": cookie, 205 | "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", 206 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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") 207 | }, 208 | "timeout": 10000, 209 | } 210 | $.post(options, (err, resp, data) => { 211 | try { 212 | if (err) { 213 | console.log(`${JSON.stringify(err)}`) 214 | console.log(`${$.name} API请求失败,请检查网路重试`) 215 | } else { 216 | if (data) { 217 | data = JSON.parse(data); 218 | if (data['retcode'] === 13) { 219 | $.isLogin = false; //cookie过期 220 | return 221 | } 222 | if (data['retcode'] === 0) { 223 | $.nickName = (data['base'] && data['base'].nickname) || $.UserName; 224 | } else { 225 | $.nickName = $.UserName 226 | } 227 | } else { 228 | console.log(`京东服务器返回空数据`) 229 | } 230 | } 231 | } catch (e) { 232 | $.logErr(e, resp) 233 | } finally { 234 | resolve(); 235 | } 236 | }) 237 | }) 238 | } 239 | function safeGet(data) { 240 | try { 241 | if (typeof JSON.parse(data) == "object") { 242 | return true; 243 | } 244 | } catch (e) { 245 | console.log(e); 246 | console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); 247 | return false; 248 | } 249 | } 250 | function jsonParse(str) { 251 | if (typeof str == "string") { 252 | try { 253 | return JSON.parse(str); 254 | } catch (e) { 255 | console.log(e); 256 | $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') 257 | return []; 258 | } 259 | } 260 | } 261 | // prettier-ignore 262 | function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),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=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,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;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 263 | -------------------------------------------------------------------------------- /jd_mofang.js: -------------------------------------------------------------------------------- 1 | /* 2 | 搞鸡玩家-小魔方 3 | Last Modified time: 2022-1-21 4 | 活动入口:京东 首页新品 魔方 5 | 更新地址:jd_xmf.js 6 | 已支持IOS双京东账号, Node.js支持N个京东账号 7 | 脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js 8 | ============Quantumultx=============== 9 | [task_local] 10 | #搞鸡玩家-小魔方 11 | 10 8 * * * jd_xmf.js, tag=搞鸡玩家-小魔方, img-url=, enabled=true 12 | 13 | ================Loon============== 14 | [Script] 15 | cron "10 8 * * *" script-path=jd_xmf.js, tag=搞鸡玩家-小魔方 16 | 17 | ===============Surge================= 18 | 搞鸡玩家-小魔方 = type=cron,cronexp="10 8 * * *",wake-system=1,timeout=3600,script-path=jd_xmf.js 19 | 20 | ============小火箭========= 21 | 搞鸡玩家-小魔方 = type=cron,script-path=jd_xmf.js, cronexpr="10 8 * * *", timeout=3600, enable=true 22 | */ 23 | const $ = new Env('搞鸡玩家-小魔方'); 24 | const notify = $.isNode() ? require('./sendNotify') : ''; 25 | //Node.js用户请在jdCookie.js处填写京东ck; 26 | const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; 27 | //IOS等用户直接用NobyDa的jd cookie 28 | let cookiesArr = [], cookie = ''; 29 | var timestamp = Math.round(new Date().getTime()).toString(); 30 | $.shareCodes = []; 31 | if ($.isNode()) { 32 | Object.keys(jdCookieNode).forEach((item) => { 33 | cookiesArr.push(jdCookieNode[item]) 34 | }) 35 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { 36 | }; 37 | } else { 38 | cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); 39 | } 40 | !(async () => { 41 | if (!cookiesArr[0]) { 42 | $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); 43 | return; 44 | } 45 | UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); 46 | for (let i = 0; i < cookiesArr.length; i++) { 47 | UA = `jdapp;iPhone;10.0.8;14.6;${UUID};network/wifi;JDEbook/openapp.jdreader;model/iPhone9,2;addressid/2214222493;appBuild/168841;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16E158;supportJDSHWK/1`; 48 | if (cookiesArr[i]) { 49 | cookie = cookiesArr[i]; 50 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 51 | $.index = i + 1; 52 | $.isLogin = true; 53 | $.nickName = ''; 54 | message = ''; 55 | await TotalBean(); 56 | console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); 57 | if (!$.isLogin) { 58 | $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); 59 | 60 | if ($.isNode()) { 61 | await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); 62 | } 63 | continue 64 | } 65 | await main() 66 | } 67 | } 68 | })().catch((e) => { $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') }).finally(() => { $.done(); }) 69 | 70 | async function main() { 71 | await getInteractionHomeInfo(); 72 | await $.wait(500) 73 | await queryInteractiveInfo($.projectId) 74 | if ($.taskList) { 75 | for (const vo of $.taskList) { 76 | if (vo.ext.extraType !== 'brandMemberList' && vo.ext.extraType !== 'assistTaskDetail') { 77 | if (vo.completionCnt < vo.assignmentTimesLimit) { 78 | console.log(`任务:${vo.assignmentName},去完成`); 79 | if (vo.ext) { 80 | if (vo.ext.extraType === 'sign1') { 81 | await doInteractiveAssignment($.projectId, vo.encryptAssignmentId, vo.ext.sign1.itemId) 82 | } 83 | for (let vi of vo.ext.productsInfo ?? []) { 84 | if (vi.status === 1) { 85 | await doInteractiveAssignment($.projectId, vo.encryptAssignmentId, vi.itemId) 86 | } 87 | } 88 | for (let vi of vo.ext.shoppingActivity ?? []) { 89 | if (vi.status === 1) { 90 | await doInteractiveAssignment($.projectId, vo.encryptAssignmentId, vi.advId, 1) 91 | await $.wait(6000) 92 | await doInteractiveAssignment($.projectId, vo.encryptAssignmentId, vi.advId, 0) 93 | } 94 | } 95 | for (let vi of vo.ext.browseShop ?? []) { 96 | if (vi.status === 1) { 97 | await doInteractiveAssignment($.projectId, vo.encryptAssignmentId, vi.itemId, 1) 98 | await $.wait(6000) 99 | await doInteractiveAssignment($.projectId, vo.encryptAssignmentId, vi.itemId, 0) 100 | } 101 | } 102 | for (let vi of vo.ext.addCart ?? []) { 103 | if (vi.status === 1) { 104 | await doInteractiveAssignment($.projectId, vo.encryptAssignmentId, vi.itemId, 1) 105 | await $.wait(6000) 106 | await doInteractiveAssignment($.projectId, vo.encryptAssignmentId, vi.itemId, 0) 107 | } 108 | } 109 | } 110 | } else { 111 | console.log(`任务:${vo.assignmentName},已完成`); 112 | } 113 | } 114 | } 115 | } else { 116 | $.log('没有获取到活动信息') 117 | } 118 | } 119 | function doInteractiveAssignment(projectId, encryptAssignmentId, itemId, actionType) { 120 | let body = { "encryptProjectId": projectId, "encryptAssignmentId": encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": itemId, "actionType": actionType, "completionFlag": "", "ext": {},"extParam":{"businessData":{"random":25500725},"signStr":timestamp+"~1hj9fq9","sceneid":"XMFhPageh5"} } 121 | return new Promise(resolve => { 122 | $.post(taskPostUrl("doInteractiveAssignment", body), async (err, resp, data) => { 123 | //$.log(data) 124 | try { 125 | if (err) { 126 | console.log(`${err}`) 127 | console.log(`${$.name} API请求失败,请检查网路重试`) 128 | } else { 129 | if (data) { 130 | data = JSON.parse(data); 131 | console.log(data.msg); 132 | } else { 133 | console.log("没有返回数据") 134 | } 135 | } 136 | } catch (e) { 137 | $.logErr(e, resp) 138 | } finally { 139 | resolve(data); 140 | } 141 | }) 142 | }) 143 | } 144 | function queryInteractiveInfo(projectId) { 145 | let body = { "encryptProjectId": projectId, "sourceCode": "acexinpin0823", "ext": {} } 146 | return new Promise(resolve => { 147 | $.post(taskPostUrl("queryInteractiveInfo", body), async (err, resp, data) => { 148 | try { 149 | if (err) { 150 | console.log(`${err}`) 151 | console.log(`${$.name} API请求失败,请检查网路重试`) 152 | } else { 153 | if (data) { 154 | data = JSON.parse(data); 155 | $.taskList = data.assignmentList 156 | } else { 157 | console.log("没有返回数据") 158 | } 159 | } 160 | } catch (e) { 161 | $.logErr(e, resp) 162 | } finally { 163 | resolve(data); 164 | } 165 | }) 166 | }) 167 | } 168 | function getInteractionHomeInfo() { 169 | let body = { "sign": "u6vtLQ7ztxgykLEr" } 170 | return new Promise(resolve => { 171 | $.get(taskPostUrl("getInteractionHomeInfo", body), (err, resp, data) => { 172 | try { 173 | if (err) { 174 | console.log(`${err}`) 175 | console.log(`${$.name} API请求失败,请检查网路重试`) 176 | } else { 177 | data = JSON.parse(data) 178 | if (data) { 179 | if (data.result.giftConfig) { 180 | $.projectId = data.result.taskConfig.projectId 181 | } else { 182 | console.log("获取projectId失败"); 183 | } 184 | } else { 185 | console.log(JSON.stringify(data)); 186 | } 187 | } 188 | } catch (e) { 189 | $.logErr(e, resp) 190 | } finally { 191 | resolve(data); 192 | } 193 | }) 194 | }) 195 | } 196 | function taskPostUrl(function_id, body) { 197 | return { 198 | url: `https://api.m.jd.com/?functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=content_ecology&client=wh5&clientVersion=1.0.0`, 199 | headers: { 200 | "Host": "api.m.jd.com", 201 | "Content-Type": "application/x-www-form-urlencoded", 202 | "Origin": "https://h5.m.jd.com", 203 | "Accept-Encoding": "gzip, deflate, br", 204 | "Connection": "keep-alive", 205 | "Accept": "application/json, text/plain, */*", 206 | "User-Agent": UA, 207 | "Referer": "https://h5.m.jd.com/babelDiy/Zeus/2bf3XEEyWG11pQzPGkKpKX2GxJz2/index.html", 208 | "Cookie": cookie, 209 | } 210 | } 211 | } 212 | function getUUID(x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", t = 0) { return x.replace(/[xy]/g, function (x) { var r = 16 * Math.random() | 0, n = "x" == x ? r : 3 & r | 8; return uuid = t ? n.toString(36).toUpperCase() : n.toString(36), uuid }) } 213 | function TotalBean() { return new Promise(async e => { const n = { url: "https://wq.jd.com/user_new/info/GetJDUserInfoUnion?sceneval=2", headers: { Host: "wq.jd.com", Accept: "*/*", Connection: "keep-alive", Cookie: cookie, "User-Agent": UA, "Accept-Language": "zh-cn", Referer: "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", "Accept-Encoding": "gzip, deflate, br" } }; $.get(n, (n, o, a) => { try { if (n) $.logErr(n); else if (a) { if (1001 === (a = JSON.parse(a))["retcode"]) return void ($.isLogin = !1); 0 === a["retcode"] && a.data && a.data.hasOwnProperty("userInfo") && ($.nickName = a.data.userInfo.baseInfo.nickname), 0 === a["retcode"] && a.data && a.data["assetInfo"] && ($.beanCount = a.data && a.data["assetInfo"]["beanNum"]) } else console.log("京东服务器返回空数据") } catch (e) { $.logErr(e) } finally { e() } }) }) } 214 | function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), 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 = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, 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; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } 215 | -------------------------------------------------------------------------------- /jd_ms.js: -------------------------------------------------------------------------------- 1 | /* 2 | 搞鸡玩家-秒秒币 3 | Last Modified time: 2022-1-21 4 | 活动入口:京东 首页秒杀 5 | 更新地址:jd_ms.js 6 | 已支持IOS双京东账号, Node.js支持N个京东账号 7 | 脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js 8 | ============Quantumultx=============== 9 | [task_local] 10 | #搞鸡玩家-秒秒币 11 | 10 8 * * * jd_ms.js, tag=搞鸡玩家-秒秒币, img-url=, enabled=true 12 | 13 | ================Loon============== 14 | [Script] 15 | cron "10 8 * * *" script-path=jd_ms.js, tag=搞鸡玩家-秒秒币 16 | 17 | ===============Surge================= 18 | 搞鸡玩家-秒秒币 = type=cron,cronexp="10 8 * * *",wake-system=1,timeout=3600,script-path=jd_ms.js 19 | 20 | ============小火箭========= 21 | 搞鸡玩家-秒秒币 = type=cron,script-path=jd_ms.js, cronexpr="10 8 * * *", timeout=3600, enable=true 22 | */ 23 | const $ = new Env('搞鸡玩家-秒秒币'); 24 | 25 | const notify = $.isNode() ? require('./sendNotify') : ''; 26 | //Node.js用户请在jdCookie.js处填写京东ck; 27 | const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; 28 | var timestamp = Math.round(new Date().getTime()).toString(); 29 | //IOS等用户直接用NobyDa的jd cookie 30 | let cookiesArr = [], cookie = '', message; 31 | if ($.isNode()) { 32 | Object.keys(jdCookieNode).forEach((item) => { 33 | cookiesArr.push(jdCookieNode[item]) 34 | }) 35 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { 36 | }; 37 | if(JSON.stringify(process.env).indexOf('GITHUB')>-1) process.exit(0) 38 | } else { 39 | cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); 40 | } 41 | const JD_API_HOST = 'https://api.m.jd.com/client.action'; 42 | !(async () => { 43 | if (!cookiesArr[0]) { 44 | $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 45 | return; 46 | } 47 | for (let i = 0; i < cookiesArr.length; i++) { 48 | if (cookiesArr[i]) { 49 | cookie = cookiesArr[i]; 50 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 51 | $.index = i + 1; 52 | $.isLogin = true; 53 | $.nickName = ''; 54 | message = ''; 55 | await TotalBean(); 56 | console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); 57 | if (!$.isLogin) { 58 | $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); 59 | 60 | if ($.isNode()) { 61 | await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); 62 | } 63 | continue 64 | } 65 | console.log(`通天塔签到`) 66 | await tttsign() 67 | await jdMs() 68 | } 69 | } 70 | })() 71 | .catch((e) => { 72 | $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') 73 | }) 74 | .finally(() => { 75 | $.done(); 76 | }) 77 | 78 | async function jdMs() { 79 | $.score = 0 80 | await getActInfo() 81 | await getUserInfo() 82 | await getActInfo() 83 | $.cur = $.score 84 | if ($.encryptProjectId) { 85 | console.log(`领红包签到`) 86 | await readpacksign() 87 | await getTaskList() 88 | } 89 | await getUserInfo(false) 90 | 91 | await showMsg() 92 | } 93 | 94 | function getActInfo() { 95 | return new Promise(resolve => { 96 | $.post(taskPostUrl('assignmentList', {}, 'appid=jwsp'), (err, resp, data) => { 97 | try { 98 | if (err) { 99 | console.log(`${err},${jsonParse(resp.body)['message']}`) 100 | console.log(`${$.name} API请求失败,请检查网路重试`) 101 | } else { 102 | if (safeGet(data)) { 103 | data = JSON.parse(data) 104 | if (data.code === 200) { 105 | $.encryptProjectId = data.result.assignmentResult.encryptProjectId 106 | console.log(`活动名称:${data.result.assignmentResult.projectName}`) 107 | sourceCode = data.result.sourceCode 108 | } 109 | } 110 | } 111 | } catch (e) { 112 | $.logErr(e, resp) 113 | } finally { 114 | resolve(data); 115 | } 116 | }) 117 | }) 118 | } 119 | function getUserInfo(info=true) { 120 | return new Promise(resolve => { 121 | $.post(taskPostUrl('homePageV2', {}, 'appid=SecKill2020'), (err, resp, data) => { 122 | try { 123 | if (err) { 124 | console.log(`${err},${jsonParse(resp.body)['message']}`) 125 | console.log(`${$.name} API请求失败,请检查网路重试`) 126 | } else { 127 | if (safeGet(data)) { 128 | data = JSON.parse(data) 129 | if (data.code === 2041) { 130 | $.score = data.result.assignment.assignmentPoints || 0 131 | if(info) console.log(`当前秒秒币${$.score}`) 132 | } 133 | } 134 | } 135 | } catch (e) { 136 | $.logErr(e, resp) 137 | } finally { 138 | resolve(data); 139 | } 140 | }) 141 | }) 142 | } 143 | 144 | function getTaskList() { 145 | let body = {"encryptProjectId": $.encryptProjectId, "sourceCode": "wh5"} 146 | return new Promise(resolve => { 147 | $.post(taskPostUrl('queryInteractiveInfo', body), async (err, resp, data) => { 148 | try { 149 | if (err) { 150 | console.log(`${err},${jsonParse(resp.body)['message']}`) 151 | console.log(`${$.name} API请求失败,请检查网路重试`) 152 | } else { 153 | if (safeGet(data)) { 154 | data = JSON.parse(data) 155 | $.risk = false 156 | if (data.code === '0') { 157 | for (let vo of data.assignmentList) { 158 | if($.risk) break 159 | if (vo['completionCnt'] < vo['assignmentTimesLimit']) { 160 | if (vo['assignmentType'] === 1) { 161 | if(vo['ext'][vo['ext']['extraType']].length === 0) continue; 162 | for (let i = vo['completionCnt']; i < vo['assignmentTimesLimit']; ++i) { 163 | console.log(`去做${vo['assignmentName']}任务:${i + 1}/${vo['assignmentTimesLimit']}`) 164 | let body = { 165 | "encryptAssignmentId": vo['encryptAssignmentId'], 166 | "itemId": vo['ext'][vo['ext']['extraType']][i]['itemId'], 167 | "actionType": 1, 168 | "completionFlag": "" 169 | } 170 | await doTask(body) 171 | await $.wait(vo['ext']['waitDuration'] * 1000 + 500) 172 | body['actionType'] = 0 173 | await doTask(body) 174 | } 175 | } else if (vo['assignmentType'] === 0) { 176 | for (let i = vo['completionCnt']; i < vo['assignmentTimesLimit']; ++i) { 177 | console.log(`去做${vo['assignmentName']}任务:${i + 1}/${vo['assignmentTimesLimit']}`) 178 | let body = { 179 | "encryptAssignmentId": vo['encryptAssignmentId'], 180 | "itemId": "", 181 | "actionType": "0", 182 | "completionFlag": true 183 | } 184 | await doTask(body) 185 | await $.wait(1000) 186 | } 187 | } else if (vo['assignmentType'] === 3) { 188 | for (let i = vo['completionCnt']; i < vo['assignmentTimesLimit']; ++i) { 189 | console.log(`去做${vo['assignmentName']}任务:${i + 1}/${vo['assignmentTimesLimit']}`) 190 | let body = { 191 | "encryptAssignmentId": vo['encryptAssignmentId'], 192 | "itemId": vo['ext'][vo['ext']['extraType']][i]['itemId'], 193 | "actionType": 0, 194 | "completionFlag": "" 195 | } 196 | await doTask(body) 197 | await $.wait(1000) 198 | } 199 | } 200 | } 201 | } 202 | } else { 203 | console.log(data) 204 | } 205 | } 206 | } 207 | } catch (e) { 208 | $.logErr(e, resp) 209 | } finally { 210 | resolve(data); 211 | } 212 | }) 213 | }) 214 | } 215 | 216 | function doTask(body) { 217 | body = {...body, "encryptProjectId": $.encryptProjectId, "sourceCode": sourceCode, "ext": {},"extParam":{"businessData":{"random":25500725},"signStr":timestamp+"~1hj9fq9","sceneid":"MShPageh5"} } 218 | return new Promise(resolve => { 219 | $.post(taskPostUrl('doInteractiveAssignment', body), (err, resp, data) => { 220 | try { 221 | if (err) { 222 | console.log(`${err},${jsonParse(resp.body)['message']}`) 223 | console.log(`${$.name} API请求失败,请检查网路重试`) 224 | } else { 225 | if (safeGet(data)) { 226 | data = JSON.parse(data) 227 | console.log(data.msg) 228 | if(data.msg==='风险等级未通过') $.risk =1 229 | } 230 | } 231 | } catch (e) { 232 | $.logErr(e, resp) 233 | } finally { 234 | resolve(data); 235 | } 236 | }) 237 | }) 238 | } 239 | 240 | function tttsign() { 241 | return new Promise(resolve => { 242 | body = 'appid=babelh5&body=%7B%22encryptProjectId%22%3A%224NzhoLbAJtBXbyRj5zGwprtf6GDv%22%2C%22encryptAssignmentId%22%3A%223yRMFkp3SN8nXpX49xAdCWsdy5XP%22%2C%22completionFlag%22%3Atrue%2C%22itemId%22%3A%221%22%2C%22sourceCode%22%3A%22aceaceqingzhan%22%7D&sign=11&t=1642929553660' 243 | $.post(ttt(body), (err, resp, data) => { 244 | try { 245 | if (err) { 246 | console.log(`${err},${jsonParse(resp.body)['message']}`) 247 | console.log(`${$.name} API请求失败,请检查网路重试`) 248 | } else { 249 | if (safeGet(data)) { 250 | data = JSON.parse(data) 251 | if (data.code === 0) { 252 | rewardsInfo = data.rewardsInfo.failRewards[0].msg 253 | console.log(`${rewardsInfo}`) 254 | }else console.log(data.msg) 255 | } 256 | } 257 | } catch (e) { 258 | $.logErr(e, resp) 259 | } finally { 260 | resolve(data); 261 | } 262 | }) 263 | }) 264 | } 265 | function readpacksign() { 266 | return new Promise(resolve => { 267 | body = 'uuid=88888&clientVersion=10.3.4&client=wh5&osVersion=&area=4_48201_54794_0&networkType=unknown&functionId=signRedPackage&body={"random":"23715587","log":"~1oji7rf","sceneid":"MShPageh5","ext":{"platform":"1","eid":"","referUrl":-1,"userAgent":-1}}&appid=SecKill2020' 268 | $.post(readpack(body), (err, resp, data) => { 269 | 270 | try { 271 | if (err) { 272 | console.log(`${err},${jsonParse(resp.body)['message']}`) 273 | console.log(`${$.name} API请求失败,请检查网路重试`) 274 | } else { 275 | if (safeGet(data)) { 276 | data = JSON.parse(data) 277 | if (data.code === 200) { 278 | rewardsInfo = data.result.assignmentResult.msg 279 | console.log(`${rewardsInfo}`) 280 | }else console.log("今日签到红包已领") 281 | } 282 | } 283 | } catch (e) { 284 | $.logErr(e, resp) 285 | } finally { 286 | resolve(data); 287 | } 288 | }) 289 | }) 290 | } 291 | function showMsg() { 292 | return new Promise(resolve => { 293 | message += `本次运行获得秒秒币${$.score-$.cur}枚,共${$.score}枚`; 294 | $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); 295 | resolve() 296 | }) 297 | } 298 | function ttt(body) { 299 | let url = `${JD_API_HOST}client.action?functionId=doInteractiveAssignment`; 300 | 301 | return { 302 | url, 303 | body: body, 304 | headers: { 305 | "Cookie": cookie, 306 | "origin": "https://prodev.m.jd.com", 307 | 308 | 'Content-Type': 'application/x-www-form-urlencoded', 309 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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"), 310 | } 311 | } 312 | } 313 | function readpack(body) { 314 | let url = `${JD_API_HOST}client.action`; 315 | 316 | return { 317 | url, 318 | body: body, 319 | headers: { 320 | "Cookie": cookie, 321 | "origin": "https://h5.m.jd.com", 322 | 323 | 'Content-Type': 'application/x-www-form-urlencoded', 324 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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"), 325 | } 326 | } 327 | } 328 | function taskPostUrl(function_id, body = {}, extra = '', function_id2) { 329 | let url = `${JD_API_HOST}`; 330 | if (function_id2) { 331 | url += `?functionId=${function_id2}`; 332 | } 333 | return { 334 | url, 335 | body: `functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&${extra}`, 336 | headers: { 337 | "Cookie": cookie, 338 | "origin": "https://h5.m.jd.com", 339 | "referer": "https://h5.m.jd.com/babelDiy/Zeus/2NUvze9e1uWf4amBhe1AV6ynmSuH/index.html", 340 | 'Content-Type': 'application/x-www-form-urlencoded', 341 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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"), 342 | } 343 | } 344 | } 345 | 346 | function TotalBean() { 347 | return new Promise(async resolve => { 348 | const options = { 349 | "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, 350 | "headers": { 351 | "Accept": "application/json,text/plain, */*", 352 | "Content-Type": "application/x-www-form-urlencoded", 353 | "Accept-Encoding": "gzip, deflate, br", 354 | "Accept-Language": "zh-cn", 355 | "Connection": "keep-alive", 356 | "Cookie": cookie, 357 | "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", 358 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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") 359 | } 360 | } 361 | $.post(options, (err, resp, data) => { 362 | try { 363 | if (err) { 364 | console.log(`${JSON.stringify(err)}`) 365 | console.log(`${$.name} API请求失败,请检查网路重试`) 366 | } else { 367 | if (data) { 368 | data = JSON.parse(data); 369 | if (data['retcode'] === 13) { 370 | $.isLogin = false; //cookie过期 371 | return 372 | } 373 | if (data['retcode'] === 0) { 374 | $.nickName = (data['base'] && data['base'].nickname) || $.UserName; 375 | } else { 376 | $.nickName = $.UserName 377 | } 378 | } else { 379 | console.log(`京东服务器返回空数据`) 380 | } 381 | } 382 | } catch (e) { 383 | $.logErr(e, resp) 384 | } finally { 385 | resolve(); 386 | } 387 | }) 388 | }) 389 | } 390 | 391 | function safeGet(data) { 392 | try { 393 | if (typeof JSON.parse(data) == "object") { 394 | return true; 395 | } 396 | } catch (e) { 397 | console.log(e); 398 | console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); 399 | return false; 400 | } 401 | } 402 | 403 | function jsonParse(str) { 404 | if (typeof str == "string") { 405 | try { 406 | return JSON.parse(str); 407 | } catch (e) { 408 | console.log(e); 409 | $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie') 410 | return []; 411 | } 412 | } 413 | } 414 | // prettier-ignore 415 | function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),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=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,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;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 416 | -------------------------------------------------------------------------------- /jd_pet-help.js: -------------------------------------------------------------------------------- 1 | 2 | const $ = new Env('搞鸡玩家-东东萌宠互助'); 3 | let cookiesArr = [], cookie = '', jdPetShareArr = [], isBox = false, notify, newShareCodes, allMessage = ''; 4 | 5 | let shareCodes = [] 6 | let message = '', subTitle = '', option = {}; 7 | let jdNotify = false;//是否关闭通知,false打开通知推送,true关闭通知推送 8 | const JD_API_HOST = 'https://api.m.jd.com/client.action'; 9 | let goodsUrl = '', taskInfoKey = []; 10 | let randomCount = $.isNode() ? 20 : 5; 11 | !(async () => { 12 | await requireConfig(); 13 | if (!cookiesArr[0]) { 14 | $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 15 | return; 16 | } 17 | for (let i = 0; i < cookiesArr.length; i++) { 18 | if (cookiesArr[i]) { 19 | cookie = cookiesArr[i]; 20 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 21 | $.index = i + 1; 22 | $.isLogin = true; 23 | $.nickName = ''; 24 | await TotalBean(); 25 | console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); 26 | if (!$.isLogin) { 27 | $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 28 | 29 | if ($.isNode()) { 30 | await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); 31 | } 32 | continue 33 | } 34 | message = ''; 35 | subTitle = ''; 36 | goodsUrl = ''; 37 | taskInfoKey = []; 38 | option = {}; 39 | // await shareCodesFormat(); 40 | await jdPet(); 41 | } 42 | } 43 | console.log(`\n开始账号内互助\n`); 44 | for (let i = 0; i < cookiesArr.length; i++) { 45 | cookie = cookiesArr[i]; 46 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 47 | 48 | console.log('开始助力好友') 49 | 50 | console.log(`格式化后的助力码::${JSON.stringify(shareCodes)}\n`); 51 | let helpPeoples = ''; 52 | 53 | await slaveHelp() 54 | 55 | } 56 | })() 57 | .catch((e) => { 58 | $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') 59 | }) 60 | .finally(() => { 61 | $.done(); 62 | }) 63 | async function jdPet() { 64 | try { 65 | //查询jd宠物信息 66 | const initPetTownRes = await request('initPetTown'); 67 | message = `【京东账号${$.index}】${$.nickName || $.UserName}\n`; 68 | if (initPetTownRes.code === '0' && initPetTownRes.resultCode === '0' && initPetTownRes.message === 'success') { 69 | $.petInfo = initPetTownRes.result; 70 | 71 | console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.petInfo.shareCode}\n`); 72 | shareCodes.push($.petInfo.shareCode) 73 | console.log(`收集邀请码‼️`) 74 | } else if (initPetTownRes.code === '0'){ 75 | console.log(`初始化萌宠失败: ${initPetTownRes.message}`); 76 | } 77 | } catch (e) { 78 | $.logErr(e) 79 | const errMsg = `京东账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`; 80 | if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg); 81 | $.msg($.name, '', `${errMsg}`) 82 | } 83 | } 84 | 85 | 86 | 87 | async function slaveHelp() { 88 | //$.log(`\n因1.6日好友助力功能下线。故暂时屏蔽\n`) 89 | //return 90 | let helpPeoples = ''; 91 | for (let code of shareCodes) { 92 | console.log(`开始助力京东账号${code}`); 93 | if (!code) continue; 94 | let response = await request(arguments.callee.name.toString(), {'shareCode': code}); 95 | if (response.code === '0' && response.resultCode === '0') { 96 | if (response.result.helpStatus === 0) { 97 | console.log('已给好友: 【' + response.result.masterNickName + '】助力成功'); 98 | helpPeoples += response.result.masterNickName + ','; 99 | } else if (response.result.helpStatus === 1) { 100 | // 您今日已无助力机会 101 | console.log(`助力好友${response.result.masterNickName}失败,您今日已无助力机会`); 102 | break; 103 | } else if (response.result.helpStatus === 2) { 104 | //该好友已满5人助力,无需您再次助力 105 | console.log(`该好友${response.result.masterNickName}已满5人助力,无需您再次助力`); 106 | } else { 107 | console.log(`助力其他情况:${JSON.stringify(response)}`); 108 | } 109 | } else { 110 | console.log(`助力好友结果: ${response.message}`); 111 | } 112 | } 113 | if (helpPeoples && helpPeoples.length > 0) { 114 | message += `【您助力的好友】${helpPeoples.substr(0, helpPeoples.length - 1)}\n`; 115 | } 116 | } 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | async function showMsg() { 129 | if ($.isNode() && process.env.PET_NOTIFY_CONTROL) { 130 | $.ctrTemp = `${process.env.PET_NOTIFY_CONTROL}` === 'false'; 131 | } else if ($.getdata('jdPetNotify')) { 132 | $.ctrTemp = $.getdata('jdPetNotify') === 'false'; 133 | } else { 134 | $.ctrTemp = `${jdNotify}` === 'false'; 135 | } 136 | // jdNotify = `${notify.petNotifyControl}` === 'false' && `${jdNotify}` === 'false' && $.getdata('jdPetNotify') === 'false'; 137 | if ($.ctrTemp) { 138 | $.msg($.name, subTitle, message, option); 139 | if ($.isNode()) { 140 | allMessage += `${subTitle}\n${message}${$.index !== cookiesArr.length ? '\n\n' : ''}` 141 | // await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}`, `${subTitle}\n${message}`); 142 | } 143 | } else { 144 | $.log(`\n${message}\n`); 145 | } 146 | } 147 | 148 | 149 | function requireConfig() { 150 | return new Promise(resolve => { 151 | console.log('开始获取东东萌宠配置文件\n') 152 | notify = $.isNode() ? require('./sendNotify') : ''; 153 | //Node.js用户请在jdCookie.js处填写京东ck; 154 | const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; 155 | 156 | //IOS等用户直接用NobyDa的jd cookie 157 | if ($.isNode()) { 158 | Object.keys(jdCookieNode).forEach((item) => { 159 | if (jdCookieNode[item]) { 160 | cookiesArr.push(jdCookieNode[item]) 161 | } 162 | }) 163 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; 164 | } else { 165 | cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); 166 | } 167 | console.log(`共${cookiesArr.length}个京东账号\n`) 168 | 169 | resolve() 170 | }) 171 | } 172 | function TotalBean() { 173 | return new Promise(async resolve => { 174 | const options = { 175 | "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, 176 | "headers": { 177 | "Accept": "application/json,text/plain, */*", 178 | "Content-Type": "application/x-www-form-urlencoded", 179 | "Accept-Encoding": "gzip, deflate, br", 180 | "Accept-Language": "zh-cn", 181 | "Connection": "keep-alive", 182 | "Cookie": cookie, 183 | "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", 184 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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") 185 | } 186 | } 187 | $.post(options, (err, resp, data) => { 188 | try { 189 | if (err) { 190 | console.log(`${JSON.stringify(err)}`) 191 | console.log(`${$.name} API请求失败,请检查网路重试`) 192 | } else { 193 | if (data) { 194 | data = JSON.parse(data); 195 | if (data['retcode'] === 13) { 196 | $.isLogin = false; //cookie过期 197 | return 198 | } 199 | if (data['retcode'] === 0 && data.base && data.base.nickname) { 200 | $.nickName = data.base.nickname; 201 | } 202 | } else { 203 | console.log(`京东服务器返回空数据`) 204 | } 205 | } 206 | } catch (e) { 207 | $.logErr(e) 208 | } finally { 209 | resolve(); 210 | } 211 | }) 212 | }) 213 | } 214 | // 请求 215 | async function request(function_id, body = {}) { 216 | await $.wait(3000); //歇口气儿, 不然会报操作频繁 217 | return new Promise((resolve, reject) => { 218 | $.post(taskUrl(function_id, body), (err, resp, data) => { 219 | try { 220 | if (err) { 221 | console.log('\n东东萌宠: API查询请求失败 ‼️‼️'); 222 | console.log(JSON.stringify(err)); 223 | $.logErr(err); 224 | } else { 225 | data = JSON.parse(data); 226 | } 227 | } catch (e) { 228 | $.logErr(e, resp); 229 | } finally { 230 | resolve(data) 231 | } 232 | }) 233 | }) 234 | } 235 | // function taskUrl(function_id, body = {}) { 236 | // return { 237 | // url: `${JD_API_HOST}?functionId=${function_id}&appid=wh5&loginWQBiz=pet-town&body=${escape(JSON.stringify(body))}`, 238 | // headers: { 239 | // Cookie: cookie, 240 | // UserAgent: $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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"), 241 | // } 242 | // }; 243 | // } 244 | function taskUrl(function_id, body = {}) { 245 | body["version"] = 2; 246 | body["channel"] = 'app'; 247 | return { 248 | url: `${JD_API_HOST}?functionId=${function_id}`, 249 | body: `body=${escape(JSON.stringify(body))}&appid=wh5&loginWQBiz=pet-town&clientVersion=9.0.4`, 250 | headers: { 251 | 'Cookie': cookie, 252 | 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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"), 253 | 'Host': 'api.m.jd.com', 254 | 'Content-Type': 'application/x-www-form-urlencoded', 255 | } 256 | }; 257 | } 258 | function jsonParse(str) { 259 | if (typeof str == "string") { 260 | try { 261 | return JSON.parse(str); 262 | } catch (e) { 263 | console.log(e); 264 | $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') 265 | return []; 266 | } 267 | } 268 | } 269 | // prettier-ignore 270 | function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),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=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,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;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 271 | -------------------------------------------------------------------------------- /jd_planbean-help.js: -------------------------------------------------------------------------------- 1 | 2 | const $ = new Env('搞鸡玩家-种豆得豆互助'); 3 | //Node.js用户请在jdCookie.js处填写京东ck; 4 | //ios等软件用户直接用NobyDa的jd cookie 5 | let jdNotify = true;//是否开启静默运行。默认true开启 6 | let cookiesArr = [], cookie = '', jdPlantBeanShareArr = [], isBox = false, notify, newShareCodes, option, message,subTitle; 7 | //京东接口地址 8 | const JD_API_HOST = 'https://api.m.jd.com/client.action'; 9 | 10 | 11 | newShareCodes = [] 12 | let allMessage = ``; 13 | let currentRoundId = null;//本期活动id 14 | let lastRoundId = null;//上期id 15 | let roundList = []; 16 | let awardState = '';//上期活动的京豆是否收取 17 | let randomCount = $.isNode() ? 20 : 5; 18 | let num; 19 | !(async () => { 20 | await requireConfig(); 21 | if (!cookiesArr[0]) { 22 | $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 23 | return; 24 | } 25 | for (let i = 0; i < cookiesArr.length; i++) { 26 | if (cookiesArr[i]) { 27 | cookie = cookiesArr[i]; 28 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 29 | $.index = i + 1; 30 | $.isLogin = true; 31 | $.nickName = ''; 32 | await TotalBean(); 33 | console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); 34 | if (!$.isLogin) { 35 | $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 36 | 37 | if ($.isNode()) { 38 | await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); 39 | } 40 | continue 41 | } 42 | message = ''; 43 | subTitle = ''; 44 | option = {}; 45 | 46 | await jdPlantBean(); 47 | 48 | } 49 | } 50 | console.log(`\n开始账号内互助\n`); 51 | for (let i = 0; i < cookiesArr.length; i++) { 52 | cookie = cookiesArr[i]; 53 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 54 | 55 | console.log('开始助力好友') 56 | 57 | console.log(`格式化后的助力码::${JSON.stringify(newShareCodes)}\n`); 58 | 59 | 60 | await doHelp() 61 | 62 | } 63 | })().catch((e) => { 64 | $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') 65 | }).finally(() => { 66 | $.done(); 67 | }) 68 | 69 | async function jdPlantBean() { 70 | try { 71 | 72 | await plantBeanIndex(); 73 | if ($.plantBeanIndexResult.errorCode === 'PB101') { 74 | console.log(`\n活动太火爆了,还是去买买买吧!\n`) 75 | return 76 | } 77 | for (let i = 0; i < $.plantBeanIndexResult.data.roundList.length; i++) { 78 | if ($.plantBeanIndexResult.data.roundList[i].roundState === "2") { 79 | num = i 80 | break 81 | } 82 | } 83 | // console.log(plantBeanIndexResult.data.taskList); 84 | if ($.plantBeanIndexResult && $.plantBeanIndexResult.code === '0' && $.plantBeanIndexResult.data) { 85 | const shareUrl = $.plantBeanIndexResult.data.jwordShareInfo.shareUrl 86 | $.myPlantUuid = getParam(shareUrl, 'plantUuid') 87 | console.log(`\n【京东账号${$.index}(${$.UserName})互助码】${$.myPlantUuid}\n`); 88 | newShareCodes.push($.myPlantUuid) 89 | $.log('收集邀请码!!!') 90 | 91 | } else { 92 | console.log(`种豆得豆-初始失败: ${JSON.stringify($.plantBeanIndexResult)}`); 93 | } 94 | } catch (e) { 95 | $.logErr(e); 96 | const errMsg = `京东账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`; 97 | if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg); 98 | $.msg($.name, '', `${errMsg}`) 99 | } 100 | } 101 | 102 | 103 | 104 | //助力好友 105 | async function doHelp() { 106 | for (let plantUuid of newShareCodes) { 107 | console.log(`开始助力`); 108 | if (!plantUuid) continue; 109 | if (plantUuid === $.myPlantUuid) { 110 | console.log(`\n跳过自己的plantUuid\n`) 111 | continue 112 | } 113 | await helpShare(plantUuid); 114 | if ($.helpResult && $.helpResult.code === '0') { 115 | 116 | if ($.helpResult.data.helpShareRes) { 117 | if ($.helpResult.data.helpShareRes.state === '1') { 118 | console.log(`助力好友成功`) 119 | console.log(`${$.helpResult.data.helpShareRes.promptText}\n`); 120 | } else if ($.helpResult.data.helpShareRes.state === '2') { 121 | console.log('您今日助力的机会已耗尽,已不能再帮助好友助力了\n'); 122 | break; 123 | } else if ($.helpResult.data.helpShareRes.state === '3') { 124 | console.log('该好友今日已满9人助力/20瓶营养液,明天再来为Ta助力吧\n') 125 | } else if ($.helpResult.data.helpShareRes.state === '4') { 126 | console.log(`${$.helpResult.data.helpShareRes.promptText}\n`) 127 | } else { 128 | console.log(`助力其他情况:${JSON.stringify($.helpResult.data.helpShareRes)}`); 129 | } 130 | } 131 | } else { 132 | console.log(`助力好友失败: ${JSON.stringify($.helpResult)}`); 133 | } 134 | } 135 | } 136 | function showMsg() { 137 | $.log(`\n${message}\n`); 138 | jdNotify = $.getdata('jdPlantBeanNotify') ? $.getdata('jdPlantBeanNotify') : jdNotify; 139 | if (!jdNotify || jdNotify === 'false') { 140 | $.msg($.name, subTitle, message); 141 | } 142 | } 143 | 144 | //助力好友的api 145 | async function helpShare(plantUuid) { 146 | 147 | const body = { 148 | "plantUuid": plantUuid, 149 | "wxHeadImgUrl": "", 150 | "shareUuid": "", 151 | "followType": "1", 152 | } 153 | $.helpResult = await request(`plantBeanIndex`, body); 154 | console.log(`助力结果的code:${$.helpResult && $.helpResult.code}`); 155 | } 156 | async function plantBeanIndex() { 157 | $.plantBeanIndexResult = await request('plantBeanIndex');//plantBeanIndexBody 158 | } 159 | 160 | function requireConfig() { 161 | return new Promise(resolve => { 162 | console.log('开始获取种豆得豆配置文件\n') 163 | notify = $.isNode() ? require('./sendNotify') : ''; 164 | //Node.js用户请在jdCookie.js处填写京东ck; 165 | const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; 166 | 167 | //IOS等用户直接用NobyDa的jd cookie 168 | if ($.isNode()) { 169 | Object.keys(jdCookieNode).forEach((item) => { 170 | if (jdCookieNode[item]) { 171 | cookiesArr.push(jdCookieNode[item]) 172 | } 173 | }) 174 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; 175 | } else { 176 | cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); 177 | } 178 | console.log(`共${cookiesArr.length}个京东账号\n`) 179 | 180 | resolve() 181 | }) 182 | } 183 | function requestGet(function_id, body = {}) { 184 | if (!body.version) { 185 | body["version"] = "9.0.0.1"; 186 | } 187 | body["monitor_source"] = "plant_app_plant_index"; 188 | body["monitor_refer"] = ""; 189 | return new Promise(async resolve => { 190 | await $.wait(2000); 191 | const option = { 192 | url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=ld`, 193 | headers: { 194 | 'Cookie': cookie, 195 | 'Host': 'api.m.jd.com', 196 | 'Accept': '*/*', 197 | 'Connection': 'keep-alive', 198 | 'User-Agent': 'JD4iPhone/167283 (iPhone;iOS 13.6.1;Scale/3.00)', 199 | 'Accept-Language': 'zh-Hans-CN;q=1,en-CN;q=0.9', 200 | 'Accept-Encoding': 'gzip, deflate, br', 201 | 'Content-Type': "application/x-www-form-urlencoded" 202 | }, 203 | timeout: 10000, 204 | }; 205 | $.get(option, (err, resp, data) => { 206 | try { 207 | if (err) { 208 | console.log('\n种豆得豆: API查询请求失败 ‼️‼️') 209 | $.logErr(err); 210 | } else { 211 | data = JSON.parse(data); 212 | } 213 | } catch (e) { 214 | $.logErr(e, resp); 215 | } finally { 216 | resolve(data); 217 | } 218 | }) 219 | }) 220 | } 221 | function TotalBean() { 222 | return new Promise(async resolve => { 223 | const options = { 224 | "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, 225 | "headers": { 226 | "Accept": "application/json,text/plain, */*", 227 | "Content-Type": "application/x-www-form-urlencoded", 228 | "Accept-Encoding": "gzip, deflate, br", 229 | "Accept-Language": "zh-cn", 230 | "Connection": "keep-alive", 231 | "Cookie": cookie, 232 | "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", 233 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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") 234 | }, 235 | "timeout": 10000, 236 | } 237 | $.post(options, (err, resp, data) => { 238 | try { 239 | if (err) { 240 | console.log(`${JSON.stringify(err)}`) 241 | console.log(`${$.name} API请求失败,请检查网路重试`) 242 | } else { 243 | if (data) { 244 | data = JSON.parse(data); 245 | if (data['retcode'] === 13) { 246 | $.isLogin = false; //cookie过期 247 | return 248 | } 249 | if (data['retcode'] === 0) { 250 | $.nickName = (data['base'] && data['base'].nickname) || $.UserName; 251 | } else { 252 | $.nickName = $.UserName 253 | } 254 | } else { 255 | console.log(`京东服务器返回空数据`) 256 | } 257 | } 258 | } catch (e) { 259 | $.logErr(e, resp) 260 | } finally { 261 | resolve(); 262 | } 263 | }) 264 | }) 265 | } 266 | function request(function_id, body = {}){ 267 | return new Promise(async resolve => { 268 | await $.wait(2000); 269 | $.post(taskUrl(function_id, body), (err, resp, data) => { 270 | try { 271 | if (err) { 272 | console.log('\n种豆得豆: API查询请求失败 ‼️‼️') 273 | console.log(`function_id:${function_id}`) 274 | $.logErr(err); 275 | } else { 276 | data = JSON.parse(data); 277 | } 278 | } catch (e) { 279 | $.logErr(e, resp); 280 | } finally { 281 | resolve(data); 282 | } 283 | }) 284 | }) 285 | } 286 | function taskUrl(function_id, body) { 287 | body["version"] = "9.2.4.0"; 288 | body["monitor_source"] = "plant_app_plant_index"; 289 | body["monitor_refer"] = ""; 290 | return { 291 | url: JD_API_HOST, 292 | body: `functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=ld&client=apple&area=19_1601_50258_51885&build=167490&clientVersion=9.3.2`, 293 | headers: { 294 | "Cookie": cookie, 295 | "Host": "api.m.jd.com", 296 | "Accept": "*/*", 297 | "Connection": "keep-alive", 298 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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"), 299 | "Accept-Language": "zh-Hans-CN;q=1,en-CN;q=0.9", 300 | "Accept-Encoding": "gzip, deflate, br", 301 | "Content-Type": "application/x-www-form-urlencoded" 302 | }, 303 | timeout: 10000, 304 | } 305 | } 306 | function getParam(url, name) { 307 | const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i") 308 | const r = url.match(reg) 309 | if (r != null) return unescape(r[2]); 310 | return null; 311 | } 312 | function jsonParse(str) { 313 | if (typeof str == "string") { 314 | try { 315 | return JSON.parse(str); 316 | } catch (e) { 317 | console.log(e); 318 | $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') 319 | return []; 320 | } 321 | } 322 | } 323 | // prettier-ignore 324 | function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),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=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,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;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 325 | -------------------------------------------------------------------------------- /jd_sgmh-help.js: -------------------------------------------------------------------------------- 1 | 2 | const $ = new Env('搞鸡玩家-闪购盲盒互助'); 3 | //Node.js用户请在jdCookie.js处填写京东ck; 4 | const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; 5 | let appId = '1EFRXxg' , homeDataFunPrefix = 'interact_template', collectScoreFunPrefix = 'harmony', message = '' 6 | let lotteryResultFunPrefix = homeDataFunPrefix, browseTime = 6 7 | const inviteCodes = []; 8 | const randomCount = $.isNode() ? 20 : 5; 9 | const notify = $.isNode() ? require('./sendNotify') : ''; 10 | let merge = {} 11 | //IOS等用户直接用NobyDa的jd cookie 12 | let cookiesArr = [], cookie = ''; 13 | if ($.isNode()) { 14 | Object.keys(jdCookieNode).forEach((item) => { 15 | cookiesArr.push(jdCookieNode[item]) 16 | }) 17 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; 18 | } else { 19 | cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); 20 | } 21 | 22 | const JD_API_HOST = `https://api.m.jd.com/client.action`; 23 | !(async () => { 24 | if (!cookiesArr[0]) { 25 | $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); 26 | return; 27 | } 28 | await requireConfig(); 29 | for (let i = 0; i < cookiesArr.length; i++) { 30 | cookie = cookiesArr[i]; 31 | if (cookie) { 32 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 33 | $.index = i + 1; 34 | $.isLogin = true; 35 | $.nickName = ''; 36 | $.beans = 0 37 | message = '' 38 | await TotalBean(); 39 | 40 | console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); 41 | if (!$.isLogin) { 42 | $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 43 | 44 | if ($.isNode()) { 45 | await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); 46 | } 47 | continue 48 | } 49 | await interact_template_getHomeData() 50 | 51 | } 52 | } 53 | 54 | 55 | console.log(`\n开始账号内互助\n`); 56 | for (let i = 0; i < cookiesArr.length; i++) { 57 | cookie = cookiesArr[i]; 58 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 59 | 60 | console.log('开始助力好友') 61 | 62 | console.log(`格式化后的助力码::${JSON.stringify(inviteCodes)}\n`); 63 | for (let code of inviteCodes) { 64 | if (!code) continue 65 | await harmony_collectScore(code, 3); 66 | await $.wait(2000) 67 | } 68 | } 69 | 70 | 71 | })() 72 | .catch((e) => $.logErr(e)) 73 | .finally(() => $.done()) 74 | function harmony_collectScore(taskToken,taskId,itemId = "",actionType = 0,timeout = 0) { 75 | return new Promise((resolve) => { 76 | setTimeout( ()=>{ 77 | let url = { 78 | url : `${JD_API_HOST}`, 79 | headers : { 80 | 'Origin' : `https://h5.m.jd.com`, 81 | 'Cookie' : cookie, 82 | 'Connection' : `keep-alive`, 83 | 'Accept' : `application/json, text/plain, */*`, 84 | 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`,//?inviteId=P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ?inviteId=${shareCode} 85 | 'Host' : `api.m.jd.com`, 86 | 'Accept-Encoding' : `gzip, deflate, br`, 87 | 'Accept-Language' : `zh-cn` 88 | }, 89 | body : `functionId=${collectScoreFunPrefix}_collectScore&body={"appId":"${appId}","taskToken":"${taskToken}","taskId":${taskId}${itemId ? ',"itemId":"'+itemId+'"' : ''},"actionType":${actionType}&client=wh5&clientVersion=1.0.0` 90 | } 91 | //console.log(url.body) 92 | //if (appId === "1EFRTxQ") url.body += "&appid=golden-egg" 93 | $.post(url, async (err, resp, data) => { 94 | try { 95 | data = JSON.parse(data); 96 | if (data.data.bizMsg === "任务领取成功") { 97 | await harmony_collectScore(taskToken,taskId,itemId,0,parseInt(browseTime) * 1000); 98 | } else{ 99 | console.log(data.data.bizMsg) 100 | } 101 | } catch (e) { 102 | $.logErr(e, resp); 103 | } finally { 104 | resolve() 105 | } 106 | }) 107 | },timeout) 108 | }) 109 | } 110 | //获取活动信息 111 | function interact_template_getHomeData(timeout = 0) { 112 | return new Promise((resolve) => { 113 | setTimeout( ()=>{ 114 | let url = { 115 | url : `${JD_API_HOST}`, 116 | headers : { 117 | 'Origin' : `https://h5.m.jd.com`, 118 | 'Cookie' : cookie, 119 | 'Connection' : `keep-alive`, 120 | 'Accept' : `application/json, text/plain, */*`, 121 | 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`, 122 | 'Host' : `api.m.jd.com`, 123 | 'Accept-Encoding' : `gzip, deflate, br`, 124 | 'Accept-Language' : `zh-cn` 125 | }, 126 | body : `functionId=${homeDataFunPrefix}_getHomeData&body={"appId":"${appId}","taskToken":""}&client=wh5&clientVersion=1.0.0` 127 | } 128 | 129 | $.post(url, async (err, resp, data) => { 130 | try { 131 | data = JSON.parse(data); 132 | if (data.data.bizCode !== 0) { 133 | console.log(data.data.bizMsg); 134 | return 135 | } 136 | scorePerLottery = data.data.result.userInfo.scorePerLottery||data.data.result.userInfo.lotteryMinusScore 137 | if (data.data.result.raiseInfo&&data.data.result.raiseInfo.levelList) scorePerLottery = data.data.result.raiseInfo.levelList[data.data.result.raiseInfo.scoreLevel]; 138 | //console.log(scorePerLottery) 139 | for (let i = 0;i < data.data.result.taskVos.length;i ++) { 140 | 141 | if (data.data.result.taskVos[i].taskName === '邀请好友助力') { 142 | console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${data.data.result.taskVos[i].assistTaskDetailVo.taskToken}\n`); 143 | inviteCodes.push(data.data.result.taskVos[i].assistTaskDetailVo.taskToken) 144 | $.log('收集邀请码!!!') 145 | 146 | 147 | } 148 | 149 | 150 | 151 | } 152 | 153 | } catch (e) { 154 | $.logErr(e, resp); 155 | } finally { 156 | resolve() 157 | } 158 | }) 159 | },timeout) 160 | }) 161 | } 162 | 163 | 164 | 165 | 166 | 167 | function requireConfig() { 168 | return new Promise(async resolve => { 169 | console.log(`开始获取${$.name}配置文件\n`); 170 | //Node.js用户请在jdCookie.js处填写京东ck; 171 | let shareCodes = [] 172 | console.log(`共${cookiesArr.length}个京东账号\n`); 173 | 174 | 175 | resolve() 176 | }) 177 | } 178 | 179 | 180 | 181 | function TotalBean() { 182 | return new Promise(async resolve => { 183 | const options = { 184 | "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, 185 | "headers": { 186 | "Accept": "application/json,text/plain, */*", 187 | "Content-Type": "application/x-www-form-urlencoded", 188 | "Accept-Encoding": "gzip, deflate, br", 189 | "Accept-Language": "zh-cn", 190 | "Connection": "keep-alive", 191 | "Cookie": cookie, 192 | "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", 193 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "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") : ($.getdata('JDUA') ? $.getdata('JDUA') : "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") 194 | } 195 | } 196 | $.post(options, (err, resp, data) => { 197 | try { 198 | if (err) { 199 | console.log(`${JSON.stringify(err)}`) 200 | console.log(`${$.name} API请求失败,请检查网路重试`) 201 | } else { 202 | if (data) { 203 | data = JSON.parse(data); 204 | if (data['retcode'] === 13) { 205 | $.isLogin = false; //cookie过期 206 | return 207 | } 208 | if (data['retcode'] === 0) { 209 | $.nickName = (data['base'] && data['base'].nickname) || $.UserName; 210 | } else { 211 | $.nickName = $.UserName 212 | } 213 | } else { 214 | console.log(`京东服务器返回空数据`) 215 | } 216 | } 217 | } catch (e) { 218 | $.logErr(e, resp) 219 | } finally { 220 | resolve(); 221 | } 222 | }) 223 | }) 224 | } 225 | function jsonParse(str) { 226 | if (typeof str == "string") { 227 | try { 228 | return JSON.parse(str); 229 | } catch (e) { 230 | console.log(e); 231 | $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') 232 | return []; 233 | } 234 | } 235 | } 236 | function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 237 | -------------------------------------------------------------------------------- /jd_sgmh.js: -------------------------------------------------------------------------------- 1 | /* 2 | 闪购盲盒 3 | 长期活动,一人每天5次助力机会,10次被助机会,被助力一次获得一次抽奖机会,前几次必中京豆 4 | 修改自 @yangtingxiao 抽奖机脚本 5 | 活动入口:京东APP首页-闪购-闪购盲盒 6 | 网页地址:https://h5.m.jd.com/babelDiy/Zeus/3vzA7uGuWL2QeJ5UeecbbAVKXftQ/index.html 7 | 更新地址:jd_sgmh.js 8 | 已支持IOS双京东账号, Node.js支持N个京东账号 9 | 脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js 10 | ============Quantumultx=============== 11 | [task_local] 12 | #闪购盲盒 13 | 20 8 * * * jd_sgmh.js, tag=闪购盲盒, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true 14 | 15 | ================Loon============== 16 | [Script] 17 | cron "20 8 * * *" script-path=jd_sgmh.js, tag=闪购盲盒 18 | 19 | ===============Surge================= 20 | 闪购盲盒 = type=cron,cronexp="20 8 * * *",wake-system=1,timeout=3600,script-path=jd_sgmh.js 21 | 22 | ============小火箭========= 23 | 闪购盲盒 = type=cron,script-path=jd_sgmh.js, cronexpr="20 8 * * *", timeout=3600, enable=true 24 | 25 | */ 26 | const $ = new Env('闪购盲盒'); 27 | //Node.js用户请在jdCookie.js处填写京东ck; 28 | const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; 29 | let appId = '1EFRXxg' , homeDataFunPrefix = 'interact_template', collectScoreFunPrefix = 'harmony', message = '' 30 | let lotteryResultFunPrefix = homeDataFunPrefix, browseTime = 6 31 | const inviteCodes = []; 32 | const randomCount = $.isNode() ? 20 : 5; 33 | const notify = $.isNode() ? require('./sendNotify') : ''; 34 | let merge = {} 35 | //IOS等用户直接用NobyDa的jd cookie 36 | let cookiesArr = [], cookie = ''; 37 | if ($.isNode()) { 38 | Object.keys(jdCookieNode).forEach((item) => { 39 | cookiesArr.push(jdCookieNode[item]) 40 | }) 41 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; 42 | } else { 43 | cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); 44 | } 45 | 46 | const JD_API_HOST = `https://api.m.jd.com/client.action`; 47 | !(async () => { 48 | if (!cookiesArr[0]) { 49 | $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); 50 | return; 51 | } 52 | await requireConfig(); 53 | for (let i = 0; i < cookiesArr.length; i++) { 54 | cookie = cookiesArr[i]; 55 | if (cookie) { 56 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 57 | $.index = i + 1; 58 | $.isLogin = true; 59 | $.nickName = ''; 60 | $.beans = 0 61 | message = '' 62 | await TotalBean(); 63 | 64 | console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); 65 | if (!$.isLogin) { 66 | $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 67 | 68 | if ($.isNode()) { 69 | await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); 70 | } 71 | continue 72 | } 73 | await interact_template_getHomeData() 74 | await showMsg(); 75 | } 76 | } 77 | })() 78 | .catch((e) => $.logErr(e)) 79 | .finally(() => $.done()) 80 | //获取活动信息 81 | function interact_template_getHomeData(timeout = 0) { 82 | return new Promise((resolve) => { 83 | setTimeout( ()=>{ 84 | let url = { 85 | url : `${JD_API_HOST}`, 86 | headers : { 87 | 'Origin' : `https://h5.m.jd.com`, 88 | 'Cookie' : cookie, 89 | 'Connection' : `keep-alive`, 90 | 'Accept' : `application/json, text/plain, */*`, 91 | 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`, 92 | 'Host' : `api.m.jd.com`, 93 | 'Accept-Encoding' : `gzip, deflate, br`, 94 | 'Accept-Language' : `zh-cn` 95 | }, 96 | body : `functionId=${homeDataFunPrefix}_getHomeData&body={"appId":"${appId}","taskToken":""}&client=wh5&clientVersion=1.0.0` 97 | } 98 | 99 | $.post(url, async (err, resp, data) => { 100 | try { 101 | data = JSON.parse(data); 102 | if (data.data.bizCode !== 0) { 103 | console.log(data.data.bizMsg); 104 | return 105 | } 106 | scorePerLottery = data.data.result.userInfo.scorePerLottery||data.data.result.userInfo.lotteryMinusScore 107 | if (data.data.result.raiseInfo&&data.data.result.raiseInfo.levelList) scorePerLottery = data.data.result.raiseInfo.levelList[data.data.result.raiseInfo.scoreLevel]; 108 | //console.log(scorePerLottery) 109 | for (let i = 0;i < data.data.result.taskVos.length;i ++) { 110 | console.log("\n" + data.data.result.taskVos[i].taskType + '-' + data.data.result.taskVos[i].taskName + '-' + (data.data.result.taskVos[i].status === 1 ? `已完成${data.data.result.taskVos[i].times}-未完成${data.data.result.taskVos[i].maxTimes}` : "全部已完成")) 111 | //签到 112 | 113 | if (data.data.result.taskVos[i].status === 3) { 114 | console.log('开始抽奖') 115 | await interact_template_getLotteryResult(data.data.result.taskVos[i].taskId); 116 | } 117 | else if ([0,13].includes(data.data.result.taskVos[i].taskType)) { 118 | if (data.data.result.taskVos[i].status === 1) { 119 | await harmony_collectScore(data.data.result.taskVos[i].simpleRecordInfoVo.taskToken,data.data.result.taskVos[i].taskId); 120 | } 121 | } 122 | else if ([14,6].includes(data.data.result.taskVos[i].taskType)) { 123 | //console.log(data.data.result.taskVos[i].assistTaskDetailVo.taskToken) 124 | for (let j = 0;j <(data.data.result.userInfo.lotteryNum||0);j++) { 125 | if (appId === "1EFRTxQ") { 126 | await ts_smashGoldenEggs() 127 | } else { 128 | await interact_template_getLotteryResult(data.data.result.taskVos[i].taskId); 129 | } 130 | } 131 | } 132 | let list = data.data.result.taskVos[i].productInfoVos || data.data.result.taskVos[i].followShopVo || data.data.result.taskVos[i].shoppingActivityVos || data.data.result.taskVos[i].browseShopVo 133 | for (let k = data.data.result.taskVos[i].times; k < data.data.result.taskVos[i].maxTimes; k++) { 134 | for (let j in list) { 135 | if (list[j].status === 1) { 136 | //console.log(list[j].simpleRecordInfoVo||list[j].assistTaskDetailVo) 137 | console.log("\n" + (list[j].title || list[j].shopName||list[j].skuName)) 138 | //console.log(list[j].itemId) 139 | if (list[j].itemId) { 140 | await harmony_collectScore(list[j].taskToken,data.data.result.taskVos[i].taskId,list[j].itemId,1); 141 | if (k === data.data.result.taskVos[i].maxTimes - 1) await interact_template_getLotteryResult(data.data.result.taskVos[i].taskId); 142 | } else { 143 | await harmony_collectScore(list[j].taskToken,data.data.result.taskVos[i].taskId) 144 | } 145 | list[j].status = 2; 146 | break; 147 | } 148 | } 149 | } 150 | } 151 | if (scorePerLottery) await interact_template_getLotteryResult(); 152 | } catch (e) { 153 | $.logErr(e, resp); 154 | } finally { 155 | resolve() 156 | } 157 | }) 158 | },timeout) 159 | }) 160 | } 161 | //做任务 162 | function harmony_collectScore(taskToken,taskId,itemId = "",actionType = 0,timeout = 0) { 163 | return new Promise((resolve) => { 164 | setTimeout( ()=>{ 165 | let url = { 166 | url : `${JD_API_HOST}`, 167 | headers : { 168 | 'Origin' : `https://h5.m.jd.com`, 169 | 'Cookie' : cookie, 170 | 'Connection' : `keep-alive`, 171 | 'Accept' : `application/json, text/plain, */*`, 172 | 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`,//?inviteId=P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ?inviteId=${shareCode} 173 | 'Host' : `api.m.jd.com`, 174 | 'Accept-Encoding' : `gzip, deflate, br`, 175 | 'Accept-Language' : `zh-cn` 176 | }, 177 | body : `functionId=${collectScoreFunPrefix}_collectScore&body={"appId":"${appId}","taskToken":"${taskToken}","taskId":${taskId}${itemId ? ',"itemId":"'+itemId+'"' : ''},"actionType":${actionType}&client=wh5&clientVersion=1.0.0` 178 | } 179 | //console.log(url.body) 180 | //if (appId === "1EFRTxQ") url.body += "&appid=golden-egg" 181 | $.post(url, async (err, resp, data) => { 182 | try { 183 | data = JSON.parse(data); 184 | if (data.data.bizMsg === "任务领取成功") { 185 | await harmony_collectScore(taskToken,taskId,itemId,0,parseInt(browseTime) * 1000); 186 | } else{ 187 | console.log(data.data.bizMsg) 188 | } 189 | } catch (e) { 190 | $.logErr(e, resp); 191 | } finally { 192 | resolve() 193 | } 194 | }) 195 | },timeout) 196 | }) 197 | } 198 | //抽奖 199 | function interact_template_getLotteryResult(taskId,timeout = 0) { 200 | return new Promise((resolve) => { 201 | setTimeout( ()=>{ 202 | let url = { 203 | url : `${JD_API_HOST}`, 204 | headers : { 205 | 'Origin' : `https://h5.m.jd.com`, 206 | 'Cookie' : cookie, 207 | 'Connection' : `keep-alive`, 208 | 'Accept' : `application/json, text/plain, */*`, 209 | 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html?inviteId=P04z54XCjVXmYaW5m9cZ2f433tIlGBj3JnLHD0`,//?inviteId=P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ 210 | 'Host' : `api.m.jd.com`, 211 | 'Accept-Encoding' : `gzip, deflate, br`, 212 | 'Accept-Language' : `zh-cn` 213 | }, 214 | body : `functionId=${lotteryResultFunPrefix}_getLotteryResult&body={"appId":"${appId}"${taskId ? ',"taskId":"'+taskId+'"' : ''}}&client=wh5&clientVersion=1.0.0` 215 | } 216 | //console.log(url.body) 217 | //if (appId === "1EFRTxQ") url.body = `functionId=ts_getLottery&body={"appId":"${appId}"${taskId ? ',"taskId":"'+taskId+'"' : ''}}&client=wh5&clientVersion=1.0.0&appid=golden-egg` 218 | $.post(url, async (err, resp, data) => { 219 | try { 220 | if (!timeout) console.log('\n开始抽奖') 221 | data = JSON.parse(data); 222 | if (data.data.bizCode === 0) { 223 | if (data.data.result.userAwardsCacheDto.jBeanAwardVo) { 224 | console.log('京豆:' + data.data.result.userAwardsCacheDto.jBeanAwardVo.quantity) 225 | $.beans += parseInt(data.data.result.userAwardsCacheDto.jBeanAwardVo.quantity) 226 | } 227 | if (data.data.result.raiseInfo) scorePerLottery = parseInt(data.data.result.raiseInfo.nextLevelScore); 228 | if (parseInt(data.data.result.userScore) >= scorePerLottery && scorePerLottery) { 229 | await interact_template_getLotteryResult(1000) 230 | } 231 | } 232 | } catch (e) { 233 | $.logErr(e, resp); 234 | } finally { 235 | resolve() 236 | } 237 | }) 238 | },timeout) 239 | }) 240 | } 241 | 242 | 243 | //通知 244 | function showMsg() { 245 | message += `任务已完成,本次运行获得京豆${$.beans}` 246 | return new Promise(resolve => { 247 | if ($.beans) $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); 248 | $.log(`【京东账号${$.index}】${$.nickName}\n${message}`); 249 | resolve() 250 | }) 251 | } 252 | 253 | function requireConfig() { 254 | return new Promise(async resolve => { 255 | console.log(`开始获取${$.name}配置文件\n`); 256 | //Node.js用户请在jdCookie.js处填写京东ck; 257 | 258 | resolve() 259 | }) 260 | } 261 | 262 | 263 | 264 | 265 | function TotalBean() { 266 | return new Promise(async resolve => { 267 | const options = { 268 | "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, 269 | "headers": { 270 | "Accept": "application/json,text/plain, */*", 271 | "Content-Type": "application/x-www-form-urlencoded", 272 | "Accept-Encoding": "gzip, deflate, br", 273 | "Accept-Language": "zh-cn", 274 | "Connection": "keep-alive", 275 | "Cookie": cookie, 276 | "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", 277 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "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") : ($.getdata('JDUA') ? $.getdata('JDUA') : "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") 278 | } 279 | } 280 | $.post(options, (err, resp, data) => { 281 | try { 282 | if (err) { 283 | console.log(`${JSON.stringify(err)}`) 284 | console.log(`${$.name} API请求失败,请检查网路重试`) 285 | } else { 286 | if (data) { 287 | data = JSON.parse(data); 288 | if (data['retcode'] === 13) { 289 | $.isLogin = false; //cookie过期 290 | return 291 | } 292 | if (data['retcode'] === 0) { 293 | $.nickName = (data['base'] && data['base'].nickname) || $.UserName; 294 | } else { 295 | $.nickName = $.UserName 296 | } 297 | } else { 298 | console.log(`京东服务器返回空数据`) 299 | } 300 | } 301 | } catch (e) { 302 | $.logErr(e, resp) 303 | } finally { 304 | resolve(); 305 | } 306 | }) 307 | }) 308 | } 309 | function jsonParse(str) { 310 | if (typeof str == "string") { 311 | try { 312 | return JSON.parse(str); 313 | } catch (e) { 314 | console.log(e); 315 | $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') 316 | return []; 317 | } 318 | } 319 | } 320 | function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 321 | -------------------------------------------------------------------------------- /jd_tyt.js: -------------------------------------------------------------------------------- 1 | /* 2 | 入口 极速版 赚金币 推一推 3 | 4 | [task_local] 5 | #搞基大神-推一推 6 | 0 0 * * * http://47.101.146.160/scripts/jd_tyt.js, tag=搞基大神-推一推, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true 7 | */ 8 | 9 | const $ = new Env('搞鸡玩家-推一推'); 10 | const notify = $.isNode() ? require('./sendNotify') : ''; 11 | //Node.js用户请在jdCookie.js处填写京东ck; 12 | const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; 13 | const JD_API_HOST = 'https://api.m.jd.com'; 14 | //IOS等用户直接用NobyDa的jd cookie 15 | let cookiesArr = [], cookie = '', message; 16 | let status='' 17 | 18 | let insertCodes = [] 19 | let inviteCodes = [] 20 | 21 | if ($.isNode()) { 22 | Object.keys(jdCookieNode).forEach((item) => { 23 | cookiesArr.push(jdCookieNode[item]) 24 | }) 25 | if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; 26 | } else { 27 | cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); 28 | } 29 | 30 | !(async () => { 31 | if (!cookiesArr[0]) { 32 | $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 33 | return; 34 | } 35 | 36 | for (let i = 0; i < cookiesArr.length; i++) { 37 | if (cookiesArr[i]) { 38 | cookie = cookiesArr[i]; 39 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 40 | $.index = i + 1; 41 | $.isLogin = true; 42 | $.nickName = ''; 43 | message = ''; 44 | await TotalBean(); 45 | console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); 46 | if (!$.isLogin) { 47 | $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); 48 | 49 | if ($.isNode()) { 50 | await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); 51 | } 52 | continue 53 | } 54 | 55 | 56 | 57 | } 58 | console.log('\n入口 狗东极速版 我的 推一推\n'); 59 | console.log('\n本脚本无任何内置助力\n如果你发现有那么就是别人二改加的\n一切与本人无关\n'); 60 | await info() 61 | await coinDozerBackFlow() 62 | await getCoinDozerInfo() 63 | console.log('\n注意全部助力给账号一\n'); 64 | 65 | 66 | } 67 | 68 | 69 | console.log('\n#######开始全部助力账号1#######\n'); 70 | for (let i = 0; i < cookiesArr.length; i++) { 71 | cookie = cookiesArr[i]; 72 | $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) 73 | $.index = i + 1; 74 | 75 | if (!cookie) continue 76 | for (let code of inviteCodes) { 77 | if ($.UserName === code['user']) continue; 78 | if ($.index === 1 &&2) break 79 | await helpCoinDozer(code['packetId']) 80 | console.log(`\n【${$.UserName}】去助力【${code['user']}】邀请码:${code['packetId']}`); 81 | if (status == 1) { 82 | break 83 | } 84 | 85 | await $.wait(10000) 86 | let res = await help(code['packetId'])} 87 | } 88 | 89 | 90 | })() 91 | .catch((e) => { 92 | $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') 93 | }) 94 | .finally(() => { 95 | $.done(); 96 | }) 97 | 98 | 99 | function info() { 100 | return new Promise((resolve) => { 101 | 102 | const nm= { 103 | url: `${JD_API_HOST}`, 104 | body:`functionId=initiateCoinDozer&body={"actId":"49f40d2f40b3470e8d6c39aa4866c7ff","channel":"coin_dozer","antiToken":"","referer":"-1","frontendInitStatus":"s"}&appid=megatron&client=ios&clientVersion=14.3&t=1636014459632&networkType=4g&eid=&fp=-1&frontendInitStatus=s&uuid=8888&osVersion=14.3&d_brand=&d_model=&agent=-1&pageClickKey=-1&screen=400*700&platform=3&lang=zh_CN`, 105 | headers: { 106 | 107 | "Cookie": cookie, 108 | "Origin": "https://pushgold.jd.com", 109 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36", 110 | 111 | } 112 | } 113 | $.post(nm, async (err, resp, data) => { 114 | 115 | try { 116 | if (err) { 117 | console.log(`${JSON.stringify(err)}`) 118 | console.log(`${$.name} API请求失败,请检查网路重试`) 119 | } else { 120 | if (safeGet(data)) { 121 | data = JSON.parse(data); 122 | if(data.success==true){ 123 | console.log('邀请码:'+data.data.packetId) 124 | console.log('初始推出:'+data.data.amount) 125 | if (data.data && data.data.packetId && inviteCodes.length === 0) { 126 | inviteCodes.push({ 127 | user: $.UserName, 128 | packetId: data.data.packetId, 129 | 130 | }); 131 | } 132 | }else if(data.success==false){ 133 | console.log(data.msg)} 134 | } 135 | } 136 | } catch (e) { 137 | $.logErr(e, resp) 138 | } finally { 139 | resolve(data); 140 | } 141 | }) 142 | }) 143 | } 144 | function coinDozerBackFlow() { 145 | return new Promise((resolve) => { 146 | 147 | const nm= { 148 | url: `${JD_API_HOST}`, 149 | body:`functionId=coinDozerBackFlow&body={"actId":"49f40d2f40b3470e8d6c39aa4866c7ff","channel":"coin_dozer","antiToken":"","referer":"-1","frontendInitStatus":"s"}&appid=megatron&client=ios&clientVersion=14.3&t=1636015617899&networkType=4g&eid=&fp=-1&frontendInitStatus=s&uuid=8888&osVersion=14.3&d_brand=&d_model=&agent=-1&pageClickKey=-1&screen=400*700&platform=3&lang=zh_CN`, 150 | headers: { 151 | 152 | "Cookie": cookie, 153 | "Origin": "https://pushgold.jd.com", 154 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36", 155 | 156 | } 157 | } 158 | $.post(nm, async (err, resp, data) => { 159 | 160 | try { 161 | if (err) { 162 | console.log(`${JSON.stringify(err)}`) 163 | console.log(`${$.name} API请求失败,请检查网路重试`) 164 | } else { 165 | if (safeGet(data)) { 166 | data = JSON.parse(data); 167 | if(data.success==true){ 168 | console.log('浏览任务完成再推一次') 169 | 170 | 171 | } 172 | }else if(data.success==false){ 173 | console.log(data.msg)} 174 | } 175 | 176 | } catch (e) { 177 | $.logErr(e, resp) 178 | } finally { 179 | resolve(data); 180 | } 181 | }) 182 | }) 183 | } 184 | 185 | function helpCoinDozer(packetId) { 186 | return new Promise((resolve) => { 187 | 188 | const nm= { 189 | url: `${JD_API_HOST}`, 190 | body:`functionId=helpCoinDozer&appid=station-soa-h5&client=H5&clientVersion=1.0.0&t=1636015855103&body={"actId":"49f40d2f40b3470e8d6c39aa4866c7ff","channel":"coin_dozer","antiToken":"","referer":"-1","frontendInitStatus":"s","packetId":"${packetId}"}&_ste=1&_stk=appid,body,client,clientVersion,functionId,t&h5st=20211104165055104;9806356985655163;10005;tk01wd1ed1d5f30nBDriGzaeVZZ9vuiX+cBzRLExSEzpfTriRD0nxU6BbRIOcSQvnfh74uInjSeb6i+VHpnHrBJdVwzs;017f330f7a84896d31a8d6017a1504dc16be8001273aaea9a04a8d04aad033d9`, 191 | headers: { 192 | 193 | "Cookie": cookie, 194 | "Origin": "https://pushgold.jd.com", 195 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36", 196 | 197 | } 198 | } 199 | $.post(nm, async (err, resp, data) => { 200 | 201 | try { 202 | if (err) { 203 | console.log(`${JSON.stringify(err)}`) 204 | console.log(`${$.name} API请求失败,请检查网路重试`) 205 | } else { 206 | if (safeGet(data)) { 207 | data = JSON.parse(data); 208 | if(data.success==true){ 209 | console.log('推出:'+data.data.amount) 210 | console.log('已经推出:'+data.data.dismantledAmount) 211 | 212 | } 213 | }else if(data.success==false){ 214 | console.log(data.msg)} 215 | } 216 | 217 | } catch (e) { 218 | $.logErr(e, resp) 219 | } finally { 220 | resolve(data); 221 | } 222 | }) 223 | }) 224 | } 225 | 226 | 227 | function help(packetId) { 228 | return new Promise((resolve) => { 229 | 230 | const nm= { 231 | url: `${JD_API_HOST}`, 232 | body:`functionId=helpCoinDozer&appid=station-soa-h5&client=H5&clientVersion=1.0.0&t=1623120183787&body={"actId":"49f40d2f40b3470e8d6c39aa4866c7ff","channel":"coin_dozer","antiToken":"","referer":"-1","frontendInitStatus":"s","packetId":"${packetId}","helperStatus":"0"}&_ste=1&_stk=appid,body,client,clientVersion,functionId,t&h5st=20210608104303790;8489907903583162;10005;tk01w89681aa9a8nZDdIanIyWnVuWFLK4gnqY+05WKcPY3NWU2dcfa73B7PBM7ufJEN0U+4MyHW5N2mT/RNMq72ycJxH;7e6b956f1a8a71b269a0038bbb4abd24bcfb834a88910818cf1bdfc55b7b96e5`, 233 | headers: { 234 | 235 | "Cookie": cookie, 236 | "Origin": "https://pushgold.jd.com", 237 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36", 238 | 239 | } 240 | } 241 | $.post(nm, async (err, resp, data) => { 242 | 243 | try { 244 | if (err) { 245 | console.log(`${JSON.stringify(err)}`) 246 | console.log(`${$.name} API请求失败,请检查网路重试`) 247 | } else { 248 | if (safeGet(data)) { 249 | data = JSON.parse(data); 250 | if(data.success==true){ 251 | console.log("帮砍:" + data.data.amount) 252 | 253 | } 254 | } 255 | else 256 | if (data.msg.indexOf("完成") != -1) { 257 | status = 1 258 | } 259 | if(data.success==false){ 260 | console.log(data.msg)} 261 | } 262 | 263 | } catch (e) { 264 | $.logErr(e, resp) 265 | } finally { 266 | resolve(data); 267 | } 268 | }) 269 | }) 270 | } 271 | 272 | function getCoinDozerInfo() { 273 | return new Promise((resolve) => { 274 | 275 | const nm= { 276 | url: `${JD_API_HOST}`, 277 | body:`functionId=getCoinDozerInfo&body={"actId":"49f40d2f40b3470e8d6c39aa4866c7ff","channel":"coin_dozer","antiToken":"","referer":"-1","frontendInitStatus":"s"}&appid=megatron&client=ios&clientVersion=14.3&t=1636015858295&networkType=4g&eid=&fp=-1&frontendInitStatus=s&uuid=8888&osVersion=14.3&d_brand=&d_model=&agent=-1&pageClickKey=-1&screen=400*700&platform=3&lang=zh_CN`, 278 | headers: { 279 | 280 | "Cookie": cookie, 281 | "Origin": "https://pushgold.jd.com", 282 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36", 283 | 284 | } 285 | } 286 | $.post(nm, async (err, resp, data) => { 287 | 288 | try { 289 | if (err) { 290 | console.log(`${JSON.stringify(err)}`) 291 | console.log(`${$.name} API请求失败,请检查网路重试`) 292 | } else { 293 | if (safeGet(data)) { 294 | data = JSON.parse(data); 295 | if(data.success==true){ 296 | console.log('叼毛:'+data.data.sponsorActivityInfo.initiatorNickname) 297 | console.log('邀请码:'+data.data.sponsorActivityInfo.packetId) 298 | console.log('推出:'+data.data.sponsorActivityInfo.dismantledAmount) 299 | 300 | if (data.data && data.data.sponsorActivityInfo.packetId && inviteCodes.length === 0) { 301 | inviteCodes.push({ 302 | user: $.UserName, 303 | packetId: data.data.sponsorActivityInfo.packetId 304 | 305 | }); 306 | } 307 | }else if(data.success==false){ 308 | console.log(data.msg)} 309 | } 310 | } 311 | 312 | } catch (e) { 313 | $.logErr(e, resp) 314 | } finally { 315 | resolve(data); 316 | } 317 | }) 318 | }) 319 | } 320 | 321 | 322 | function TotalBean() { 323 | return new Promise(async resolve => { 324 | const options = { 325 | "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, 326 | "headers": { 327 | "Accept": "application/json,text/plain, */*", 328 | "Content-Type": "application/x-www-form-urlencoded", 329 | "Accept-Encoding": "gzip, deflate, br", 330 | "Accept-Language": "zh-cn", 331 | "Connection": "keep-alive", 332 | "Cookie": cookie, 333 | "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", 334 | "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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") 335 | } 336 | } 337 | $.post(options, (err, resp, data) => { 338 | try { 339 | if (err) { 340 | console.log(`${JSON.stringify(err)}`) 341 | console.log(`${$.name} API请求失败,请检查网路重试`) 342 | } else { 343 | if (data) { 344 | data = JSON.parse(data); 345 | if (data["retcode"] === 13) { 346 | $.isLogin = false; //cookie过期 347 | return; 348 | } 349 | if (data["retcode"] === 0) { 350 | $.nickName = (data["base"] && data["base"].nickname) || $.UserName; 351 | } else { 352 | $.nickName = $.UserName; 353 | } 354 | } else { 355 | console.log(`京东服务器返回空数据`) 356 | } 357 | } 358 | } catch (e) { 359 | $.logErr(e, resp) 360 | } finally { 361 | resolve(); 362 | } 363 | }) 364 | }) 365 | } 366 | function safeGet(data) { 367 | try { 368 | if (typeof JSON.parse(data) == "object") { 369 | return true; 370 | } 371 | } catch (e) { 372 | console.log(e); 373 | console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); 374 | return false; 375 | } 376 | } 377 | function jsonParse(str) { 378 | if (typeof str == "string") { 379 | try { 380 | return JSON.parse(str); 381 | } catch (e) { 382 | console.log(e); 383 | $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') 384 | return []; 385 | } 386 | } 387 | } 388 | 389 | 390 | 391 | function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),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=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,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;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 392 | --------------------------------------------------------------------------------