├── .gitignore ├── JS_USER_AGENTS.js ├── LICENSE ├── README.md ├── TS_JDHelloWorld.d.ts ├── TS_JDHelloWorld.js ├── TS_USER_AGENTS.ts ├── USER_AGENTS.js ├── iOS_Cookie.js ├── jdCookie.js ├── jdFruitShareCodes.js ├── jdPetShareCodes.js ├── jdPlantBeanShareCodes.js ├── jd_bean_box.ts ├── jd_bean_sign.ts ├── jd_cash.ts ├── jd_checkCookie.ts ├── jd_cww.ts ├── jd_cww_help.ts ├── jd_dwapp.ts ├── jd_farm.ts ├── jd_fission.ts ├── jd_fruit_help.ts ├── jd_fruit_without_help.ts ├── jd_health.ts ├── jd_health_collect.ts ├── jd_joy_park_run.ts ├── jd_kuaidi.ts ├── jd_miniTask.ts ├── jd_pet.js ├── jd_plantBean.js ├── jd_plantBean__help.ts ├── jd_ql_repo.ts ├── jd_queryRedpacket.ts ├── jd_rmFollowList.ts ├── jd_sgmh.ts ├── jd_speed_coin.js ├── jd_speed_sign.ts ├── jd_track.ts ├── jd_wechat_sign.ts ├── jd_windControl.ts ├── jd_wx_hbrain.ts ├── old └── jd_fruit.js ├── package.json ├── reset.sh ├── sendNotify.js ├── tsconfig.json └── utils ├── account_demo.json ├── empty.json ├── exceptCookie.json ├── h5st.d.ts ├── h5st.js ├── h5st_4.2.d.ts ├── h5st_4.2.js ├── h5st_42.js ├── h5st_43.js ├── h5st_pro.ts ├── jdShareCodes.js ├── jd_appopen.js ├── jd_joy_getInvokeKey.ts ├── pushplus.ts ├── shareCodesTool.ts ├── sharecodes.json └── validate_single.js /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Toulu-debug 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # About 2 | A NodeJS project 3 | 4 | # Languages 5 | TypeScript & JavaScript 6 | 7 | # Environment 8 | Windows, Linux, MacOS 9 | 10 | NodeJS https://nodejs.org 11 | ```shell 12 | npm install -g cnpm 13 | ``` 14 | 15 | # Usage 16 | ```shell 17 | cd enen 18 | cnpm install 19 | node filename.js 20 | ts-node filename.ts 21 | ``` -------------------------------------------------------------------------------- /TS_JDHelloWorld.d.ts: -------------------------------------------------------------------------------- 1 | interface User { 2 | index: number; 3 | UserName: string; 4 | cookie: string; 5 | UserAgent: string; 6 | end?: boolean; 7 | } 8 | declare class JDHelloWorld { 9 | scriptName: string; 10 | cookiesArr: string[]; 11 | users: User[]; 12 | constructor(scriptName?: string); 13 | getCookie(): Promise; 14 | exceptCookie(filename?: string): string[]; 15 | get(url: string, headers?: any, params?: object): Promise; 16 | post(url: string, data: string | object, headers?: object, params?: object): Promise; 17 | wait(ms?: number): Promise; 18 | o2s(msg: string | object, title?: string): void; 19 | getShareCodePool(key: string, num: number): Promise; 20 | getshareCodeHW(key: string): Promise; 21 | getRandomWord(): string; 22 | getRandomNumberByRange(start: number, end: number): number; 23 | getRandomNumString(e: number): string; 24 | getEncStr(fn: string, body: { 25 | id?: number; 26 | taskType?: number; 27 | }): object; 28 | getSign(fn: string, body: object): Promise; 29 | getIosVer(): string; 30 | getFp(): Promise; 31 | getFp4_1(): Promise; 32 | algo(appId: string, fp: string, ua: string, pin: string, url: string, og: string): Promise; 33 | h5st(version: string, appId: string, ua: string): any; 34 | run(son: { 35 | main: Function; 36 | help?: Function; 37 | tips?: Function; 38 | }, help?: Function, tips?: Function): Promise; 39 | } 40 | export { User, JDHelloWorld }; 41 | -------------------------------------------------------------------------------- /TS_USER_AGENTS.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios" 2 | import {Md5} from "ts-md5" 3 | import * as dotenv from "dotenv" 4 | import {existsSync, readFileSync} from "fs" 5 | 6 | dotenv.config() 7 | const USER_AGENTS_ARR: string[] = [ 8 | "jdapp;android;10.0.2;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", 9 | "jdapp;iPhone;10.0.2;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", 10 | "jdapp;android;10.0.2;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", 11 | "jdapp;android;10.0.2;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", 12 | "jdapp;android;10.0.2;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", 13 | "jdapp;iPhone;10.0.2;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", 14 | "jdapp;iPhone;10.0.2;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", 15 | "jdapp;iPhone;10.0.2;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", 16 | "jdapp;iPhone;10.0.2;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", 17 | "jdapp;iPhone;10.0.2;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", 18 | "jdapp;iPhone;10.0.2;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", 19 | "jdapp;iPhone;10.0.2;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", 20 | "jdapp;iPhone;10.0.2;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", 21 | "jdapp;iPhone;10.0.2;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", 22 | "jdapp;iPhone;10.0.2;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", 23 | "jdapp;android;10.0.2;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", 24 | "jdapp;android;10.0.2;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", 25 | "jdapp;iPhone;10.0.2;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", 26 | "jdapp;android;10.0.2;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", 27 | "jdapp;android;10.0.2;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", 28 | "jdapp;android;10.0.2;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", 29 | "jdapp;android;10.0.2;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", 30 | "jdapp;android;10.0.2;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", 31 | "jdapp;android;10.0.2;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", 32 | "jdapp;iPhone;10.0.2;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", 33 | "jdapp;android;10.0.2;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", 34 | "jdapp;iPhone;10.0.2;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", 35 | "jdapp;iPhone;10.0.2;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", 36 | "jdapp;iPhone;10.0.2;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", 37 | "jdapp;android;10.0.2;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", 38 | "jdapp;android;10.0.2;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", 39 | "jdapp;iPhone;10.0.2;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", 40 | "jdapp;iPhone;10.0.2;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", 41 | "jdapp;android;10.0.2;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", 42 | "jdapp;android;10.0.2;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", 43 | "jdapp;iPhone;10.0.2;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", 44 | ] 45 | 46 | function getRandomNumberByRange(start: number, end: number) { 47 | end <= start && (end = start + 100) 48 | return Math.floor(Math.random() * (end - start) + start) 49 | } 50 | 51 | let USER_AGENT = USER_AGENTS_ARR[getRandomNumberByRange(0, USER_AGENTS_ARR.length)] 52 | 53 | async function getBeanShareCode(cookie: string) { 54 | let {data}: any = await axios.post('https://api.m.jd.com/client.action', 55 | `functionId=plantBeanIndex&body=${encodeURIComponent( 56 | JSON.stringify({version: "9.0.0.1", "monitor_source": "plant_app_plant_index", "monitor_refer": ""}) 57 | )}&appid=ld&client=apple&area=5_274_49707_49973&build=167283&clientVersion=9.1.0`, { 58 | headers: { 59 | Cookie: cookie, 60 | Host: "api.m.jd.com", 61 | Accept: "*/*", 62 | Connection: "keep-alive", 63 | "User-Agent": USER_AGENT 64 | } 65 | }) 66 | if (data.data?.jwordShareInfo?.shareUrl) 67 | return data.data.jwordShareInfo.shareUrl.split('Uuid=')![1] 68 | else 69 | return '' 70 | } 71 | 72 | async function getFarmShareCode(cookie: string) { 73 | let {data}: any = await axios.post('https://api.m.jd.com/client.action?functionId=initForFarm', `body=${encodeURIComponent(JSON.stringify({"version": 4}))}&appid=wh5&clientVersion=9.1.0`, { 74 | headers: { 75 | "cookie": cookie, 76 | "origin": "https://home.m.jd.com", 77 | "referer": "https://home.m.jd.com/myJd/newhome.action", 78 | "User-Agent": USER_AGENT, 79 | "Content-Type": "application/x-www-form-urlencoded" 80 | } 81 | }) 82 | 83 | if (data.farmUserPro) 84 | return data.farmUserPro.shareCode 85 | else 86 | return '' 87 | } 88 | 89 | async function getCookie(): Promise { 90 | let cookiesArr: string[] = [] 91 | const jdCookieNode = require('./jdCookie.js') 92 | for (let keys of Object.keys(jdCookieNode)) { 93 | cookiesArr.push(jdCookieNode[keys]) 94 | } 95 | let ptpin_temp: string[] = [], uniqueCookieArr: string[] = [] 96 | for (let cookie of cookiesArr) { 97 | let UserName: string = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) 98 | if (!ptpin_temp.includes(UserName)) { 99 | ptpin_temp.push(UserName) 100 | uniqueCookieArr.push(cookie) 101 | } 102 | } 103 | cookiesArr = uniqueCookieArr 104 | console.log(`共${cookiesArr.length}个京东账号\n`) 105 | return cookiesArr 106 | } 107 | 108 | function wait(ms: number) { 109 | return new Promise(resolve => { 110 | setTimeout(resolve, ms) 111 | }) 112 | } 113 | 114 | function getJxToken(cookie: string, phoneId: string = '') { 115 | function generateStr(input: number) { 116 | let src = 'abcdefghijklmnopqrstuvwxyz1234567890' 117 | let res = '' 118 | for (let i = 0; i < input; i++) { 119 | res += src[Math.floor(src.length * Math.random())] 120 | } 121 | return res 122 | } 123 | 124 | if (!phoneId) 125 | phoneId = generateStr(40) 126 | let timestamp = Date.now().toString() 127 | let nickname = cookie.match(/pt_pin=([^;]*)/)![1] 128 | let jstoken = Md5.hashStr('' + decodeURIComponent(nickname) + timestamp + phoneId + 'tPOamqCuk9NLgVPAljUyIHcPRmKlVxDy') 129 | return { 130 | 'strPgtimestamp': timestamp, 131 | 'strPhoneID': phoneId, 132 | 'strPgUUNum': jstoken 133 | } 134 | } 135 | 136 | function exceptCookie(filename: string = 'x.ts') { 137 | let except: any = [] 138 | if (existsSync('./utils/exceptCookie.json')) { 139 | try { 140 | except = JSON.parse(readFileSync('./utils/exceptCookie.json').toString() || '{}')[filename] || [] 141 | } catch (e) { 142 | console.log('./utils/exceptCookie.json JSON格式错误') 143 | } 144 | } 145 | return except 146 | } 147 | 148 | function randomString(e: number, word?: number) { 149 | e = e || 32 150 | let t = word === 26 ? "012345678abcdefghijklmnopqrstuvwxyz" : "0123456789abcdef", a = t.length, n = "" 151 | for (let i = 0; i < e; i++) 152 | n += t.charAt(Math.floor(Math.random() * a)) 153 | return n 154 | } 155 | 156 | function o2s(msg: object | string, title: string = '') { 157 | title && console.log('⬇️', title, '⬇️') 158 | typeof msg === 'string' ? console.log(msg) : console.log(JSON.stringify(msg)) 159 | } 160 | 161 | function randomNumString(e: number) { 162 | e = e || 32 163 | let t = '0123456789', a = t.length, n = "" 164 | for (let i = 0; i < e; i++) 165 | n += t.charAt(Math.floor(Math.random() * a)) 166 | return n 167 | } 168 | 169 | function randomWord(n: number = 1) { 170 | let t = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', a = t.length 171 | let rnd: string = '' 172 | for (let i = 0; i < n; i++) { 173 | rnd += t.charAt(Math.floor(Math.random() * a)) 174 | } 175 | return rnd 176 | } 177 | 178 | async function getshareCodeHW(key: string) { 179 | let shareCodeHW: string[] = [] 180 | for (let i = 0; i < 5; i++) { 181 | try { 182 | let {data}: any = await axios.get('http://sharecodepool.cnmb.pw/api/HW_CODES') 183 | shareCodeHW = data[key] || [] 184 | if (shareCodeHW.length !== 0) { 185 | break 186 | } 187 | } catch (e) { 188 | console.log("getshareCodeHW Error, Retry...") 189 | await wait(getRandomNumberByRange(2000, 6000)) 190 | } 191 | } 192 | return shareCodeHW 193 | } 194 | 195 | async function getShareCodePool(key: string, num: number) { 196 | let shareCode: string[] = [] 197 | for (let i = 0; i < 2; i++) { 198 | try { 199 | let {data}: any = await axios.get(`http://sharecodepool.cnmb.pw/api/${key}/${num}`) 200 | shareCode = data.data || [] 201 | console.log(`随机获取${num}个${key}成功:${JSON.stringify(shareCode)}`) 202 | if (shareCode.length !== 0) { 203 | break 204 | } 205 | } catch (e) { 206 | console.log("getShareCodePool Error, Retry...") 207 | await wait(getRandomNumberByRange(2000, 6000)) 208 | } 209 | } 210 | return shareCode 211 | } 212 | 213 | /* 214 | async function wechat_app_msg(title: string, content: string, user: string) { 215 | let corpid: string = "", corpsecret: string = "" 216 | let {data: gettoken} = await axios.get(`https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=${corpid}&corpsecret=${corpsecret}`) 217 | let access_token: string = gettoken.access_token 218 | 219 | let {data: send} = await axios.post(`https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${access_token}`, { 220 | "touser": user, 221 | "msgtype": "text", 222 | "agentid": 1000002, 223 | "text": { 224 | "content": `${title}\n\n${content}` 225 | }, 226 | "safe": 0 227 | }) 228 | if (send.errcode === 0) { 229 | console.log('企业微信应用消息发送成功') 230 | } else { 231 | console.log('企业微信应用消息发送失败', send) 232 | } 233 | } 234 | */ 235 | 236 | async function getDevice() { 237 | let {data} = await axios.get('https://betahub.cn/api/apple/devices/iPhone', { 238 | headers: { 239 | 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' 240 | } 241 | }) 242 | data = data[getRandomNumberByRange(0, 16)] 243 | return data.identifier 244 | } 245 | 246 | async function getVersion(device: string) { 247 | let {data} = await axios.get(`https://betahub.cn/api/apple/firmwares/${device}`, { 248 | headers: { 249 | 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' 250 | } 251 | }) 252 | data = data[getRandomNumberByRange(0, data.length)] 253 | return data.firmware_info.version 254 | } 255 | 256 | async function jdpingou() { 257 | let device: string, version: string; 258 | device = await getDevice(); 259 | version = await getVersion(device); 260 | return `jdpingou;iPhone;5.19.0;${version};${randomString(40)};network/wifi;model/${device};appBuild/100833;ADID/;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/${getRandomNumberByRange(10, 90)};pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148` 261 | } 262 | 263 | function get(url: string, headers?: any): Promise { 264 | return new Promise((resolve, reject) => { 265 | axios.get(url, { 266 | headers: headers 267 | }).then(res => { 268 | if (typeof res.data === 'string' && res.data.includes('jsonpCBK')) { 269 | resolve(JSON.parse(res.data.match(/jsonpCBK.?\(([\w\W]*)\);?/)[1])) 270 | } else { 271 | resolve(res.data) 272 | } 273 | }).catch(err => { 274 | reject({ 275 | code: err?.response?.status || -1, 276 | msg: err?.response?.statusText || err.message || 'error' 277 | }) 278 | }) 279 | }) 280 | } 281 | 282 | function post(url: string, prarms?: string | object, headers?: any): Promise { 283 | return new Promise((resolve, reject) => { 284 | axios.post(url, prarms, { 285 | headers: headers 286 | }).then(res => { 287 | resolve(res.data) 288 | }).catch(err => { 289 | reject({ 290 | code: err?.response?.status || -1, 291 | msg: err?.response?.statusText || err.message || 'error' 292 | }) 293 | }) 294 | }) 295 | } 296 | 297 | export default USER_AGENT 298 | export { 299 | getBeanShareCode, 300 | getFarmShareCode, 301 | getCookie, 302 | wait, 303 | getRandomNumberByRange, 304 | getJxToken, 305 | exceptCookie, 306 | randomString, 307 | o2s, 308 | randomNumString, 309 | getshareCodeHW, 310 | getShareCodePool, 311 | randomWord, 312 | jdpingou, 313 | get, 314 | post, 315 | USER_AGENT, 316 | USER_AGENTS_ARR 317 | } 318 | -------------------------------------------------------------------------------- /USER_AGENTS.js: -------------------------------------------------------------------------------- 1 | const USER_AGENTS = [ 2 | "jdapp;android;10.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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.0.2;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 | * 生成随机数字 42 | * @param {number} min 最小值(包含) 43 | * @param {number} max 最大值(不包含) 44 | */ 45 | function randomNumber(min = 0, max = 100) { 46 | return Math.min(Math.floor(min + Math.random() * (max - min)), max); 47 | } 48 | 49 | const USER_AGENT = USER_AGENTS[randomNumber(0, USER_AGENTS.length)]; 50 | 51 | module.exports = { 52 | USER_AGENT, 53 | } 54 | -------------------------------------------------------------------------------- /iOS_Cookie.js: -------------------------------------------------------------------------------- 1 | /** 2 | * RegExp: 3 | * https:\/\/api\.m\.jd\.com\/client\.action\?functionId=(trade_config|genToken) 4 | */ 5 | 6 | const $ = new Env('cookie'); 7 | 8 | let cookie = '', s = '' 9 | if ($request.url.includes('https://api.m.jd.com/client.action?functionId=trade_config')) { 10 | // h5 11 | cookie = $request.headers['cookie'] || $request.headers['Cookie'] 12 | cookie.match(/(pt_key|pt_pin)[^;]*/g).map(item => { 13 | s += item + ';' 14 | }) 15 | 16 | } else if ($request.url.includes('https://api.m.jd.com/client.action?functionId=genToken')) { 17 | cookie = $request.headers['cookie'] || $request.headers['Cookie'] 18 | cookie.match(/(wskey|pt_pin)[^;]*/g).map(item => { 19 | s += item + ';' 20 | }) 21 | } 22 | 23 | console.log('========================') 24 | console.log(s) 25 | console.log('========================') 26 | $.msg('获取成功', 'success', '在日志中查看'); 27 | $.done() 28 | 29 | function Env(t, e) { 30 | "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); 31 | 32 | class s { 33 | constructor(t) { 34 | this.env = t 35 | } 36 | 37 | send(t, e = "GET") { 38 | t = "string" == typeof t ? {url: t} : t; 39 | let s = this.get; 40 | return "POST" === e && (s = this.post), new Promise((e, i) => { 41 | s.call(this, t, (t, s, r) => { 42 | t ? i(t) : e(s) 43 | }) 44 | }) 45 | } 46 | 47 | get(t) { 48 | return this.send.call(this.env, t) 49 | } 50 | 51 | post(t) { 52 | return this.send.call(this.env, t, "POST") 53 | } 54 | } 55 | 56 | return new class { 57 | constructor(t, e) { 58 | 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}, 开始!`) 59 | } 60 | 61 | isNode() { 62 | return "undefined" != typeof module && !!module.exports 63 | } 64 | 65 | isQuanX() { 66 | return "undefined" != typeof $task 67 | } 68 | 69 | isSurge() { 70 | return "undefined" != typeof $httpClient && "undefined" == typeof $loon 71 | } 72 | 73 | isLoon() { 74 | return "undefined" != typeof $loon 75 | } 76 | 77 | toObj(t, e = null) { 78 | try { 79 | return JSON.parse(t) 80 | } catch { 81 | return e 82 | } 83 | } 84 | 85 | toStr(t, e = null) { 86 | try { 87 | return JSON.stringify(t) 88 | } catch { 89 | return e 90 | } 91 | } 92 | 93 | getjson(t, e) { 94 | let s = e; 95 | const i = this.getdata(t); 96 | if (i) try { 97 | s = JSON.parse(this.getdata(t)) 98 | } catch { 99 | } 100 | return s 101 | } 102 | 103 | setjson(t, e) { 104 | try { 105 | return this.setdata(JSON.stringify(t), e) 106 | } catch { 107 | return !1 108 | } 109 | } 110 | 111 | getScript(t) { 112 | return new Promise(e => { 113 | this.get({url: t}, (t, s, i) => e(i)) 114 | }) 115 | } 116 | 117 | runScript(t, e) { 118 | return new Promise(s => { 119 | let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); 120 | i = i ? i.replace(/\n/g, "").trim() : i; 121 | let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); 122 | r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; 123 | 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: "*/*"}}; 124 | this.post(n, (t, e, i) => s(i)) 125 | }).catch(t => this.logErr(t)) 126 | } 127 | 128 | loaddata() { 129 | if (!this.isNode()) return {}; 130 | { 131 | this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); 132 | 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); 133 | if (!s && !i) return {}; 134 | { 135 | const i = s ? t : e; 136 | try { 137 | return JSON.parse(this.fs.readFileSync(i)) 138 | } catch (t) { 139 | return {} 140 | } 141 | } 142 | } 143 | } 144 | 145 | writedata() { 146 | if (this.isNode()) { 147 | this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); 148 | 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); 149 | s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) 150 | } 151 | } 152 | 153 | lodash_get(t, e, s) { 154 | const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); 155 | let r = t; 156 | for (const t of i) if (r = Object(r)[t], void 0 === r) return s; 157 | return r 158 | } 159 | 160 | lodash_set(t, e, s) { 161 | 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) 162 | } 163 | 164 | getdata(t) { 165 | let e = this.getval(t); 166 | if (/^@/.test(t)) { 167 | const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; 168 | if (r) try { 169 | const t = JSON.parse(r); 170 | e = t ? this.lodash_get(t, i, "") : e 171 | } catch (t) { 172 | e = "" 173 | } 174 | } 175 | return e 176 | } 177 | 178 | setdata(t, e) { 179 | let s = !1; 180 | if (/^@/.test(e)) { 181 | const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; 182 | try { 183 | const e = JSON.parse(h); 184 | this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) 185 | } catch (e) { 186 | const o = {}; 187 | this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) 188 | } 189 | } else s = this.setval(t, e); 190 | return s 191 | } 192 | 193 | getval(t) { 194 | 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 195 | } 196 | 197 | setval(t, e) { 198 | 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 199 | } 200 | 201 | initGotEnv(t) { 202 | 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)) 203 | } 204 | 205 | get(t, e = (() => { 206 | })) { 207 | 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) => { 208 | !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) 209 | })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {hints: !1})), $task.fetch(t).then(t => { 210 | const {statusCode: s, statusCode: i, headers: r, body: o} = t; 211 | e(null, {status: s, statusCode: i, headers: r, body: o}, o) 212 | }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { 213 | try { 214 | if (t.headers["set-cookie"]) { 215 | const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); 216 | s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar 217 | } 218 | } catch (t) { 219 | this.logErr(t) 220 | } 221 | }).then(t => { 222 | const {statusCode: s, statusCode: i, headers: r, body: o} = t; 223 | e(null, {status: s, statusCode: i, headers: r, body: o}, o) 224 | }, t => { 225 | const {message: s, response: i} = t; 226 | e(s, i, i && i.body) 227 | })) 228 | } 229 | 230 | post(t, e = (() => { 231 | })) { 232 | 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) => { 233 | !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) 234 | }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {hints: !1})), $task.fetch(t).then(t => { 235 | const {statusCode: s, statusCode: i, headers: r, body: o} = t; 236 | e(null, {status: s, statusCode: i, headers: r, body: o}, o) 237 | }, t => e(t)); else if (this.isNode()) { 238 | this.initGotEnv(t); 239 | const {url: s, ...i} = t; 240 | this.got.post(s, i).then(t => { 241 | const {statusCode: s, statusCode: i, headers: r, body: o} = t; 242 | e(null, {status: s, statusCode: i, headers: r, body: o}, o) 243 | }, t => { 244 | const {message: s, response: i} = t; 245 | e(s, i, i && i.body) 246 | }) 247 | } 248 | } 249 | 250 | time(t, e = null) { 251 | const s = e ? new Date(e) : new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000); 252 | 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()}; 253 | /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); 254 | 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))); 255 | return t 256 | } 257 | 258 | msg(e = t, s = "", i = "", r) { 259 | const o = t => { 260 | if (!t) return t; 261 | if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? {"open-url": t} : this.isSurge() ? {url: t} : void 0; 262 | if ("object" == typeof t) { 263 | if (this.isLoon()) { 264 | let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; 265 | return {openUrl: e, mediaUrl: s} 266 | } 267 | if (this.isQuanX()) { 268 | let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; 269 | return {"open-url": e, "media-url": s} 270 | } 271 | if (this.isSurge()) { 272 | let e = t.url || t.openUrl || t["open-url"]; 273 | return {url: e} 274 | } 275 | } 276 | }; 277 | if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { 278 | let t = ["", "==============📣系统通知📣=============="]; 279 | t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) 280 | } 281 | } 282 | 283 | log(...t) { 284 | t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) 285 | } 286 | 287 | logErr(t, e) { 288 | const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); 289 | s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) 290 | } 291 | 292 | wait(t) { 293 | return new Promise(e => setTimeout(e, t)) 294 | } 295 | 296 | done(t = {}) { 297 | const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; 298 | this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) 299 | } 300 | }(t, e) 301 | } 302 | -------------------------------------------------------------------------------- /jdCookie.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const dotenv = require('dotenv') 3 | 4 | let CookieJDs = [] 5 | 6 | try { 7 | process.chdir(__dirname) 8 | fs.accessSync('.env', fs.constants.R_OK) 9 | dotenv.config() 10 | } catch (e) { 11 | } 12 | 13 | if (process.env.JD_COOKIE) { 14 | if (process.env.JD_COOKIE.indexOf('&') > -1) { 15 | CookieJDs = process.env.JD_COOKIE.split('&'); 16 | } else if (process.env.JD_COOKIE.indexOf('\n') > -1) { 17 | CookieJDs = process.env.JD_COOKIE.split('\n'); 18 | } else { 19 | CookieJDs = [process.env.JD_COOKIE]; 20 | } 21 | } 22 | if (JSON.stringify(process.env).indexOf('GITHUB') > -1) { 23 | process.exit(0); 24 | } 25 | CookieJDs = [...new Set(CookieJDs.filter(item => !!item))] 26 | if (!require.main.filename.includes('.ts')) { 27 | console.log(`\n====================共${CookieJDs.length}个京东账号Cookie=========\n`); 28 | console.log(`================== ${new Date().toLocaleString('zh-CN', {timeZone: 'Asia/Shanghai'})} =====================\n`) 29 | } 30 | for (let i = 0; i < CookieJDs.length; i++) { 31 | const index = (i + 1 === 1) ? '' : (i + 1); 32 | exports['CookieJD' + index] = CookieJDs[i].trim(); 33 | } 34 | -------------------------------------------------------------------------------- /jdFruitShareCodes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 东东农场互助码 3 | * 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 4 | * 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 5 | */ 6 | 7 | let FruitShareCodes = [] 8 | 9 | if (process.env.FRUITSHARECODES) { 10 | if (process.env.FRUITSHARECODES.indexOf('&') > -1) { 11 | console.log(`您的东东农场互助码选择的是用&隔开\n`) 12 | FruitShareCodes = process.env.FRUITSHARECODES.split('&'); 13 | } else if (process.env.FRUITSHARECODES.indexOf('\n') > -1) { 14 | console.log(`您的东东农场互助码选择的是用换行隔开\n`) 15 | FruitShareCodes = process.env.FRUITSHARECODES.split('\n'); 16 | } else { 17 | FruitShareCodes = process.env.FRUITSHARECODES.split(); 18 | } 19 | } else { 20 | console.log('FRUITSHARECODES undefined') 21 | } 22 | for (let i = 0; i < FruitShareCodes.length; i++) { 23 | const index = (i + 1 === 1) ? '' : (i + 1); 24 | exports['FruitShareCode' + index] = FruitShareCodes[i]; 25 | } -------------------------------------------------------------------------------- /jdPetShareCodes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 萌宠互助码 3 | * 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开 4 | * 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 5 | */ 6 | 7 | let PetShareCodes = [] 8 | 9 | if (process.env.PETSHARECODES) { 10 | if (process.env.PETSHARECODES.indexOf('&') > -1) { 11 | console.log(`您的东东萌宠互助码选择的是用&隔开\n`) 12 | PetShareCodes = process.env.PETSHARECODES.split('&'); 13 | } else if (process.env.PETSHARECODES.indexOf('\n') > -1) { 14 | console.log(`您的东东萌宠互助码选择的是用换行隔开\n`) 15 | PetShareCodes = process.env.PETSHARECODES.split('\n'); 16 | } else { 17 | PetShareCodes = process.env.PETSHARECODES.split(); 18 | } 19 | } else { 20 | console.log(`PETSHARECODES undefined`) 21 | } 22 | for (let i = 0; i < PetShareCodes.length; i++) { 23 | const index = (i + 1 === 1) ? '' : (i + 1); 24 | exports['PetShareCode' + index] = PetShareCodes[i]; 25 | } -------------------------------------------------------------------------------- /jdPlantBeanShareCodes.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 京东种豆得豆互助码 3 | * 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 4 | * 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 5 | */ 6 | 7 | let PlantBeanShareCodes = [] 8 | 9 | if (process.env.PLANT_BEAN_SHARECODES) { 10 | if (process.env.PLANT_BEAN_SHARECODES.indexOf('&') > -1) { 11 | console.log(`您的种豆互助码选择的是用&隔开\n`) 12 | PlantBeanShareCodes = process.env.PLANT_BEAN_SHARECODES.split('&'); 13 | } else if (process.env.PLANT_BEAN_SHARECODES.indexOf('\n') > -1) { 14 | console.log(`您的种豆互助码选择的是用换行隔开\n`) 15 | PlantBeanShareCodes = process.env.PLANT_BEAN_SHARECODES.split('\n'); 16 | } else { 17 | PlantBeanShareCodes = process.env.PLANT_BEAN_SHARECODES.split(); 18 | } 19 | } else { 20 | console.log('PLANT_BEAN_SHARECODES undefined') 21 | } 22 | for (let i = 0; i < PlantBeanShareCodes.length; i++) { 23 | const index = (i + 1 === 1) ? '' : (i + 1); 24 | exports['PlantBeanShareCodes' + index] = PlantBeanShareCodes[i]; 25 | } 26 | -------------------------------------------------------------------------------- /jd_bean_box.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 领京豆-任务 3 | * 助力:内部 -> HW 4 | * cron: 1 0,9,12,18 * * * 5 | */ 6 | 7 | import axios from 'axios' 8 | import USER_AGENT, {get, randomNumString, getCookie, wait} from './TS_USER_AGENTS' 9 | 10 | let cookie: string = '', res: any = '', UserName: string, index: number, uuid: string 11 | 12 | !(async () => { 13 | let cookiesArr: string[] = await getCookie() 14 | for (let i = 0; i < cookiesArr.length; i++) { 15 | cookie = cookiesArr[i] 16 | UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) 17 | index = i + 1 18 | console.log(`\n开始【京东账号${index}】${UserName}\n`) 19 | 20 | let headers: object = { 21 | 'Host': 'api.m.jd.com', 22 | 'Origin': 'https://h5.m.jd.com', 23 | 'User-Agent': USER_AGENT, 24 | 'Referer': 'https://h5.m.jd.com/', 25 | 'Cookie': cookie 26 | } 27 | res = await get('https://api.m.jd.com/client.action?functionId=initForTurntableFarm&body=%7B%22version%22%3A4%2C%22channel%22%3A1%7D&appid=wh5', headers) 28 | let times: number = res.remainLotteryTimes 29 | console.log('剩余抽奖机会:', times) 30 | for (let j = 0; j < times; j++) { 31 | console.log('开始抽奖...') 32 | res = await get('https://api.m.jd.com/client.action?functionId=lotteryForTurntableFarm&body=%7B%22type%22%3A1%2C%22version%22%3A4%2C%22channel%22%3A1%7D&appid=wh5', headers) 33 | if (res.code === '0') { 34 | if (res.type === 'thanks') { 35 | console.log('抽奖成功,获得:狗屁') 36 | } else { 37 | console.log('抽奖成功,获得:', res.type) 38 | } 39 | } else { 40 | console.log('抽奖失败', res) 41 | } 42 | await wait(5000) 43 | } 44 | 45 | uuid = randomNumString(40) 46 | for (let j = 0; j < 2; j++) { 47 | console.log(`Round:${j + 1}`) 48 | res = await api('beanTaskList', {"viewChannel": "AppHome"}) 49 | try { 50 | for (let t of res.data.taskInfos) { 51 | if (t.status === 1) { 52 | console.log(t.taskName) 53 | res = await api('beanDoTask', { 54 | "actionType": t.taskType === 3 ? 0 : 1, 55 | "taskToken": t.subTaskVOS[0].taskToken 56 | }) 57 | res.data?.bizMsg ? console.log(res.data.bizMsg) : console.log(res) 58 | await wait(t.waitDuration * 1000 || 2000) 59 | 60 | if (t.taskType !== 3) { 61 | res = await api('beanDoTask', { 62 | "actionType": 0, 63 | "taskToken": t.subTaskVOS[0].taskToken 64 | }) 65 | if (res.data?.bizMsg) 66 | console.log(res.data.bizMsg) 67 | } 68 | await wait(1000) 69 | } 70 | } 71 | } catch (e) { 72 | console.log('Error!', e) 73 | } 74 | await wait(2000) 75 | } 76 | } 77 | })() 78 | 79 | async function api(fn: string, body: object) { 80 | let {data}: any = await axios.post(`https://api.m.jd.com/client.action?functionId=${fn}`, 81 | `body=${encodeURIComponent(JSON.stringify(body))}&appid=ld&client=apple&clientVersion=10.0.8&uuid=${uuid}&openudid=${uuid}`, { 82 | headers: { 83 | 'Host': 'api.m.jd.com', 84 | 'content-type': 'application/x-www-form-urlencoded', 85 | 'referer': '', 86 | 'user-agent': 'JD4iPhone/167863%20(iPhone;%20iOS;%20Scale/3.00)', 87 | 'Cookie': cookie 88 | } 89 | }) 90 | return data 91 | } 92 | -------------------------------------------------------------------------------- /jd_bean_sign.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * App签到 3 | * cron: 8 10 * * * 4 | */ 5 | 6 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 7 | import {H5ST} from "./utils/h5st" 8 | 9 | class Jd_bean_sign extends JDHelloWorld { 10 | user: User 11 | h5stTool: H5ST 12 | fp: string = '' 13 | 14 | constructor() { 15 | super(); 16 | } 17 | 18 | async init() { 19 | this.fp = await this.getFp4_1() 20 | await this.run(this) 21 | } 22 | 23 | async main(user: User) { 24 | try { 25 | this.user = user 26 | this.user.UserAgent = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 MicroMessenger/6.8.0(0x16080000) NetType/WIFI MiniProgramEnv/Mac MacWechat/WMPF XWEB/30515` 27 | this.h5stTool = new H5ST('64e35', this.fp, this.user.UserAgent, this.user.UserName, 'https://h5.m.jd.com/', 'https://h5.m.jd.com/') 28 | await this.h5stTool.genAlgo() 29 | let timestamp: number = Date.now() 30 | let h5st = this.h5stTool.genH5st('235ec', {"fp": "-1", "shshshfp": "-1", "shshshfpa": "-1", "referUrl": "-1", "userAgent": "-1", "jda": "-1", "rnVersion": "3.9", "appid": "64e35", "needSecurity": true, "bizId": "active"}, 'apple', '12.1.4', 'signBeanAct', timestamp) 31 | let res: any = await this.get(`https://api.m.jd.com/client.action?functionId=signBeanAct&body=%7B%22fp%22%3A%22-1%22%2C%22shshshfp%22%3A%22-1%22%2C%22shshshfpa%22%3A%22-1%22%2C%22referUrl%22%3A%22-1%22%2C%22userAgent%22%3A%22-1%22%2C%22jda%22%3A%22-1%22%2C%22rnVersion%22%3A%223.9%22%2C%22appid%22%3A%2264e35%22%2C%22needSecurity%22%3Atrue%2C%22bizId%22%3A%22active%22%7D&appid=signed_wh5&client=apple&clientVersion=12.1.4&loginType=2&h5st=${h5st}`, { 32 | 'Host': 'api.m.jd.com', 33 | 'User-Agent': this.user.UserAgent, 34 | 'Referer': 'https://h5.m.jd.com/', 35 | 'Cookie': this.user.cookie 36 | }) 37 | this.o2s(res) 38 | 39 | if (res.data.status === '1') { 40 | console.log('签到成功', res.data.dailyAward.beanAward.beanCount * 1) 41 | } else if (res.data.status === '2') { 42 | console.log('已签到') 43 | } 44 | } catch (e) { 45 | console.log(e.message) 46 | } 47 | } 48 | } 49 | 50 | new Jd_bean_sign().init().then() -------------------------------------------------------------------------------- /jd_cash.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 领现金 3 | * cron: 8 0,9,15 * * * 4 | */ 5 | 6 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 7 | import {H5ST} from "./utils/h5st_pro"; 8 | 9 | class Jd_Cash extends JDHelloWorld { 10 | user: User 11 | fp: string 12 | h5stTool: H5ST 13 | shareCodeSelf: { inviteCode: string, shareDate: string }[] = [] 14 | 15 | constructor() { 16 | super(); 17 | } 18 | 19 | async init() { 20 | this.fp = process.env.FP_c8815 || await this.getFp() 21 | await this.run(this) 22 | } 23 | 24 | async api(fn: string, body: object) { 25 | let timestamp: number = Date.now() 26 | let h5st: string = await this.h5stTool.__genH5st({ 27 | appid: 'signed_mp', 28 | body: JSON.stringify(body), 29 | client: 'wh5', 30 | clientVersion: '1.0.0', 31 | functionId: fn, 32 | t: timestamp.toString() 33 | }) 34 | return await this.post('https://api.m.jd.com/', 35 | `loginType=2&clientType=wxapp&client=wh5&clientVersion=1.0.0&appid=signed_mp&t=${timestamp}&functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&loginWQBiz=pet-town&h5st=${h5st}&_ste=2`, { 36 | 'Host': 'api.m.jd.com', 37 | 'user-agent': this.user.UserAgent, 38 | 'referer': 'https://servicewechat.com/wx91d27dbf599dff74/707/page-frame.html', 39 | 'wqreferer': 'http://wq.jd.com/wxapp/pages/ac/get_cash/pages/index/index', 40 | 'X-Referer-Page': '/pages/ac/get_cash/pages/index/index', 41 | 'Cookie': this.user.cookie 42 | }) 43 | } 44 | 45 | async main(user: User) { 46 | try { 47 | this.user = user 48 | this.h5stTool = new H5ST("c8815", this.user.UserAgent, this.fp, 'https://servicewechat.com/wx91d27dbf599dff74/707/page-frame.html', 'https://servicewechat.com', this.user.UserName); 49 | await this.h5stTool.__genAlgo() 50 | let res: any = await this.api('cash_mob_home', {"version": "1", "channel": "applet"}) 51 | console.log('signedStatus', res.data.result.signedStatus) 52 | // this.o2s(res) 53 | console.log('助力码', res.data.result.inviteCode) 54 | this.shareCodeSelf.push({ 55 | inviteCode: res.data.result.inviteCode, 56 | shareDate: res.data.result.shareDate 57 | }) 58 | res = await this.post('https://api.m.jd.com/', `appid=wh5_mp&client=wh5&t=${Date.now()}&clientVersion=1.0.0&functionId=cash_mini_app_detail&body=%7B%22version%22%3A%221%22%2C%22channel%22%3A%22applet%22%2C%22type%22%3A3%7D&loginType=2&loginWQBiz=pet-town`, { 59 | 'Host': 'api.m.jd.com', 60 | 'user-agent': this.user.UserAgent, 61 | 'referer': 'https://servicewechat.com/wx91d27dbf599dff74/710/page-frame.html', 62 | 'wqreferer': 'http://wq.jd.com/wxapp/pages/ac/get_cash/pages/details/index', 63 | 'Content-Type': 'application/x-www-form-urlencoded', 64 | 'Cookie': this.user.cookie 65 | }) 66 | console.log('收到助力', res.data.result.assistDetail[0].assistResult.length) 67 | if (res.data.result.signedStatus !== 1) { 68 | console.log('签到') 69 | res = await this.api('cash_mob_sign', {"version": "1", "channel": "applet", "remind": 0}) 70 | if (res.data.bizCode === 0) { 71 | console.log('签到成功', res.data.result.signCash) 72 | } else { 73 | this.o2s(res, '签到失败') 74 | } 75 | } 76 | } catch (e) { 77 | console.log(e.message) 78 | } 79 | await this.wait(15000) 80 | } 81 | 82 | async help(users: User[]) { 83 | this.o2s(this.shareCodeSelf, '内部助力') 84 | let res: any 85 | let temp: any = await this.getshareCodeHW('cash') 86 | let shareCodeHW: { inviteCode: string, shareDate: string }[] = [] 87 | for (let t of temp) 88 | shareCodeHW.push({inviteCode: t.inviteCode, shareDate: t.shareDate}) 89 | for (let user of users) { 90 | try { 91 | this.user = user 92 | let shareCode: { inviteCode: string, shareDate: string }[] 93 | if (user.index === 0) 94 | shareCode = [...shareCodeHW, ...this.shareCodeSelf] 95 | else 96 | shareCode = [...this.shareCodeSelf, ...shareCodeHW] 97 | this.h5stTool = new H5ST("c8815", this.user.UserAgent, this.fp, 'https://servicewechat.com/wx91d27dbf599dff74/707/page-frame.html', 'https://servicewechat.com', this.user.UserName); 98 | await this.h5stTool.__genAlgo() 99 | for (let code of shareCode) { 100 | console.log(`账号${user.index + 1} ${user.UserName} 去助力 ${code.inviteCode}`) 101 | res = await this.api('cash_qr_code_assist', {"version": "1", "channel": "applet", "type": 2, "inviteCode": code.inviteCode, "shareDate": code.shareDate, "lng": "", "lat": ""}) 102 | if (res.data.bizCode === 0) { 103 | console.log('助力成功') 104 | break 105 | } else if (res.data.bizCode === 207) { 106 | console.log('上限') 107 | break 108 | } else { 109 | this.o2s(res, '助力结果') 110 | } 111 | await this.wait(15000) 112 | } 113 | } catch (e) { 114 | console.log(e) 115 | } 116 | await this.wait(15000) 117 | } 118 | } 119 | } 120 | 121 | new Jd_Cash().init().then() 122 | -------------------------------------------------------------------------------- /jd_checkCookie.ts: -------------------------------------------------------------------------------- 1 | import {User, JDHelloWorld} from './TS_JDHelloWorld' 2 | 3 | class Check_cookie extends JDHelloWorld { 4 | constructor() { 5 | super("Cookie检测"); 6 | } 7 | 8 | async init() { 9 | await this.run(this) 10 | } 11 | 12 | async main(user: User) { 13 | let res: any = await this.get(`https://plogin.m.jd.com/cgi-bin/ml/islogin`, { 14 | 'user-agent': user.UserAgent, 15 | 'cookie': user.cookie 16 | }) 17 | if (res.islogin === '1') { 18 | console.log('✅') 19 | } else { 20 | console.log('❌') 21 | return {msg: `Cookie过期 账号${user.index + 1} ${user.UserName}`} 22 | } 23 | } 24 | } 25 | 26 | new Check_cookie().init().then() 27 | -------------------------------------------------------------------------------- /jd_cww.ts: -------------------------------------------------------------------------------- 1 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 2 | import {H5ST} from "./utils/h5st_pro"; 3 | import * as JDJRValidator from './utils/validate_single' 4 | import {differenceInMinutes, format} from "date-fns"; 5 | 6 | class Cww extends JDHelloWorld { 7 | user: User 8 | h5stTool: H5ST 9 | shareCodeSelf: string[] = [] 10 | fp: any = undefined 11 | 12 | constructor() { 13 | super(); 14 | } 15 | 16 | async init() { 17 | this.fp = process.env.FP_D7BFE || await this.getFp() 18 | await this.run(this) 19 | } 20 | 21 | async beforeApi(fn: string, body: object) { 22 | let timestamp: string = Date.now().toString(); 23 | let h5st: string = await this.h5stTool.__genH5st({ 24 | 'appid': 'jdchoujiang_h5', 25 | 'body': JSON.stringify(body), 26 | 'client': 'iOS', 27 | 'clientVersion': '11.3.0', 28 | 'functionId': fn, 29 | 't': timestamp.toString() 30 | }) 31 | let params: string = '' 32 | for (let key of Object.keys(body)) params += '&' + key + '=' + body[key] 33 | let beforeApiRes = await this.get(`https://api.m.jd.com/api?client=iOS&clientVersion=11.3.0&appid=jdchoujiang_h5&t=${timestamp}&functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&h5st=${h5st}${params}`, { 34 | 'Host': 'api.m.jd.com', 35 | 'Content-Type': 'application/json', 36 | 'Origin': 'https://h5.m.jd.com', 37 | 'Cookie': this.user.cookie, 38 | 'User-Agent': this.user.UserAgent, 39 | 'Referer': 'https://h5.m.jd.com/', 40 | }) 41 | if (JSON.stringify(beforeApiRes).includes("请进行验证")) { 42 | let {validate} = await new JDJRValidator.JDJRValidator().run() 43 | console.log('validate', validate) 44 | return await this.beforeApi(fn, {...body, validate}) 45 | } else { 46 | return beforeApiRes 47 | } 48 | } 49 | 50 | async api(fn: string, body: object) { 51 | let timestamp: string = Date.now().toString(); 52 | let h5st: string = await this.h5stTool.__genH5st({ 53 | 'appid': 'jdchoujiang_h5', 54 | 'body': JSON.stringify(body), 55 | 'client': '', 56 | 'clientVersion': '', 57 | 'functionId': fn, 58 | 't': timestamp.toString() 59 | }) 60 | let url: string = `https://api.m.jd.com/api?client=&clientVersion=&appid=jdchoujiang_h5&t=${timestamp}&functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&h5st=${h5st}` 61 | let res: any = await this.post(url, body, { 62 | 'Host': 'api.m.jd.com', 63 | 'Content-Type': 'application/json', 64 | 'Origin': 'https://h5.m.jd.com', 65 | 'Cookie': this.user.cookie, 66 | 'User-Agent': this.user.UserAgent, 67 | 'Referer': 'https://h5.m.jd.com/', 68 | }) 69 | if (JSON.stringify(res).includes("请进行验证")) { 70 | let {validate} = await new JDJRValidator.JDJRValidator().run() 71 | console.log('validate', validate) 72 | return await this.api(fn, {...body, validate}) 73 | } else { 74 | return res 75 | } 76 | } 77 | 78 | async main(user: User) { 79 | try { 80 | this.user = user 81 | this.user.UserAgent = `jdapp;iPhone;11.3.0;;;M/5.0;appBuild/167874;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 82 | let res: any, data: any 83 | 84 | this.h5stTool = new H5ST('2bba1', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 85 | await this.h5stTool.__genAlgo() 86 | res = await this.api('petEnterRoom', {"invitePin": "", "reqSource": "h5"}) 87 | this.o2s(res, 'petEnterRoom') 88 | 89 | // feed 90 | let petFood: number = res.data.petFood 91 | let lastFeedTime: number = res.data.lastFeedTime 92 | console.log('狗粮', petFood) 93 | console.log('lastFeedTime', format(lastFeedTime, "yyyy-MM-dd HH:mm:ss")) 94 | let feedCount: number = 0 95 | for (let t of [10, 20, 40, 80]) { 96 | if (petFood < t) { 97 | break 98 | } else { 99 | feedCount = t 100 | } 101 | } 102 | if (differenceInMinutes(Date.now(), lastFeedTime) > 180 && feedCount) { 103 | this.h5stTool = new H5ST('15dc2', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 104 | await this.h5stTool.__genAlgo() 105 | res = await this.beforeApi('feed', {"feedCount": feedCount, "reqSource": "h5"}) 106 | console.log(res.errorCode) 107 | await this.wait(3000) 108 | } 109 | 110 | res = await this.beforeApi('combatDetail', {"help": false, "reqSource": "h5"}) 111 | this.o2s(res, 'combatDetail') 112 | if (res.data.petRaceResult === 'participate') { 113 | console.log('比赛中') 114 | for (let raceUser of res.data.raceUsers) { 115 | raceUser.myself 116 | ? console.log(raceUser.nickName, raceUser.distance) 117 | : console.log('对手', raceUser.distance) 118 | } 119 | } else if (res.data.petRaceResult === 'not_participate') { 120 | console.log('开始匹配') 121 | this.h5stTool = new H5ST('79b06', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 122 | await this.h5stTool.__genAlgo() 123 | data = await this.beforeApi('clickIcon', {"code": "1624363341529274068136", "iconCode": "race_match", "reqSource": "h5"}) 124 | this.h5stTool = new H5ST('d91e0', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 125 | await this.h5stTool.__genAlgo() 126 | data = await this.beforeApi('clickIconNew', {"iconCode": "race_match", "reqSource": "h5"}) 127 | 128 | this.h5stTool = new H5ST('6f192', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 129 | await this.h5stTool.__genAlgo() 130 | data = await this.beforeApi('combatMatch', {"teamLevel": "2", "reqSource": "h5"}) 131 | this.o2s(data, 'combatMatch') 132 | } else if (res.data.petRaceResult === 'unreceive') { 133 | let winCoin: number = res.data.winCoin 134 | this.h5stTool = new H5ST('04889', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 135 | await this.h5stTool.__genAlgo() 136 | data = await this.beforeApi('combatReceive', {"reqSource": "h5"}) 137 | console.log('赛跑获胜', winCoin) 138 | } 139 | 140 | this.h5stTool = new H5ST('922a5', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 141 | await this.h5stTool.__genAlgo() 142 | res = await this.api('petGetPetTaskConfig', {"reqSource": "h5"}) 143 | this.o2s(res, 'petGetPetTaskConfig') 144 | await this.wait(2000) 145 | 146 | for (let t of res.datas) { 147 | if (t.followShops) { 148 | this.h5stTool = new H5ST('79b06', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 149 | await this.h5stTool.__genAlgo() 150 | data = await this.beforeApi('clickIcon', {"code": "1624363341529274068136", "iconCode": "follow_shop", "reqSource": "h5"}) 151 | this.h5stTool = new H5ST('d91e0', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 152 | await this.h5stTool.__genAlgo() 153 | data = await this.beforeApi('clickIconNew', {"iconCode": "follow_shop", "reqSource": "h5"}) 154 | 155 | for (let followShops of t.followShops) { 156 | if (followShops.status) continue 157 | console.log(t.taskName, followShops.name) 158 | this.h5stTool = new H5ST('79b06', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 159 | await this.h5stTool.__genAlgo() 160 | data = await this.beforeApi('clickIcon', {"code": "1624363341529274068136", "iconCode": "follow_shop", "linkAddr": followShops.shopId.toString(), "reqSource": "h5"}) 161 | 162 | this.h5stTool = new H5ST('d91e0', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 163 | await this.h5stTool.__genAlgo() 164 | data = await this.beforeApi('clickIconNew', {"iconCode": "follow_shop", "linkAddr": followShops.shopId.toString(), "reqSource": "h5"}) 165 | 166 | this.h5stTool = new H5ST('30717', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 167 | await this.h5stTool.__genAlgo() 168 | data = await this.api('followShopColor', {'shopId': followShops.shopId.toString(), 'reqSource': 'h5'}) 169 | console.log('followShopColor', data.errorCode) 170 | } 171 | } 172 | 173 | if (t.followChannelList) { 174 | this.h5stTool = new H5ST('d91e0', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 175 | await this.h5stTool.__genAlgo() 176 | data = await this.beforeApi('clickIconNew', {"iconCode": "follow_channel", "reqSource": "h5"}) 177 | this.h5stTool = new H5ST('5f8cb', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 178 | await this.h5stTool.__genAlgo() 179 | data = await this.api('getFollowChannels', {"reqSource": "h5"}) 180 | await this.wait(1000) 181 | 182 | for (let followChannelList of t.followChannelList) { 183 | if (followChannelList.status) continue 184 | console.log(t.taskName, followChannelList.channelName) 185 | this.h5stTool = new H5ST('79b06', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 186 | await this.h5stTool.__genAlgo() 187 | data = await this.beforeApi('clickIcon', {"code": "1624363341529274068136", "iconCode": "follow_channel", "linkAddr": followChannelList.channelId, "reqSource": "h5"}) 188 | 189 | this.h5stTool = new H5ST('d91e0', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 190 | await this.h5stTool.__genAlgo() 191 | data = await this.beforeApi('clickIconNew', {"code": "1624363341529274068136", "iconCode": "follow_channel", "linkAddr": followChannelList.channelId, "reqSource": "h5"}) 192 | 193 | this.h5stTool = new H5ST('30717', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 194 | await this.h5stTool.__genAlgo() 195 | data = await this.api('scan', {'channelId': followChannelList.channelId, 'taskType': 'FollowChannel', 'sid': '66594924', 'reqSource': 'h5'}) 196 | console.log('scan', data.errorCode) 197 | await this.wait(5000) 198 | } 199 | } 200 | 201 | if (t.scanMarketList) { 202 | for (let scanMarketList of t.scanMarketList) { 203 | if (scanMarketList.status) continue 204 | console.log(t.taskName, scanMarketList.marketName) 205 | 206 | this.h5stTool = new H5ST('79b06', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 207 | await this.h5stTool.__genAlgo() 208 | data = await this.beforeApi('clickIcon', {"code": "1624363341529274068136", "iconCode": "scan_market", "linkAddr": scanMarketList.marketLinkH5, "reqSource": "h5"}) 209 | 210 | this.h5stTool = new H5ST('d91e0', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 211 | await this.h5stTool.__genAlgo() 212 | data = await this.beforeApi('clickIconNew', {"iconCode": "scan_market", "linkAddr": scanMarketList.marketLinkH5, "reqSource": "h5"}) 213 | 214 | this.h5stTool = new H5ST('30717', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 215 | await this.h5stTool.__genAlgo() 216 | data = await this.api('scan', {"marketLink": scanMarketList.marketLinkH5, "marketId": scanMarketList.marketLinkH5, "taskType": "ScanMarket", "sid": "66594924", "reqSource": "h5"}) 217 | console.log('scanMarketList', data.errorCode) 218 | await this.wait(5000) 219 | } 220 | } 221 | 222 | if (t.receiveStatus === 'unreceive') { 223 | this.h5stTool = new H5ST('6917d', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 224 | await this.h5stTool.__genAlgo() 225 | data = await this.api('getFood', {"taskType": t.taskType, "reqSource": "h5"}) 226 | this.o2s(data, '领取奖励') 227 | console.log('领取奖励', t.taskName, data.data) 228 | await this.wait(1000) 229 | } 230 | } 231 | } catch (e) { 232 | console.log(e.message) 233 | } 234 | } 235 | } 236 | 237 | new Cww().init().then() -------------------------------------------------------------------------------- /jd_cww_help.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 宠汪汪-助力 3 | * cron: 15 8,12 * * * 4 | */ 5 | 6 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 7 | import {H5ST} from "./utils/h5st_pro"; 8 | 9 | class Jd_cww_help extends JDHelloWorld { 10 | user: User 11 | h5stTool: H5ST 12 | shareCodeSelf: string[] = [] 13 | fp: any = undefined 14 | 15 | constructor() { 16 | super(); 17 | } 18 | 19 | async init() { 20 | await this.run(this) 21 | } 22 | 23 | async api(fn: string, body: object) { 24 | let timestamp: string = Date.now().toString(); 25 | let h5st: string = await this.h5stTool.__genH5st({ 26 | 'appid': 'choujiangyingyong', 27 | 'body': JSON.stringify(body), 28 | 'client': 'macOS 12.6.0', 29 | 'clientVersion': '3.5.5', 30 | 'functionId': fn, 31 | 't': timestamp.toString() 32 | }) 33 | let url: string = `https://api.m.jd.com/api?client=macOS%2012.6.0&clientVersion=3.5.5&appid=choujiangyingyong&t=${timestamp}&functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&h5st=${h5st}` 34 | return await this.get(url, { 35 | 'Host': 'api.m.jd.com', 36 | 'User-Agent': this.user.UserAgent, 37 | 'Referer': 'https://servicewechat.com/wxccb5c536b0ecd1bf/854/page-frame.html', 38 | 'Accept-Language': 'zh-CN,zh-Hans;q=0.9', 39 | 'Content-Type': 'application/json', 40 | 'Cookie': this.user.cookie 41 | }) 42 | } 43 | 44 | async main(user: User) { 45 | console.log(user.index) 46 | } 47 | 48 | async help(users: User[]) { 49 | let full: string[] = [] 50 | this.fp = await this.getFp() 51 | for (let user of users) { 52 | this.user = user 53 | this.user.UserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E217 MicroMessenger/6.8.0(0x16080000) NetType/WIFI Language/en Branch/Br_trunk MiniProgramEnv/Mac` 54 | let res: any 55 | 56 | this.h5stTool = new H5ST('538b4', this.user.UserAgent, this.fp, "https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html", "https://h5.m.jd.com/") 57 | await this.h5stTool.__genAlgo() 58 | 59 | for (let code of users) { 60 | if (user.UserName === code.UserName || full.includes(code.UserName)) continue 61 | console.log(`账号${user.index + 1} ${user.UserName} 去助力 ${code.UserName}`) 62 | res = await this.api('helpFriend', {"friendPin": code.UserName, "reqSource": "weapp"}) 63 | await this.wait(2000) 64 | console.log(res.errorCode) 65 | 66 | if (res.errorCode === 'invite_full') full.push(code.UserName) 67 | if (res.errorCode === 'help_full') break 68 | } 69 | } 70 | } 71 | } 72 | 73 | new Jd_cww_help().init().then() -------------------------------------------------------------------------------- /jd_dwapp.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 京东-生活积分 3 | */ 4 | 5 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 6 | 7 | class Jd_dwapp extends JDHelloWorld { 8 | user: User 9 | 10 | constructor() { 11 | super(); 12 | } 13 | 14 | async init() { 15 | await this.run(this) 16 | } 17 | 18 | async api(fn: string, body: object) { 19 | return await this.post(`https://api.m.jd.com/api?functionId=${fn}`, new URLSearchParams({ 20 | 'appid': 'h5-sep', 21 | 'functionId': fn, 22 | 'body': JSON.stringify(this.getEncStr(fn, body)), 23 | 'client': 'm', 24 | 'clientVersion': '6.0.0' 25 | }), { 26 | 'Host': 'api.m.jd.com', 27 | 'Origin': 'https://prodev.m.jd.com', 28 | 'User-Agent': this.user.UserAgent, 29 | 'Referer': 'https://prodev.m.jd.com/mall/active/eEcYM32eezJB7YX4SBihziJCiGV/index.html', 30 | 'Cookie': this.user.cookie 31 | }) 32 | } 33 | 34 | async task(fn: string, body: object) { 35 | let url: string = fn === 'dwSignInfo' ? fn : `task/${fn}` 36 | return await this.post(`https://dwapp.jd.com/user/${url}`, this.getEncStr(fn, body), { 37 | 'Host': 'dwapp.jd.com', 38 | 'Origin': 'https://prodev.m.jd.com', 39 | 'User-Agent': this.user.UserAgent, 40 | 'Referer': 'https://prodev.m.jd.com/mall/active/eEcYM32eezJB7YX4SBihziJCiGV/index.html', 41 | 'Cookie': this.user.cookie 42 | }) 43 | } 44 | 45 | async main(user: User) { 46 | this.user = user 47 | let res: any 48 | res = await this.task('dwSignInfo', {}) 49 | if (res.data.signInfo.signStatus !== 1) { 50 | res = await this.api('DATAWALLET_USER_SIGN', {}) 51 | console.log('签到成功', res.data.signInfo.signNum) 52 | } else { 53 | console.log('已签到') 54 | } 55 | 56 | res = await this.api('dwapp_task_dwList', {}) 57 | for (let t of res.data) { 58 | if (t.viewStatus === 0) { 59 | console.log(t.name) 60 | res = await this.task('dwRecord', {id: t.id, "taskType": t.taskType, "agentNum": "m", "followChannelStatus": ""}) 61 | console.log(res.msg) 62 | await this.wait(4000) 63 | res = await this.task('dwReceive', {id: t.id}) 64 | console.log(res?.data?.giveScoreNum) 65 | } 66 | await this.wait(6000) 67 | } 68 | await this.wait(120000) 69 | } 70 | } 71 | 72 | new Jd_dwapp().init().then() -------------------------------------------------------------------------------- /jd_farm.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 新版农场 3 | * cron: 15 8-10,18-20 * * * 4 | */ 5 | 6 | import {H5ST_42} from './utils/h5st_4.2' 7 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 8 | 9 | class Jd_farm extends JDHelloWorld { 10 | user: User 11 | fp41: string 12 | appId: string 13 | shareCodeSelf: string[] = [] 14 | h5stTool: H5ST_42 15 | 16 | constructor() { 17 | super(); 18 | } 19 | 20 | async init() { 21 | this.fp41 = await this.getFp4_1() 22 | await this.run(this) 23 | } 24 | 25 | async api(fn: string, body: object): Promise<{}> { 26 | let timestamp: number = Date.now() 27 | let h5st: string = this.h5stTool.h5st({ 28 | appid: 'signed_wh5', 29 | body: body, 30 | client: '', 31 | clientVersion: '1.0.0', 32 | functionId: fn, 33 | t: timestamp 34 | }) 35 | return await this.post('https://api.m.jd.com/client.action', 36 | `appid=signed_wh5&client=&clientVersion=1.0.0&t=${timestamp}&body=${JSON.stringify(body)}&functionId=${fn}&h5st=${h5st}`, 37 | { 38 | 'authority': 'api.m.jd.com', 39 | 'cookie': this.user.cookie, 40 | 'origin': 'https://h5.m.jd.com', 41 | 'referer': 'https://h5.m.jd.com/', 42 | 'user-agent': this.user.UserAgent, 43 | 'x-referer-page': 'https://h5.m.jd.com/pb/015686010/Bc9WX7MpCW7nW9QjZ5N3fFeJXMH/index.html', 44 | 'x-rp-client': 'h5_1.0.0' 45 | } 46 | ) 47 | } 48 | 49 | async main(user: User) { 50 | try { 51 | this.user = user 52 | this.user.UserAgent = `jdapp;iPhone;12.2.2;;;M/5.0;appBuild/168923;jdSupportDarkMode/0;ef/1;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 53 | let res: any, data: any 54 | this.appId = 'c57f6' 55 | this.h5stTool = new H5ST_42(this.appId, this.user.UserAgent, this.user.UserName, 'https://h5.m.jd.com/pb/015686010/Bc9WX7MpCW7nW9QjZ5N3fFeJXMH/index.html', 'https://h5.m.jd.com') 56 | await this.h5stTool.algo() 57 | 58 | res = await this.api('farm_home', {"version": 1}) 59 | this.o2s(res) 60 | 61 | let bottleWater: number = res.data.result.bottleWater 62 | console.log('💧', bottleWater) 63 | let inviteCode: string = res.data.result.farmHomeShare.inviteCode 64 | console.log('助力码', inviteCode) 65 | this.shareCodeSelf.push(inviteCode) 66 | 67 | res = await this.api('farm_task_list', {"version": 1, "channel": 0}) 68 | this.appId = '28981' 69 | this.h5stTool = new H5ST_42(this.appId, this.user.UserAgent, this.user.UserName, 'https://h5.m.jd.com/pb/015686010/Bc9WX7MpCW7nW9QjZ5N3fFeJXMH/index.html', 'https://h5.m.jd.com') 70 | await this.h5stTool.algo() 71 | 72 | for (let t of res.data.result.taskList) { 73 | if (t.taskType.includes('BROWSE')) { 74 | if (!t.taskDoTimes) { 75 | let taskSourceUrl: string = t.taskSourceUrl, taskInsert: boolean = false 76 | if (!t.taskSourceUrl) { 77 | data = await this.api('farm_task_detail', {"version": 1, "taskType": t.taskType, "taskId": t.taskId, "channel": 0}) 78 | taskSourceUrl = data.data.result.taskDetaiList[0].itemId 79 | taskInsert = true 80 | } 81 | console.log('开始任务', t.mainTitle) 82 | data = await this.api('farm_do_task', { 83 | "version": 1, "taskType": t.taskType, "taskId": t.taskId, "taskInsert": taskInsert, "itemId": Buffer.from(taskSourceUrl, 'utf8').toString('base64'), "channel": 84 | 0 85 | }) 86 | await this.wait(3000) 87 | data.data.bizCode === 0 ? console.log('任务完成') : console.log('任务失败', data) 88 | } 89 | } else if (t.taskType === 'CUMULATIVE_TIMES') { 90 | console.log(`今日浇水${t.taskDoTimes}/10`) 91 | for (let i = 0; i < 10 - t.taskDoTimes; i++) { 92 | if (bottleWater < 10) break 93 | data = await this.api('farm_water', {"version": 1, "waterType": 1}) 94 | if (data.data.bizCode === 0) { 95 | console.log('浇水成功', t.taskDoTimes + i + 1) 96 | bottleWater = data.data.result.bottleWater 97 | } 98 | await this.wait(3000) 99 | } 100 | } 101 | } 102 | 103 | res = await this.api('farm_task_list', {"version": 1, "channel": 0}) 104 | this.appId = '33e0f' 105 | this.h5stTool = new H5ST_42(this.appId, this.user.UserAgent, this.user.UserName, 'https://h5.m.jd.com/pb/015686010/Bc9WX7MpCW7nW9QjZ5N3fFeJXMH/index.html', 'https://h5.m.jd.com') 106 | await this.h5stTool.algo() 107 | 108 | for (let t of res.data.result.taskList) { 109 | if (t.taskStatus === 2) { 110 | data = await this.api('farm_task_receive_award', {"version": 1, "taskType": t.taskType, "taskId": t.taskId, "channel": 0}) 111 | console.log('领取奖励💧', data.data.result.taskAward[0].awardValue) 112 | await this.wait(2000) 113 | } 114 | } 115 | // farm_water {"version":1,"waterType":1} 28981 116 | 117 | // this.h5st41 = new H5ST('deba1', this.fp41, this.user.UserAgent, this.user.UserName, 'https://pro.m.jd.com/mall/active/37KFb2rZywRxkAeiCGrE57oring8/index.html', 'https://pro.m.jd.com') 118 | // await this.h5st41.genAlgo() 119 | // res = await this.old('dongDongFarmSignHome', {"linkId": "LCH-fV7hSnChB-6i5f4ayw"}) 120 | // this.o2s(res) 121 | } catch (e) { 122 | console.log(e.message) 123 | await this.wait(30000) 124 | } 125 | } 126 | 127 | async help(users: User[]): Promise { 128 | let res: any 129 | this.appId = '28981' 130 | for (let user of users) { 131 | try { 132 | this.user = user 133 | this.user.UserAgent = `jdapp;iPhone;12.2.2;;;M/5.0;appBuild/168923;jdSupportDarkMode/0;ef/1;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 134 | this.h5stTool = new H5ST_42(this.appId, this.user.UserAgent, this.user.UserName, 'https://h5.m.jd.com/pb/015686010/Bc9WX7MpCW7nW9QjZ5N3fFeJXMH/index.html', 'https://h5.m.jd.com') 135 | await this.h5stTool.algo() 136 | 137 | let shareCodePool: string[] = await this.getShareCodePool('farm2', 50) 138 | let shareCode: string[] = Array.from(new Set([...this.shareCodeSelf, ...shareCodePool])) 139 | for (let code of shareCode) { 140 | try { 141 | console.log(`账号${user.index + 1} ${user.UserName} 去助力 ${code} ${this.shareCodeSelf.includes(code) ? '*内部*' : ''}`) 142 | res = await this.api('farm_assist', {"version": 1, "inviteCode": code, "shareChannel": "ttt7", "assistChannel": ""}) 143 | this.o2s(res, '助力结果') 144 | if (res.code === 0 && res.data.bizCode === 0) { 145 | console.log('助力成功') 146 | } else if (res.code === 0 && res.data.bizCode !== 0) { 147 | console.log(res.data.bizMsg) 148 | } else { 149 | console.log(res) 150 | } 151 | } catch (e) { 152 | console.log(e.message) 153 | } 154 | await this.wait(5000) 155 | } 156 | } catch (e) { 157 | console.log(e) 158 | } 159 | await this.wait(60000) 160 | } 161 | } 162 | } 163 | 164 | new Jd_farm().init().then() -------------------------------------------------------------------------------- /jd_fission.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 抽奖 3 | * cron: 5 0-3,20-22 * * * 4 | */ 5 | 6 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 7 | import {readFileSync} from "fs" 8 | import {JSDOM, ResourceLoader, VirtualConsole} from "jsdom" 9 | import CryptoJS from "crypto-js"; 10 | 11 | class Jd_fission extends JDHelloWorld { 12 | user: User 13 | fp: string 14 | appId: string 15 | shareCodeSelf: string[] = [] 16 | htstTool: any 17 | 18 | constructor() { 19 | super(); 20 | } 21 | 22 | async init() { 23 | await this.run(this) 24 | } 25 | 26 | async h5stToolInit() { 27 | let dom = new JSDOM(``, { 28 | url: "http://localhost", 29 | userAgent: this.user.UserAgent, 30 | runScripts: "dangerously", 31 | resources: new ResourceLoader({ 32 | userAgent: this.user.UserAgent 33 | }), 34 | includeNodeLocations: true, 35 | storageQuota: 1000000000, 36 | pretendToBeVisual: true, 37 | virtualConsole: new VirtualConsole() 38 | }) 39 | this.htstTool = new dom.window.ParamsSign({appId: this.appId}) 40 | } 41 | 42 | async api(fn: string, body: object) { 43 | let t = Date.now() 44 | let h5st: string = (await this.htstTool.sign({ 45 | appid: 'activities_platform', 46 | body: CryptoJS.SHA256(JSON.stringify(body)).toString(CryptoJS.enc.Hex), 47 | client: 'ios', 48 | clientVersion: '12.3.2', 49 | functionId: fn, 50 | t: t 51 | })).h5st 52 | return await this.post('https://api.m.jd.com/api', `functionId=${fn}&body=${JSON.stringify(body)}&t=${t}&appid=activities_platform&client=ios&clientVersion=12.3.2&h5st=${h5st}`, { 53 | 'authority': 'api.m.jd.com', 54 | 'User-Agent': this.user.UserAgent, 55 | 'origin': 'https://pro.m.jd.com', 56 | 'referer': 'https://pro.m.jd.com/mall/active/3BwUqhLsJYrHP4qgAgDDJGrSVngK/index.html', 57 | 'Cookie': this.user.cookie, 58 | 'x-referer-page': 'https://pro.m.jd.com/mall/active/3BwUqhLsJYrHP4qgAgDDJGrSVngK/index.html', 59 | 'x-rp-client': 'h5_1.0.0' 60 | }) 61 | } 62 | 63 | async main(user: User) { 64 | for (let j = 0; j < 2; j++) { 65 | try { 66 | this.user = user 67 | this.user.UserAgent = j === 0 68 | ? `jdapp;iPhone;12.3.2;;;M/5.0;appBuild/169031;Mozilla/5.0 (iPhone; CPU iPhone OS 15_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 69 | : `jdltapp;iPhone;6.3.0;;;M/5.0;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;hasOCPay/0;appBuild/1372;Mozilla/5.0 (iPhone; CPU iPhone OS 15_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 70 | this.appId = '02f8d' 71 | await this.h5stToolInit() 72 | let res: any, data: any 73 | let linkId: string = j === 0 ? '3orGfh1YkwNLksxOcN8zWQ' : 'Wvzc_VpNTlSkiQdHT8r7QA' 74 | res = await this.api('inviteFissionBeforeHome', {"linkId": linkId, "isJdApp": true, "inviter": ""}) 75 | console.log('助力码', res.data.inviter) 76 | this.shareCodeSelf.push(res.data.inviter) 77 | await this.wait(1000) 78 | 79 | this.appId = 'eb67b' 80 | await this.h5stToolInit() 81 | 82 | res = await this.api('inviteFissionHome', {"linkId": linkId, "inviter": ""}) 83 | let lotteryTimes: number = res.data.prizeNum 84 | console.log('可抽奖', lotteryTimes) 85 | 86 | if (lotteryTimes) { 87 | this.appId = 'c02c6' 88 | await this.h5stToolInit() 89 | for (let i: number = 0; i < lotteryTimes; i++) { 90 | data = await this.api('inviteFissionDrawPrize', {"linkId": linkId}) 91 | try { 92 | if (data.data.prizeType === 2) { 93 | console.log('🧧', data.data.prizeValue * 1) 94 | } else if (data.data.prizeType === 4) { 95 | console.log('💰', data.data.prizeValue * 1) 96 | } else { 97 | this.o2s(data, '抽到其他') 98 | } 99 | } catch (e) { 100 | console.log(e.message) 101 | this.o2s(data) 102 | } 103 | await this.wait(8000) 104 | } 105 | } 106 | 107 | 108 | this.appId = 'f2b1d' 109 | await this.h5stToolInit() 110 | let end: boolean = false 111 | for (let i = 1; i < 5; i++) { 112 | console.log('page', i) 113 | res = await this.api('superRedBagList', {"pageNum": i, "pageSize": 20, "linkId": linkId, "business": "fission"}) 114 | if (end) break 115 | try { 116 | for (let t of res.data.items) { 117 | if (t.prizeType === 4 && t.state === -1) { 118 | end = true 119 | break 120 | } else if (res.data.items.length < 20) { 121 | end = true 122 | break 123 | } else if (t.prizeType === 4 && t.state === 0) { 124 | data = await this.api('apCashWithDraw', {"businessSource": "NONE", "base": {"id": t.id, "business": "fission", "poolBaseId": t.poolBaseId, "prizeGroupId": t.prizeGroupId, "prizeBaseId": t.prizeBaseId, "prizeType": 4}, "linkId": linkId}) 125 | console.log(data.data.message, data.data.record.amount * 1) 126 | await this.wait(8000) 127 | if (data.data.message === '提现中') 128 | break 129 | } 130 | } 131 | } catch (e) { 132 | console.log(e.message) 133 | break 134 | } 135 | await this.wait(8000) 136 | } 137 | } catch (e) { 138 | console.log(e.message) 139 | await this.wait(5000) 140 | } 141 | } 142 | } 143 | 144 | async help(users: User[]) { 145 | this.o2s(this.shareCodeSelf, '内部助力') 146 | let res: any 147 | this.appId = 'c5389' 148 | let shareCodeHW: string[] = [] 149 | for (let j = 0; j < 2; j++) { 150 | for (let user of users) { 151 | try { 152 | if (shareCodeHW.length === 0) shareCodeHW = await this.getshareCodeHW('fission') 153 | this.user = user 154 | this.user.UserAgent = j === 0 155 | ? `jdapp;iPhone;12.2.0;;;M/5.0;appBuild/168919;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 156 | : `jdltapp;iPhone;6.3.0;;;M/5.0;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;hasOCPay/0;appBuild/1372;Mozilla/5.0 (iPhone; CPU iPhone OS 15_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 157 | await this.h5stToolInit() 158 | let shareCode: string[] = [...shareCodeHW, ...this.shareCodeSelf] 159 | for (let code of shareCode) { 160 | console.log(`账号${user.index + 1} ${user.UserName} 去助力 ${code}`) 161 | res = await this.api('inviteFissionhelp', {"linkId": j === 0 ? '3orGfh1YkwNLksxOcN8zWQ' : "Wvzc_VpNTlSkiQdHT8r7QA", "isJdApp": true, "inviter": code}) 162 | this.o2s(res, 'inviteFissionhelp') 163 | await this.wait(3000) 164 | if (!res.data.helpResult) { 165 | console.log('!helpResult') 166 | continue 167 | } 168 | if (res.data.helpResult === 1) { 169 | console.log('助力成功') 170 | break 171 | } else if (res.data.helpResult === 3) { 172 | console.log('上限') 173 | break 174 | } 175 | } 176 | } catch (e) { 177 | console.log(e.message) 178 | } 179 | } 180 | } 181 | } 182 | } 183 | 184 | new Jd_fission().init().then() -------------------------------------------------------------------------------- /jd_fruit_help.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 种树助力 3 | * cron: 35 0,6,12,18,23 * * * 4 | */ 5 | 6 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 7 | import {JSDOM, ResourceLoader, VirtualConsole} from "jsdom"; 8 | import {readFileSync} from "fs"; 9 | import CryptoJS from "crypto-js"; 10 | 11 | class Jd_fruit_help extends JDHelloWorld { 12 | user: User 13 | shareCodeSelf: string[] = [] 14 | appId: string 15 | htstTool: any 16 | 17 | constructor() { 18 | super(); 19 | } 20 | 21 | async init() { 22 | await this.run(this) 23 | } 24 | 25 | async h5stToolInit() { 26 | let dom = new JSDOM(``, { 27 | url: "http://localhost", 28 | userAgent: this.user.UserAgent, 29 | runScripts: "dangerously", 30 | resources: new ResourceLoader({ 31 | userAgent: this.user.UserAgent 32 | }), 33 | includeNodeLocations: true, 34 | storageQuota: 1000000000, 35 | pretendToBeVisual: true, 36 | virtualConsole: new VirtualConsole() 37 | }) 38 | this.htstTool = new dom.window.ParamsSign({appId: this.appId}) 39 | } 40 | 41 | async api(fn: string, body: object) { 42 | let t = Date.now(), h5st: string = (await this.htstTool.sign({ 43 | appid: 'signed_wh5', 44 | body: CryptoJS.SHA256(JSON.stringify(body)).toString(CryptoJS.enc.Hex), 45 | client: 'iOS', 46 | clientVersion: '13.0.2', 47 | functionId: fn, 48 | timestamp: t.toString() 49 | })).h5st 50 | return await this.get(`https://api.m.jd.com/client.action?functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&appid=signed_wh5&area=0_0_0_0×tamp=${t}&client=iOS&clientVersion=13.0.2&h5st=${h5st}`, { 51 | 'Host': 'api.m.jd.com', 52 | 'Origin': 'https://carry.m.jd.com', 53 | 'User-Agent': this.user.UserAgent, 54 | 'Cookie': this.user.cookie, 55 | 'Referer': 'https://carry.m.jd.com/', 56 | 'x-referer-page': 'https://carry.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html', 57 | }) 58 | } 59 | 60 | async main(user: User) { 61 | try { 62 | this.user = user 63 | this.user.UserAgent = `jdapp;iPhone;13.0.2;;;M/5.0;appBuild/169363;jdSupportDarkMode/0;ef/1;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 64 | this.appId = '8a2af' 65 | await this.h5stToolInit() 66 | let res: any = await this.api('initForFarm', {"babelChannel": "522", "shareCode": "", "mpin": "", "from": "", "version": 26, "channel": 1, "lat": "0", "lng": "0"}) 67 | console.log('助力码', res['farmUserPro'].shareCode) 68 | this.shareCodeSelf.push(res['farmUserPro'].shareCode) 69 | } catch (e) { 70 | console.log('获取失败', e) 71 | } 72 | await this.wait(5000) 73 | } 74 | 75 | async help(users: User[]) { 76 | let res: any 77 | for (let user of users) { 78 | try { 79 | this.user = user 80 | this.user.UserAgent = `jdapp;iPhone;13.0.2;;;M/5.0;appBuild/169363;jdSupportDarkMode/0;ef/1;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 81 | this.appId = '8a2af' 82 | await this.h5stToolInit() 83 | let shareCodePool: string[] = await this.getShareCodePool('farm', 50) 84 | let shareCode: string[] = Array.from(new Set([...this.shareCodeSelf, ...shareCodePool])) 85 | for (let code of shareCode) { 86 | try { 87 | console.log(`账号${user.index + 1} ${user.UserName} 去助力 ${code}`) 88 | res = await this.api('initForFarm', {"babelChannel": "522", "shareCode": code, "mpin": "", "from": "kouling", "version": 26, "channel": 1, "lat": "0", "lng": "0"}) 89 | console.log('剩余助力', res.helpResult.remainTimes, '助力结果', res.helpResult.code) 90 | if (res.helpResult.remainTimes === 0) { 91 | console.log('上限') 92 | break 93 | } 94 | } catch (e) { 95 | console.log(e.message) 96 | } 97 | await this.wait(5000) 98 | } 99 | } catch (e) { 100 | console.log(e) 101 | } 102 | await this.wait(15000) 103 | } 104 | } 105 | } 106 | 107 | new Jd_fruit_help().init().then() -------------------------------------------------------------------------------- /jd_fruit_without_help.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 京东-种树 3 | * 不带水滴助力 4 | * cron: 35 7,13,20 * * * 5 | */ 6 | 7 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 8 | import {H5ST} from "./utils/h5st_pro"; 9 | import {addHours, getTime} from "date-fns"; 10 | 11 | class Jd_fruit extends JDHelloWorld { 12 | user: User 13 | h5stTool: H5ST 14 | shareCodeSelf: string[] = [] 15 | fp: any = undefined 16 | 17 | constructor() { 18 | super(); 19 | } 20 | 21 | async init() { 22 | this.fp = await this.getFp() 23 | await this.run(this) 24 | } 25 | 26 | async api(fn: string, body: object) { 27 | let timestamp: string = Date.now().toString(); 28 | let h5st: string = await this.h5stTool.__genH5st({ 29 | 'appid': 'signed_wh5', 30 | 'body': JSON.stringify(body), 31 | 'client': 'iOS', 32 | 'clientVersion': '11.3.0', 33 | 'functionId': fn, 34 | }) 35 | return await this.get(`https://api.m.jd.com/client.action?functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&appid=signed_wh5×tamp=${timestamp}&client=iOS&clientVersion=11.3.0&h5st=${h5st}`, { 36 | 'Host': 'api.m.jd.com', 37 | 'Origin': 'https://carry.m.jd.com', 38 | 'User-Agent': this.user.UserAgent, 39 | 'Referer': 'https://carry.m.jd.com/', 40 | 'Cookie': this.user.cookie 41 | }) 42 | } 43 | 44 | async friendListInitForFarm() { 45 | return await this.get(`https://api.m.jd.com/client.action?functionId=friendListInitForFarm&body=%7B%22lastId%22%3Anull%2C%22version%22%3A18%2C%22channel%22%3A1%2C%22babelChannel%22%3A%2210%22%7D&appid=wh5×tamp=${Date.now()}&client=iOS&clientVersion=11.3.0`, { 46 | 'Host': 'api.m.jd.com', 47 | 'Origin': 'https://carry.m.jd.com', 48 | 'User-Agent': this.user.UserAgent, 49 | 'Referer': 'https://carry.m.jd.com/', 50 | 'Cookie': this.user.cookie 51 | }) 52 | } 53 | 54 | async main(user: User) { 55 | try { 56 | this.user = user 57 | this.user.UserAgent = `jdapp;iPhone;11.3.0;;;M/5.0;appBuild/168341;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 58 | let res: any, data: any 59 | 60 | this.h5stTool = new H5ST('8a2af', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 61 | await this.h5stTool.__genAlgo() 62 | res = await this.api('initForFarm', {"babelChannel": "10", "sid": "", "un_area": "", "version": 18, "channel": 1}) 63 | if (res.code === '0') { 64 | console.log('助力码', res.farmUserPro.shareCode) 65 | this.shareCodeSelf.push(res.farmUserPro.shareCode) 66 | } else if (res.code === '3') { 67 | console.log('Cookie过期') 68 | return {msg: `账号${this.user.index + 1} ${this.user.UserName}\nCookie过期\n`} 69 | } else { 70 | this.o2s(res, '初始化失败') 71 | process.exit(0) 72 | } 73 | let totalEnergy: number = res.farmUserPro.totalEnergy 74 | console.log('🌲', res.farmUserPro.treeEnergy) 75 | if (res.farmUserPro.treeEnergy === res.farmUserPro.treeTotalEnergy) { 76 | return {msg: `账号${this.user.index + 1} ${this.user.UserName}\n种树成熟\n`} 77 | } 78 | 79 | // 弹窗水滴 80 | if (res.todayGotWaterGoalTask.canPop) { 81 | this.h5stTool = new H5ST('c901b', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 82 | await this.h5stTool.__genAlgo() 83 | data = await this.api('gotWaterGoalTaskForFarm', {"type": 3, "version": 18, "channel": 1, "babelChannel": "10"}) 84 | console.log('弹窗水滴💧', data.addEnergy) 85 | } 86 | 87 | // 背包 88 | this.h5stTool = new H5ST('157b6', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 89 | await this.h5stTool.__genAlgo() 90 | res = await this.api('myCardInfoForFarm', {"version": 18, "channel": 1, "babelChannel": "10"}) 91 | if (res.doubleCard && totalEnergy >= 100) { 92 | console.log('水滴翻倍卡数量', res.doubleCard) 93 | this.h5stTool = new H5ST('86ba5', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 94 | await this.h5stTool.__genAlgo() 95 | for (; res.doubleCard > 0; --res.doubleCard) { 96 | data = await this.api('userMyCardForFarm', {"cardType": "doubleCard", "type": "", "version": 18, "channel": 1, "babelChannel": "10"}) 97 | data.code === '0' && console.log('使用水滴翻倍卡', data.addWater) 98 | await this.wait(1000) 99 | } 100 | } 101 | 102 | res = await this.api('initForTurntableFarm', {"version": 4, "channel": 1}) 103 | for (let t of res.turntableBrowserAds) { 104 | if (!t.status) { 105 | console.log(t.main) 106 | await this.api('browserForTurntableFarm', {"type": 1, "adId": t.adId, "version": 4, "channel": 1}) 107 | await this.wait(t.browserTimes * 1000 || 1000) 108 | data = await this.api('browserForTurntableFarm', {"type": 2, "adId": t.adId, "version": 4, "channel": 1}) 109 | data.code === '0' && console.log('抽奖次数', data.totalTimes) 110 | } 111 | } 112 | res = await this.api('initForTurntableFarm', {"version": 4, "channel": 1}) 113 | if (!res.timingGotStatus && Date.now() > getTime(addHours(res.timingLastSysTime, 4))) { 114 | data = await this.api('timingAwardForTurntableFarm', {"version": 4, "channel": 1}) 115 | data.code === '0' && console.log('抽奖次数+', data.addTimes) 116 | } 117 | for (let i = 0; i < res.remainLotteryTimes; i++) { 118 | data = await this.api('lotteryForTurntableFarm', {"type": 1, "version": 4, "channel": 1}) 119 | console.log('抽奖结果', data.type) 120 | await this.wait(3000) 121 | } 122 | 123 | // 任务列表 124 | this.h5stTool = new H5ST('fcb5a', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 125 | await this.h5stTool.__genAlgo() 126 | res = await this.api('taskInitForFarm', {"version": 18, "channel": 1, "babelChannel": "10"}) 127 | 128 | if (!res['treasureBoxInit-getBean']?.f) { 129 | 130 | } 131 | // this.h5stTool = new H5ST('67dfc', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/','https://carry.m.jd.com/') 132 | // await this.h5stTool.__genAlgo() 133 | // data = await this.api('ddnc_getTreasureBoxAward', {"type": 1, "babelChannel": "10", "line": "getBean", "version": 18, "channel": 1}) 134 | // await this.wait(2000) 135 | // data = await this.api('farmMarkStatus', {"version": 18, "channel": 1, "babelChannel": "98"}) 136 | // data = await this.api('ddnc_getTreasureBoxAward', {"type": 2, "babelChannel": "98", "line": "getBean", "version": 18, "channel": 1}) 137 | // this.o2s(data) 138 | // data.code === '0' && console.log('ddnc_getTreasureBoxAward 💧', data.waterGram) 139 | // } 140 | 141 | if (!res.totalWaterTaskInit.f) { 142 | this.h5stTool = new H5ST('0c010', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 143 | await this.h5stTool.__genAlgo() 144 | for (let i = 0; i < 10 - res.totalWaterTaskTimes; i++) { 145 | data = await this.api('waterGoodForFarm', {"type": "", "version": 18, "channel": 1, "babelChannel": "10"}) 146 | if (data.code === '0') { 147 | console.log('💧', data.totalEnergy) 148 | console.log('🌲', data.treeEnergy) 149 | } else { 150 | console.log('浇水失败', data) 151 | break 152 | } 153 | await this.wait(5000) 154 | } 155 | this.h5stTool = new H5ST('102f5', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 156 | await this.h5stTool.__genAlgo() 157 | data = await this.api('totalWaterTaskForFarm', {"version": 18, "channel": 1, "babelChannel": "10"}) 158 | data.code === '0' && console.log('十次奖励💧', data.totalWaterTaskEnergy) 159 | } 160 | 161 | if (!res.firstWaterInit.f && res.firstWaterInit.totalWaterTimes) { 162 | this.h5stTool = new H5ST('0cf1e', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 163 | await this.h5stTool.__genAlgo() 164 | data = await this.api('firstWaterTaskForFarm', {"version": 18, "channel": 1, "babelChannel": "10"}) 165 | data.code === '0' && console.log('首次奖励💧', data.amount) 166 | } 167 | 168 | if (!res.gotThreeMealInit.f) { 169 | if (![10, 15, 16, 22, 23].includes(new Date().getHours())) { 170 | data = await this.api('gotThreeMealForFarm', {"version": 18, "channel": 1, "babelChannel": "10"}) 171 | data.code === '0' && console.log('定时奖励💧', data.amount) 172 | await this.wait(1000) 173 | } 174 | } 175 | 176 | if (!res.gotBrowseTaskAdInit.f) { 177 | this.h5stTool = new H5ST('53f09', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 178 | await this.h5stTool.__genAlgo() 179 | for (let t of res.gotBrowseTaskAdInit.userBrowseTaskAds) { 180 | if (t.hadFinishedTimes !== t.limit) { 181 | console.log(t.mainTitle) 182 | data = await this.api('browseAdTaskForFarm', {"advertId": t.advertId, "type": 0, "version": 18, "channel": 1, "babelChannel": "10"}) 183 | data.code === '0' && console.log('任务完成') 184 | await this.wait(t.time * 1000 || 2000) 185 | data = await this.api('browseAdTaskForFarm', {"advertId": t.advertId, "type": 1, "version": 18, "channel": 1, "babelChannel": "10"}) 186 | data.code === '0' && console.log('领奖成功💧', data.amount) 187 | await this.wait(1000) 188 | } 189 | } 190 | } 191 | 192 | if (!res.waterRainInit.f && Date.now() > getTime(addHours(res.lastTime || 1669906397000, 4))) { 193 | this.h5stTool = new H5ST('9983a', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 194 | await this.h5stTool.__genAlgo() 195 | data = await this.api('waterRainForFarm', {"type": 1, "hongBaoTimes": 99, "version": 14, "channel": 1}) 196 | data.code === '0' ? console.log('红包雨💧', data.addEnergy) : this.o2s(data, '红包雨error') 197 | await this.wait(1000) 198 | } 199 | 200 | if (!res.waterFriendTaskInit.f) { 201 | let friendList = await this.friendListInitForFarm() 202 | let finishCount: number = 0 203 | for (let t of friendList.friends) { 204 | if (t.friendState === 1) { 205 | console.log(`帮好友 ${t.nickName} ${t.shareCode} 浇水`) 206 | this.h5stTool = new H5ST('a5a9c', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 207 | await this.h5stTool.__genAlgo() 208 | await this.api('friendInitForFarm', {"shareCode": t.shareCode, "version": 18, "channel": 1, "babelChannel": "10"}) 209 | this.h5stTool = new H5ST('673a0', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 210 | await this.h5stTool.__genAlgo() 211 | data = await this.api('waterFriendForFarm', {"shareCode": t.shareCode, "version": 18, "channel": 1, "babelChannel": "10"}) 212 | if (data.code === '0') { 213 | console.log('帮助成功') 214 | finishCount++ 215 | } else { 216 | this.o2s(data, '帮助失败') 217 | break 218 | } 219 | await this.wait(2000) 220 | if (finishCount === 2) break 221 | } 222 | } 223 | this.h5stTool = new H5ST('d08ff', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 224 | await this.h5stTool.__genAlgo() 225 | data = await this.api('waterFriendGotAwardForFarm', {"version": 18, "channel": 1, "babelChannel": "10"}) 226 | console.log('帮好友浇水奖励💧', data.addWater) 227 | } 228 | 229 | // 签到页面 230 | this.h5stTool = new H5ST('08dc3', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 231 | await this.h5stTool.__genAlgo() 232 | res = await this.api('clockInInitForFarm', {"timestamp": Date.now(), "version": 18, "channel": 1, "babelChannel": "10"}) 233 | this.h5stTool = new H5ST('4a0b4', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 234 | await this.h5stTool.__genAlgo() 235 | for (let t of res.themes || []) { 236 | if (!t.hadGot) { 237 | console.log(t.name) 238 | await this.api('clockInFollowForFarm', {"id": t.id, "type": "theme", "step": 1, "version": 18, "channel": 1, "babelChannel": "10"}) 239 | await this.wait(1000) 240 | data = await this.api('clockInFollowForFarm', {"id": t.id, "type": "theme", "step": 2, "version": 18, "channel": 1, "babelChannel": "10"}) 241 | data.code === '0' && console.log('关注成功💧', data.amount) 242 | } 243 | } 244 | 245 | if (!res.todaySigned) { 246 | this.h5stTool = new H5ST('32b94', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 247 | await this.h5stTool.__genAlgo() 248 | data = await this.api('clockInForFarm', {"type": 1, "version": 18, "channel": 1, "babelChannel": "10"}) 249 | data.code === '0' ? console.log('签到成功', data.amount) : this.o2s(data, '签到失败') 250 | await this.wait(2000) 251 | } else { 252 | console.log('已签到') 253 | } 254 | 255 | if (res.totalSigned === 7 && !res.gotClockInGift) { 256 | data = await this.api('clockInForFarm', {"type": 2, "version": 19, "channel": 1, "babelChannel": "10", "lat": "0", "lng": "0"}) 257 | console.log('签到7天奖励', data.amount) 258 | } 259 | 260 | // 删除好友 261 | this.h5stTool = new H5ST('eaf91', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 262 | await this.h5stTool.__genAlgo() 263 | res = await this.friendListInitForFarm() 264 | for (let t of res.friends) { 265 | data = await this.api('deleteFriendForFarm', {"shareCode": t.shareCode, "version": 18, "channel": 1, "babelChannel": "10"}) 266 | if (data.code === '0') { 267 | console.log(`删除好友 ${t.nickName} 成功`) 268 | } else { 269 | console.log(`删除失败 ${t.nickName} 失败`, data) 270 | break 271 | } 272 | await this.wait(2000) 273 | } 274 | 275 | // 点鸭子 276 | this.h5stTool = new H5ST('5c767', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 277 | await this.h5stTool.__genAlgo() 278 | for (let i = 0; i < 10; i++) { 279 | data = await this.api('getFullCollectionReward', {"type": 2, "version": 18, "channel": 1, "babelChannel": "10"}) 280 | if (data.code === '0') { 281 | data.title === '小鸭子为你带回了水滴' ? console.log(data.title, data.addWater) : console.log(data.title) 282 | } else if (data.code === '10' || data.hasLimit) { 283 | console.log('鸭子上限') 284 | break 285 | } 286 | await this.wait(5000) 287 | } 288 | } catch (e) { 289 | console.log('error', e.message) 290 | } 291 | await this.wait(30000) 292 | } 293 | 294 | async help(users: User[]) { 295 | if (new Date().getHours() > 12) return 296 | let res: any 297 | for (let user of users) { 298 | this.user = user 299 | this.user.UserAgent = `jdapp;iPhone;10.2.4;;;M/5.0;appBuild/167874;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 300 | this.h5stTool = new H5ST('8a2af', this.user.UserAgent, this.fp, 'https://carry.m.jd.com/', 'https://carry.m.jd.com/') 301 | await this.h5stTool.__genAlgo() 302 | 303 | let shareCodePool: string[] = await this.getShareCodePool('farm', 50) 304 | let shareCode: string[] = [...this.shareCodeSelf, ...shareCodePool] 305 | 306 | for (let code of shareCode) { 307 | try { 308 | console.log(`账号${user.index + 1} ${user.UserName} 去助力 ${code} ${this.shareCodeSelf.includes(code) ? '*内部*' : ''}`) 309 | res = await this.api('initForFarm', {"shareCode": `${code}-3`, "sid": "", "un_area": "", "version": 18, "channel": 1, "babelChannel": 0}) 310 | if (res.code === '0') { 311 | console.log('红包助力成功') 312 | } else if (res.code === '11') { 313 | console.log('红包已助力过') 314 | } else if (res.code === '13') { 315 | console.log('红包助力上限') 316 | break 317 | } 318 | await this.wait(2000) 319 | } catch (e) { 320 | console.log(e.message) 321 | break 322 | } 323 | } 324 | } 325 | } 326 | } 327 | 328 | new Jd_fruit().init().then() -------------------------------------------------------------------------------- /jd_health.ts: -------------------------------------------------------------------------------- 1 | import {User, JDHelloWorld} from "./TS_JDHelloWorld"; 2 | 3 | class Health extends JDHelloWorld { 4 | user: User 5 | shareCodeSelf: string[] = [] 6 | shareCodePool: string [] = [] 7 | 8 | constructor() { 9 | super(); 10 | } 11 | 12 | async init() { 13 | await this.run(new Health, this.help) 14 | } 15 | 16 | async api(fn: string, body: object) { 17 | return await this.post('https://api.m.jd.com/', `functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&uuid=`, { 18 | 'Host': 'api.m.jd.com', 19 | 'Origin': 'https://h5.m.jd.com', 20 | 'User-Agent': this.user.UserAgent, 21 | 'Referer': 'https://h5.m.jd.com/', 22 | 'Content-Type': 'application/x-www-form-urlencoded', 23 | 'Cookie': this.user.cookie 24 | }) 25 | } 26 | 27 | async runTimes(code: string) { 28 | try { 29 | let data = await this.get(`http://sharecodepool.cnmb.pw/api/runTimes0917?activityId=health&sharecode=${code}`) 30 | console.log(data) 31 | } catch (e) { 32 | await this.wait(5000) 33 | } 34 | } 35 | 36 | async main(user: User) { 37 | this.user = user 38 | let res: any 39 | res = await this.api('jdhealth_getHomeData', {}) 40 | if (!res.data?.result) { 41 | return 42 | } 43 | if (res.data.result.popupInfo.continuousSignInfo) { 44 | res = await this.api('jdhealth_collectScore', {"taskToken": res.data.result.popupInfo.continuousSignInfo.signInTaskToken, "taskId": res.data.result.continuousSignTaskId, "actionType": "0"}) 45 | if (res.data.bizCode === 0) { 46 | console.log('签到成功', res.data.result.acquiredScore) 47 | } 48 | } 49 | for (let i = 0; i < 3; i++) { 50 | res = await this.api('jdhealth_getTaskDetail', {"buildingId": "", "taskId": "", "channelId": 1}) 51 | try { 52 | for (let t of res.data.result.taskVos) { 53 | if (t.status === 1 || t.status === 3) { 54 | console.log(t.taskName) 55 | if (t.taskName.includes('打卡') && t.threeMealInfoVos[0].status === 1) { 56 | let data: any = await this.api('jdhealth_collectScore', {"taskToken": t.threeMealInfoVos[0].taskToken, "taskId": t.taskId, "actionType": 0}) 57 | if (res.data.bizCode === 0) 58 | console.log('打卡成功', parseInt(data.data.result.score)) 59 | else 60 | console.log('打卡失败', data.data.bizMsg) 61 | await this.wait(3000) 62 | } 63 | 64 | for (let tp of t.productInfoVos || t.followShopVo || t.shoppingActivityVos || []) { 65 | if (tp.status === 1) { 66 | console.log('\t', tp.skuName || tp.shopName || tp.title) 67 | if (t.waitDuration) { 68 | res = await this.api('jdhealth_collectScore', {"taskToken": tp.taskToken, "taskId": t.taskId, "actionType": 1}) 69 | console.log('\t', res.data.bizMsg) 70 | await this.wait(t.waitDuration * 1000 + 1000) 71 | } 72 | res = await this.api('jdhealth_collectScore', {"taskToken": tp.taskToken, "taskId": t.taskId, "actionType": 0}) 73 | if (res.data.bizMsg.includes('做完')) { 74 | console.log(res.data.bizMsg) 75 | break 76 | } else { 77 | console.log(res.data.bizMsg, parseInt(res.data.result.score)) 78 | await this.wait(3000) 79 | } 80 | } 81 | } 82 | await this.wait(3000) 83 | } 84 | } 85 | } catch (e) { 86 | console.log('Error', e) 87 | } 88 | await this.wait(10000) 89 | } 90 | } 91 | 92 | async help(users: User[]) { 93 | let res: any 94 | for (let user of users) { 95 | this.user = user 96 | console.log(`\n开始【京东账号${user.index + 1}】${user.UserName}\n`) 97 | res = await this.api('jdhealth_getTaskDetail', {"buildingId": "", "taskId": 6, "channelId": 1}) 98 | try { 99 | let code: string = res.data.result.taskVos[0].assistTaskDetailVo.taskToken 100 | console.log('助力码', code) 101 | this.shareCodeSelf.push(code) 102 | await this.runTimes(code) 103 | } catch (e) { 104 | } 105 | } 106 | this.o2s(this.shareCodeSelf, '内部助力码') 107 | 108 | for (let user of users) { 109 | this.user = user 110 | this.shareCodePool = await this.getShareCodePool('health', 1) 111 | let shareCode: string[] = Array.from(new Set([...this.shareCodeSelf, ...this.shareCodePool])), full: string[] = [] 112 | 113 | for (let code of shareCode) { 114 | if (full.includes(code)) 115 | continue 116 | console.log(`账号${user.index + 1} ${user.UserName} 去助力 ${code}`) 117 | res = await this.api('jdhealth_collectScore', {"taskToken": code, "taskId": "6", "actionType": 0}) 118 | try { 119 | if (res.data.bizMsg === '助力失败丨啊哦您今日的爱心值已爆棚,明天继续吧') { 120 | break 121 | } else if (res.data.bizMsg === '助力失败丨助力已满员!谢谢你哦~') { 122 | full.push(code) 123 | } else { 124 | console.log(res.data.bizMsg) 125 | } 126 | } catch (e) { 127 | this.o2s(res, 'jdhealth_collectScore catch') 128 | } finally { 129 | await this.wait(3000) 130 | } 131 | } 132 | } 133 | } 134 | } 135 | 136 | new Health().init().then() 137 | -------------------------------------------------------------------------------- /jd_health_collect.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 健康能量收集 3 | * cron: 5-45/20 * * * * 4 | */ 5 | 6 | import axios from "axios"; 7 | import * as path from "path" 8 | import USER_AGENT, {getCookie, exceptCookie, wait, o2s} from "./TS_USER_AGENTS" 9 | 10 | let cookie: string = '', UserName: string, res: any = '' 11 | 12 | !(async () => { 13 | let cookiesArr: string[] = await getCookie() 14 | let except: string[] = exceptCookie(path.basename(__filename)) 15 | 16 | for (let [index, value] of cookiesArr.entries()) { 17 | cookie = value 18 | UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) 19 | console.log(`\n开始【京东账号${index + 1}】${UserName}\n`) 20 | 21 | if (except.includes(encodeURIComponent(UserName))) { 22 | console.log('已设置跳过') 23 | continue 24 | } 25 | 26 | res = await api('jdhealth_collectProduceScore', {}) 27 | o2s(res) 28 | 29 | await wait(1000) 30 | } 31 | })() 32 | 33 | async function api(fn: string, body: object) { 34 | let {data} = await axios.post('https://api.m.jd.com/', `functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&uuid=`, { 35 | headers: { 36 | 'Host': 'api.m.jd.com', 37 | 'Origin': 'https://h5.m.jd.com', 38 | 'User-Agent': USER_AGENT, 39 | 'Referer': 'https://h5.m.jd.com/', 40 | 'Content-Type': 'application/x-www-form-urlencoded', 41 | 'Cookie': cookie 42 | } 43 | }) 44 | return data 45 | } -------------------------------------------------------------------------------- /jd_joy_park_run.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 汪汪乐园-跑步+组队+浏览 3 | * cron: 20 * * * * 4 | * export FP_448DE="" 5 | * export FP_B6AC3="" 6 | */ 7 | 8 | import {H5ST} from "./utils/h5st_pro" 9 | import {getDate} from "date-fns"; 10 | import {JDHelloWorld, User} from "./TS_JDHelloWorld"; 11 | 12 | class Joy_Park_Run extends JDHelloWorld { 13 | teamTool: H5ST 14 | apiTool: H5ST 15 | user: User 16 | captainId: string | number 17 | 18 | constructor() { 19 | super() 20 | } 21 | 22 | async init() { 23 | await this.run(this) 24 | } 25 | 26 | // 秒转分:秒 27 | secondsToMinutes(seconds: number) { 28 | let minutes: number = Math.floor(seconds / 60) 29 | let second: number = Math.floor(seconds % 60) 30 | return `${minutes}分${second}秒` 31 | } 32 | 33 | async team(fn: string, body: object) { 34 | let timestamp: number = Date.now(), h5st: string 35 | h5st = await this.teamTool.__genH5st({ 36 | appid: "activities_platform", 37 | body: JSON.stringify(body), 38 | client: "ios", 39 | clientVersion: "3.9.2", 40 | functionId: fn, 41 | t: timestamp.toString() 42 | }) 43 | return await this.get(`https://api.m.jd.com/?functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&t=${timestamp}&appid=activities_platform&client=ios&clientVersion=3.9.2&cthr=1&h5st=${h5st}`, { 44 | 'Host': 'api.m.jd.com', 45 | 'User-Agent': this.user.UserAgent, 46 | 'Origin': 'https://h5platform.jd.com', 47 | 'X-Requested-With': 'com.jd.jdlite', 48 | 'Referer': 'https://h5platform.jd.com/', 49 | 'Cookie': this.user.cookie 50 | }) 51 | } 52 | 53 | async api(fn: string, body: object) { 54 | let timestamp: number = Date.now(), h5st: string = '' 55 | if (fn === 'runningOpenBox') { 56 | h5st = await this.apiTool.__genH5st({ 57 | appid: "activities_platform", 58 | body: JSON.stringify(body), 59 | client: "ios", 60 | clientVersion: "3.9.2", 61 | functionId: fn, 62 | t: timestamp.toString() 63 | }) 64 | } 65 | let params: string = `functionId=${fn}&body=${JSON.stringify(body)}&t=${timestamp}&appid=activities_platform&client=ios&clientVersion=3.9.2&cthr=1` 66 | h5st && (params += `&h5st=${h5st}`) 67 | return await this.post('https://api.m.jd.com/', params, { 68 | 'authority': 'api.m.jd.com', 69 | 'content-type': 'application/x-www-form-urlencoded', 70 | 'cookie': this.user.cookie, 71 | 'origin': 'https://h5platform.jd.com', 72 | 'referer': 'https://h5platform.jd.com/', 73 | 'User-Agent': this.user.UserAgent, 74 | }) 75 | } 76 | 77 | async runningPageHome() { 78 | return this.get(`https://api.m.jd.com/?functionId=runningPageHome&body=%7B%22linkId%22:%22L-sOanK_5RJCz7I314FpnQ%22,%22isFromJoyPark%22:true,%22joyLinkId%22:%22LsQNxL7iWDlXUs6cFl-AAg%22%7D&t=${Date.now()}&appid=activities_platform&client=ios&clientVersion=3.9.2`, { 79 | 'Host': 'api.m.jd.com', 80 | 'Origin': 'https://h5platform.jd.com', 81 | 'User-Agent': this.user.UserAgent, 82 | 'Referer': 'https://h5platform.jd.com/', 83 | 'Cookie': this.user.cookie 84 | }) 85 | } 86 | 87 | async startRunning(res: any, assets: number) { 88 | if (!res.data.runningHomeInfo.nextRunningTime) { 89 | console.log('终点目标', assets) 90 | for (let i = 0; i < 5; i++) { 91 | res = await this.api('runningOpenBox', {"linkId": "L-sOanK_5RJCz7I314FpnQ"}) 92 | if (parseFloat(res.data.assets) >= assets) { 93 | assets = parseFloat(res.data.assets) 94 | res = await this.api('runningFail', {"linkId": "L-sOanK_5RJCz7I314FpnQ"}) 95 | this.o2s(res, 'runningFail') 96 | 97 | res = await this.api('runningPreserveAssets', {"linkId": "L-sOanK_5RJCz7I314FpnQ"}) 98 | console.log('领取成功', assets) 99 | break 100 | } else { 101 | if (res.data.doubleSuccess) { 102 | console.log('翻倍成功', parseFloat(res.data.assets)) 103 | await this.wait(10000) 104 | } else if (!res.data.doubleSuccess && !res.data.runningHomeInfo.runningFinish) { 105 | console.log('开始跑步', parseFloat(res.data.assets)) 106 | await this.wait(10000) 107 | } else { 108 | console.log('翻倍失败') 109 | break 110 | } 111 | } 112 | } 113 | } 114 | await this.wait(3000) 115 | } 116 | 117 | async main(user: User) { 118 | this.user = user 119 | this.user.UserAgent = `jdltapp;iPhone;3.9.2;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 120 | let assets: number = parseFloat(process.env.JD_JOY_PARK_RUN_ASSETS || '0.08') 121 | let rewardAmount: number = 0 122 | try { 123 | this.teamTool = new H5ST('448de', this.user.UserAgent, process.env.FP_448DE || "", 'https://h5platform.jd.com/swm-stable/people-run/index?activityId=L-sOanK_5RJCz7I314FpnQ', 'https://h5platform.jd.com') 124 | await this.teamTool.__genAlgo() 125 | let res: any, apTaskList: any 126 | 127 | apTaskList = await this.api('apTaskList', {"linkId": "LsQNxL7iWDlXUs6cFl-AAg"}) 128 | for (let t of apTaskList.data) { 129 | if (t.taskType === 'BROWSE_CHANNEL' && !t.taskFinished) { 130 | console.log(t.taskTitle) 131 | res = await this.api('apDoTask', {"taskType": t.taskType, "taskId": t.id, "itemId": encodeURIComponent(t.taskSourceUrl), "linkId": "LsQNxL7iWDlXUs6cFl-AAg"}) 132 | res.success ? console.log('任务完成') : this.o2s(res, '任务失败') 133 | await this.wait(1000) 134 | res = await this.api('apTaskDrawAward', {"taskType": t.taskType, "taskId": t.id, "linkId": "LsQNxL7iWDlXUs6cFl-AAg"}) 135 | res.success ? console.log('领奖成功', res.data[0].awardGivenNumber) : this.o2s(res, '领奖失败') 136 | } 137 | } 138 | 139 | apTaskList = await this.api('apTaskList', {"linkId": "L-sOanK_5RJCz7I314FpnQ"}) 140 | for (let t of apTaskList.data) { 141 | if (t.taskShowTitle === '逛会场得生命值' && !t.taskFinished) { 142 | let apTaskDetail: any = await this.api('apTaskDetail', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "taskType": "BROWSE_CHANNEL", "taskId": t.id, "channel": 4}) 143 | await this.wait(1000) 144 | let taskItemList = apTaskDetail.data.taskItemList 145 | for (let i = apTaskDetail.data.status.userFinishedTimes; i < apTaskDetail.data.status.finishNeed; i++) { 146 | console.log(taskItemList[i].itemName) 147 | res = await this.api('apTaskTimeRecord', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "taskId": 817}) 148 | await this.wait(31000) 149 | 150 | res = await this.api('apDoTask', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "taskType": "BROWSE_CHANNEL", "taskId": t.id, "channel": 4, "itemId": encodeURIComponent(taskItemList[i].itemId), "checkVersion": true}) 151 | if (res.success) { 152 | console.log('任务完成') 153 | } else { 154 | this.o2s(res, '任务失败') 155 | } 156 | await this.wait(3000) 157 | } 158 | } 159 | } 160 | await this.wait(2000) 161 | 162 | res = await this.team('runningMyPrize', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "pageSize": 20, "time": null, "ids": null}) 163 | // res = await this.team('runningMyPrize', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "pageSize": 10, "time": 1660943842000, "ids": [1263040]}) 164 | // this.o2s(res) 165 | 166 | let sum: number = 0, success: number = 0 167 | rewardAmount = res.data.rewardAmount 168 | if (res.data.runningCashStatus.currentEndTime && res.data.runningCashStatus.status === 0) { 169 | console.log('可提现', rewardAmount) 170 | res = await this.api('runningPrizeDraw', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "type": 2}) 171 | await this.wait(2000) 172 | console.log(res.data.message) 173 | res = await this.team('runningMyPrize', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "pageSize": 20, "time": null, "ids": null}) 174 | } 175 | 176 | for (let t of res?.data?.detailVos || []) { 177 | if (t.amount > 0 && getDate(new Date(t.createTime)) === new Date().getDate()) { 178 | sum += t.amount 179 | success++ 180 | } else { 181 | break 182 | } 183 | } 184 | console.log('成功', success) 185 | sum = parseFloat(sum.toFixed(2)) 186 | console.log('收益', sum) 187 | 188 | res = await this.team('runningTeamInfo', {"linkId": "L-sOanK_5RJCz7I314FpnQ"}) 189 | if (!this.captainId) { 190 | if (res.data.members.length === 0) { 191 | console.log('成为队长') 192 | this.captainId = res.data.captainId 193 | } else if (res.data.members.length !== 6) { 194 | console.log('队伍未满', res.data.members.length) 195 | this.captainId = res.data.captainId 196 | } else { 197 | console.log('队伍已满') 198 | } 199 | } else if (this.captainId && res.data.members.length === 0) { 200 | console.log('已有组队ID,未加入队伍') 201 | res = await this.team('runningJoinTeam', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "captainId": this.captainId}) 202 | if (res.code === 0) { 203 | console.log('组队成功') 204 | for (let member of res.data.members) { 205 | if (member.captain) { 206 | console.log('队长', member.nickName) 207 | break 208 | } 209 | } 210 | if (res.data.members.length === 6) { 211 | console.log('队伍已满') 212 | this.captainId = '' 213 | } 214 | } else { 215 | this.o2s(res, '组队失败') 216 | } 217 | } else { 218 | console.log('已组队', res.data.members.length) 219 | console.log('战队收益', res.data.teamSumPrize) 220 | } 221 | 222 | this.apiTool = new H5ST('b6ac3', this.user.UserAgent, process.env.FP_B6AC3 || "", 'https://h5platform.jd.com/swm-stable/people-run/index?activityId=L-sOanK_5RJCz7I314FpnQ', 'https://h5platform.jd.com') 223 | await this.apiTool.__genAlgo() 224 | res = await this.runningPageHome() 225 | console.log('🧧', res.data.runningHomeInfo.prizeValue) 226 | console.log('💊', res.data.runningHomeInfo.energy) 227 | let energy: number = res.data.runningHomeInfo.energy 228 | await this.wait(2000) 229 | 230 | console.log('⏳', this.secondsToMinutes(res.data.runningHomeInfo.nextRunningTime / 1000)) 231 | if (res.data.runningHomeInfo.nextRunningTime && res.data.runningHomeInfo.nextRunningTime / 1000 < 300) { 232 | console.log('⏳') 233 | await this.wait(res.data.runningHomeInfo.nextRunningTime + 3000) 234 | res = await this.runningPageHome() 235 | await this.wait(1000) 236 | } 237 | await this.startRunning(res, assets) 238 | 239 | res = await this.runningPageHome() 240 | for (let i = 0; i < energy; i++) { 241 | if (res.data.runningHomeInfo.nextRunningTime / 1000 < 3000 || new Date().getHours() > 15) 242 | break 243 | console.log('💉') 244 | res = await this.api('runningUseEnergyBar', {"linkId": "L-sOanK_5RJCz7I314FpnQ"}) 245 | console.log(res.errMsg) 246 | res = await this.runningPageHome() 247 | await this.startRunning(res, assets) 248 | await this.wait(1000) 249 | } 250 | 251 | res = await this.runningPageHome() 252 | console.log('🧧', res.data.runningHomeInfo.prizeValue) 253 | await this.wait(2000) 254 | } catch (e) { 255 | console.log('Error', e.message) 256 | await this.wait(3000) 257 | } 258 | } 259 | } 260 | 261 | new Joy_Park_Run().init().then() -------------------------------------------------------------------------------- /jd_kuaidi.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 微信快递小程序签到 3 | * cron: 8 10 * * * 4 | */ 5 | 6 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 7 | 8 | class Jd_wechat_sign extends JDHelloWorld { 9 | user: User 10 | 11 | constructor() { 12 | super("微信签到"); 13 | } 14 | 15 | async init() { 16 | await this.run(this) 17 | } 18 | 19 | async main(user: User) { 20 | try { 21 | let uuid: string = '' 22 | for (let i = 0; i < 32; i++) { 23 | uuid += this.getRandomNumberByRange(0, 2) 24 | ? this.getRandomNumString(1) 25 | : this.getRandomWord().toLowerCase() 26 | } 27 | this.user = user 28 | let res: any = await this.post('https://lop-proxy.jd.com/jiFenApi/signInAndGetReward', '[{"userNo":"$cooMrdGatewayUid$"}]', { 29 | 'Host': 'lop-proxy.jd.com', 30 | 'AppParams': '{"appid":158,"ticket_type":"m"}', 31 | 'uuid': uuid, 32 | 'LOP-DN': 'jingcai.jd.com', 33 | 'User-Agent': this.user.UserAgent, 34 | 'Origin': 'https://jingcai-h5.jd.com', 35 | 'Referer': 'https://jingcai-h5.jd.com/', 36 | 'Cookie': this.user.cookie 37 | }) 38 | this.o2s(res) 39 | if (res.success) { 40 | console.log('签到成功', JSON.parse(res.content[0].param)) 41 | } else { 42 | console.log(res.msg) 43 | } 44 | } catch (e) { 45 | console.log(e.message) 46 | } 47 | } 48 | } 49 | 50 | new Jd_wechat_sign().init().then() -------------------------------------------------------------------------------- /jd_miniTask.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 微信小程序-领红包 3 | * cron: 15 0,2,8 * * * 4 | */ 5 | 6 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 7 | import {H5ST} from "./utils/h5st" 8 | 9 | class Jd_Hbrain extends JDHelloWorld { 10 | user: User 11 | fp: string 12 | h5stTool: H5ST 13 | 14 | constructor() { 15 | super() 16 | } 17 | 18 | async init() { 19 | this.fp = await this.getFp4_1() 20 | await this.run(this) 21 | } 22 | 23 | async api(fn: string, body: object): Promise { 24 | let ts: number = Date.now() 25 | let h5st: string = this.h5stTool.genH5st('hot_channel', body, 'android', '8.21.260', fn, ts) 26 | return await this.post(`https://api.m.jd.com/${fn}`, 27 | `loginType=2&client=android&clientVersion=8.21.260&functionId=${fn}&t=${ts}&body=${encodeURIComponent(JSON.stringify(body))}&appid=hot_channel&d_name=&h5st=${h5st}&_ste=2`, 28 | { 29 | 'Host': 'api.m.jd.com', 30 | 'User-Agent': this.user.UserAgent, 31 | 'Cookie': this.user.cookie, 32 | 'X-Referer-Package': 'wx91d27dbf599dff74', 33 | 'wqreferer': 'http://wq.jd.com/wxapp/pages/yixiaoshida/index/index', 34 | 'X-Rp-Client': 'mini_2.0.0', 35 | 'X-Referer-Page': '/pages/yixiaoshida/index/index', 36 | 'referer': 'https://servicewechat.com/wx91d27dbf599dff74/728/page-frame.html' 37 | }) 38 | } 39 | 40 | async main(user: User) { 41 | try { 42 | this.user = user 43 | this.user.UserAgent = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 MicroMessenger/6.8.0(0x16080000) NetType/WIFI MiniProgramEnv/Mac MacWechat/WMPF XWEB/30817` 44 | this.h5stTool = new H5ST('60d61', this.fp, this.user.UserAgent, this.user.UserName, 'https://servicewechat.com/wx91d27dbf599dff74/728/page-frame.html', 'https://servicewechat.com') 45 | await this.h5stTool.genAlgo() 46 | 47 | let data: any, res: any 48 | res = await this.api('MiniTask_ChannelPage', {"source": "task"}) 49 | this.o2s(res) 50 | let shareCode: string[] = await this.getshareCodeHW('miniTask') 51 | for (let t of res.data.signInfo.signTaskList) { 52 | if (t.currentDay && t.signStatus === 0) { 53 | if (this.user.index === 0) { 54 | data = await this.api('miniTask_assistCheck', {"itemId": shareCode[0]}) 55 | } else { 56 | data = await this.api('miniTask_doSign', {"itemId": "1"}) 57 | } 58 | if (res.subCode === 0) { 59 | console.log('签到成功', res.data.toastMsg, '连续签到:', res.data.signDays) 60 | } else { 61 | console.log(res.message) 62 | } 63 | } 64 | } 65 | 66 | for (let t of res.data.scanTaskList) { 67 | if (t.status === 0) { 68 | console.log(t.title) 69 | data = await this.api('MiniTask_ScanTask', {"actionType": 1, "scanAssignmentId": t.scanAssignmentId, "itemId": t.itemId}) 70 | if (data.subCode === 0) { 71 | console.log('开始任务') 72 | await this.wait((t.times + 1) * 1000) 73 | data = await this.api('MiniTask_ScanTask', {"actionType": 0, "scanAssignmentId": t.scanAssignmentId, "itemId": t.itemId}) 74 | if (data.subCode === 0) { 75 | console.log('任务完成') 76 | await this.wait(1000) 77 | data = await this.api('MiniTask_ScanReward', {"scanAssignmentId": t.scanAssignmentId}) 78 | console.log(data) 79 | console.log('领取奖励', data.data[0].discount) 80 | } 81 | } 82 | } 83 | } 84 | 85 | } catch (e) { 86 | console.log(e.message) 87 | await this.wait(5000) 88 | } 89 | } 90 | } 91 | 92 | new Jd_Hbrain().init().then() -------------------------------------------------------------------------------- /jd_plantBean__help.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 京东-种豆-助力 3 | * 所有CK助力顺序 4 | * 内部 -> 助力池 5 | * cron: 15 7-21/2 * * * 6 | */ 7 | 8 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 9 | import {H5ST} from "./utils/h5st_pro"; 10 | 11 | class Jd_plantBean__help extends JDHelloWorld { 12 | user: User 13 | h5stTool: H5ST 14 | fp: any = undefined 15 | 16 | constructor() { 17 | super(); 18 | } 19 | 20 | async init() { 21 | try { 22 | this.fp = process.env.FP_6B93E || await this.getFp() 23 | } catch (e) { 24 | console.log(e.message) 25 | } 26 | await this.run(this) 27 | } 28 | 29 | async api(fn: string, body: object) { 30 | let h5st: string = await this.h5stTool.__genH5st({ 31 | 'appid': 'signed_wh5', 32 | 'body': JSON.stringify(body), 33 | 'client': 'apple', 34 | 'clientVersion': '11.3.6', 35 | 'functionId': fn, 36 | }) 37 | let data: string = await this.get(`https://api.m.jd.com/client.action?functionId=${fn}&appid=signed_wh5&body=${encodeURIComponent(JSON.stringify(body))}&client=apple&clientVersion=11.3.6&h5st=${h5st}&jsonp=jsonp_${Date.now()}_${this.getRandomNumberByRange(12345, 56789)}`, { 38 | 'Host': 'api.m.jd.com', 39 | 'User-Agent': this.user.UserAgent, 40 | 'Referer': 'https://plantearth.m.jd.com/', 41 | 'Cookie': this.user.cookie, 42 | }) 43 | return JSON.parse(data.match(/jsonp_.*\((.*)\)/)[1]) 44 | } 45 | 46 | async runTimes(code: string) { 47 | try { 48 | let data = await this.get(`http://sharecodepool.cnmb.pw/api/runTimes0917?activityId=bean&sharecode=${code}`) 49 | console.log(data) 50 | } catch (e) { 51 | await this.wait(5000) 52 | } 53 | } 54 | 55 | async main(user: User) { 56 | let res: any, data: any 57 | try { 58 | this.user = user 59 | this.user.UserAgent = `jdapp;iPhone;11.3.6;;;M/5.0;appBuild/168392;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 60 | this.h5stTool = new H5ST('6b93e', this.user.UserAgent, this.fp, 'https://plantearth.m.jd.com/plantBean/index?source=lingjingdoushouye', 'https://plantearth.m.jd.com', this.user.UserName) 61 | await this.h5stTool.__genAlgo() 62 | res = await this.api('plantBeanIndex', {"monitor_source": "plant_m_plant_index", "monitor_refer": "", "version": "9.2.4.2"}) 63 | let code: string = res.data.jwordShareInfo.shareUrl.match(/plantUuid=(\w+)/)[1] 64 | console.log('助力码', code) 65 | 66 | res = await this.api('plantShareSupportList', {"roundId": ""}) 67 | console.log('收到助力', res.data.length) 68 | } catch (e) { 69 | console.log(e.message) 70 | } 71 | } 72 | 73 | async help(users: User[]) { 74 | let res: any, full: string[] = [] 75 | for (let user of users) { 76 | try { 77 | this.user = user 78 | this.user.UserAgent = `jdapp;iPhone;11.3.6;;;M/5.0;appBuild/168392;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 79 | this.h5stTool = new H5ST('6b93e', this.user.UserAgent, this.fp, 'https://plantearth.m.jd.com/plantBean/index?source=lingjingdoushouye', 'https://plantearth.m.jd.com', this.user.UserName) 80 | await this.h5stTool.__genAlgo() 81 | let shareCodePool: string[] = await this.getShareCodePool('bean', 50) 82 | let shareCode: string[] = Array.from(new Set([...shareCodePool])) 83 | res = await this.api('plantBeanIndex', {"monitor_source": "plant_m_plant_index", "monitor_refer": "", "version": "9.2.4.2"}) 84 | let my: string = res.data.jwordShareInfo.shareUrl.match(/plantUuid=(\w+)/)[1] 85 | for (let code of shareCode) { 86 | console.log(`账号${user.index + 1} ${user.UserName} 去助力 ${code}`) 87 | if (full.includes(code)) { 88 | console.log('full contains') 89 | continue 90 | } 91 | res = await this.api('plantBeanIndex', {"plantUuid": code, "monitor_source": "plant_m_plant_index", "monitor_refer": "", "version": "9.2.4.2"}) 92 | console.log(res.data.helpShareRes.promptText) 93 | if (res.data.helpShareRes.state === '2') { 94 | console.log('上限') 95 | break 96 | } else if (res.data.helpShareRes.state === '3') { 97 | full.push(code) 98 | } 99 | await this.runTimes(my) 100 | await this.wait(3000) 101 | } 102 | } catch (e) { 103 | console.log(e.message) 104 | await this.wait(5000) 105 | } 106 | } 107 | } 108 | } 109 | 110 | new Jd_plantBean__help().init().then() -------------------------------------------------------------------------------- /jd_ql_repo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 🐉 ql repo 3 | * cron: 30 2 * * * 4 | */ 5 | 6 | import {execSync} from "child_process"; 7 | 8 | if (process.env.HOSTNAME === 'qinglong' || process.env.QL_DIR) { 9 | process.chdir('../../repo/JDHelloWorld_jd_scripts/') 10 | execSync('git fetch --all; git reset --hard origin/main; git pull') 11 | execSync('ql repo https://github.com/JDHelloWorld/jd_scripts.git "jd_|jx_" "backUp" "^jd[^_]|USER|^TS|utils"') 12 | } 13 | -------------------------------------------------------------------------------- /jd_queryRedpacket.ts: -------------------------------------------------------------------------------- 1 | import {JDHelloWorld, User} from "./TS_JDHelloWorld"; 2 | 3 | class Jd_queryRedpacket extends JDHelloWorld { 4 | constructor() { 5 | super("京东红包"); 6 | } 7 | 8 | async init() { 9 | await this.run(new Jd_queryRedpacket()) 10 | } 11 | 12 | add(arg1: number, arg2: number) { 13 | let r1, r2, m 14 | try { 15 | r1 = arg1.toString().split('.')[1].length 16 | } catch (e) { 17 | r1 = 0 18 | } 19 | try { 20 | r2 = arg2.toString().split('.')[1].length 21 | } catch (e) { 22 | r2 = 0 23 | } 24 | m = Math.pow(10, Math.max(r1, r2)) 25 | return parseFloat(((arg1 * m + arg2 * m) / m).toFixed(2)) 26 | } 27 | 28 | async main(user: User) { 29 | let res: any = await this.get(`https://m.jingxi.com/user/info/QueryUserRedEnvelopesV2?type=1&orgFlag=JD_PinGou_New&page=1&cashRedType=1&redBalanceFlag=1&channel=1&_=${Date.now()}&sceneval=2&g_login_type=1&g_ty=ls`, { 30 | 'Host': 'm.jingxi.com', 31 | 'Referer': 'https://st.jingxi.com/my/redpacket.shtml', 32 | "Cookie": user.cookie, 33 | 'User-Agent': user.UserAgent 34 | }) 35 | let day: number = new Date().getDay(), jdRed: number = 0, jdRedExp: number = 0, jsRed: number = 0, jsRedExp: number = 0 36 | for (let j of res.data.useRedInfo?.redList || []) { 37 | console.log(j) 38 | if (j.orgLimitStr.includes('京喜')) { 39 | } else if (j.activityName.includes('极速版')) { 40 | jsRed = this.add(jsRed, j.balance) 41 | if (new Date(j.endTime * 1000).getDay() === day) 42 | jsRedExp = this.add(jsRedExp, j.balance) 43 | } else if (j.orgLimitStr.includes('京东健康')) { 44 | } else { 45 | jdRed = this.add(jdRed, j.balance) 46 | if (new Date(j.endTime * 1000).getDay() === day) 47 | jdRedExp = this.add(jdRedExp, j.balance) 48 | } 49 | } 50 | console.log('京东', jdRed, ' 今日过期:', jdRedExp) 51 | console.log('极速', jsRed, ' 今日过期:', jsRedExp) 52 | let msg = `【账号】 ${user.UserName}\n京东红包 ${jdRed}\n今日过期 ${jdRedExp}\n\n` 53 | return { 54 | msg: msg 55 | } 56 | } 57 | } 58 | 59 | new Jd_queryRedpacket().init().then() 60 | -------------------------------------------------------------------------------- /jd_rmFollowList.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 取消关注商品、店铺 3 | * cron: 10 10 * * * 4 | */ 5 | 6 | import {JDHelloWorld, User} from "./TS_JDHelloWorld"; 7 | import {H5ST} from "./utils/h5st_pro"; 8 | 9 | class Jd_RmFollowList extends JDHelloWorld { 10 | user: User 11 | h5stTool: H5ST 12 | fp: string 13 | 14 | constructor() { 15 | super('取消关注商品、店铺'); 16 | } 17 | 18 | async init() { 19 | try { 20 | this.fp = process.env.FP_B3F11 ?? await this.getFp() 21 | } catch (e) { 22 | console.log('FP Error: ', e.message) 23 | process.exit(0) 24 | } 25 | await this.run(this) 26 | } 27 | 28 | async api(fn: string, params: object) { 29 | let res: any = await this.get(`https://wq.jd.com/fav/shop/${fn}`, { 30 | 'Host': 'wq.jd.com', 31 | 'Cookie': this.user.cookie, 32 | 'user-agent': this.user.UserAgent, 33 | 'referer': 'https://wqs.jd.com/', 34 | }, params) 35 | res = JSON.parse(res.match(/\(([\S\s]+)\);/)[1]) 36 | return res 37 | } 38 | 39 | async api2(fn: string, body: object) { 40 | let h5st: string = await this.h5stTool.__genH5st({ 41 | appid: "jd-cphdeveloper-m", 42 | body: JSON.stringify(body), 43 | functionId: fn, 44 | }) 45 | return await this.get('https://api.m.jd.com/api', { 46 | 'cookie': this.user.cookie, 47 | 'origin': 'https://wqs.jd.com', 48 | 'referer': 'https://wqs.jd.com/', 49 | 'user-agent': this.user.UserAgent, 50 | 'x-referer-page': 'https://wqs.jd.com/my/fav/goods_fav.shtml', 51 | 'x-rp-client': 'h5_1.0.0' 52 | }, { 53 | 'appid': 'jd-cphdeveloper-m', 54 | 'functionId': fn, 55 | 'body': JSON.stringify(body), 56 | 'loginType': '2', 57 | 'h5st': h5st, 58 | 'sceneval': '2', 59 | 'g_login_type': '1', 60 | 'g_ty': 'ajax', 61 | 'appCode': 'ms0ca95114' 62 | }) 63 | } 64 | 65 | async main(user: User) { 66 | this.user = user 67 | this.h5stTool = new H5ST("c420a", this.user.UserAgent, this.fp, 'https://wqs.jd.com/', 'https://wqs.jd.com/', this.user.UserName); 68 | await this.h5stTool.__genAlgo() 69 | let res: any, data: any 70 | try { 71 | for (let i = 0; i < 3; i++) { 72 | res = await this.api('QueryShopFavList', { 73 | 'cp': '1', 74 | 'pageSize': '10', 75 | 'g_login_type': '0', 76 | 'appCode': 'msd95910c4', 77 | 'callback': `jsonpCBK${this.getRandomWord()}`, 78 | }) 79 | console.log('当前关注店铺', res.totalNum * 1) 80 | let venderIdList: string[] = res.data.map(t => { 81 | console.log(t.shopName) 82 | return t.shopId 83 | }) 84 | 85 | if (venderIdList.length === 0) { 86 | break 87 | } 88 | res = await this.api('batchunfollow', { 89 | 'shopId': venderIdList.join(','), 90 | '_': Date.now(), 91 | 'g_login_type': 0, 92 | 'appCode': 'msd95910c4', 93 | 'callback': `jsonpCBK${this.getRandomWord()}` 94 | }) 95 | res.iRet === '0' && console.log('取关成功') 96 | await this.wait(4000) 97 | } 98 | 99 | this.user.UserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1` 100 | for (let i = 0; i < 3; i++) { 101 | res = await this.api2('queryFollowProduct', {"cp": 1, "pageSize": 10, "category": "", "promote": 0, "cutPrice": 0, "coupon": 0, "stock": 0, "area": "", "tenantCode": "jgm", "bizModelCode": "6", "bizModeClientType": "M", "externalLoginType": "1"}) 102 | console.log('关注商品', res.totalNum) 103 | let arr: string[] = [] 104 | for (let t of res.followProductList) { 105 | console.log(t.commTitle) 106 | arr.push(t.commId) 107 | } 108 | if (arr.length === 0) 109 | break 110 | data = await this.api2('delFollowProduct', {"commId": arr.join(','), "tenantCode": "jgm", "bizModelCode": "6", "bizModeClientType": "M", "externalLoginType": "1"}) 111 | data.code === '0' && console.log('取关成功') 112 | await this.wait(4000) 113 | } 114 | } catch (e) { 115 | console.log('error', e) 116 | } 117 | } 118 | } 119 | 120 | new Jd_RmFollowList().init().then() -------------------------------------------------------------------------------- /jd_sgmh.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 闪购盲盒 3 | * cron: 20 8 * * * 4 | */ 5 | 6 | import {getCookie, getShareCodePool, wait} from "./TS_USER_AGENTS" 7 | import axios from "axios"; 8 | 9 | let cookie: string = '', UserName: string, res: any 10 | let shareCodeSelf: string[] = [], shareCode: string[] = [], shareCodePool: string[] = [] 11 | 12 | !(async () => { 13 | let cookiesArr: string[] = await getCookie() 14 | for (let [index, value] of cookiesArr.entries()) { 15 | cookie = value 16 | UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) 17 | console.log(`\n开始【京东账号${index + 1}】${UserName}\n`) 18 | 19 | res = await api('healthyDay_getHomeData', {"appId": "1ElZXwKuP", "taskToken": "", "channelId": 1}) 20 | 21 | for (let t of res.data.result.taskVos) { 22 | if (t.taskType === 14) { 23 | console.log('助力码', t.assistTaskDetailVo?.taskToken) 24 | shareCodeSelf.push(t.assistTaskDetailVo?.taskToken) 25 | } 26 | if ((t.browseShopVo || t.productInfoVos || t.shoppingActivityVos) && t.times < t.maxTimes) { 27 | for (let i = 0; i < t.maxTimes - t.times; i++) { 28 | let tp: any[] = [] 29 | if (t.productInfoVos) 30 | tp = t.productInfoVos 31 | else if (t.browseShopVo) 32 | tp = t.browseShopVo 33 | else if (t.shoppingActivityVos) 34 | tp = t.shoppingActivityVos 35 | console.log(tp[i]?.shopName || tp[i]?.skuName || tp[i]?.title) 36 | if (!t.shoppingActivityVos) { 37 | res = await api('harmony_collectScore', { 38 | "appId": "1ElZXwKuP", 39 | "taskToken": tp[i].taskToken, 40 | "taskId": t.taskId, 41 | "actionType": 1 42 | }) 43 | console.log(res.data.bizMsg) 44 | await wait(t.waitDuration * 1000 || 2000) 45 | } 46 | res = await api('harmony_collectScore', { 47 | "appId": "1ElZXwKuP", 48 | "taskToken": tp[i].taskToken, 49 | "taskId": t.taskId, 50 | "actionType": 0 51 | }) 52 | await wait(1000) 53 | if (res.data.bizMsg === 'success') { 54 | console.log('任务完成') 55 | } else { 56 | break 57 | } 58 | } 59 | } 60 | } 61 | } 62 | 63 | // 助力 64 | let full: string[] = [] 65 | for (let [index, value] of cookiesArr.entries()) { 66 | cookie = value 67 | UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) 68 | console.log(`\n开始【京东账号${index + 1}】${UserName}\n`) 69 | 70 | shareCodePool = await getShareCodePool('sgmh', 30) 71 | shareCode = Array.from(new Set([...shareCodeSelf, ...shareCodePool])) 72 | 73 | for (let code of shareCode) { 74 | if (full.includes(code)) { 75 | console.log('full contains') 76 | continue 77 | } 78 | console.log('去助力', code) 79 | res = await api('harmony_collectScore', {"appId": "1ElZXwKuP", "taskToken": code, "taskId": 3}) 80 | if (res.data.bizCode === 0) { 81 | console.log('助力成功') 82 | } else if (res.data.bizCode === 108) { 83 | console.log('上限') 84 | break 85 | } else if (res.data.bizMsg === '助力已满员!谢谢你哦~') { 86 | full.push(code) 87 | console.log('已满') 88 | } else { 89 | console.log('助力失败', res.data.bizMsg) 90 | } 91 | await wait(2000) 92 | } 93 | } 94 | 95 | // 抽奖 96 | for (let [index, value] of cookiesArr.entries()) { 97 | cookie = value 98 | UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) 99 | console.log(`\n开始【京东账号${index + 1}】${UserName}\n`) 100 | res = await api('healthyDay_getHomeData', {"appId": "1ElZXwKuP", "taskToken": "", "channelId": 1}) 101 | await wait(1000) 102 | let lotteryNum: number = parseInt(res.data.result.userInfo.lotteryNum) 103 | console.log('可以抽奖', lotteryNum, '次') 104 | for (let i = 0; i < lotteryNum; i++) { 105 | res = await api('interact_template_getLotteryResult', {"appId": "1ElZXwKuP"}) 106 | if (res.data.result.userAwardsCacheDto.type === 0) { 107 | console.log('抽奖成功 空气') 108 | } else { 109 | console.log('抽奖成功', res.data.result.userAwardsCacheDto.jBeanAwardVo?.prizeName) 110 | } 111 | await wait(1000) 112 | } 113 | } 114 | })() 115 | 116 | async function api(fn: string, body: object) { 117 | let {data} = await axios.post('https://api.m.jd.com/client.action', 118 | `functionId=${fn}&body=${JSON.stringify(body)}&client=wh5&clientVersion=1.0.0`, { 119 | headers: { 120 | 'Host': 'api.m.jd.com', 121 | 'Origin': 'https://h5.m.jd.com', 122 | 'User-Agent': 'jdapp;iPhone;10.4.3;', 123 | 'Referer': 'https://h5.m.jd.com/', 124 | 'Cookie': cookie 125 | } 126 | }) 127 | return data 128 | } -------------------------------------------------------------------------------- /jd_speed_sign.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 极速版-签到+提现 3 | * cron: 45 0 * * * 4 | * export FP_15097="" 5 | */ 6 | 7 | import {H5ST} from "./utils/h5st_pro" 8 | import {JDHelloWorld, User} from "./TS_JDHelloWorld"; 9 | 10 | class Speed_Sign extends JDHelloWorld { 11 | user: User 12 | h5stTool: H5ST 13 | fp: string 14 | 15 | constructor() { 16 | super(); 17 | } 18 | 19 | async init() { 20 | this.fp = process.env.FP_15097 || await this.getFp() 21 | await this.run(this) 22 | } 23 | 24 | async api(fn: string, body: object) { 25 | let timestamp: number = Date.now() 26 | let h5st: string = await this.h5stTool.__genH5st({ 27 | appid: 'activities_platform', 28 | body: JSON.stringify(body), 29 | client: 'H5', 30 | clientVersion: '1.0.0', 31 | functionId: fn, 32 | t: timestamp.toString() 33 | }) 34 | return await this.post('https://api.m.jd.com/', `functionId=${fn}&body=${JSON.stringify(body)}&t=${timestamp}&appid=activities_platform&client=H5&clientVersion=1.0.0&h5st=${h5st}`, { 35 | 'Host': 'api.m.jd.com', 36 | 'Cookie': this.user.cookie, 37 | 'accept': 'application/json, text/plain, */*', 38 | 'content-type': 'application/x-www-form-urlencoded', 39 | 'origin': 'https://daily-redpacket.jd.com', 40 | 'user-agent': this.user.UserAgent, 41 | 'referer': 'https://daily-redpacket.jd.com/' 42 | }) 43 | } 44 | 45 | async main(user: User) { 46 | this.user = user 47 | this.user.UserAgent = `jdltapp;iPhone;3.9.2;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` 48 | this.h5stTool = new H5ST("15097", this.user.UserAgent, this.fp, 'https://daily-redpacket.jd.com/?activityId=9WA12jYGulArzWS7vcrwhw', 'https://daily-redpacket.jd.com', this.user.UserName); 49 | await this.h5stTool.__genAlgo() 50 | let res: any = await this.api('apSignIn_day', {"linkId": "9WA12jYGulArzWS7vcrwhw", "serviceName": "dayDaySignGetRedEnvelopeSignService", "business": 1}) 51 | try { 52 | if (res.data.retCode === 0) { 53 | console.log('签到成功') 54 | } else { 55 | console.log(res.data.retMessage) 56 | } 57 | await this.wait(2000) 58 | 59 | res = await this.api('signPrizeDetailList', {"linkId": "9WA12jYGulArzWS7vcrwhw", "serviceName": "dayDaySignGetRedEnvelopeSignService", "business": 1, "pageSize": 20, "page": 1}) 60 | for (let t of res.data.prizeDrawBaseVoPageBean.items) { 61 | if (t.prizeType === 4 && t.prizeStatus === 0) { 62 | res = await this.api('apCashWithDraw', {"linkId": "9WA12jYGulArzWS7vcrwhw", "businessSource": "DAY_DAY_RED_PACKET_SIGN", "base": {"prizeType": t.prizeType, "business": t.business, "id": t.id, "poolBaseId": t.poolBaseId, "prizeGroupId": t.prizeGroupId, "prizeBaseId": t.prizeBaseId}}) 63 | console.log(parseFloat(t.prizeValue), res.data.message) 64 | await this.wait(2000) 65 | } 66 | } 67 | } catch (e) { 68 | console.log('error', e) 69 | } 70 | } 71 | } 72 | 73 | new Speed_Sign().init().then() -------------------------------------------------------------------------------- /jd_track.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 京东快递更新通知 3 | * cron: 0 0-23/4 * * * 4 | */ 5 | 6 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 7 | import {H5ST} from "./utils/h5st" 8 | import {readFileSync, writeFileSync} from "fs" 9 | import {sendNotify} from './sendNotify' 10 | 11 | class Jd_track extends JDHelloWorld { 12 | user: User 13 | fp: string 14 | h5stTool: H5ST 15 | arr: { user: string, orderId: string, wareName: string, time: string, content: string }[] 16 | existOrderId: string[] 17 | msg: string = '' 18 | 19 | constructor() { 20 | super() 21 | } 22 | 23 | async init() { 24 | this.fp = await this.getFp4_1() 25 | this.arr = JSON.parse(readFileSync('json/jd_track.json').toString()) 26 | this.existOrderId = this.arr.map(t => { 27 | return t.orderId 28 | }) 29 | await this.run(this) 30 | } 31 | 32 | async api(body: object): Promise { 33 | let ts: number = Date.now() 34 | let h5st: string = this.h5stTool.genH5st('new_order', body, 'mac', '3.8.2', 'common_order_list', ts) 35 | return await this.get(`https://api.m.jd.com/client.action?t=${ts}&loginType=2&loginWQBiz=golden-trade&appid=new_order&client=mac&clientVersion=3.8.2&functionId=common_order_list&body=${encodeURIComponent(JSON.stringify(body))}&h5st=${h5st}`, { 36 | 'Host': 'api.m.jd.com', 37 | 'xweb_xhr': '1', 38 | 'X-Rp-Client': 'mini_2.0.0', 39 | 'User-Agent': this.user.UserAgent, 40 | 'X-Referer-Package': 'wx91d27dbf599dff74', 41 | 'X-Referer-Page': '/pages/order_taro/pages/list/index', 42 | 'Referer': 'https://servicewechat.com/wx91d27dbf599dff74/728/page-frame.html', 43 | 'Cookie': this.user.cookie 44 | }) 45 | } 46 | 47 | async main(user: User) { 48 | try { 49 | this.user = user 50 | this.user.UserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.132 Safari/537.36 MicroMessenger/6.8.0(0x16080000) NetType/WIFI MiniProgramEnv/Mac MacWechat/WMPF XWEB/30817' 51 | this.h5stTool = new H5ST('2d275', this.fp, this.user.UserAgent, this.user.UserName, 'https://servicewechat.com/wx91d27dbf599dff74/728/page-frame.html', 'https://servicewechat.com') 52 | await this.h5stTool.genAlgo() 53 | 54 | let res: any = await this.api({"externalLoginType": 1, "appType": "1", "bizType": "2", "source": "-1", "token": "", "deviceUUId": "", "platform": 2, "uuid": "", "systemBaseInfo": "{\"SDKVersion\":\"2.32.3\",\"system\":\"Mac OS X 13.5.0\"}", "orderListTag": 128, "curTab": "waitReceipt", "referer": "http%3A%2F%2Fwq.jd.com%2Fwxapp%2Fpages%2Fmy%2Findex%2Findex", "page": 1, "pageSize": 10}) 55 | for (let t of res.body.orderList) { 56 | let orderId: string = t.orderId, time: string = t.progressInfo?.tip, content: string = t.progressInfo?.content ?? '', wareName: string = t.wareInfoList[0].wareName 57 | if (content) { 58 | console.log(orderId, wareName, time, content) 59 | if (!this.existOrderId.includes(orderId)) { 60 | this.arr.push({user: this.user.UserName, orderId, wareName, time, content}) 61 | this.msg += `${this.user.UserName}\n${wareName}\n${time} ${content}\n\n` 62 | } else { 63 | this.arr.forEach(order => { 64 | if (order.orderId === orderId && order.time !== time) { 65 | this.msg += `${this.user.UserName}\n${wareName}\n${time} ${content}\n\n` 66 | } 67 | }) 68 | } 69 | } 70 | } 71 | writeFileSync('json/jd_track.json', JSON.stringify(this.arr, null, 2)) 72 | } catch (e) { 73 | console.log(e.message) 74 | await this.wait(5000) 75 | } 76 | } 77 | 78 | async help() { 79 | await sendNotify('京东待收货', this.msg) 80 | } 81 | } 82 | 83 | new Jd_track().init().then() -------------------------------------------------------------------------------- /jd_wechat_sign.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 微信小程序签到 3 | */ 4 | 5 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 6 | import {JSDOM, ResourceLoader, VirtualConsole} from "jsdom"; 7 | import {readFileSync} from "fs"; 8 | import CryptoJS from "crypto-js"; 9 | 10 | class Jd_fruit_help extends JDHelloWorld { 11 | user: User 12 | appId: string 13 | htstTool: any 14 | 15 | constructor() { 16 | super(); 17 | } 18 | 19 | async init() { 20 | await this.run(this) 21 | } 22 | 23 | async h5stToolInit() { 24 | let dom = new JSDOM(``, { 25 | url: "http://localhost", 26 | userAgent: this.user.UserAgent, 27 | runScripts: "dangerously", 28 | resources: new ResourceLoader({ 29 | userAgent: this.user.UserAgent 30 | }), 31 | includeNodeLocations: true, 32 | storageQuota: 1000000000, 33 | pretendToBeVisual: true, 34 | virtualConsole: new VirtualConsole() 35 | }) 36 | this.htstTool = new dom.window.ParamsSign({appId: this.appId}) 37 | } 38 | 39 | async api(fn: string, body: object) { 40 | let h5st: string = (await this.htstTool.sign({ 41 | appid: 'hot_channel', 42 | body: CryptoJS.SHA256(JSON.stringify(body)).toString(CryptoJS.enc.Hex), 43 | client: 'android', 44 | clientVersion: '9.17.240', 45 | functionId: fn, 46 | })).h5st 47 | return await this.post('https://api.m.jd.com/signTask/doSignTask', `loginType=2&client=android&clientVersion=9.17.240&functionId=SignComponent_doSignTask&appid=hot_channel&body=${encodeURIComponent(JSON.stringify(body))}&h5st=${h5st}`, { 48 | 'Host': 'api.m.jd.com', 49 | 'User-Agent': this.user.UserAgent, 50 | 'Cookie': this.user.cookie, 51 | 'xweb_xhr': '1', 52 | 'X-Rp-Client': 'mini_2.0.0', 53 | 'X-Referer-Package': 'wx91d27dbf599dff74', 54 | 'wqreferer': 'http://wq.jd.com/wxapp/pages/marketing/glb/glb/index', 55 | 'X-Referer-Page': '/pages/marketing/glb/glb/index', 56 | 'Referer': 'https://servicewechat.com/wx91d27dbf599dff74/752/page-frame.html' 57 | }) 58 | } 59 | 60 | async main(user: User) { 61 | try { 62 | this.user = user 63 | this.user.UserAgent = `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/6.8.0(0x16080000) NetType/WIFI MiniProgramEnv/Mac MacWechat/WMPF MacWechat/3.8.8(0x13080811) XWEB/1216` 64 | this.appId = '9a38a' 65 | await this.h5stToolInit() 66 | let res: any = await this.api('SignComponent_doSignTask', {"activityId": "10004", "version": 1}) 67 | if (res.success) { 68 | console.log('签到天数', res.data.signDays) 69 | console.log('获得红包', res.data.rewardList[0].discount) 70 | } else { 71 | console.log(res.message) 72 | } 73 | } catch (e) { 74 | console.log('Error', e) 75 | } 76 | } 77 | } 78 | 79 | new Jd_fruit_help().init().then() -------------------------------------------------------------------------------- /jd_windControl.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 我的PLUS综合分 3 | * cron: 30 9 * * 1 4 | */ 5 | 6 | import {User, JDHelloWorld} from './TS_JDHelloWorld' 7 | import {H5ST} from './utils/h5st_pro' 8 | 9 | class jd_WindControl extends JDHelloWorld { 10 | user: User 11 | h5stTool: H5ST 12 | fp: string 13 | 14 | constructor() { 15 | super() 16 | } 17 | 18 | async init() { 19 | this.fp = await this.getFp() 20 | await this.run(this) 21 | } 22 | 23 | async api(fn: string, body: object) { 24 | let h5st: string = await this.h5stTool.__genH5st({ 25 | appid: 'plus_business', 26 | body: JSON.stringify(body), 27 | functionId: fn, 28 | }) 29 | return await this.post( 30 | `https://api.m.jd.com/api?functionId=${fn}`, 31 | new URLSearchParams({ 32 | appid: 'plus_business', 33 | loginType: '2', 34 | loginWQBiz: '', 35 | functionId: fn, 36 | body: '{}', 37 | h5st: h5st, 38 | }), 39 | { 40 | 'Host': 'api.m.jd.com', 41 | 'x-rp-client': 'h5_1.0.0', 42 | 'Origin': 'https://plus.m.jd.com', 43 | 'User-Agent': this.user.UserAgent, 44 | 'Referer': 'https://plus.m.jd.com/rights/windControl', 45 | 'x-referer-page': 'https://plus.m.jd.com/rights/windControl', 46 | 'Cookie': this.user.cookie, 47 | } 48 | ) 49 | } 50 | 51 | async main(user: User) { 52 | try { 53 | this.user = user 54 | let res: any 55 | this.h5stTool = new H5ST('b63ff', this.user.UserAgent, this.fp, 'https://plus.m.jd.com/rights/windControl', 'https://plus.m.jd.com') 56 | await this.h5stTool.__genAlgo() 57 | res = await this.api('windControl_queryScore_v1', {}) 58 | 59 | console.log('综合:',res.rs.userSynthesizeScore.totalScore) 60 | console.log('信用:', res.rs.userDimensionScore.baiScore) 61 | console.log('购物合规:', res.rs.userDimensionScore.shop) 62 | console.log('售后行为:', res.rs.userDimensionScore.active) 63 | console.log('账户信息:', res.rs.userDimensionScore.accountInfo) 64 | } catch (e) { 65 | console.log(e.message) 66 | } 67 | await this.wait(3000) 68 | } 69 | } 70 | 71 | new jd_WindControl().init().then() 72 | -------------------------------------------------------------------------------- /jd_wx_hbrain.ts: -------------------------------------------------------------------------------- 1 | import {User, JDHelloWorld} from "./TS_JDHelloWorld" 2 | import {JSDOM, ResourceLoader, VirtualConsole} from "jsdom"; 3 | import {readFileSync} from "fs"; 4 | import CryptoJS from "crypto-js"; 5 | 6 | class Jd_fruit_help extends JDHelloWorld { 7 | user: User 8 | shareCodeSelf: string[] = [] 9 | appId: string 10 | h5stTool: any 11 | 12 | constructor() { 13 | super(); 14 | } 15 | 16 | async init() { 17 | await this.run(this) 18 | } 19 | 20 | async h5stToolInit() { 21 | let dom = new JSDOM(``, { 22 | url: "http://localhost", 23 | userAgent: this.user.UserAgent, 24 | runScripts: "dangerously", 25 | resources: new ResourceLoader({ 26 | userAgent: this.user.UserAgent 27 | }), 28 | includeNodeLocations: true, 29 | storageQuota: 1000000000, 30 | pretendToBeVisual: true, 31 | virtualConsole: new VirtualConsole() 32 | }) 33 | this.h5stTool = new dom.window.ParamsSign({appId: this.appId}) 34 | } 35 | 36 | async api(fn: string, body: object) { 37 | let t = Date.now(), h5st: string = (await this.h5stTool.sign({ 38 | appid: 'hot_channel', 39 | body: CryptoJS.SHA256(JSON.stringify(body)).toString(CryptoJS.enc.Hex), 40 | client: 'android', 41 | clientVersion: '9.17.240', 42 | functionId: fn, 43 | timestamp: t.toString() 44 | })).h5st 45 | return await this.post('https://api.m.jd.com/wxsport_hbrain_draw', `functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&appid=hot_channel×tamp=${t}&client=android&clientVersion=9.17.240&h5st=${h5st}`, { 46 | 'Host': 'api.m.jd.com', 47 | 'User-Agent': this.user.UserAgent, 48 | 'Cookie': this.user.cookie, 49 | 'xweb_xhr': '1', 50 | 'X-Rp-Client': 'mini_2.0.0', 51 | 'X-Referer-Package': 'wx91d27dbf599dff74', 52 | 'wqreferer': 'http://wq.jd.com/wxapp/pages/index/index', 53 | 'X-Referer-Page': '/pages/index/index', 54 | 'Referer': 'https://servicewechat.com/wx91d27dbf599dff74/752/page-frame.html' 55 | }) 56 | } 57 | 58 | async main(user: User) { 59 | try { 60 | this.user = user 61 | this.user.UserAgent = `Mozilla/5.0 (Macintosh; Intel Mac OS X ${this.getIosVer()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 MicroMessenger/6.8.0(0x16080000) NetType/WIFI MiniProgramEnv/Mac MacWechat/WMPF MacWechat/3.8.8(0x13080811) XWEB/1216` 62 | this.appId = 'd983f' 63 | await this.h5stToolInit() 64 | let res: any = await this.api('wxsport_hbrain_draw', {}) 65 | this.o2s(res) 66 | } catch (e) { 67 | console.log('获取失败', e) 68 | } 69 | await this.wait(5000) 70 | } 71 | } 72 | 73 | new Jd_fruit_help().init().then() -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jd", 3 | "version": "1.0.0", 4 | "description": "{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}", 5 | "main": "AlipayManor.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "" 12 | }, 13 | "keywords": [ 14 | "JD" 15 | ], 16 | "author": "", 17 | "license": "ISC", 18 | "dependencies": { 19 | "axios": "^0.21.4", 20 | "commander": "^10.0.1", 21 | "console-grid": "^2.0.1", 22 | "crypto-js": "^4.1.1", 23 | "date-fns": "^2.30.0", 24 | "dotenv": "^16.0.3", 25 | "download": "^8.0.0", 26 | "form-data": "^4.0.0", 27 | "got": "^11.8.3", 28 | "http-server": "^14.1.1", 29 | "jsdom": "^22.0.0", 30 | "md5": "^2.3.0", 31 | "png-js": "^1.0.0", 32 | "prettytable": "^0.3.1", 33 | "qrcode-terminal": "^0.12.0", 34 | "request": "^2.88.2", 35 | "tough-cookie": "^4.1.2", 36 | "ts-md5": "^1.3.1", 37 | "tslib": "^2.5.0", 38 | "tunnel": "0.0.6", 39 | "uglify-js": "^3.17.4", 40 | "ws": "^8.13.0" 41 | }, 42 | "devDependencies": { 43 | "@types/express": "^4.17.17", 44 | "@types/node": "^20.1.0", 45 | "express": "^4.18.2", 46 | "gulp": "^4.0.2", 47 | "gulp-typescript": "^6.0.0-alpha.1", 48 | "ts-node": "^10.9.1", 49 | "typescript": "^5.0.4" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /reset.sh: -------------------------------------------------------------------------------- 1 | git reset --hard $1 2 | git push origin HEAD --force 3 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "downlevelIteration": true 4 | } 5 | } -------------------------------------------------------------------------------- /utils/account_demo.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "pt_pin": "与jdCookie中pt_pin相同,禁止出现中文", 4 | "remarks": "备注", 5 | "pushplus": "", 6 | "jdpingou": "jdpingou;", 7 | "joy_park_run": 0.04 8 | }, 9 | { 10 | "pt_pin": "jd_xxxx", 11 | "joy_park_run": 0.08 12 | } 13 | ] -------------------------------------------------------------------------------- /utils/empty.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /utils/exceptCookie.json: -------------------------------------------------------------------------------- 1 | { 2 | "jd_88hb.ts": [ 3 | "jd_xxxxx" 4 | ], 5 | "jd_jxgc.ts": [ 6 | "%E7%A4%BA%E4%BE%8B%E8%B4%A6%E5%8F%B7" 7 | ] 8 | } -------------------------------------------------------------------------------- /utils/h5st.d.ts: -------------------------------------------------------------------------------- 1 | declare class H5ST { 2 | timestamp: number; 3 | fp_appid: string; 4 | functionId: string; 5 | client: string; 6 | clientVersion: string; 7 | ua: string; 8 | url: string; 9 | og: string; 10 | pin: string; 11 | fp: string; 12 | algo: { 13 | tk: string; 14 | algo: string; 15 | fp: string; 16 | }; 17 | constructor(fp_appid: string, fp: string, ua: string, pin: string, url: string, og: string); 18 | randomString(n: number, s: string): string; 19 | genAlgo(): Promise; 20 | genH5st(appid: string, body: object, client: string, clientVersion: string, functionId: string, t: number): string; 21 | } 22 | export { H5ST }; 23 | -------------------------------------------------------------------------------- /utils/h5st_4.2.d.ts: -------------------------------------------------------------------------------- 1 | declare class H5ST_42 { 2 | appId: string; 3 | fp: string; 4 | ua: string; 5 | pin: string; 6 | url: string; 7 | og: string; 8 | _algo: { 9 | tk: string; 10 | algo: string; 11 | fp: string; 12 | }; 13 | constructor(appId: string, ua: string, pin: string, url: string, og: string); 14 | randomString(n: number, s: string): string; 15 | algo(): Promise; 16 | _fp(): string; 17 | __genSign(t: string, n: { 18 | key: string; 19 | value: string; 20 | }[]): string; 21 | h5st(body: any): string; 22 | } 23 | export { H5ST_42 }; 24 | -------------------------------------------------------------------------------- /utils/h5st_pro.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios" 2 | import {format} from "date-fns" 3 | import * as CryptoJS from 'crypto-js' 4 | 5 | class H5ST { 6 | tk: string 7 | timestamp: string 8 | rd: string 9 | appId: string 10 | fp: string 11 | time: number 12 | ua: string 13 | enc: string 14 | url: string 15 | og: string 16 | pin: string 17 | iosVer: string 18 | api: string 19 | 20 | constructor(appId: string, ua: string, fp: string, url: string, og: string, pin?: string) { 21 | this.appId = appId 22 | this.ua = ua 23 | this.iosVer = ua.match(/iPhone OS (\d{2}_\d)/)[1] 24 | this.fp = fp 25 | this.url = url 26 | this.og = og 27 | this.pin = pin || '' 28 | this.api = 'http://sharecodepool.cnmb.pw/api' 29 | } 30 | 31 | async __genAlgo() { 32 | this.time = Date.now() 33 | this.timestamp = format(this.time, "yyyyMMddHHmmssSSS") 34 | let {data: expandParams} = await axios.post(`${this.api}/expandParams`, { 35 | iosVer: this.iosVer, 36 | ua: this.ua, 37 | pin: this.pin, 38 | url: this.url, 39 | og: this.og, 40 | appId: this.appId, 41 | fp: this.fp 42 | }) 43 | let {data: algo} = await axios.post(`https://cactus.jd.com/request_algo?g_ty=ajax`, { 44 | 'version': '3.1', 45 | 'fp': this.fp, 46 | 'appId': this.appId.toString(), 47 | 'timestamp': this.time, 48 | 'platform': 'web', 49 | 'expandParams': expandParams 50 | }, { 51 | headers: { 52 | 'authority': 'cactus.jd.com', 53 | 'accept': 'application/json', 54 | 'content-type': 'application/json', 55 | 'origin': this.og, 56 | 'referer': this.og, 57 | 'user-agent': this.ua 58 | } 59 | }) 60 | this.tk = algo.data.result.tk 61 | this.rd = algo.data.result.algo.match(/rd='(.*)'/)[1] 62 | this.enc = algo.data.result.algo.match(/algo\.(.*)\(/)[1] 63 | } 64 | 65 | __genKey(tk: string, fp: string, ts: string, ai: string, algo: object) { 66 | let str = `${tk}${fp}${ts}${ai}${this.rd}` 67 | return algo[this.enc](str, tk) 68 | } 69 | 70 | async __genH5st(body: object) { 71 | let y = this.__genKey(this.tk, this.fp, this.timestamp, this.appId, CryptoJS).toString(CryptoJS.enc.Hex) 72 | let s = '' 73 | for (let key of Object.keys(body)) { 74 | key === 'body' ? s += `${key}:${CryptoJS.SHA256(body[key]).toString(CryptoJS.enc.Hex)}&` : s += `${key}:${body[key]}&` 75 | } 76 | s = s.slice(0, -1) 77 | let {data} = await axios.post(`${this.api}/h5st`, {s, y, iosVer: this.iosVer, pin: this.pin, fp: this.fp}) 78 | return encodeURIComponent(`${this.timestamp};${this.fp};${this.appId.toString()};${this.tk};${data.s};3.1;${this.time.toString()};${data.u}`) 79 | } 80 | } 81 | 82 | export { 83 | H5ST 84 | } -------------------------------------------------------------------------------- /utils/jdShareCodes.js: -------------------------------------------------------------------------------- 1 | // 从日志中获取互助码 2 | 3 | // process.env.SHARE_CODE_FILE = "/scripts/logs/sharecode.log"; 4 | // process.env.JD_COOKIE = "cookie1&cookie2"; 5 | 6 | exports.JDZZ_SHARECODES = []; 7 | exports.DDFACTORY_SHARECODES = []; 8 | exports.DREAM_FACTORY_SHARE_CODES = []; 9 | exports.PLANT_BEAN_SHARECODES = []; 10 | exports.FRUITSHARECODES = []; 11 | exports.PETSHARECODES = []; 12 | exports.JDJOY_SHARECODES = []; 13 | 14 | let fileContent = ''; 15 | if (process.env.SHARE_CODE_FILE) { 16 | try { 17 | const fs = require('fs'); 18 | if (fs.existsSync(process.env.SHARE_CODE_FILE)) fileContent = fs.readFileSync(process.env.SHARE_CODE_FILE, 'utf8'); 19 | } catch (err) { 20 | console.error(err) 21 | } 22 | } 23 | let lines = fileContent.split('\n'); 24 | 25 | let shareCodesMap = { 26 | "JDZZ_SHARECODES": [], 27 | "DDFACTORY_SHARECODES": [], 28 | "DREAM_FACTORY_SHARE_CODES": [], 29 | "PLANT_BEAN_SHARECODES": [], 30 | "FRUITSHARECODES": [], 31 | "PETSHARECODES": [], 32 | "JDJOY_SHARECODES": [], 33 | }; 34 | for (let i = 0; i < lines.length; i++) { 35 | if (lines[i].includes('京东赚赚')) { 36 | shareCodesMap.JDZZ_SHARECODES.push(lines[i].split('】')[1].trim()); 37 | } else if (lines[i].includes('东东工厂')) { 38 | shareCodesMap.DDFACTORY_SHARECODES.push(lines[i].split('】')[1].trim()); 39 | } else if (lines[i].includes('京喜工厂')) { 40 | shareCodesMap.DREAM_FACTORY_SHARE_CODES.push(lines[i].split('】')[1].trim()); 41 | } else if (lines[i].includes('京东种豆得豆')) { 42 | shareCodesMap.PLANT_BEAN_SHARECODES.push(lines[i].split('】')[1].trim()); 43 | } else if (lines[i].includes('东东农场')) { 44 | shareCodesMap.FRUITSHARECODES.push(lines[i].split('】')[1].trim()); 45 | } else if (lines[i].includes('东东萌宠')) { 46 | shareCodesMap.PETSHARECODES.push(lines[i].split('】')[1].trim()); 47 | } else if (lines[i].includes('crazyJoy')) { 48 | shareCodesMap.JDJOY_SHARECODES.push(lines[i].split('】')[1].trim()); 49 | } 50 | } 51 | for (let key in shareCodesMap) { 52 | shareCodesMap[key] = shareCodesMap[key].reduce((prev, cur) => prev.includes(cur) ? prev : [...prev, cur], []); // 去重 53 | } 54 | let cookieCount = 0; 55 | if (process.env.JD_COOKIE) { 56 | if (process.env.JD_COOKIE.indexOf('&') > -1) { 57 | cookieCount = process.env.JD_COOKIE.split('&').length; 58 | } else { 59 | cookieCount = process.env.JD_COOKIE.split('\n').length; 60 | } 61 | } 62 | 63 | for (let key in shareCodesMap) { 64 | exports[key] = []; 65 | if (shareCodesMap[key].length === 0) { 66 | continue; 67 | } 68 | for (let i = 0; i < cookieCount; i++) { 69 | exports[key][i] = shareCodesMap[key].sort(() => Math.random() - 0.5).join('@'); 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /utils/jd_appopen.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | 杀掉后台后打开京东app获取app_open 4 | 在脚本日志查看值 5 | 6 | [MITM] 7 | hostname = api.m.jd.com 8 | 9 | ===========Surge================= 10 | [Script] 11 | jd_appopen = type=http-request,pattern=^https:\/\/api\.m\.jd\.com\/openUpgrade, max-size=0, script-path=jd_appopen.js 12 | 13 | ===================Quantumult X===================== 14 | [rewrite_local] 15 | # jd_appopen 16 | ^https:\/\/api\.m\.jd\.com\/openUpgrade url script-request-header jd_appopen.js 17 | 18 | =====================Loon===================== 19 | [Script] 20 | http-request ^https:\/\/api\.m\.jd\.com\/openUpgrade script-path=jd_appopen.js, timeout=3600, tag=jd_appopen 21 | 22 | */ 23 | 24 | const $ = new Env("app_open") 25 | 26 | let cookie = $request.headers.Cookie 27 | let pt_key = cookie.match(/(pt_key=[^;]*)/)[1] 28 | let pt_pin = cookie.match(/(pt_pin=[^;]*)/)[1] 29 | console.log('================') 30 | console.log(`${pt_key};${pt_pin};`) 31 | console.log('================') 32 | $.msg("app_open获取成功!", "在运行日志中查看") 33 | 34 | function Env(t, e) { 35 | "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); 36 | 37 | class s { 38 | constructor(t) { 39 | this.env = t 40 | } 41 | 42 | send(t, e = "GET") { 43 | t = "string" == typeof t ? {url: t} : t; 44 | let s = this.get; 45 | return "POST" === e && (s = this.post), new Promise((e, i) => { 46 | s.call(this, t, (t, s, r) => { 47 | t ? i(t) : e(s) 48 | }) 49 | }) 50 | } 51 | 52 | get(t) { 53 | return this.send.call(this.env, t) 54 | } 55 | 56 | post(t) { 57 | return this.send.call(this.env, t, "POST") 58 | } 59 | } 60 | 61 | return new class { 62 | constructor(t, e) { 63 | 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}, 开始!`) 64 | } 65 | 66 | isNode() { 67 | return "undefined" != typeof module && !!module.exports 68 | } 69 | 70 | isQuanX() { 71 | return "undefined" != typeof $task 72 | } 73 | 74 | isSurge() { 75 | return "undefined" != typeof $httpClient && "undefined" == typeof $loon 76 | } 77 | 78 | isLoon() { 79 | return "undefined" != typeof $loon 80 | } 81 | 82 | toObj(t, e = null) { 83 | try { 84 | return JSON.parse(t) 85 | } catch { 86 | return e 87 | } 88 | } 89 | 90 | toStr(t, e = null) { 91 | try { 92 | return JSON.stringify(t) 93 | } catch { 94 | return e 95 | } 96 | } 97 | 98 | getjson(t, e) { 99 | let s = e; 100 | const i = this.getdata(t); 101 | if (i) try { 102 | s = JSON.parse(this.getdata(t)) 103 | } catch { 104 | } 105 | return s 106 | } 107 | 108 | setjson(t, e) { 109 | try { 110 | return this.setdata(JSON.stringify(t), e) 111 | } catch { 112 | return !1 113 | } 114 | } 115 | 116 | getScript(t) { 117 | return new Promise(e => { 118 | this.get({url: t}, (t, s, i) => e(i)) 119 | }) 120 | } 121 | 122 | runScript(t, e) { 123 | return new Promise(s => { 124 | let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); 125 | i = i ? i.replace(/\n/g, "").trim() : i; 126 | let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); 127 | r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; 128 | 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: "*/*"}}; 129 | this.post(n, (t, e, i) => s(i)) 130 | }).catch(t => this.logErr(t)) 131 | } 132 | 133 | loaddata() { 134 | if (!this.isNode()) return {}; 135 | { 136 | this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); 137 | 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); 138 | if (!s && !i) return {}; 139 | { 140 | const i = s ? t : e; 141 | try { 142 | return JSON.parse(this.fs.readFileSync(i)) 143 | } catch (t) { 144 | return {} 145 | } 146 | } 147 | } 148 | } 149 | 150 | writedata() { 151 | if (this.isNode()) { 152 | this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); 153 | 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); 154 | s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) 155 | } 156 | } 157 | 158 | lodash_get(t, e, s) { 159 | const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); 160 | let r = t; 161 | for (const t of i) if (r = Object(r)[t], void 0 === r) return s; 162 | return r 163 | } 164 | 165 | lodash_set(t, e, s) { 166 | 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) 167 | } 168 | 169 | getdata(t) { 170 | let e = this.getval(t); 171 | if (/^@/.test(t)) { 172 | const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; 173 | if (r) try { 174 | const t = JSON.parse(r); 175 | e = t ? this.lodash_get(t, i, "") : e 176 | } catch (t) { 177 | e = "" 178 | } 179 | } 180 | return e 181 | } 182 | 183 | setdata(t, e) { 184 | let s = !1; 185 | if (/^@/.test(e)) { 186 | const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; 187 | try { 188 | const e = JSON.parse(h); 189 | this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) 190 | } catch (e) { 191 | const o = {}; 192 | this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) 193 | } 194 | } else s = this.setval(t, e); 195 | return s 196 | } 197 | 198 | getval(t) { 199 | 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 200 | } 201 | 202 | setval(t, e) { 203 | 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 204 | } 205 | 206 | initGotEnv(t) { 207 | 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)) 208 | } 209 | 210 | get(t, e = (() => { 211 | })) { 212 | 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) => { 213 | !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) 214 | })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {hints: !1})), $task.fetch(t).then(t => { 215 | const {statusCode: s, statusCode: i, headers: r, body: o} = t; 216 | e(null, {status: s, statusCode: i, headers: r, body: o}, o) 217 | }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { 218 | try { 219 | if (t.headers["set-cookie"]) { 220 | const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); 221 | s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar 222 | } 223 | } catch (t) { 224 | this.logErr(t) 225 | } 226 | }).then(t => { 227 | const {statusCode: s, statusCode: i, headers: r, body: o} = t; 228 | e(null, {status: s, statusCode: i, headers: r, body: o}, o) 229 | }, t => { 230 | const {message: s, response: i} = t; 231 | e(s, i, i && i.body) 232 | })) 233 | } 234 | 235 | post(t, e = (() => { 236 | })) { 237 | 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) => { 238 | !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) 239 | }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {hints: !1})), $task.fetch(t).then(t => { 240 | const {statusCode: s, statusCode: i, headers: r, body: o} = t; 241 | e(null, {status: s, statusCode: i, headers: r, body: o}, o) 242 | }, t => e(t)); else if (this.isNode()) { 243 | this.initGotEnv(t); 244 | const {url: s, ...i} = t; 245 | this.got.post(s, i).then(t => { 246 | const {statusCode: s, statusCode: i, headers: r, body: o} = t; 247 | e(null, {status: s, statusCode: i, headers: r, body: o}, o) 248 | }, t => { 249 | const {message: s, response: i} = t; 250 | e(s, i, i && i.body) 251 | }) 252 | } 253 | } 254 | 255 | time(t, e = null) { 256 | const s = e ? new Date(e) : new Date; 257 | 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()}; 258 | /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); 259 | 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))); 260 | return t 261 | } 262 | 263 | msg(e = t, s = "", i = "", r) { 264 | const o = t => { 265 | if (!t) return t; 266 | if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? {"open-url": t} : this.isSurge() ? {url: t} : void 0; 267 | if ("object" == typeof t) { 268 | if (this.isLoon()) { 269 | let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; 270 | return {openUrl: e, mediaUrl: s} 271 | } 272 | if (this.isQuanX()) { 273 | let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; 274 | return {"open-url": e, "media-url": s} 275 | } 276 | if (this.isSurge()) { 277 | let e = t.url || t.openUrl || t["open-url"]; 278 | return {url: e} 279 | } 280 | } 281 | }; 282 | if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { 283 | let t = ["", "==============📣系统通知📣=============="]; 284 | t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) 285 | } 286 | } 287 | 288 | log(...t) { 289 | t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) 290 | } 291 | 292 | logErr(t, e) { 293 | const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); 294 | s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) 295 | } 296 | 297 | wait(t) { 298 | return new Promise(e => setTimeout(e, t)) 299 | } 300 | 301 | done(t = {}) { 302 | const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; 303 | this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) 304 | } 305 | }(t, e) 306 | } 307 | -------------------------------------------------------------------------------- /utils/jd_joy_getInvokeKey.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * cron: 0 0 * * * 3 | */ 4 | 5 | import axios from "axios"; 6 | import {sendNotify} from '../sendNotify'; 7 | 8 | !(async () => { 9 | let res: any = await api('https://prodev.m.jd.com/mall/active/2tZssTgnQsiUqhmg5ooLSHY9XSeN/index.html') 10 | let file: string = 'https://storage.360buyimg.com/' + res.match(/htmlSourceUrl":"([^"]*)/)[1] 11 | res = await api(file) 12 | file = 'https:' + res.match(/src="(\/\/storage.*)"/)[1] 13 | res = await api(file) 14 | file = res.match(/invokeKey: '(.*)'/)[1] 15 | console.log('invokeKey:', file) 16 | if (file !== 'q8DNJdpcfRQ69gIx') { 17 | await sendNotify('invokeKey Update', file) 18 | } 19 | })() 20 | 21 | async function api(url: string) { 22 | let {data}: any = await axios.get(url, { 23 | headers: { 24 | 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36', 25 | } 26 | }) 27 | return data 28 | } -------------------------------------------------------------------------------- /utils/pushplus.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import {readFileSync} from "fs"; 3 | 4 | let account: { pt_pin: string, pushplus?: string } [] = [] 5 | 6 | try { 7 | account = JSON.parse(readFileSync("./utils/account.json").toString()) 8 | } catch (e) { 9 | console.log('utils/account.json load failed') 10 | } 11 | 12 | export async function pushplus(title: string, content: string, template: string = 'html'): Promise { 13 | let token: string 14 | for (let user of account) { 15 | if (content.includes(decodeURIComponent(user.pt_pin)) && user.pushplus) { 16 | token = user.pushplus 17 | break 18 | } 19 | } 20 | if (!token) { 21 | console.log('no pushplus token') 22 | return 23 | } 24 | let {data}: any = await axios.post('https://www.pushplus.plus/send', { 25 | token: token, 26 | title: title, 27 | content: content, 28 | template: template 29 | }, { 30 | headers: { 31 | 'Content-Type': 'application/json' 32 | } 33 | }) 34 | if (data.code === 200) { 35 | console.log('pushplus发送成功') 36 | } else { 37 | console.log('pushplus发送失败', JSON.stringify(data)) 38 | } 39 | } -------------------------------------------------------------------------------- /utils/shareCodesTool.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import USER_AGENT, {randomWord} from "../TS_USER_AGENTS"; 3 | import {requestAlgo, geth5st} from './V3' 4 | 5 | async function bean(cookie: string) { 6 | let {data}: any = await axios.post('https://api.m.jd.com/client.action', `functionId=plantBeanIndex&body=${decodeURIComponent(JSON.stringify({version: "9.0.0.1", "monitor_source": "plant_app_plant_index", "monitor_refer": ""}))}&appid=ld&client=apple&area=5_274_49707_49973&build=167283&clientVersion=9.1.0`, { 7 | headers: { 8 | Cookie: cookie, 9 | Host: "api.m.jd.com", 10 | "User-Agent": USER_AGENT 11 | } 12 | }) 13 | if (data.data?.jwordShareInfo?.shareUrl) 14 | return data.data?.jwordShareInfo.shareUrl.split('Uuid=')![1] 15 | else 16 | return 'null' 17 | } 18 | 19 | async function farm(cookie: string) { 20 | let {data}: any = await axios.post('https://api.m.jd.com/client.action?functionId=initForFarm', `body=${encodeURIComponent(JSON.stringify({"version": 4}))}&appid=wh5&clientVersion=9.1.0`, { 21 | headers: { 22 | "cookie": cookie, 23 | "origin": "https://home.m.jd.com", 24 | "referer": "https://home.m.jd.com/myJd/newhome.action", 25 | "User-Agent": USER_AGENT, 26 | "Content-Type": "application/x-www-form-urlencoded" 27 | } 28 | }) 29 | return data.farmUserPro?.shareCode ?? 'null' 30 | } 31 | 32 | async function health(cookie: string) { 33 | let {data}: any = await axios.get(`https://api.m.jd.com/client.action/client.action?functionId=jdhealth_getTaskDetail&body=${encodeURIComponent(JSON.stringify({"buildingId": "", taskId: 6, "channelId": 1}))}&client=wh5&clientVersion=1.0.0`, { 34 | headers: { 35 | "Cookie": cookie, 36 | "origin": "https://h5.m.jd.com", 37 | "referer": "https://h5.m.jd.com/", 38 | 'Content-Type': 'application/x-www-form-urlencoded', 39 | "User-Agent": USER_AGENT 40 | } 41 | }) 42 | return data.data?.result?.taskVos[0].assistTaskDetailVo.taskToken ?? 'null' 43 | } 44 | 45 | async function pet(cookie: string) { 46 | let {data} = await axios.post('https://api.m.jd.com/client.action', 47 | `functionId=initPetTown&body=${JSON.stringify({"version": 1})}&appid=wh5&client=apple&clientVersion=10.3.6&build=167963&rfs=0000`, { 48 | headers: { 49 | 'Host': 'api.m.jd.com', 50 | 'Origin': 'https://h5.m.jd.com', 51 | 'User-Agent': USER_AGENT, 52 | 'Referer': 'https://h5.m.jd.com/', 53 | 'Content-Type': 'application/x-www-form-urlencoded', 54 | 'Cookie': cookie 55 | } 56 | }) 57 | return data.result?.shareCode ?? 'null' 58 | } 59 | 60 | async function factory(cookie: string) { 61 | let {data}: any = await axios.post(`https://api.m.jd.com/client.action?functionId=jdfactory_getTaskDetail`, 62 | `functionId=jdfactory_getTaskDetail&body=${encodeURIComponent(JSON.stringify({}))}&client=wh5&clientVersion=9.1.0`, { 63 | headers: { 64 | Cookie: cookie, 65 | origin: "https://h5.m.jd.com", 66 | referer: "https://h5.m.jd.com/", 67 | "Content-Type": "application/x-www-form-urlencoded", 68 | 'User-Agent': USER_AGENT, 69 | } 70 | }); 71 | if (data.data.bizCode === 0) { 72 | for (let t of data.data?.result?.taskVos) { 73 | if (t.taskType === 14) 74 | return t.assistTaskDetailVo.taskToken 75 | } 76 | } 77 | return 'null' 78 | } 79 | 80 | async function sgmh(cookie: string) { 81 | let {data}: any = await axios.post(`https://api.m.jd.com/client.action`, 82 | `functionId=interact_template_getHomeData&body={"appId":"1EFRXxg","taskToken":""}&client=wh5&clientVersion=1.0.0`, { 83 | headers: { 84 | 'Origin': `https://h5.m.jd.com`, 85 | 'Cookie': cookie, 86 | 'Accept': `application/json, text/plain, */*`, 87 | 'Referer': `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`, 88 | 'Host': `api.m.jd.com`, 89 | } 90 | }) 91 | if (data.data.bizCode === 0) { 92 | for (let t of data.data?.result?.taskVos) { 93 | if (t.taskName === '邀请好友助力') 94 | return t.assistTaskDetailVo.taskToken 95 | } 96 | } 97 | return 'null' 98 | } 99 | 100 | async function jxfactory(cookie: string) { 101 | await requestAlgo('c0ff1') 102 | let url: string, timestamp = Date.now() 103 | let stk = `_time,bizCode,showAreaTaskFlag,source`, params = {showAreaTaskFlag: '1', bizCode: 'dream_factory'} 104 | let t: { key: string, value: string } [] = [ 105 | {key: '_time', value: timestamp.toString()}, 106 | {key: '_ts', value: timestamp.toString()}, 107 | {key: 'bizCode', value: 'dream_factory'}, 108 | {key: 'source', value: 'dreamfactory'}, 109 | ] 110 | url = `https://m.jingxi.com/newtasksys/newtasksys_front/GetUserTaskStatusList?source=dreamfactory&_time=${timestamp}&_ts=${timestamp}&_stk=${encodeURIComponent(stk)}&_=${timestamp + 3}&sceneval=2&g_login_type=1&callback=jsonpCBK${randomWord()}&g_ty=ls` 111 | 112 | for (let [key, value] of Object.entries(params)) { 113 | t.push({key, value}) 114 | url += `&${key}=${value}` 115 | } 116 | let h5st = geth5st(t, 'c0ff1') 117 | url += `&h5st=${encodeURIComponent(h5st)}` 118 | let {data}: any = await axios.get(url, { 119 | headers: { 120 | 'Referer': 'https://actst.jingxi.com/pingou/dream_factory/index.html', 121 | 'User-Agent': USER_AGENT, 122 | 'Host': 'm.jingxi.com', 123 | 'Cookie': cookie 124 | } 125 | }) 126 | return JSON.parse(data.match(/try{jsonpCBK.?\((.*)/)![1]).data?.encryptPin || 'null' 127 | } 128 | 129 | export { 130 | bean, 131 | farm, 132 | health, 133 | pet, 134 | factory, 135 | sgmh, 136 | jxfactory 137 | } -------------------------------------------------------------------------------- /utils/sharecodes.json: -------------------------------------------------------------------------------- 1 | { 2 | "cfd":["abcd", "abc123"], 3 | "jxfactory":["tuanid:123", "tuanid:234"] 4 | } 5 | -------------------------------------------------------------------------------- /utils/validate_single.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | const stream = require('stream'); 3 | const zlib = require('zlib'); 4 | const vm = require('vm'); 5 | const PNG = require('png-js'); 6 | const UA = require('../USER_AGENTS.js').USER_AGENT; 7 | 8 | 9 | Math.avg = function average() { 10 | var sum = 0; 11 | var len = this.length; 12 | for (var i = 0; i < len; i++) { 13 | sum += this[i]; 14 | } 15 | return sum / len; 16 | }; 17 | 18 | function sleep(timeout) { 19 | return new Promise((resolve) => setTimeout(resolve, timeout)); 20 | } 21 | 22 | class PNGDecoder extends PNG { 23 | constructor(args) { 24 | super(args); 25 | this.pixels = []; 26 | } 27 | 28 | decodeToPixels() { 29 | return new Promise((resolve) => { 30 | this.decode((pixels) => { 31 | this.pixels = pixels; 32 | resolve(); 33 | }); 34 | }); 35 | } 36 | 37 | getImageData(x, y, w, h) { 38 | const {pixels} = this; 39 | const len = w * h * 4; 40 | const startIndex = x * 4 + y * (w * 4); 41 | 42 | return {data: pixels.slice(startIndex, startIndex + len)}; 43 | } 44 | } 45 | 46 | const PUZZLE_GAP = 8; 47 | const PUZZLE_PAD = 10; 48 | 49 | class PuzzleRecognizer { 50 | constructor(bg, patch, y) { 51 | // console.log(bg); 52 | const imgBg = new PNGDecoder(Buffer.from(bg, 'base64')); 53 | const imgPatch = new PNGDecoder(Buffer.from(patch, 'base64')); 54 | 55 | // console.log(imgBg); 56 | 57 | this.bg = imgBg; 58 | this.patch = imgPatch; 59 | this.rawBg = bg; 60 | this.rawPatch = patch; 61 | this.y = y; 62 | this.w = imgBg.width; 63 | this.h = imgBg.height; 64 | } 65 | 66 | async run() { 67 | await this.bg.decodeToPixels(); 68 | await this.patch.decodeToPixels(); 69 | 70 | return this.recognize(); 71 | } 72 | 73 | recognize() { 74 | const {ctx, w: width, bg} = this; 75 | const {width: patchWidth, height: patchHeight} = this.patch; 76 | const posY = this.y + PUZZLE_PAD + ((patchHeight - PUZZLE_PAD) / 2) - (PUZZLE_GAP / 2); 77 | // const cData = ctx.getImageData(0, a.y + 10 + 20 - 4, 360, 8).data; 78 | const cData = bg.getImageData(0, posY, width, PUZZLE_GAP).data; 79 | const lumas = []; 80 | 81 | for (let x = 0; x < width; x++) { 82 | var sum = 0; 83 | 84 | // y xais 85 | for (let y = 0; y < PUZZLE_GAP; y++) { 86 | var idx = x * 4 + y * (width * 4); 87 | var r = cData[idx]; 88 | var g = cData[idx + 1]; 89 | var b = cData[idx + 2]; 90 | var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; 91 | 92 | sum += luma; 93 | } 94 | 95 | lumas.push(sum / PUZZLE_GAP); 96 | } 97 | 98 | const n = 2; // minium macroscopic image width (px) 99 | const margin = patchWidth - PUZZLE_PAD; 100 | const diff = 20; // macroscopic brightness difference 101 | const radius = PUZZLE_PAD; 102 | for (let i = 0, len = lumas.length - 2 * 4; i < len; i++) { 103 | const left = (lumas[i] + lumas[i + 1]) / n; 104 | const right = (lumas[i + 2] + lumas[i + 3]) / n; 105 | const mi = margin + i; 106 | const mLeft = (lumas[mi] + lumas[mi + 1]) / n; 107 | const mRigth = (lumas[mi + 2] + lumas[mi + 3]) / n; 108 | 109 | if (left - right > diff && mLeft - mRigth < -diff) { 110 | const pieces = lumas.slice(i + 2, margin + i + 2); 111 | const median = pieces.sort((x1, x2) => x1 - x2)[20]; 112 | const avg = Math.avg(pieces); 113 | 114 | // noise reducation 115 | if (median > left || median > mRigth) return; 116 | if (avg > 100) return; 117 | // console.table({left,right,mLeft,mRigth,median}); 118 | // ctx.fillRect(i+n-radius, 0, 1, 360); 119 | // console.log(i+n-radius); 120 | return i + n - radius; 121 | } 122 | } 123 | 124 | // not found 125 | return -1; 126 | } 127 | 128 | runWithCanvas() { 129 | const {createCanvas, Image} = require('canvas'); 130 | const canvas = createCanvas(); 131 | const ctx = canvas.getContext('2d'); 132 | const imgBg = new Image(); 133 | const imgPatch = new Image(); 134 | const prefix = 'data:image/png;base64,'; 135 | 136 | imgBg.src = prefix + this.rawBg; 137 | imgPatch.src = prefix + this.rawPatch; 138 | const {naturalWidth: w, naturalHeight: h} = imgBg; 139 | canvas.width = w; 140 | canvas.height = h; 141 | ctx.clearRect(0, 0, w, h); 142 | ctx.drawImage(imgBg, 0, 0, w, h); 143 | 144 | const width = w; 145 | const {naturalWidth, naturalHeight} = imgPatch; 146 | const posY = this.y + PUZZLE_PAD + ((naturalHeight - PUZZLE_PAD) / 2) - (PUZZLE_GAP / 2); 147 | // const cData = ctx.getImageData(0, a.y + 10 + 20 - 4, 360, 8).data; 148 | const cData = ctx.getImageData(0, posY, width, PUZZLE_GAP).data; 149 | const lumas = []; 150 | 151 | for (let x = 0; x < width; x++) { 152 | var sum = 0; 153 | 154 | // y xais 155 | for (let y = 0; y < PUZZLE_GAP; y++) { 156 | var idx = x * 4 + y * (width * 4); 157 | var r = cData[idx]; 158 | var g = cData[idx + 1]; 159 | var b = cData[idx + 2]; 160 | var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; 161 | 162 | sum += luma; 163 | } 164 | 165 | lumas.push(sum / PUZZLE_GAP); 166 | } 167 | 168 | const n = 2; // minium macroscopic image width (px) 169 | const margin = naturalWidth - PUZZLE_PAD; 170 | const diff = 20; // macroscopic brightness difference 171 | const radius = PUZZLE_PAD; 172 | for (let i = 0, len = lumas.length - 2 * 4; i < len; i++) { 173 | const left = (lumas[i] + lumas[i + 1]) / n; 174 | const right = (lumas[i + 2] + lumas[i + 3]) / n; 175 | const mi = margin + i; 176 | const mLeft = (lumas[mi] + lumas[mi + 1]) / n; 177 | const mRigth = (lumas[mi + 2] + lumas[mi + 3]) / n; 178 | 179 | if (left - right > diff && mLeft - mRigth < -diff) { 180 | const pieces = lumas.slice(i + 2, margin + i + 2); 181 | const median = pieces.sort((x1, x2) => x1 - x2)[20]; 182 | const avg = Math.avg(pieces); 183 | 184 | // noise reducation 185 | if (median > left || median > mRigth) return; 186 | if (avg > 100) return; 187 | // console.table({left,right,mLeft,mRigth,median}); 188 | // ctx.fillRect(i+n-radius, 0, 1, 360); 189 | // console.log(i+n-radius); 190 | return i + n - radius; 191 | } 192 | } 193 | 194 | // not found 195 | return -1; 196 | } 197 | } 198 | 199 | const DATA = { 200 | "appId": "17839d5db83", 201 | "scene": "cww", 202 | "product": "embed", 203 | "lang": "zh_CN", 204 | }; 205 | const SERVER = 'iv.jd.com'; 206 | 207 | class JDJRValidator { 208 | constructor() { 209 | this.data = {}; 210 | this.x = 0; 211 | this.t = Date.now(); 212 | } 213 | 214 | async run() { 215 | const tryRecognize = async () => { 216 | const x = await this.recognize(); 217 | 218 | if (x > 0) { 219 | return x; 220 | } 221 | // retry 222 | return await tryRecognize(); 223 | }; 224 | const puzzleX = await tryRecognize(); 225 | console.log(puzzleX); 226 | const pos = new MousePosFaker(puzzleX).run(); 227 | const d = getCoordinate(pos); 228 | 229 | // console.log(pos[pos.length-1][2] -Date.now()); 230 | // await sleep(4500); 231 | await sleep(pos[pos.length - 1][2] - Date.now()); 232 | const result = await JDJRValidator.jsonp('/slide/s.html', {d, ...this.data}); 233 | 234 | if (result.message === 'success') { 235 | console.log(result); 236 | console.log('JDJRValidator: %fs', (Date.now() - this.t) / 1000); 237 | return result; 238 | } else { 239 | console.count(JSON.stringify(result)); 240 | await sleep(300); 241 | return await this.run(); 242 | } 243 | } 244 | 245 | async recognize() { 246 | const data = await JDJRValidator.jsonp('/slide/g.html', {e: ''}); 247 | const {bg, patch, y} = data; 248 | // const uri = 'data:image/png;base64,'; 249 | // const re = new PuzzleRecognizer(uri+bg, uri+patch, y); 250 | const re = new PuzzleRecognizer(bg, patch, y); 251 | const puzzleX = await re.run(); 252 | 253 | if (puzzleX > 0) { 254 | this.data = { 255 | c: data.challenge, 256 | w: re.w, 257 | e: '', 258 | s: '', 259 | o: '', 260 | }; 261 | this.x = puzzleX; 262 | } 263 | return puzzleX; 264 | } 265 | 266 | async report(n) { 267 | console.time('PuzzleRecognizer'); 268 | let count = 0; 269 | 270 | for (let i = 0; i < n; i++) { 271 | const x = await this.recognize(); 272 | 273 | if (x > 0) count++; 274 | if (i % 50 === 0) { 275 | console.log('%f\%', (i / n) * 100); 276 | } 277 | } 278 | 279 | console.log('successful: %f\%', (count / n) * 100); 280 | console.timeEnd('PuzzleRecognizer'); 281 | } 282 | 283 | static jsonp(api, data = {}) { 284 | return new Promise((resolve, reject) => { 285 | const fnId = `jsonp_${String(Math.random()).replace('.', '')}`; 286 | const extraData = {callback: fnId}; 287 | const query = new URLSearchParams({...DATA, ...extraData, ...data}).toString(); 288 | const url = `http://${SERVER}${api}?${query}`; 289 | const headers = { 290 | 'Accept': '*/*', 291 | 'Accept-Encoding': 'gzip,deflate,br', 292 | 'Accept-Language': 'zh-CN,en-US', 293 | 'Connection': 'keep-alive', 294 | 'Host': SERVER, 295 | 'Proxy-Connection': 'keep-alive', 296 | 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html', 297 | 'User-Agent': UA, 298 | }; 299 | const req = http.get(url, {headers}, (response) => { 300 | let res = response; 301 | if (res.headers['content-encoding'] === 'gzip') { 302 | const unzipStream = new stream.PassThrough(); 303 | stream.pipeline( 304 | response, 305 | zlib.createGunzip(), 306 | unzipStream, 307 | reject, 308 | ); 309 | res = unzipStream; 310 | } 311 | res.setEncoding('utf8'); 312 | 313 | let rawData = ''; 314 | 315 | res.on('data', (chunk) => rawData += chunk); 316 | res.on('end', () => { 317 | try { 318 | const ctx = { 319 | [fnId]: (data) => ctx.data = data, 320 | data: {}, 321 | }; 322 | 323 | vm.createContext(ctx); 324 | vm.runInContext(rawData, ctx); 325 | 326 | // console.log(ctx.data); 327 | res.resume(); 328 | resolve(ctx.data); 329 | } catch (e) { 330 | reject(e); 331 | } 332 | }); 333 | }); 334 | 335 | req.on('error', reject); 336 | req.end(); 337 | }); 338 | } 339 | } 340 | 341 | function getCoordinate(c) { 342 | function string10to64(d) { 343 | var c = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~".split("") 344 | , b = c.length 345 | , e = +d 346 | , a = []; 347 | do { 348 | mod = e % b; 349 | e = (e - mod) / b; 350 | a.unshift(c[mod]) 351 | } while (e); 352 | return a.join("") 353 | } 354 | 355 | function prefixInteger(a, b) { 356 | return (Array(b).join(0) + a).slice(-b) 357 | } 358 | 359 | function pretreatment(d, c, b) { 360 | var e = string10to64(Math.abs(d)); 361 | var a = ""; 362 | if (!b) { 363 | a += (d > 0 ? "1" : "0") 364 | } 365 | a += prefixInteger(e, c); 366 | return a 367 | } 368 | 369 | var b = new Array(); 370 | for (var e = 0; e < c.length; e++) { 371 | if (e == 0) { 372 | b.push(pretreatment(c[e][0] < 262143 ? c[e][0] : 262143, 3, true)); 373 | b.push(pretreatment(c[e][1] < 16777215 ? c[e][1] : 16777215, 4, true)); 374 | b.push(pretreatment(c[e][2] < 4398046511103 ? c[e][2] : 4398046511103, 7, true)) 375 | } else { 376 | var a = c[e][0] - c[e - 1][0]; 377 | var f = c[e][1] - c[e - 1][1]; 378 | var d = c[e][2] - c[e - 1][2]; 379 | b.push(pretreatment(a < 4095 ? a : 4095, 2, false)); 380 | b.push(pretreatment(f < 4095 ? f : 4095, 2, false)); 381 | b.push(pretreatment(d < 16777215 ? d : 16777215, 4, true)) 382 | } 383 | } 384 | return b.join("") 385 | } 386 | 387 | const HZ = 20; 388 | 389 | class MousePosFaker { 390 | constructor(puzzleX) { 391 | this.x = parseInt(Math.random() * 20 + 20, 10); 392 | this.y = parseInt(Math.random() * 80 + 80, 10); 393 | this.t = Date.now(); 394 | this.pos = [[this.x, this.y, this.t]]; 395 | this.minDuration = parseInt(1000 / HZ, 10); 396 | // this.puzzleX = puzzleX; 397 | this.puzzleX = puzzleX + parseInt(Math.random() * 2 - 1, 10); 398 | 399 | this.STEP = parseInt(Math.random() * 6 + 5, 10); 400 | this.DURATION = parseInt(Math.random() * 7 + 14, 10) * 100; 401 | // [9,1600] [10,1400] 402 | this.STEP = 9; 403 | // this.DURATION = 2000; 404 | console.log(this.STEP, this.DURATION); 405 | } 406 | 407 | run() { 408 | const perX = this.puzzleX / this.STEP; 409 | const perDuration = this.DURATION / this.STEP; 410 | const firstPos = [this.x - parseInt(Math.random() * 6, 10), this.y + parseInt(Math.random() * 11, 10), this.t]; 411 | 412 | this.pos.unshift(firstPos); 413 | this.stepPos(perX, perDuration); 414 | this.fixPos(); 415 | 416 | const reactTime = parseInt(60 + Math.random() * 100, 10); 417 | const lastIdx = this.pos.length - 1; 418 | const lastPos = [this.pos[lastIdx][0], this.pos[lastIdx][1], this.pos[lastIdx][2] + reactTime]; 419 | 420 | this.pos.push(lastPos); 421 | return this.pos; 422 | } 423 | 424 | stepPos(x, duration) { 425 | let n = 0; 426 | const sqrt2 = Math.sqrt(2); 427 | for (let i = 1; i <= this.STEP; i++) { 428 | n += 1 / i; 429 | } 430 | for (let i = 0; i < this.STEP; i++) { 431 | x = this.puzzleX / (n * (i + 1)); 432 | const currX = parseInt((Math.random() * 30 - 15) + x, 10); 433 | const currY = parseInt(Math.random() * 7 - 3, 10); 434 | const currDuration = parseInt((Math.random() * 0.4 + 0.8) * duration, 10); 435 | 436 | this.moveToAndCollect({ 437 | x: currX, 438 | y: currY, 439 | duration: currDuration, 440 | }); 441 | } 442 | } 443 | 444 | fixPos() { 445 | const actualX = this.pos[this.pos.length - 1][0] - this.pos[1][0]; 446 | const deviation = this.puzzleX - actualX; 447 | 448 | if (Math.abs(deviation) > 4) { 449 | this.moveToAndCollect({ 450 | x: deviation, 451 | y: parseInt(Math.random() * 8 - 3, 10), 452 | duration: 250, 453 | }); 454 | } 455 | } 456 | 457 | moveToAndCollect({x, y, duration}) { 458 | let movedX = 0; 459 | let movedY = 0; 460 | let movedT = 0; 461 | const times = duration / this.minDuration; 462 | let perX = x / times; 463 | let perY = y / times; 464 | let padDuration = 0; 465 | 466 | if (Math.abs(perX) < 1) { 467 | padDuration = duration / Math.abs(x) - this.minDuration; 468 | perX = 1; 469 | perY = y / Math.abs(x); 470 | } 471 | 472 | while (Math.abs(movedX) < Math.abs(x)) { 473 | const rDuration = parseInt(padDuration + Math.random() * 16 - 4, 10); 474 | 475 | movedX += perX + Math.random() * 2 - 1; 476 | movedY += perY; 477 | movedT += this.minDuration + rDuration; 478 | 479 | const currX = parseInt(this.x + movedX, 10); 480 | const currY = parseInt(this.y + movedY, 10); 481 | const currT = this.t + movedT; 482 | 483 | this.pos.push([currX, currY, currT]); 484 | } 485 | 486 | this.x += x; 487 | this.y += y; 488 | this.t += Math.max(duration, movedT); 489 | } 490 | } 491 | 492 | // new JDJRValidator().run().then(r => { 493 | // console.log(r.validate) 494 | // }) 495 | module.exports = { 496 | JDJRValidator 497 | } --------------------------------------------------------------------------------