From 01936173f7d4a8488e85e8416ba6507a460fb7e8 Mon Sep 17 00:00:00 2001 From: smallfawn <860562056@QQ.COM> Date: Sat, 4 Apr 2026 21:45:27 +0800 Subject: [PATCH] feat(new hyjk): new hyjk.js --- README.md | 1 - daily/ddsy.js | 8 +- haofan.py | 39 -- hfzj.js | 404 --------------------- htx.js | 966 -------------------------------------------------- hyjk.js | 852 ++++++++++++++++++++++++++++---------------- 6 files changed, 559 insertions(+), 1711 deletions(-) delete mode 100644 haofan.py delete mode 100644 hfzj.js delete mode 100644 htx.js diff --git a/README.md b/README.md index 134c383..f5ce00d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ | 爱玛会员俱乐部 | 2026-04-02 09:08:43 | ✅ | | 快手极速版 | 2026-04-02 09:08:43 | ✅ | | 奇瑞汽车 | 2026-04-03 08:37:37 | ✅ | -| 9 9 * * * | 2026-04-02 18:56:55 | ✅ | | 东方烟草报 | 2026-04-02 21:10:57 | ✅ | | babycare | 2026-04-03 08:37:37 | ✅ | | 海底捞 | 2026-04-03 08:37:37 | ✅ | diff --git a/daily/ddsy.js b/daily/ddsy.js index 8c3f1f1..1fa0b17 100644 --- a/daily/ddsy.js +++ b/daily/ddsy.js @@ -2,13 +2,13 @@ ------------------------------------------ @Author: sm @Date: 2024.06.07 19:15 -@Description: ddky -cron: 9 30 * * * +@Description: 叮当快药 +cron: 9 9 * * * ------------------------------------------ #Notice: 变量值:https://hapi.ddky.com/mcp/weixin/rest.htm?后面的loginToken&userId&uDate 多账户换行或者&分隔 网页版登录 https://m.ddky.com/ -小程序登录9 9 * * * +小程序登录叮当快药 APP 都可以找到这三个值 ⚠️【免责声明】 ------------------------------------------ @@ -22,7 +22,7 @@ APP 都可以找到这三个值 */ const { Env } = require("./tools/env") -const $ = new Env("9 9 * * *"); +const $ = new Env("叮当快药"); let ckName = `ddky`; const strSplitor = "#"; const axios = require("axios"); diff --git a/haofan.py b/haofan.py deleted file mode 100644 index f40873b..0000000 --- a/haofan.py +++ /dev/null @@ -1,39 +0,0 @@ -import requests -import json -import time - -# ====================== 【自行填写】 ====================== -token = "这里填你自己的token" -# ========================================================== - -url = "https://api.haofanhuoban.com/api/v1/activity/draw/draw" - -payload = { - "openid": "MrkPfIgybOsRVIhswiLQmDBvJcSwU1", - "openId": "MrkPfIgybOsRVIhswiLQmDBvJcSwU1", - "activityId": "15" -} - -headers = { - 'User-Agent': "Mozilla/5.0 (Linux; Android 10; MI 8 UD Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.101 Mobile Safari/537.36", - 'Content-Type': "application/json", - 'authorization': f"Bearer {token}", - 'appid': "1", - 'os': "1" -} - -# 抽奖次数 -draw_times = 6 - -print("========== 好饭伙伴 抽奖脚本 ==========") -for i in range(1, draw_times + 1): - try: - response = requests.post(url, data=json.dumps(payload), headers=headers, timeout=10) - res = response.json() - print(f"第{i}次抽奖: {res}") - time.sleep(1) - except Exception as e: - print(f"第{i}次抽奖异常: {e}") - time.sleep(2) - -print("脚本执行完成") diff --git a/hfzj.js b/hfzj.js deleted file mode 100644 index 7df8633..0000000 --- a/hfzj.js +++ /dev/null @@ -1,404 +0,0 @@ -/** - * 哈弗智家 - * cron 14 14 * * * hfzj.js - * 23/01/29 积分查询和点赞文章 - * 23/01/30 更新签到 - * ========= 青龙--配置文件 =========== - * # 项目名称 - * export hfzj_data='accessToken @ accessToken' - * - * 多账号用 换行 或 @ 分割 - * 抓包 https://gw-app.beantechyun.com , 找到 accessToken 即可 - * ==================================== - * - */ - - - -const $ = new Env("哈弗智家"); -const ckName = "hfzj_data"; -//-------------------- 一般不动变量区域 ------------------------------------- -const Notify = 1; //0为关闭通知,1为打开通知,默认为1 -let debug = 1; //Debug调试 0关闭 1开启 -let envSplitor = ["@", "\n"]; //多账号分隔符 -let ck = msg = ''; //let ck,msg -let host, hostname; -let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || ''; -let userList = []; -let userIdx = 0; -let userCount = 0; -//---------------------- 自定义变量区域 ----------------------------------- -//--------------------------------------------------------- - -async function start() { - - - console.log('\n================== 用户信息 ==================\n'); - taskall = []; - for (let user of userList) { - taskall.push(await user.point_info()); - await $.wait(5000); //延迟 1秒 可充分利用 $.环境函数 - } - await Promise.all(taskall); - console.log('\n================== 用户信息 ==================\n'); - taskall = []; - for (let user of userList) { - taskall.push(await user.art_list()); - await $.wait(5000); //延迟 1秒 可充分利用 $.环境函数 - } - await Promise.all(taskall); - - - -} - - -class UserInfo { - constructor(str) { - this.index = ++userIdx; - this.ck = str.split('&')[0]; //单账号多变量分隔符 - //let ck = str.split('&') - //this.data1 = ck[0] - this.ts = ts13(); - this.nonce = randomszxx(16) - - this.getHeaders = { - 'ip': '192.168.31.223', - 'rs': 2, - 'bt-auth-appkey': 7736975579, - 'terminal': 'GW_APP_Haval', - 'enterpriseId': 'CC01', - 'sys': 'Android', - 'brand': '1', - 'accessToken': this.ck, - 'tokenId': '3177c9de1b5841d39b4dd85cc119edad', - 'sys': 'Android', - 'cVer': '4.4.900', - 'Host': 'gw-app.beantechyun.com', - 'Connection': 'Keep-Alive', - //'Accept-Encoding': 'gzip' - 'User-Agent': 'okhttp/4.2.2', - 'If-Modified-Since': 'Sun, 29 Jan 2023 02:20:01 GMT', - } - this.postHeaders = { - 'ip': '192.168.31.223', - 'rs': 2, - 'bt-auth-appkey': 7736975579, - 'terminal': 'GW_APP_Haval', - 'enterpriseId': 'CC01', - 'sys': 'Android', - 'brand': '1', - 'accessToken': this.ck, - 'tokenId': '3177c9de1b5841d39b4dd85cc119edad', - 'sys': 'Android', - 'cVer': '4.4.900', - 'Host': 'gw-app.beantechyun.com', - 'Connection': 'Keep-Alive', - //'Accept-Encoding': 'gzip' - 'User-Agent': 'okhttp/4.2.2', - 'Content-Type': 'application/json; charset=UTF-8' - } - - } - async getSign(method, url, nonce, ts, data) { - let r = encodeURIComponent(method + url + 'bt-auth-appkey:7736975579' + 'bt-auth-nonce:' + nonce + 'bt-auth-timestamp:' + ts + data + '8a23355d9f6a3a41deaf37a628645c62') - return SHA256_Encrypt(r) - } - async point_info() { - try { - let Headers = this.getHeaders; - let url = `/app-api/api/v1.0/point/querySumPoint` - let data = 'port=HJ0002' - Headers['bt-auth-nonce'] = this.nonce - Headers['bt-auth-timestamp'] = this.ts - Headers['bt-auth-sign'] = await this.getSign('GET', url, this.nonce, this.ts, data) - let options = { - url: `https://gw-app.beantechyun.com` + url + '?' + data, - headers: Headers - } - options = changeCode(options) //把某软件生成的代码(request或axios或jquery)转换为got通用 - //console.log(options); - let result = await httpRequest(options); - //console.log(result); - if (result.code == '000000') { - DoubleLog(`账号[${this.index}] 积分剩余: ${result.data.remindPoint}`); - if (!result.data.signIn) { - //签到 - DoubleLog(`检测到未签到,执行签到`) - await this.task_signin() - } - } else { - DoubleLog(`账号[${this.index}] 积分剩余:失败 ❌ 了呢,原因未知!`); - console.log(result); - } - } catch (e) { - console.log(e); - } - } - async task_signin() { - try { - let options = { - url: `https://bt-h5-gateway.beantechyun.com/app-api/api/v1.0/point/sign`, - headers: { - 'Host': 'bt-h5-gateway.beantechyun.com', - 'Connection': 'keep-alive', - //'Content-Length': 17, - 'Cache-Control': 'max-age=0', - 'accessToken': this.ck, - 'rs': '2', - 'terminal': 'GW_APP_Haval', - 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; MI 8 Lite Build/QKQ1.190910.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/89.0.4389.72 MQQBrowser/6.2 TBS/046141 Mobile Safari/537.36 fromapp fromapp_Android_havalcVer=4.4.900', - 'Content-Type': 'application/json;charset=UTF-8', - 'cVer': '4.4.900', - //'Accept': 'application/json, textain, */*', - 'bt-auth-appKey': '7849495624', - 'brand': '1', - 'If-Modified-Since': '0', - 'tokenId': '3177c9de1b5841d39b4dd85cc119edad', - 'enterpriseId': 'CC01', - 'os': 'ANDROID', - 'Origin': 'https://haval-restructure-h5.beantechyun.com', - 'X-Requested-With': 'com.navinfo.gw', - 'Sec-Fetch-Site': 'same-site', - 'Sec-Fetch-Mode': 'cors', - 'Sec-Fetch-Dest': 'empty', - 'Referer': 'https://haval-restructure-h5.beantechyun.com/', - //'Accept-Encoding': 'gzip, deflate, br', - //'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7' - }, - body: { "port": "HJ0002" } - } - options = changeCode(options) //把某软件生成的代码(request或axios或jquery)转换为got通用 - //console.log(options); - let result = await httpRequest(options); - //console.log(result); - if (result.code == '000000') { - DoubleLog(`账号[${this.index}] 签到成功: 获得[${result.data.pointResultMessage}]`); - } else { - DoubleLog(`账号[${this.index}] 签到:失败 ❌ 了呢,原因未知!`); - console.log(result); - } - } catch (e) { - console.log(e); - } - } - async art_list() { - try { - let body = `{"newVersion":"1","pageParam":{"pageNo":1,"pageSize":21},"queryParam":{"firstThreadId":"","homeRecommendation":"0","lastThreadCreateTime":"202301280730000","lastThreadId":"","newVersion":"1","operatingTime":"202301291603577"},"routeRecommendDTO":{"latitude":"37.190615","longitude":"114.551969","startCity":"邢台市","startCityCode":"0319"},"sortParam":{"order":"1","type":"6"}}` - let bodydata = `json=` + body - let Headers = this.postHeaders; - let url = `/app-api/api/v1.0/community/route/queryPostAndActivity` - Headers['bt-auth-nonce'] = this.nonce - Headers['bt-auth-timestamp'] = this.ts - Headers['bt-auth-sign'] = await this.getSign('POST', url, this.nonce, this.ts, bodydata) - let options = {//注意看sign的参数 这里要注意 和url一直一致 - url: `https://gw-app.beantechyun.com` + url, - headers: Headers, - body: body - } - options = changeCode(options) - //console.log(options); - let result = await httpRequest(options); - //console.log(result); - if (result.code == '000000') { - let artId, value; - for (let i = 0; i < 5; i++) { - if ('posts' in result.data.list[i]) { - artId = result.data.list[i].posts[0].threadBasic.id - value = result.data.list[i].posts[0].threadBasic.author.beanId - //await $.wait(5000) - //await this.task_like(artId, value) - } else { - artId = result.data.list[i].threadBasic.id - value = result.data.list[i].threadBasic.author.userBasic.beanId - //await $.wait(5000) - //await this.task_like(artId, value) - } - } - - } else { - console.log(result); - } - } catch (e) { - console.log(e); - } - } - async task_like(artId, value) { - try { - let body = `{"id":${artId},"objs":[{"attr":"masterId","value":${value}},{"attr":"mobile","value":""},{"attr":"objectId","value":${artId}}],"oprType":1,"port":"HJ0013","type":0}` - let bodydata = `json=` + body - let Headers = this.postHeaders; - let url = '/app-api/api/v1.0/community/like' - Headers['bt-auth-nonce'] = this.nonce - Headers['bt-auth-timestamp'] = this.ts - Headers['bt-auth-sign'] = await this.getSign('POST', url, this.nonce, this.ts, bodydata) - let options = { - url: `https://gw-app.beantechyun.com` + url, - headers: Headers, - body: body - } - options = changeCode(options) - //console.log(options); - let result = await httpRequest(options); - //console.log(result); - if (result.code == '000000') { - DoubleLog(`账号[${this.index}] 点赞成功: [${artId}]`); - } else { - DoubleLog(`账号[${this.index}] 点赞:失败 ❌ 了呢,原因未知!`); - console.log(result); - } - } catch (e) { - console.log(e); - } - } - - - - -} - -!(async () => { - if (!(await checkEnv())) return; - if (userList.length > 0) { - await start(); - } - await SendMsg(msg); -})() - .catch((e) => console.log(e)) - .finally(() => $.done()); - - -//******************************************************** -// 变量检查与处理 -async function checkEnv() { - if (userCookie) { - // console.log(userCookie); - let e = envSplitor[0]; - for (let o of envSplitor) - if (userCookie.indexOf(o) > -1) { - e = o; - break; - } - for (let n of userCookie.split(e)) n && userList.push(new UserInfo(n)); - userCount = userList.length; - } else { - console.log("未找到CK"); - return; - } - return console.log(`共找到${userCount}个账号`), true;//true == !0 -} -///////////////////////////////////////////////////////////////////////////////////// -function randomszxx(e) { - e = e || 32; - var t = "qwertyuioplkjhgfdsazxcvbnm1234567890", - a = t.length, - n = ""; - - for (i = 0; i < e; i++) n += t.charAt(Math.floor(Math.random() * a)); - return n; -} -function ts13() { - return Math.round(new Date().getTime()).toString(); -} - -function changeCode(oldoptions) { - let newoptions = new Object(), - urlTypeArr = ['qs', 'params'], - bodyTypeArr = ['body', 'data', 'form', 'formData'] - for (let e in urlTypeArr) { - urlTypeArr[e] in oldoptions ? newoptions.url = changeUrl(urlTypeArr[e]) : newoptions.url = oldoptions.url - } - 'content-type' in oldoptions.headers ? newoptions.headers = changeHeaders(oldoptions.headers) : newoptions.headers = oldoptions.headers - function changeUrl(type) { - url = oldoptions.url + '?' - for (let key in oldoptions[type]) { url += key + '=' + oldoptions[type][key] + '&' } - url = url.substring(0, url.length - 1) - return url - } - function changeHeaders(headers) { - let tmp = headers['content-type'] - delete headers['content-type'] - headers['Content-Type'] = tmp - return headers - } - for (let o in bodyTypeArr) { - if (bodyTypeArr[o] in oldoptions) { - (Object.prototype.toString.call(oldoptions[bodyTypeArr[o]]) === '[object Object]') ? newoptions.body = JSON.stringify(oldoptions[bodyTypeArr[o]]) : newoptions.body = oldoptions[bodyTypeArr[o]] - } - } - return newoptions -} -function httpRequest(options, method) { - //options = changeCode(options) - typeof (method) === 'undefined' ? ('body' in options ? method = 'post' : method = 'get') : method = method - return new Promise((resolve) => { - $[method](options, (err, resp, data) => { - try { - if (err) { - console.log(`${method}请求失败`); - //console.log(JSON.parse(err)); - $.logErr(err); - //throw new Error(err); - //console.log(err); - } else { - //httpResult = data; - //httpResponse = resp; - if (data) { - //console.log(data); - data = JSON.parse(data); - resolve(data) - } else { - console.log(`请求api返回数据为空,请检查自身原因`) - } - } - } catch (e) { - //console.log(e, resp); - $.logErr(e, resp); - } finally { - resolve(); - } - }) - }) -} -// 等待 X 秒 -function wait(n) { - return new Promise(function (resolve) { - setTimeout(resolve, n * 1000) - }) -} -// 双平台log输出 -function DoubleLog(data) { - if ($.isNode()) { - if (data) { - console.log(`${data}`); - msg += `\n${data}` - } - } else { - console.log(`${data}`); - msg += `\n${data}` - } -} -// 发送消息 -async function SendMsg(message) { - if (!message) return; - if (Notify > 0) { - if ($.isNode()) { - var notify = require("./sendNotify"); - await notify.sendNotify($.name, message) - } else { - $.msg($.name, '', message) - } - } else { - console.log(message) - } -} -function SHA256_Encrypt(data) { - sha256_init(); - sha256_update(data, data.length); - sha256_final(); - return sha256_encode_hex(); -} -/* SHA256 logical functions */ function rotateRight(n, x) { return (x >>> n) | (x << (32 - n)); } function choice(x, y, z) { return (x & y) ^ (~x & z); } function majority(x, y, z) { return (x & y) ^ (x & z) ^ (y & z); } function sha256_Sigma0(x) { return rotateRight(2, x) ^ rotateRight(13, x) ^ rotateRight(22, x); } function sha256_Sigma1(x) { return rotateRight(6, x) ^ rotateRight(11, x) ^ rotateRight(25, x); } function sha256_sigma0(x) { return rotateRight(7, x) ^ rotateRight(18, x) ^ (x >>> 3); } function sha256_sigma1(x) { return rotateRight(17, x) ^ rotateRight(19, x) ^ (x >>> 10); } function sha256_expand(W, j) { return (W[j & 0x0f] += sha256_sigma1(W[(j + 14) & 0x0f]) + W[(j + 9) & 0x0f] + sha256_sigma0(W[(j + 1) & 0x0f])); } /* Hash constant words K: */ var K256 = new Array(0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2); /* global arrays */ var ihash, count, buffer; var sha256_hex_digits = "0123456789abcdef"; /* Add 32-bit integers with 16-bit operations (bug in some JS-interpreters: overflow) */ function safe_add(x, y) { var lsw = (x & 0xffff) + (y & 0xffff); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xffff); } /* Initialise the SHA256 computation */ function sha256_init() { ihash = new Array(8); count = new Array(2); buffer = new Array(64); count[0] = count[1] = 0; ihash[0] = 0x6a09e667; ihash[1] = 0xbb67ae85; ihash[2] = 0x3c6ef372; ihash[3] = 0xa54ff53a; ihash[4] = 0x510e527f; ihash[5] = 0x9b05688c; ihash[6] = 0x1f83d9ab; ihash[7] = 0x5be0cd19; } /* Transform a 512-bit message block */ function sha256_transform() { var a, b, c, d, e, f, g, h, T1, T2; var W = new Array(16); /* Initialize registers with the previous intermediate value */ a = ihash[0]; b = ihash[1]; c = ihash[2]; d = ihash[3]; e = ihash[4]; f = ihash[5]; g = ihash[6]; h = ihash[7]; /* make 32-bit words */ for (var i = 0; i < 16; i++) W[i] = buffer[(i << 2) + 3] | (buffer[(i << 2) + 2] << 8) | (buffer[(i << 2) + 1] << 16) | (buffer[i << 2] << 24); for (var j = 0; j < 64; j++) { T1 = h + sha256_Sigma1(e) + choice(e, f, g) + K256[j]; if (j < 16) T1 += W[j]; else T1 += sha256_expand(W, j); T2 = sha256_Sigma0(a) + majority(a, b, c); h = g; g = f; f = e; e = safe_add(d, T1); d = c; c = b; b = a; a = safe_add(T1, T2); } /* Compute the current intermediate hash value */ ihash[0] += a; ihash[1] += b; ihash[2] += c; ihash[3] += d; ihash[4] += e; ihash[5] += f; ihash[6] += g; ihash[7] += h; } /* Read the next chunk of data and update the SHA256 computation */ function sha256_update(data, inputLen) { var i, index, curpos = 0; /* Compute number of bytes mod 64 */ index = (count[0] >> 3) & 0x3f; var remainder = inputLen & 0x3f; /* Update number of bits */ if ((count[0] += inputLen << 3) < inputLen << 3) count[1]++; count[1] += inputLen >> 29; /* Transform as many times as possible */ for (i = 0; i + 63 < inputLen; i += 64) { for (var j = index; j < 64; j++) buffer[j] = data.charCodeAt(curpos++); sha256_transform(); index = 0; } /* Buffer remaining input */ for (var j = 0; j < remainder; j++) buffer[j] = data.charCodeAt(curpos++); } /* Finish the computation by operations such as padding */ function sha256_final() { var index = (count[0] >> 3) & 0x3f; buffer[index++] = 0x80; if (index <= 56) { for (var i = index; i < 56; i++) buffer[i] = 0; } else { for (var i = index; i < 64; i++) buffer[i] = 0; sha256_transform(); for (var i = 0; i < 56; i++) buffer[i] = 0; } buffer[56] = (count[1] >>> 24) & 0xff; buffer[57] = (count[1] >>> 16) & 0xff; buffer[58] = (count[1] >>> 8) & 0xff; buffer[59] = count[1] & 0xff; buffer[60] = (count[0] >>> 24) & 0xff; buffer[61] = (count[0] >>> 16) & 0xff; buffer[62] = (count[0] >>> 8) & 0xff; buffer[63] = count[0] & 0xff; sha256_transform(); } /* Split the internal hash values into an array of bytes */ function sha256_encode_bytes() { var j = 0; var output = new Array(32); for (var i = 0; i < 8; i++) { output[j++] = (ihash[i] >>> 24) & 0xff; output[j++] = (ihash[i] >>> 16) & 0xff; output[j++] = (ihash[i] >>> 8) & 0xff; output[j++] = ihash[i] & 0xff; } return output; } /* Get the internal hash as a hex string */ function sha256_encode_hex() { var output = new String(); for (var i = 0; i < 8; i++) { for (var j = 28; j >= 0; j -= 4) output += sha256_hex_digits.charAt((ihash[i] >>> j) & 0x0f); } return output; } - -// 完整 Env -function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/htx.js b/htx.js deleted file mode 100644 index bd3a08d..0000000 --- a/htx.js +++ /dev/null @@ -1,966 +0,0 @@ -/* -@随缘撸豆 - -06.25 加入通知 - -有显示系统异常的自行更新ck -沪碳行app 自行百度下载 -一天一毛数字人民币 小毛 -抓取 htx.lcago.cn body中的 token 和deviceCoding -多账号换行 也可以自建一个htx.txt放到和脚本一个文件夹内 -htx 'token#deviceCoding' -cron 10 7,17 * * * htx.js -https://raw.githubusercontent.com/liuqi6968/-/main/htx.js -*/ -const $ = new Env("沪碳行"); -const fs = require('fs') -let httpResult, httpReq, httpResp -const ckFile1 = 'htx.txt' -const ckName = 'htx' -let userCookie = [] -try { - userCookie = userCookie.concat(fs.readFileSync(`./${ckFile1}`,'utf-8').split('\n')||[]) - console.log(`ck文件[ ${ckFile1} ]加载成功`) - this.mxr = true -} catch (e) { - console.log(`未发现本地文件 调用青龙环境变量`) - this.mxr = false -} -let mxr=this.mxr -if (this.mxr == false){ - try { - userCookie = userCookie.concat((($.isNode() ? process.env[ckName] : $.getdata(ckName))||'')?.split('\n')||[]) - console.log(`环境变量[ ${ckName} ]加载成功`) -} catch (e) { - //console.log(e) -} -} -let userList = [] -let userIdx = 0 -/////////////////////////////////////////////////////////////////// -class UserInfo { - constructor(str) { - this.n=++userIdx,this.index = `账号 [${this.n}]` - this.ck=str.split('#') - } -// - async sign () { - try { - let url = `https://htx.lcago.cn/signIn/sign` - let body = `{"token":"${this.ck[0]}","deviceCoding":"${this.ck[1]}","language": "ZH","appChannel": "htx","systemversion": "9"}` - let h = { - "Content-Type": "application/json; charset\u003dutf-8", - "Host": "htx.lcago.cn", - } - let urlObject = popu(url, h, body) - // console.log(urlObject) - await httpRequest('post', urlObject) - let result = httpResult; - //console.log(result) - if (result.respcod == '01'){ - console.log(`${this.index} ${result.respmsg}`) - }else if (result.respcod == '02'){ - console.log(`${this.index} ${result.respmsg}`) - }else if (result.respcod == '04'){ - console.log(`${this.index} ${result.respmsg}`) - } - } catch (e) {} finally { - return Promise.resolve(1); - } - } - async participate () { - try { - let url = `https://carbon.lcago.cn/community/participate` - let body = `{"token":"${this.ck[0]}","deviceCoding":"${this.ck[1]}","taskId":"EHD8472JSDS_htx"}` - let h = { - "Content-Type": "application/json; charset\u003dutf-8", - "Host": "htx.lcago.cn", - } - let urlObject = popu(url, h, body) - // console.log(urlObject) - await httpRequest('post', urlObject) - let result = httpResult; - // console.log(result) - if (result.respcod == '01'){ - console.log(`${this.index} 答题 ${result.respmsg} `) - await this.dt() - }else if (result.respcod == '02'){ - console.log(result.respmsg) - }else if (result.respcod == '04'){ - console.log(result.respmsg) - } - } catch (e) {} finally { - return Promise.resolve(1); - } - } - //答题 - async dt () { - try { - let url = `https://htx.lcago.cn/community/requestQuestion` - let body = `{"token":"${this.ck[0]}","deviceCoding":"${this.ck[1]}","taskId":"EHD8472JSDS_htx"}` - let h = { - "Content-Type": "application/json; charset\u003dutf-8", - "Host": "htx.lcago.cn", - } - let urlObject = popu(url, h, body) - // console.log(urlObject) - await httpRequest('post', urlObject) - let result = httpResult; - //console.log(result) - if (result.respcod == '01'){ - console.log(`${this.index} 答题 ${result.respmsg}`) - for (let i=0;i { - if(typeof $request !== "undefined") { - await GetRewrite() - } else { - if(!(await checkEnv())) return; - if (userList.length>0){ - taskll = [], console.log(`\n============= 签到 =============`) - for(let user of userList) { - await user.sign() - } - console.log(`\n============= 答题 =============`) - for(let user of userList) { - await user.dt() - } - console.log(`\n============= 收取能量 =============`) - for(let user of userList) { - await user.interact() - } - console.log(`\n============= 个人信息 =============`) - for(let user of userList) { - await user.myData() - } - } - await $.showmsg() - - } -})() -.catch((e) => console.log(e)) - .finally(() => $.done()) -function randomArr(arr){ - return arr[parseInt(Math.random() * arr.length, 10)] - } -/////////////////////////////////////////////////////////////////// -async function GetRewrite () { - -} -function number(d) { var b = parseFloat(d); if (isNaN(b)) return !1; var b = Math.round(100 * d) / 100, a = b.toString(), c = a.indexOf("."); for (c < 0 && (c = a.length, a += "."); a.length <= c + 2;)a += "0"; return a } -function checkEnv() { - if(userCookie) { - for(let userCookies of userCookie) { - if(userCookies) userList.push(new UserInfo(userCookies)) - } - userCount = userList.length - } else { - console.log(`未找到CK`) - return false; - } - - console.log(`\n共找到${userCount}个账号`) - return true -} -//////////////////////////////////////////////////////////////////// -function popu (url, h, body = '') { - let host = url.replace('//', '/').split('/')[1] - let urlObject = { - url: url, - headers: h - } - if(body) { - urlObject.body = body - urlObject.headers['Content-Length'] = body?.length || 0 - } - return urlObject; -} - - - - -async function httpRequest (method, url) { - httpResult = null, httpReq = null, httpResp = null; - return new Promise((resolve) => { - $.send(method, url, async (err, req, resp) => { - try { - httpReq = req; - httpResp = resp; - if(err) { - console.log(`${method}请求失败`); - console.log(JSON.stringify(err)); - } else { - if(resp.body) { - if(typeof resp.body == "object") { - httpResult = resp.body; - } else { - try { - httpResult = JSON.parse(resp.body); - } catch (e) { - httpResult = resp.body; - } - } - } - } - } catch (e) { - console.log(e); - } finally { - resolve(); - } - }); - }); -} - -//////////////////////////////////////////////////////////////////// -//RSA加密,JSEncrypt -function RSA (msg, key) { - let enc = new JSEncrypt(); - enc.setPublicKey(key) - return enc.encrypt(msg).toString(); -} -//AES/DES加解密,CryptoJS -function EncryptCrypto (method, mode, padding, message, key, iv) { - return CryptoJS[method].encrypt( - CryptoJS.enc.Utf8.parse(message), - CryptoJS.enc.Utf8.parse(key), { - mode: CryptoJS.mode[mode], - padding: CryptoJS.pad[padding], - iv: CryptoJS.enc.Utf8.parse(iv) - } - ).ciphertext.toString(CryptoJS.enc.Base64); -} - -function DecryptCrypto (method, mode, padding, message, key, iv) { - return CryptoJS[method].decrypt({ - ciphertext: CryptoJS.enc.Base64.parse(message) - }, - CryptoJS.enc.Utf8.parse(key), { - mode: CryptoJS.mode[mode], - padding: CryptoJS.pad[padding], - iv: CryptoJS.enc.Utf8.parse(iv) - } - ).toString(CryptoJS.enc.Utf8); -} -//Base64加解密 -var Base64 = { - _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - encode: function(e) { - var t = ""; - var n, r, i, s, o, u, a; - var f = 0; - e = Base64._utf8_encode(e); - while(f < e.length) { - n = e.charCodeAt(f++); - r = e.charCodeAt(f++); - i = e.charCodeAt(f++); - s = n >> 2; - o = (n & 3) << 4 | r >> 4; - u = (r & 15) << 2 | i >> 6; - a = i & 63; - if(isNaN(r)) { - u = a = 64 - } else if(isNaN(i)) { - a = 64 - } - t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a) - } - return t - }, - decode: function(e) { - var t = ""; - var n, r, i; - var s, o, u, a; - var f = 0; - e = e.replace(/[^A-Za-z0-9+/=]/g, ""); - while(f < e.length) { - s = this._keyStr.indexOf(e.charAt(f++)); - o = this._keyStr.indexOf(e.charAt(f++)); - u = this._keyStr.indexOf(e.charAt(f++)); - a = this._keyStr.indexOf(e.charAt(f++)); - n = s << 2 | o >> 4; - r = (o & 15) << 4 | u >> 2; - i = (u & 3) << 6 | a; - t = t + String.fromCharCode(n); - if(u != 64) { - t = t + String.fromCharCode(r) - } - if(a != 64) { - t = t + String.fromCharCode(i) - } - } - t = Base64._utf8_decode(t); - return t - }, - _utf8_encode: function(e) { - e = e.replace(/rn/g, "n"); - var t = ""; - for(var n = 0; n < e.length; n++) { - var r = e.charCodeAt(n); - if(r < 128) { - t += String.fromCharCode(r) - } else if(r > 127 && r < 2048) { - t += String.fromCharCode(r >> 6 | 192); - t += String.fromCharCode(r & 63 | 128) - } else { - t += String.fromCharCode(r >> 12 | 224); - t += String.fromCharCode(r >> 6 & 63 | 128); - t += String.fromCharCode(r & 63 | 128) - } - } - return t - }, - _utf8_decode: function(e) { - var t = ""; - var n = 0; - var r = c1 = c2 = 0; - while(n < e.length) { - r = e.charCodeAt(n); - if(r < 128) { - t += String.fromCharCode(r); - n++ - } else if(r > 191 && r < 224) { - c2 = e.charCodeAt(n + 1); - t += String.fromCharCode((r & 31) << 6 | c2 & 63); - n += 2 - } else { - c2 = e.charCodeAt(n + 1); - c3 = e.charCodeAt(n + 2); - t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63); - n += 3 - } - } - return t - } -} -//MD5 -function MD5Encrypt (a) { - function b (a, b) { - return a << b | a >>> 32 - b - } - - function c (a, b) { - var c, d, e, f, g; - return e = 2147483648 & a, f = 2147483648 & b, c = 1073741824 & a, d = 1073741824 & b, g = (1073741823 & a) + (1073741823 & b), c & d ? 2147483648 ^ g ^ e ^ f : c | d ? 1073741824 & g ? 3221225472 ^ g ^ e ^ f : 1073741824 ^ g ^ e ^ f : g ^ e ^ f - } - - function d (a, b, c) { - return a & b | ~a & c - } - - function e (a, b, c) { - return a & c | b & ~c - } - - function f (a, b, c) { - return a ^ b ^ c - } - - function g (a, b, c) { - return b ^ (a | ~c) - } - - function h (a, e, f, g, h, i, j) { - return a = c(a, c(c(d(e, f, g), h), j)), c(b(a, i), e) - } - - function i (a, d, f, g, h, i, j) { - return a = c(a, c(c(e(d, f, g), h), j)), c(b(a, i), d) - } - - function j (a, d, e, g, h, i, j) { - return a = c(a, c(c(f(d, e, g), h), j)), c(b(a, i), d) - } - - function k (a, d, e, f, h, i, j) { - return a = c(a, c(c(g(d, e, f), h), j)), c(b(a, i), d) - } - - function l (a) { - for(var b, c = a.length, d = c + 8, e = (d - d % 64) / 64, f = 16 * (e + 1), g = new Array(f - 1), h = 0, i = 0; c > i;) b = (i - i % 4) / 4, h = i % 4 * 8, g[b] = g[b] | a.charCodeAt(i) << h, i++; - return b = (i - i % 4) / 4, h = i % 4 * 8, g[b] = g[b] | 128 << h, g[f - 2] = c << 3, g[f - 1] = c >>> 29, g - } - - function m (a) { - var b, c, d = "", - e = ""; - for(c = 0; 3 >= c; c++) b = a >>> 8 * c & 255, e = "0" + b.toString(16), d += e.substr(e.length - 2, 2); - return d - } - - function n (a) { - a = a.replace(/\r\n/g, "\n"); - for(var b = "", c = 0; c < a.length; c++) { - var d = a.charCodeAt(c); - 128 > d ? b += String.fromCharCode(d) : d > 127 && 2048 > d ? (b += String.fromCharCode(d >> 6 | 192), b += String.fromCharCode(63 & d | 128)) : (b += String.fromCharCode(d >> 12 | 224), b += String.fromCharCode(d >> 6 & 63 | 128), b += String.fromCharCode(63 & d | 128)) - } - return b - } - var o, p, q, r, s, t, u, v, w, x = [], - y = 7, - z = 12, - A = 17, - B = 22, - C = 5, - D = 9, - E = 14, - F = 20, - G = 4, - H = 11, - I = 16, - J = 23, - K = 6, - L = 10, - M = 15, - N = 21; - for(a = n(a), x = l(a), t = 1732584193, u = 4023233417, v = 2562383102, w = 271733878, o = 0; o < x.length; o += 16) p = t, q = u, r = v, s = w, t = h(t, u, v, w, x[o + 0], y, 3614090360), w = h(w, t, u, v, x[o + 1], z, 3905402710), v = h(v, w, t, u, x[o + 2], A, 606105819), u = h(u, v, w, t, x[o + 3], B, 3250441966), t = h(t, u, v, w, x[o + 4], y, 4118548399), w = h(w, t, u, v, x[o + 5], z, 1200080426), v = h(v, w, t, u, x[o + 6], A, 2821735955), u = h(u, v, w, t, x[o + 7], B, 4249261313), t = h(t, u, v, w, x[o + 8], y, 1770035416), w = h(w, t, u, v, x[o + 9], z, 2336552879), v = h(v, w, t, u, x[o + 10], A, 4294925233), u = h(u, v, w, t, x[o + 11], B, 2304563134), t = h(t, u, v, w, x[o + 12], y, 1804603682), w = h(w, t, u, v, x[o + 13], z, 4254626195), v = h(v, w, t, u, x[o + 14], A, 2792965006), u = h(u, v, w, t, x[o + 15], B, 1236535329), t = i(t, u, v, w, x[o + 1], C, 4129170786), w = i(w, t, u, v, x[o + 6], D, 3225465664), v = i(v, w, t, u, x[o + 11], E, 643717713), u = i(u, v, w, t, x[o + 0], F, 3921069994), t = i(t, u, v, w, x[o + 5], C, 3593408605), w = i(w, t, u, v, x[o + 10], D, 38016083), v = i(v, w, t, u, x[o + 15], E, 3634488961), u = i(u, v, w, t, x[o + 4], F, 3889429448), t = i(t, u, v, w, x[o + 9], C, 568446438), w = i(w, t, u, v, x[o + 14], D, 3275163606), v = i(v, w, t, u, x[o + 3], E, 4107603335), u = i(u, v, w, t, x[o + 8], F, 1163531501), t = i(t, u, v, w, x[o + 13], C, 2850285829), w = i(w, t, u, v, x[o + 2], D, 4243563512), v = i(v, w, t, u, x[o + 7], E, 1735328473), u = i(u, v, w, t, x[o + 12], F, 2368359562), t = j(t, u, v, w, x[o + 5], G, 4294588738), w = j(w, t, u, v, x[o + 8], H, 2272392833), v = j(v, w, t, u, x[o + 11], I, 1839030562), u = j(u, v, w, t, x[o + 14], J, 4259657740), t = j(t, u, v, w, x[o + 1], G, 2763975236), w = j(w, t, u, v, x[o + 4], H, 1272893353), v = j(v, w, t, u, x[o + 7], I, 4139469664), u = j(u, v, w, t, x[o + 10], J, 3200236656), t = j(t, u, v, w, x[o + 13], G, 681279174), w = j(w, t, u, v, x[o + 0], H, 3936430074), v = j(v, w, t, u, x[o + 3], I, 3572445317), u = j(u, v, w, t, x[o + 6], J, 76029189), t = j(t, u, v, w, x[o + 9], G, 3654602809), w = j(w, t, u, v, x[o + 12], H, 3873151461), v = j(v, w, t, u, x[o + 15], I, 530742520), u = j(u, v, w, t, x[o + 2], J, 3299628645), t = k(t, u, v, w, x[o + 0], K, 4096336452), w = k(w, t, u, v, x[o + 7], L, 1126891415), v = k(v, w, t, u, x[o + 14], M, 2878612391), u = k(u, v, w, t, x[o + 5], N, 4237533241), t = k(t, u, v, w, x[o + 12], K, 1700485571), w = k(w, t, u, v, x[o + 3], L, 2399980690), v = k(v, w, t, u, x[o + 10], M, 4293915773), u = k(u, v, w, t, x[o + 1], N, 2240044497), t = k(t, u, v, w, x[o + 8], K, 1873313359), w = k(w, t, u, v, x[o + 15], L, 4264355552), v = k(v, w, t, u, x[o + 6], M, 2734768916), u = k(u, v, w, t, x[o + 13], N, 1309151649), t = k(t, u, v, w, x[o + 4], K, 4149444226), w = k(w, t, u, v, x[o + 11], L, 3174756917), v = k(v, w, t, u, x[o + 2], M, 718787259), u = k(u, v, w, t, x[o + 9], N, 3951481745), t = c(t, p), u = c(u, q), v = c(v, r), w = c(w, s); - var O = m(t) + m(u) + m(v) + m(w); - return O.toLowerCase() -} -//SHA1 -function SHA1Encrypt (msg) { - function add (x, y) { - return ((x & 0x7FFFFFFF) + (y & 0x7FFFFFFF)) ^ (x & 0x80000000) ^ (y & 0x80000000); - } - - function SHA1hex (num) { - var sHEXChars = "0123456789abcdef"; - var str = ""; - for(var j = 7; j >= 0; j--) str += sHEXChars.charAt((num >> (j * 4)) & 0x0F); - return str; - } - - function AlignSHA1 (sIn) { - var nblk = ((sIn.length + 8) >> 6) + 1, - blks = new Array(nblk * 16); - for(var i = 0; i < nblk * 16; i++) blks[i] = 0; - for(i = 0; i < sIn.length; i++) blks[i >> 2] |= sIn.charCodeAt(i) << (24 - (i & 3) * 8); - blks[i >> 2] |= 0x80 << (24 - (i & 3) * 8); - blks[nblk * 16 - 1] = sIn.length * 8; - return blks; - } - - function rol (num, cnt) { - return (num << cnt) | (num >>> (32 - cnt)); - } - - function ft (t, b, c, d) { - if(t < 20) return (b & c) | ((~b) & d); - if(t < 40) return b ^ c ^ d; - if(t < 60) return (b & c) | (b & d) | (c & d); - return b ^ c ^ d; - } - - function kt (t) { - return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 : (t < 60) ? -1894007588 : -899497514; - } - var x = AlignSHA1(msg); - var w = new Array(80); - var a = 1732584193; - var b = -271733879; - var c = -1732584194; - var d = 271733878; - var e = -1009589776; - for(var i = 0; i < x.length; i += 16) { - var olda = a; - var oldb = b; - var oldc = c; - var oldd = d; - var olde = e; - for(var j = 0; j < 80; j++) { - if(j < 16) w[j] = x[i + j]; - else w[j] = rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1); - t = add(add(rol(a, 5), ft(j, b, c, d)), add(add(e, w[j]), kt(j))); - e = d; - d = c; - c = rol(b, 30); - b = a; - a = t; - } - a = add(a, olda); - b = add(b, oldb); - c = add(c, oldc); - d = add(d, oldd); - e = add(e, olde); - } - SHA1Value = SHA1hex(a) + SHA1hex(b) + SHA1hex(c) + SHA1hex(d) + SHA1hex(e); - return SHA1Value; -} -//SHA256 -function SHA256 (n) { - const r = 8, - t = 0; - - function o (n, r) { - const t = (65535 & n) + (65535 & r); - return (n >> 16) + (r >> 16) + (t >> 16) << 16 | 65535 & t - } - - function e (n, r) { - return n >>> r | n << 32 - r - } - - function u (n, r) { - return n >>> r - } - - function c (n, r, t) { - return n & r ^ ~n & t - } - - function f (n, r, t) { - return n & r ^ n & t ^ r & t - } - - function i (n) { - return e(n, 2) ^ e(n, 13) ^ e(n, 22) - } - - function h (n) { - return e(n, 6) ^ e(n, 11) ^ e(n, 25) - } - - function C (n) { - return e(n, 7) ^ e(n, 18) ^ u(n, 3) - } - return function(n) { - const r = t ? "0123456789ABCDEF" : "0123456789abcdef"; - let o = ""; - for(let t = 0; t < 4 * n.length; t++) o += r.charAt(n[t >> 2] >> 8 * (3 - t % 4) + 4 & 15) + r.charAt(n[t >> 2] >> 8 * (3 - t % 4) & 15); - return o - }(function(n, r) { - const t = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298], - a = [1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225], - g = new Array(64); - let l, d, A, S, m, s, b, p, v, w, y, B; - for(n[r >> 5] |= 128 << 24 - r % 32, n[15 + (r + 64 >> 9 << 4)] = r, v = 0; v < n.length; v += 16) { - for(l = a[0], d = a[1], A = a[2], S = a[3], m = a[4], s = a[5], b = a[6], p = a[7], w = 0; w < 64; w++) g[w] = w < 16 ? n[w + v] : o(o(o(e(D = g[w - 2], 17) ^ e(D, 19) ^ u(D, 10), g[w - 7]), C(g[w - 15])), g[w - 16]), y = o(o(o(o(p, h(m)), c(m, s, b)), t[w]), g[w]), B = o(i(l), f(l, d, A)), p = b, b = s, s = m, m = o(S, y), S = A, A = d, d = l, l = o(y, B); - a[0] = o(l, a[0]), a[1] = o(d, a[1]), a[2] = o(A, a[2]), a[3] = o(S, a[3]), a[4] = o(m, a[4]), a[5] = o(s, a[5]), a[6] = o(b, a[6]), a[7] = o(p, a[7]) - } - var D; - return a - }(function(n) { - const t = [], - o = (1 << r) - 1; - for(let e = 0; e < n.length * r; e += r) t[e >> 5] |= (n.charCodeAt(e / r) & o) << 24 - e % 32; - return t - }(n = function(n) { - n = n.replace(/\r\n/g, "\n"); - let r = ""; - for(let t = 0; t < n.length; t++) { - const o = n.charCodeAt(t); - o < 128 ? r += String.fromCharCode(o) : o > 127 && o < 2048 ? (r += String.fromCharCode(o >> 6 | 192), r += String.fromCharCode(63 & o | 128)) : (r += String.fromCharCode(o >> 12 | 224), r += String.fromCharCode(o >> 6 & 63 | 128), r += String.fromCharCode(63 & o | 128)) - } - return r - }(n)), n.length * r)) -} -//////////////////////////////////////////////////////////////////// -function Env (name, env) { - "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); - return new class { - constructor(name, env) { - this.name = name - this.notifyStr = '' - this.startTime = (new Date).getTime() - Object.assign(this, env) - console.log(`${this.name} 开始运行:\n`) - } - isNode() { - return "undefined" != typeof module && !!module.exports - } - isQuanX() { - return "undefined" != typeof $task - } - isSurge() { - return "undefined" != typeof $httpClient && "undefined" == typeof $loon - } - isLoon() { - return "undefined" != typeof $loon - } - getdata(t) { - let e = this.getval(t); - if(/^@/.test(t)) { - const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), - r = s ? this.getval(s) : ""; - if(r) - try { - const t = JSON.parse(r); - e = t ? this.lodash_get(t, i, "") : e - } catch (t) { - e = "" - } - } - return e - } - setdata(t, e) { - let s = !1; - if(/^@/.test(e)) { - const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), - o = this.getval(i), - h = i ? "null" === o ? null : o || "{}" : "{}"; - try { - const e = JSON.parse(h); - this.lodash_set(e, r, t), - s = this.setval(JSON.stringify(e), i) - } catch (e) { - const o = {}; - this.lodash_set(o, r, t), - s = this.setval(JSON.stringify(o), i) - } - } else { - s = this.setval(t, e); - } - return s - } - getval(t) { - return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null - } - setval(t, e) { - return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null - } - send(m, t, e = (() => {})) { - if(m != 'get' && m != 'post' && m != 'put' && m != 'delete') { - console.log(`无效的http方法:${m}`); - return; - } - if(m == 'get' && t.headers) { - delete t.headers["Content-Type"]; - delete t.headers["Content-Length"]; - } else if(t.body && t.headers) { - if(!t.headers["Content-Type"]) t.headers["Content-Type"] = "application/x-www-form-urlencoded"; - } - if(this.isSurge() || this.isLoon()) { - if(this.isSurge() && this.isNeedRewrite) { - t.headers = t.headers || {}; - Object.assign(t.headers, { - "X-Surge-Skip-Scripting": !1 - }); - } - let conf = { - method: m, - url: t.url, - headers: t.headers, - timeout: t.timeout, - data: t.body - }; - if(m == 'get') delete conf.data - $axios(conf).then(t => { - const { - status: i, - request: q, - headers: r, - data: o - } = t; - e(null, q, { - statusCode: i, - headers: r, - body: o - }); - }).catch(err => console.log(err)) - } else if(this.isQuanX()) { - t.method = m.toUpperCase(), this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { - hints: !1 - })), - $task.fetch(t).then(t => { - const { - statusCode: i, - request: q, - headers: r, - body: o - } = t; - e(null, q, { - statusCode: i, - headers: r, - body: o - }) - }, t => e(t)) - } else if(this.isNode()) { - this.got = this.got ? this.got : require("got"); - const { - url: s, - ...i - } = t; - this.instance = this.got.extend({ - followRedirect: false - }); - this.instance[m](s, i).then(t => { - const { - statusCode: i, - request: q, - headers: r, - body: o - } = t; - e(null, q, { - statusCode: i, - headers: r, - body: o - }) - }, t => { - const { - message: s, - response: i - } = t; - e(s, i, i && i.body) - }) - } - } - time(t) { - let e = { - "M+": (new Date).getMonth() + 1, - "d+": (new Date).getDate(), - "h+": (new Date).getHours(), - "m+": (new Date).getMinutes(), - "s+": (new Date).getSeconds(), - "q+": Math.floor(((new Date).getMonth() + 3) / 3), - S: (new Date).getMilliseconds() - }; - /(y+)/.test(t) && (t = t.replace(RegExp.$1, ((new Date).getFullYear() + "").substr(4 - RegExp.$1.length))); - for(let s in e) - new RegExp("(" + s + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? e[s] : ("00" + e[s]).substr(("" + e[s]).length))); - return t - } - async showmsg () { - if(!this.notifyStr) return; - let notifyBody = this.name + " 运行通知\n\n" + this.notifyStr - if($.isNode()) { - var notify = require('./sendNotify'); - console.log('\n============== 推送 ==============') - await notify.sendNotify(this.name, notifyBody); - } else { - this.msg(notifyBody); - } - } - logAndNotify(str) { - console.log(str) - this.notifyStr += str - this.notifyStr += '\n' - } - msg(e = t, s = "", i = "", r) { - const o = t => { - if(!t) - return t; - if("string" == typeof t) - return this.isLoon() ? t : this.isQuanX() ? { - "open-url": t - } : - this.isSurge() ? { - url: t - } : - void 0; - if("object" == typeof t) { - if(this.isLoon()) { - let e = t.openUrl || t.url || t["open-url"], - s = t.mediaUrl || t["media-url"]; - return { - openUrl: e, - mediaUrl: s - } - } - if(this.isQuanX()) { - let e = t["open-url"] || t.url || t.openUrl, - s = t["media-url"] || t.mediaUrl; - return { - "open-url": e, - "media-url": s - } - } - if(this.isSurge()) { - let e = t.url || t.openUrl || t["open-url"]; - return { - url: e - } - } - } - }; - this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))); - let h = ["", "============== 系统通知 =============="]; - h.push(e), - s && h.push(s), - i && h.push(i), - console.log(h.join("\n")) - } - getMin(a, b) { - return ((a < b) ? a : b) - } - getMax(a, b) { - return ((a < b) ? b : a) - } - padStr(num, length, padding = '0') { - let numStr = String(num) - let numPad = (length > numStr.length) ? (length - numStr.length) : 0 - let retStr = '' - for(let i = 0; i < numPad; i++) { - retStr += padding - } - retStr += numStr - return retStr; - } - json2str(obj, c, encodeUrl = false) { - let ret = [] - for(let keys of Object.keys(obj).sort()) { - let v = obj[keys] - if(v && encodeUrl) v = encodeURIComponent(v) - ret.push(keys + '=' + v) - } - return ret.join(c); - } - str2json(str, decodeUrl = false) { - let ret = {} - for(let item of str.split('&')) { - if(!item) continue; - let idx = item.indexOf('=') - if(idx == -1) continue; - let k = item.substr(0, idx) - let v = item.substr(idx + 1) - if(decodeUrl) v = decodeURIComponent(v) - ret[k] = v - } - return ret; - } - randomString(len, charset = 'abcdef0123456789') { - let str = ''; - for(let i = 0; i < len; i++) { - str += charset.charAt(Math.floor(Math.random() * charset.length)); - } - return str; - } - randomList(a) { - let idx = Math.floor(Math.random() * a.length) - return a[idx] - } - wait(t) { - return new Promise(e => setTimeout(e, t)) - } - done(t = {}) { - const e = (new Date).getTime(), - s = (e - this.startTime) / 1e3; - console.log(`\n${this.name} 运行结束,共运行了 ${s} 秒!`) - if(this.isSurge() || this.isQuanX() || this.isLoon()) $done(t) - } - }(name, env) -} \ No newline at end of file diff --git a/hyjk.js b/hyjk.js index a731b85..a6a5b4c 100644 --- a/hyjk.js +++ b/hyjk.js @@ -1,185 +1,544 @@ -/** - * cron 10 15 * * * - * Show:重写请求函数 在got环境或axios环境都可以请求 适用于 20V版本以上node 本地运行 - * 需要的依赖 jsrsasign 和 encryptlong - * 变量名: heyeHealth - * 变量值: https://tuan.api.ybm100.com/ 请求头Headers中的token 多账号& 或换行 或新建同名变量 - * scriptVersionNow = "0.0.1"; - */ +/* +------------------------------------------ +@Author: sm +@Date: 2024.06.07 19:15 +@Description: 荷叶健康小程序 +cron: 30 10 * * * +------------------------------------------ +#Notice: +微信荷叶健康小程序 免费水果+打卡签到抽奖 +抓tuan.api.ybm100.com/miniapp中请求头的token 多账户&或换行 +⚠️【免责声明】 +------------------------------------------ +1、此脚本仅用于学习研究,不保证其合法性、准确性、有效性,请根据情况自行判断,本人对此不承担任何保证责任。 +2、由于此脚本仅用于学习研究,您必须在下载后 24 小时内将所有内容从您的计算机或手机或任何存储设备中完全删除,若违反规定引起任何事件本人对此均不负责。 +3、请勿将此脚本用于任何商业或非法目的,若违反规定请自行对此负责。 +4、此脚本涉及应用与本人无关,本人对因此引起的任何隐私泄漏或其他后果不承担任何责任。 +5、本人对任何脚本引发的问题概不负责,包括但不限于由脚本错误引起的任何损失和损害。 +6、如果任何单位或个人认为此脚本可能涉嫌侵犯其权利,应及时通知并提供身份证明,所有权证明,我们将在收到认证文件确认后删除此脚本。 +7、所有直接或间接使用、查看此脚本的人均应该仔细阅读此声明。本人保留随时更改或补充此声明的权利。一旦您使用或复制了此脚本,即视为您已接受此免责声明。 +*/ + global['window'] = {} global['navigator'] = {} const { JSEncrypt } = require("encryptlong") const JsRsaSign = require("jsrsasign") -const $ = new Env("荷叶健康小程序-果园[免费领水果]"); -const notify = $.isNode() ? require('./sendNotify') : ''; -let ckName = "heyeHealth"; -let envSplitor = ["&", "\n"]; //多账号分隔符 -let strSplitor = "#"; //多变量分隔符 -let userIdx = 0; -let userList = []; +const { Env } = require("./tools/env") +const $ = new Env("荷叶健康小程序"); +let ckName = `hyjk`; +const strSplitor = "#"; +const axios = require("axios"); +const defaultUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.31(0x18001e31) NetType/WIFI Language/zh_CN miniProgram" + + class Task { - constructor(str) { - this.index = ++userIdx; - this.ck = str.split(strSplitor)[0]; //单账号多变量分隔符 - this.ckStatus = true; - //定义在这里的headers会被get请求删掉content-type 而不会重置 - this.taskIdList = [] - this.taskVenueIdList = [] + constructor(env) { + this.index = $.userIdx++ + this.user = env.split(strSplitor); + this.token = this.user[0]; + this.channelCode = this.user[1] || process.env.HYJK_CHANNEL_CODE || "130"; + this.userFlag = false this.userId = '' - this.treeId = '' - } - async main() { - await this.getInfo() - if (this.userId !== "" && this.treeId !== "") { - await this.signInInfo() - await this.getTaskList();//采集任务API - for (let i of this.taskVenueIdList) { - await this.taskList(i.venueId) - } - if (this.taskIdList.length > 0) { - $.log(` 获取到任务列表`) - $.log(JSON.stringify(this.taskIdList)) - } - for (let i of this.taskIdList) { - await this.updateTaskInfo(i.taskId, 0) - await $.wait(20000) - await this.updateTaskInfo(i.taskId, 1) - } - for (let i of this.taskVenueIdList) { - //在执行一次 领取水滴 - await this.taskList(i.venueId) - } - await this.getInfo() - } - - } - async signInInfo() { - try { - let result = await this.taskRequest("post", `https://tuan.api.ybm100.com/miniapp/marketing/signActivity/signRecord`, JSON.stringify({ - "actId": 5712, - "sceneId": 6, - "channelCode": "130" - })) - //console.log(options); - //console.log(result); - if (result.code == 0) { - $.log(`✅账号[${this.index}] 当日签到状态 ${result.result.todaySignStatusDesc == "已签到" ? "✅" : "❌"} 🎉`) - if (result.result.todaySignStatusDesc !== "已签到") { - await this.signIn() - } - } else { - $.log(`❌账号[${this.index}] 获取签到状态失败[${result.msg}]`); - } - } catch (e) { - console.log(e); - } - } - async signIn() { - try { - let result = await this.taskRequest("post", `https://tuan.api.ybm100.com/miniapp/marketing/signActivity/sign`, JSON.stringify({ "actId": 5712, "sceneId": 6, "channelCode": "130" })) - //console.log(options); - //console.log(result); - if (result.code == 0) { - $.log(`✅账号[${this.index}] 签到成功🎉`) - } else { - $.log(`❌账号[${this.index}] 签到失败[${result.msg}]`); - } - } catch (e) { - console.log(e); - } - } - async getInfo() { - try { - let result = await this.taskRequest("get", `https://tuan.api.ybm100.com/api/healthSquare/fruitManor/getMyManorInfo?channelCode=130`) - //console.log(options); - //console.log(result); - if (result.code == 0) { - $.log(`✅账号[${this.index}] 当前水滴[${result.result.kettleWater}]-[${result.result.progressBarTips}]🎉`) - this.treeId = Number(result.result.treeId) - this.userId = result.result.userId - for (let i = 0; i < Math.floor(Number(result.result.kettleWater) / 10); i++) { - await $.wait(3000) - await this.doWater() - } - } else { - $.log(`❌账号[${this.index}] 获取果园信息失败[${result.msg}]`); - } - } catch (e) { - console.log(e); - } - } - async getTaskList() { - try { - let result = await this.taskRequest("get", `https://tuan.api.ybm100.com/api/healthSquare/fruitManor/getVenueInfo?channelCode=130`) - //console.log(options); - //console.log(result); - if (result.code == 0) { - //获得taskList的venueId - for (let i of result.result.list) { - this.taskVenueIdList.push({ venueId: i.venueId, waterNum: i.waterNum, venueName: i.venueName }) - } - - $.log(`✅账号[${this.index}] 采集任务成功🎉`) - } else { - $.log(`❌账号[${this.index}] 采集任务失败`); - } - } catch (e) { - console.log(e); - } - } - async taskList(venueId) { - try { - let result = await this.taskRequest("get", `https://tuan.api.ybm100.com/api/healthSquare/task/getTaskList?channelCode=130&venueId=${venueId}`) - //console.log(options); - //console.log(result); - if (result.code == 0) { - for (let i of result.result) { - if (i.taskStatus == 0) { //2已完成 - //去完成 - //i.reward 奖励水滴 - if (i.subTitle.indexOf("浏览") != -1) { - this.taskIdList.push({ taskId: i.taskId, mainTitle: i.mainTitle }); - - } - } else if (i.taskStatus == 1) { - await this.collectWater(i.taskId) - } - } - //$.log(`✅账号[${this.index}] 获取到任务🎉`) - } else { - $.log(`❌账号[${this.index}] 未获取到失败`); - } - } catch (e) { - console.log(e); + this.headers = { + "host": "tuan.api.ybm100.com", + "userid": "" + this.userId, + "referer": "https://www.heyejk.com/", + "apptype": "1", + "user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 16_7_15 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.70(0x18004630) NetType/WIFI Language/zh_CN miniProgram/wx776afedbfae3a228", + "appversion": "3.1.7", + "origin": "https://www.heyejk.com", + "sec-fetch-dest": "empty", + "sec-fetch-site": "cross-site", + "terminal": "h5", + "usertype": "groupuser", + "appname": "ykq-xcx", + "token": "" + this.token, + "accept-language": "zh-CN,zh-Hans;q=0.9", + "accept": "application/json, text/plain, */*", + "content-type": "application/json;charset=UTF-8", + "accept-encoding": "gzip, deflate, br", + "sec-fetch-mode": "cors" } } + async run() { + await this.getFruitInfo() + await this.autoByUserOperation() + await this.getSignInfo() + } + + async getSignInfo() { + let options = { + method: 'POST', + url: `https://tuan.api.ybm100.com/miniapp/marketing/signActivity/signRecord`, + headers: this.headers, + data: { "actId": "9093", "channelCode": this.channelCode, "adornId": "217" } + }; + let { data: result } = await axios.request(options); + if (result.code == 0) { + const isSigned = result?.result?.todaySignStatusDesc === "已签到"; + $.log(`[账号${this.index}] 今日签到: ${isSigned ? "已签到" : "未签到"}`) + if (!isSigned) { + await this.doSign() + } + } else { + $.log(`[账号${this.index}] 获取签到状态失败[${result.msg}]`); + } + } + + async doSign() { + let options = { + method: 'POST', + url: `https://tuan.api.ybm100.com/miniapp/marketing/signActivity/sign`, + headers: this.headers, + data: { "actId": "9093", "channelCode": this.channelCode, "adornId": "217" } + }; + let { data: result } = await axios.request(options); + if (result?.code == '0') { + $.log(`[账号${this.index}] 签到成功[${result.msg}]`); + } else { + $.log(`[账号${this.index}] 签到失败:${result.msg}`) + } + } + + async getFruitInfo() { + let options = { + method: 'GET', + url: `https://tuan.api.ybm100.com/api/healthSquare/fruitManor/getMyManorInfo?channelCode=${this.channelCode}`, + headers: this.headers, + }; + let { data: result } = await axios.request(options); + if (result.code == 0) { + $.log(`[账号${this.index}] [${result.result.kettleWater}]-[${result.result.progressBarTips}]`) + this.treeId = Number(result.result.treeId) + this.userId = result.result.userId + this.headers.userid = String(this.userId || "") + this.todayFullWaterTaskId = Number(result?.result?.todayFullWaterTaskId || 0) + for (let i = 0; i < Math.floor(Number(result.result.kettleWater) / 10); i++) { + await $.wait(3000) + await this.doWater() + } + } else { + $.log(`[账号${this.index}] 查询失败[${result.msg}]`); + } + } + async doWater() { + try { + let data = { "channelCode": this.channelCode, "treeId": this.treeId, "nonce": $.randomString(6) } + let options = { + method: 'POST', + url: `https://tuan.api.ybm100.com/api/healthSquare/water/watering?secret=${encodeURIComponent(this.encrypt(data))}`, + headers: this.headers, + data: data + } + let { data: result } = await axios.request(options); + if (result?.code == 0) { + $.log(`账号${this.index}] 浇水[${result.result.progressBarTips}]`) + } else { + $.log(`账号${this.index}] 胶水[${result.msg}]`); + } + } catch (e) { + + } + + + + } + + async request(options) { + const finalOptions = { + timeout: Number(process.env.HYJK_HTTP_TIMEOUT || 15000), + ...options, + headers: { + ...this.headers, + ...(options.headers || {}) + } + }; + return axios.request(finalOptions); + } + + async userOperation(operateType, operateValueObj) { + const data = { + operateType, + operateValue: JSON.stringify(operateValueObj), + channelCode: this.channelCode + }; + const { data: result } = await this.request({ + method: "POST", + url: "https://tuan.api.ybm100.com/api/healthSquare/user/userOperation", + data + }); + return result; + } + + async getTaskListNew() { + const { data: result } = await this.request({ + method: "GET", + url: `https://tuan.api.ybm100.com/api/healthSquare/task/getTaskListNew?channelCode=${this.channelCode}&venueId=5` + }); + + return result; + } + + async getPopupList() { + const { data: result } = await this.request({ + method: "GET", + url: `https://tuan.api.ybm100.com/api/healthSquare/fruitManor/getPopup`, + params: { + channelCode: this.channelCode, + entranceType: 0 + } + }); + return result; + } + + async getVenueInfo() { + const { data: result } = await this.request({ + method: "GET", + url: `https://tuan.api.ybm100.com/api/healthSquare/fruitManor/getVenueInfo`, + params: { channelCode: this.channelCode } + }); + return result; + } + + async getBlindBoxInfo(taskId) { + const { data: result } = await this.request({ + method: "GET", + url: `https://tuan.api.ybm100.com/api/healthSquare/task/getBlindBoxInfo`, + params: { + channelCode: this.channelCode, + taskId + } + }); + return result; + } + + async collectWater(payload) { + const data = { + channelCode: this.channelCode, + nonce: $.randomString(6), + ...payload + }; + const secret = encodeURIComponent(this.encrypt(data)); + const { data: result } = await this.request({ + method: "POST", + url: `https://tuan.api.ybm100.com/api/healthSquare/water/collectWater?secret=${secret}`, + data + }); + return result; + } + + async goFruitOrGarden(taskId) { + const { data: result } = await this.request({ + method: "POST", + url: `https://tuan.api.ybm100.com/healthSquare/herbalGarden/goFruitOrGarden`, + data: { + channelCode: this.channelCode, + taskId: Number(taskId) + } + }); + return result; + } + + flattenTaskList(taskResult) { + if (!taskResult || taskResult.code !== 0) return []; + const root = taskResult.result; + if (Array.isArray(root)) return root; + if (Array.isArray(root?.list)) { + if (root.list.some(item => item && Object.prototype.hasOwnProperty.call(item, "taskId"))) { + return root.list; + } + return root.list.flatMap(group => Array.isArray(group?.taskList) ? group.taskList : []); + } + return []; + } + + async autoByUserOperation() { + await this.autoTodayFullWaterTask(); + await this.autoPopups(); + await this.autoVenueClicks(); + await this.autoTasks(); + } + + + async autoTodayFullWaterTask() { + try { + if (!this.todayFullWaterTaskId) return; + const opRes = await this.userOperation(6, { taskId: this.todayFullWaterTaskId, status: 1 }); + $.log(`[账号${this.index}] fullWater(taskId=${this.todayFullWaterTaskId}) 上报: ${opRes?.msg || opRes?.code}`); + await $.wait(500); + } catch (e) { + $.log(`[账号${this.index}] fullWater自动化异常: ${e.message}`); + } + } + async autoPopups() { + try { + const popupRes = await this.getPopupList(); + const list = Array.isArray(popupRes?.result?.list) ? popupRes.result.list : []; + for (const popup of list) { + const payload = { + popupType: Number(popup?.popupType || 0), + waterNum: Number(popup?.waterNum || 0) + }; + const opRes = await this.userOperation(7, payload); + $.log(`[账号${this.index}] popupType=${payload.popupType} 上报: ${opRes?.msg || opRes?.code}`); + await $.wait(500); + } + } catch (e) { + $.log(`[账号${this.index}] popup自动化异常: ${e.message}`); + } + } + + async autoVenueClicks() { + try { + const venueRes = await this.getVenueInfo(); + const list = Array.isArray(venueRes?.result?.list) ? venueRes.result.list : []; + for (const venue of list) { + if (Number(venue?.clickStatus) === 0 && venue?.id) { + const opRes = await this.userOperation(10, { venueId: Number(venue.id) }); + $.log(`[账号${this.index}] venueId=${venue.id} 上报: ${opRes?.msg || opRes?.code}`); + await $.wait(500); + } + } + } catch (e) { + $.log(`[账号${this.index}] venue自动化异常: ${e.message}`); + } + } + + normalizeTaskNumber(value, fallback = 0) { + const n = Number(value); + return Number.isFinite(n) ? n : fallback; + } + + resolveTaskEventType(item) { + const taskType = this.normalizeTaskNumber(item?.taskType); + const browseType = this.normalizeTaskNumber(item?.browseType); + const waterEventType = this.normalizeTaskNumber(item?.waterEventType); + if (taskType === 50) { + if (browseType === 1) return 11; + if (browseType === 2) return 12; + if (browseType === 3) return 13; + return 11; + } + if (taskType === 60 || taskType === 61) return 7; + if (taskType === 70) return 5; + if (taskType === 80) return 3; + if (taskType === 90) return 4; + if (taskType === 110 || taskType === 120) return waterEventType || 0; + return waterEventType || this.normalizeTaskNumber(item?.eventType); + } + + resolveTaskWaterNum(item) { + const raw = [ + item?.reward, + item?.waterNum, + item?.waterConf, + item?.taskRewardNum + ]; + for (const value of raw) { + const n = Number(value); + if (Number.isFinite(n) && n > 0) return n; + } + return undefined; + } + + async claimTaskWater(item, tag = "claim") { + const taskId = this.normalizeTaskNumber(item?.taskId); + const eventType = this.resolveTaskEventType(item); + if (!eventType) { + $.log(`[账号${this.index}] ${tag} taskId=${taskId} 跳过: 缺少eventType(taskType=${this.normalizeTaskNumber(item?.taskType)})`); + return; + } + const payload = { + extTask: 0, + eventType + }; + if (taskId) payload.taskId = taskId; + const waterNum = this.resolveTaskWaterNum(item); + if (waterNum) payload.waterNum = waterNum; + const res = await this.collectWater(payload); + $.log(`[账号${this.index}] ${tag} collectWater(taskId=${taskId},eventType=${eventType},waterNum=${waterNum || 0}): ${res?.msg || res?.code}`); + } + + logTaskItem(item, prefix = "task") { + const taskId = this.normalizeTaskNumber(item?.taskId); + const taskType = this.normalizeTaskNumber(item?.taskType); + const taskStatus = this.normalizeTaskNumber(item?.taskStatus); + const browseType = this.normalizeTaskNumber(item?.browseType); + const waterEventType = this.normalizeTaskNumber(item?.waterEventType); + $.log(`[账号${this.index}] ${prefix} taskId=${taskId}, taskType=${taskType}, taskStatus=${taskStatus}, browseType=${browseType}, waterEventType=${waterEventType}`); + } + + buildBrowseSecondsCandidates(item) { + const candidates = []; + const maybeSeconds = [ + item?.seconds, + item?.browseSeconds, + item?.needSeconds, + item?.taskSeconds, + process.env.HYJK_BROWSE_SECONDS + ]; + for (const v of maybeSeconds) { + const n = Number(v); + if (Number.isFinite(n) && n >= 0) candidates.push(n); + } + candidates.unshift(0, 20, 30, 60); + return [...new Set(candidates.filter(n => Number.isFinite(n) && n >= 0))]; + } + + resolveBrowseTargetSeconds(item) { + const maybe = [ + item?.needSeconds, + item?.seconds, + item?.browseSeconds, + item?.taskSeconds, + process.env.HYJK_BROWSE_SECONDS + ]; + for (const v of maybe) { + const n = Number(v); + if (Number.isFinite(n) && n > 0) return n; + } + return 20; + } + + async autoBrowseTask(item) { + const taskId = this.normalizeTaskNumber(item?.taskId); + const targetSeconds = this.resolveBrowseTargetSeconds(item); + const waitPadding = Number(process.env.HYJK_BROWSE_WAIT_PADDING || 1); + + const startRes = await this.userOperation(5, { taskId, seconds: 0 }); + $.log(`[账号${this.index}] 浏览任务(taskId=${taskId}) 起始上报seconds=0: ${startRes?.msg || startRes?.code}`); + + const waitMs = Math.max(0, Math.floor((targetSeconds + waitPadding) * 1000)); + if (waitMs > 0) { + $.log(`[账号${this.index}] 浏览任务(taskId=${taskId}) 等待${Math.floor(waitMs / 1000)}秒以满足停留时长`); + await $.wait(62); + } + + const targetRes = await this.userOperation(5, { taskId, seconds: targetSeconds }); + $.log(`[账号${this.index}] 浏览任务(taskId=${taskId}) 目标上报seconds=${targetSeconds}: ${targetRes?.msg || targetRes?.code}`); + + const secondsCandidates = this.buildBrowseSecondsCandidates(item).filter(s => s !== 0 && s !== targetSeconds); + for (const seconds of secondsCandidates) { + const opRes = await this.userOperation(5, { taskId, seconds }); + $.log(`[账号${this.index}] 浏览任务(taskId=${taskId}) 兜底上报seconds=${seconds}: ${opRes?.msg || opRes?.code}`); + await $.wait(400); + } + } + + async autoTasks() { + try { + const firstTaskRes = await this.getTaskListNew(); + const firstTaskList = this.flattenTaskList(firstTaskRes); + $.log(`[账号${this.index}] taskList数量: ${firstTaskList.length}`); + for (const item of firstTaskList) { + const taskType = Number(item?.taskType); + const taskStatus = Number(item?.taskStatus); + const taskId = Number(item?.taskId); + if (!taskId) continue; + this.logTaskItem(item, "scan"); + + if (taskType === 50 && (taskStatus === 0 || taskStatus === 3)) { + await this.autoBrowseTask(item); + continue; + } + + if (taskType === 70 && taskStatus === 0) { + const opRes = await this.userOperation(9, { taskId }); + $.log(`[账号${this.index}] task70(taskId=${taskId}) 上报: ${opRes?.msg || opRes?.code}`); + await $.wait(500); + continue; + } + + if (taskType === 80 && (taskStatus === 0 || taskStatus === 3)) { + await this.autoBlindBox(taskId); + continue; + } + + if ((taskType === 60 || taskType === 61) && taskStatus === 0) { + await this.claimTaskWater(item, "task60/61直领"); + await $.wait(500); + continue; + } + + if (taskType === 90 && (taskStatus === 0 || taskStatus === 3)) { + await this.claimTaskWater(item, "task90直领"); + await $.wait(500); + continue; + } + + if ((taskType === 110 || taskType === 120) && (taskStatus === 0 || taskStatus === 3)) { + const jumpRes = await this.goFruitOrGarden(taskId); + $.log(`[账号${this.index}] task${taskType}(taskId=${taskId}) goFruitOrGarden: ${jumpRes?.msg || jumpRes?.code}`); + await $.wait(500); + continue; + } + + if (taskStatus === 1) { + await this.claimTaskWater(item, "立即领奖"); + await $.wait(500); + continue; + } + + if (taskStatus !== 2 && taskStatus !== 10000) { + $.log(`[账号${this.index}] 未适配任务: taskType=${taskType}, taskStatus=${taskStatus}, taskId=${taskId}`); + } + } + + const secondTaskRes = await this.getTaskListNew(); + const secondTaskList = this.flattenTaskList(secondTaskRes); + for (const item of secondTaskList) { + const taskStatus = this.normalizeTaskNumber(item?.taskStatus); + if (taskStatus !== 1) continue; + await this.claimTaskWater(item, "二次领奖"); + await $.wait(500); + } + } catch (e) { + $.log(`[账号${this.index}] task自动化异常: ${e.message}`); + } + } + + async autoBlindBox(taskId) { + try { + const boxRes = await this.getBlindBoxInfo(taskId); + const boxList = Array.isArray(boxRes?.result) ? boxRes.result : []; + for (const box of boxList) { + if (Number(box?.status) === 0 || Number(box?.status) === 1) { + const blindBoxId = Number(box?.blindBoxId); + if (!blindBoxId) continue; + const opRes = await this.userOperation(4, { taskId, blindBoxId }); + $.log(`[账号${this.index}] 盲盒(taskId=${taskId}, blindBoxId=${blindBoxId}) 上报: ${opRes?.msg || opRes?.code}`); + await $.wait(500); + } + } + } catch (e) { + $.log(`[账号${this.index}] 盲盒自动化异常(taskId=${taskId}): ${e.message}`); + } + } encrypt(body) { - const PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCiBksv2xaOJdSWblaTQl93HI393gYHqKFs89EIFBWYSmYSV+z8XXzMO/Xyo8EeWRpAjT5TuBf0wN467aBx3nsDfJd7e3+txBS7nf+S7Nyjnxx2J5AKPWx1gVmr/OF3aWqxg+DPCB7avakhj+p0QjoJ7eMqgJl/HSX2Kfb6/O3J9wIDAQAB"; const PRIVATE_KEY = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAKIGSy/bFo4l1JZuVpNCX3ccjf3eBgeooWzz0QgUFZhKZhJX7PxdfMw79fKjwR5ZGkCNPlO4F/TA3jrtoHHeewN8l3t7f63EFLud/5Ls3KOfHHYnkAo9bHWBWav84XdparGD4M8IHtq9qSGP6nRCOgnt4yqAmX8dJfYp9vr87cn3AgMBAAECgYEAlwzbB5Bu5LKsEFppZ/wW2ArM7YIRiQ5TACoGFEv1HfcuVaeXDmdxs02rKzwzDEHxUYDcPFyCKPGtvK5QSBgsAUUBHb6uu0fNGUccGX31NRAfLuQ8fj3W0uvkoYlpDARuokDHhWNqWzI6f8bFHkewJwpjXCO8w1WkogTLiX9Gu3ECQQDd5J4jEDS5+7KaohYRoryyX939mzsZ4RC6ufsfzTJwSlnLyYHEbm0Cs+7gbBxRrioqApBMQPIIoa5ujm1C88MNAkEAuu3htlbpR1ZL9b3wUuf3el/D3i/k9XvSChfHQ1q46Y/eck2yEDH9Kv/ZUxEl4fR8mB2MONm9oc2l+chPd9uQEwJBALcWuNU9vgPoB0tIiuUqXoDgUY+80ltcNi2c3/Uxn3jAIK/iKU0nwJMGXQiYrBVJnEjlrKL+w7cTkZZvtwATmtECQC2JV4vQvkFHj3eMzqeTpKDmBVPx/OekQzV8N2l8B0G2b20O6kqxssevzeRDcCQMJ/HyeL88o8pvy3f+yQUcsosCQQDZXV8K7Ek0R/V3dAdUzoetFSlfjCGy9QKPruz7m+iXBASxiA0R7YGfJzc8jWpuv0pxujtB/awy22K/ggLAhkZU"; - const JAVA_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDNQpS4ZeHRiIPFIdZgupShTHFlGOqFkT6XEqByvWqt2BvLo3a+YfzyJHOXyfX41OvbIkuIaycuxU9w7RHI1e7F3O7Io+XxncjyU3GR+ae2DEtLaG3o/rtpONF5q1jTN/Spu4GKXsjhHrP9xxMThLF6134NKAyQZfvOms0gS0zmxwIDAQAB" const JAVA_PRIVATE_KEY = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAM1ClLhl4dGIg8Uh1mC6lKFMcWUY6oWRPpcSoHK9aq3YG8ujdr5h/PIkc5fJ9fjU69siS4hrJy7FT3DtEcjV7sXc7sij5fGdyPJTcZH5p7YMS0tobej+u2k40XmrWNM39Km7gYpeyOEes/3HExOEsXrXfg0oDJBl+86azSBLTObHAgMBAAECgYA08JI5CRX4G/SYeIS5SAYjn/qzL3z1XCO/hS9ayJ3mHpH0sMFkkxNRRLOHl7BYMFpwl2TR14kwl/VIU+y9VugRK6Se/gdJ/jwGiMdVkO6tGD7s8TwLcgNjAVbwpZCq40h8dQazzyIsPxyww4AP9fQlo5x3eY9v8icw+U58fj4FcQJBAPk4PPCy54ZHMqSTl4E1z+QzZ51z07PFIbGsT/oAg9GOwFjrPjOTQDEPp3cBeAlKmWdUVAjdGYExwuCw4EkG/XkCQQDS2Cx09pwNwMWIN+u3CVneECXS3iUiRPGJkbliFczwjByk3DnBMW15wGNVtJfsM7YFOIir+hW+QfbCKSBjxTY/AkEArPam9LZ1kO/g6e+0+mwKeGpkwxYcG2v5UoIwj2XEFrBoNk4twUW1C1e99g4C7Q/lH52bJPuuM8gBZEfdoVFEoQJBALZ4CPlsVx973jeGFcPBHvoURXeZcs+WlOY2rBYbwdHHoB54zK7KZPECM7V/Zh8vnW4lP/p9owWVtsTPrM1LZicCQDhgvSmpBy0QoUI+wPS9l+YYuLc2loGoWU97RiFbgKqXBexnSg4UHfU8Ot6N4VbIWEhOZV27P0ktsI3UfjGNS6s=" - // 生成随机串 + // 鐢熸垚闅忔満涓? function generateRandomString(length) { - var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; // 包含所有字母和数字的字符集合 + var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; // 鍖呭惈鎵€鏈夊瓧姣嶅拰鏁板瓧鐨勫瓧绗﹂泦鍚? var result = ''; for (var i = 0; i < length; i++) { - var randomIndex = Math.floor(Math.random() * chars.length); // 获取随机索引值 - var charAtIndex = chars[randomIndex]; // 根据索引值从字符集合中选择对应的字符 + var randomIndex = Math.floor(Math.random() * chars.length); // 鑾峰彇闅忔満绱㈠紩鍊? + var charAtIndex = chars[randomIndex]; // 鏍规嵁绱㈠紩鍊间粠瀛楃闆嗗悎涓€夋嫨瀵瑰簲鐨勫瓧绗? - result += charAtIndex; // 将字符添加到最终结果中 + result += charAtIndex; // 灏嗗瓧绗︽坊鍔犲埌鏈€缁堢粨鏋滀腑 } return result; } - // 参数字典表排序 + // 鍙傛暟瀛楀吀琛ㄦ帓搴? function sortedKeys(obj) { let keys = Object.keys(obj).sort(); let res = {} @@ -204,7 +563,7 @@ class Task { str = str.slice(0, str.length - 1) return str } - // 生成签名 + // 鐢熸垚绛惧悕 function getSign(data) { const signature = new JsRsaSign.KJUR.crypto.Signature({ alg: "SHA1withRSA", @@ -217,18 +576,18 @@ class Task { } function getKey() { const encryptor = new JSEncrypt() - encryptor.setPublicKey("-----BEGIN PUBLIC KEY-----" + JAVA_PUBLIC_KEY + "-----END PUBLIC KEY-----") // 设置公钥 + encryptor.setPublicKey("-----BEGIN PUBLIC KEY-----" + JAVA_PUBLIC_KEY + "-----END PUBLIC KEY-----") // 璁剧疆鍏挜 return encryptor } - // 生成加密 + // 鐢熸垚鍔犲瘑 function entryData(data) { let encryptor = getKey(); let str = objToStr(data) - return encryptor.encryptLong(str); // 调用封装的方法 + return encryptor.encryptLong(str); // 璋冪敤灏佽鐨勬柟娉? } - // 解密 + // 瑙e瘑 function decrypt(data) { const encryptor = new JSEncrypt() encryptor.setPrivateKey(PRIVATE_KEY) @@ -240,9 +599,8 @@ class Task { sign: sign, timestamp: timestamp }) - //通过抓包得到加密JS网址https://www.heyejk.com/game/js/app.87d7f243.js 代码很多 慢慢补环境即可 - //不理解为什么弄两个加密 烦死了 - //smallfawn 2024 / 3 / 23 22.11 + //from by https://www.heyejk.com/game + /*const t = body const { KJUR, hextob64 } = require("jsrsasign") global['window'] = {} @@ -259,147 +617,47 @@ class Task { function he(e) { let t = de(), n = ce(e); return t.encryptLong(n) } function le(e) { const t = new KJUR.crypto.Signature({ alg: "SHA1withRSA" }); t.init("-----BEGIN PRIVATE KEY-----" + te + "-----END PRIVATE KEY-----"); let n = ae(e), o = ce(n); return t.updateString(o), hextob64(t.sign()) }*/ } - async doWater() { - try { - let body = { "channelCode": "130", "treeId": this.treeId, "nonce": $.randomString(6) } - let result = await this.taskRequest("post", `https://tuan.api.ybm100.com/api/healthSquare/water/watering?secret=${encodeURIComponent(this.encrypt(body))}`, JSON.stringify(body)) - //console.log(options); - //console.log(result); - if (result.code == 0) { - $.log(`✅账号[${this.index}] 浇水成功🎉`) - } else { - $.log(`❌账号[${this.index}] 浇水失败[${result.msg}]`); - } - } catch (e) { - console.log(e); - } - } - async updateTaskInfo(taskId, taskStatus) { - //如果是第一次上报 - let body - if (taskStatus == 0) { - body = { "operateType": 5, "operateValue": `{\"taskId\":${taskId},\"seconds\":0}`, "channelCode": "130" } - - } else { - body = { "userId": `${this.userId}`, "operateType": 6, "operateValue": `{\"taskId\":\"${taskId}\",\"status\":1}`, "channelCode": "130" } - - } - //第二次 - try { - let result = await this.taskRequest("post", `https://tuan.api.ybm100.com/api/healthSquare/user/userOperation`, JSON.stringify(body)) - //console.log(options); - //console.log(result); - if (result.code == 0) { - $.log(`✅账号[${this.index}] 上报任务成功🎉`) - } else { - $.log(`❌账号[${this.index}] 上报任务失败`); - } - } catch (e) { - console.log(e); - } - } - async collectWater(taskId) { - let body = { - "channelCode": "130", - "taskId": taskId, - "extTask": 0, - "eventType": 12, - "waterNum": 10, - "nonce": $.randomString(6) - } - try { - let result = await this.taskRequest("post", `https://tuan.api.ybm100.com/api/healthSquare/water/collectWater?secret=${encodeURIComponent(this.encrypt(body))}`, JSON.stringify(body)) - //console.log(options); - //console.log(result); - if (result.code == 0) { - $.log(`✅账号[${this.index}] 领取水滴成功 当前水滴[${result.result.kettleWater}]💧🎉`) - } else { - $.log(`❌账号[${this.index}] 领取水滴失败`); - console.log(result); - - } - } catch (e) { - console.log(e); - } - } - - async taskRequest(method, url, body = "") { - // - let headers = { - "host": "tuan.api.ybm100.com", - "apptype": "1", - "terminal": "h5", - "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x6309092b) XWEB/9079", - "content-type": "application/json; charset=UTF-8", - "accept": "application/json, text/plain, */*", - "appname": "ykq-xcx", - "usertype": "groupuser", - "token": this.ck, - "appversion": "v3.1.7", - "origin": "https://www.heyejk.com", - "sec-fetch-site": "cross-site", - "sec-fetch-mode": "cors", - "sec-fetch-dest": "empty", - "referer": "https://www.heyejk.com/", - "accept-encoding": "gzip, deflate, br", - "accept-language": "zh-CN,zh;q=0.9" - } - this.userId != '' ? Object.assign(headers, { "userid": this.userId }) : '' - const reqeuestOptions = { - url: url, - method: method, - headers: headers - } - body == "" ? "" : Object.assign(reqeuestOptions, { body: body }) - let { body: result } = await $.httpRequest(reqeuestOptions) - return result - } } - - !(async () => { - if (!(await checkEnv())) return; - if (userList.length > 0) { - let taskall = []; - for (let user of userList) { - if (user.ckStatus) { - taskall.push(user.main()); - } - } - await Promise.all(taskall); + await getNotice().catch(e => $.log(`[Notice失败] ${e.message}`)) + $.checkEnv(ckName); + + for (let user of $.userList) { + await new Task(user).run(); } - await $.sendMsg($.logs.join("\n")) })() .catch((e) => console.log(e)) - .finally(() => $.done()); + .finally(async () => { + try { + await $.done(); + } catch (e) { + console.log(e.message || e); + process.exit(1); + } + }); -//******************************************************** -/** - * 变量检查与处理 - * @returns - */ -async function checkEnv() { - let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || ""; - if (userCookie) { - let e = envSplitor[0]; - for (let o of envSplitor) - if (userCookie.indexOf(o) > -1) { - e = o; - break; - } - for (let n of userCookie.split(e)) n && userList.push(new Task(n)); - } else { - console.log(`未找到CK【${ckName}】`); - return; +async function getNotice() { + let options = { + url: `https://ghproxy.net/https://raw.githubusercontent.com/smallfawn/Note/refs/heads/main/Notice.json`, + headers: { + "User-Agent": defaultUserAgent, + } } - return console.log(`共找到${userList.length}个账号`), true; //true == !0 + let { data: res } = await axios.request(options); + $.log(res) + return res } -//Env Api ============================= -/* -* @modifyAuthor @smallfawn -* @modifyTime 2021-08-01 -* @modifyInfo 重写请求函数 在got环境或axios环境都可以请求 -*/ -function Env(t, s) { return new (class { constructor(t, s) { this.name = t; this.data = null; this.dataFile = "box.dat"; this.logs = []; this.logSeparator = "\n"; this.startTime = new Date().getTime(); Object.assign(this, s); this.log("", `\ud83d\udd14${this.name},\u5f00\u59cb!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"); this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), s = this.path.resolve(process.cwd(), this.dataFile), e = this.fs.existsSync(t), i = !e && this.fs.existsSync(s); if (!e && !i) return {}; { const i = e ? t : s; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"); this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), s = this.path.resolve(process.cwd(), this.dataFile), e = this.fs.existsSync(t), i = !e && this.fs.existsSync(s), o = JSON.stringify(this.data); e ? this.writeFileSync(t, o) : i ? this.fs.writeFileSync(s, o) : this.fs.writeFileSync(t, o) } } lodash_get(t, s, e) { const i = s.replace(/\[(\d+)\]/g, ".$1").split("."); let o = t; for (const t of i) if (((o = Object(o)[t]), void 0 === o)) return e; return o } lodash_set(t, s, e) { return Object(t) !== t ? t : (Array.isArray(s) || (s = s.toString().match(/[^.[\]]+/g) || []), (s.slice(0, -1).reduce((t, e, i) => Object(t[e]) === t[e] ? t[e] : (t[e] = Math.abs(s[i + 1]) >> 0 == +s[i + 1] ? [] : {}), t)[s[s.length - 1]] = e), t) } getdata(t) { let s = this.getval(t); if (/^@/.test(t)) { const [, e, i] = /^@(.*?)\.(.*?)$/.exec(t), o = e ? this.getval(e) : ""; if (o) try { const t = JSON.parse(o); s = t ? this.lodash_get(t, i, "") : s } catch (t) { s = "" } } return s } setdata(t, s) { let e = !1; if (/^@/.test(s)) { const [, i, o] = /^@(.*?)\.(.*?)$/.exec(s), h = this.getval(i), a = i ? ("null" === h ? null : h || "{}") : "{}"; try { const s = JSON.parse(a); this.lodash_set(s, o, t), (e = this.setval(JSON.stringify(s), i)) } catch (s) { const h = {}; this.lodash_set(h, o, t), (e = this.setval(JSON.stringify(h), i)) } } else e = this.setval(t, s); return e } getval(t) { if (this.isSurge() || this.isLoon()) { return $persistentStore.read(t) } else if (this.isQuanX()) { return $prefs.valueForKey(t) } else if (this.isNode()) { this.data = this.loaddata(); return this.data[t] } else { return this.data && this.data[t] || null } } setval(t, s) { if (this.isSurge() || this.isLoon()) { return $persistentStore.write(t, s) } else if (this.isQuanX()) { return $prefs.setValueForKey(t, s) } else if (this.isNode()) { this.data = this.loaddata(); this.data[s] = t; this.writedata(); return true } else { return this.data && this.data[s] || null } } initRequestEnv(t) { try { require.resolve('got') && (this.requset = require("got"), this.requestModule = "got") } catch (e) { } try { require.resolve('axios') && (this.requset = require("axios"), this.requestModule = "axios") } catch (e) { } this.cktough = this.cktough ? this.cktough : require("tough-cookie"); this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar(); if (t) { t.headers = t.headers ? t.headers : {}; if (typeof t.headers.Cookie === "undefined" && typeof t.cookieJar === "undefined") { t.cookieJar = this.ckjar } } } queryStr(options) { return Object.entries(options).map(([key, value]) => `${key}=${typeof value === 'object' ? JSON.stringify(value) : value}`).join('&') } getURLParams(url) { const params = {}; const queryString = url.split('?')[1]; if (queryString) { const paramPairs = queryString.split('&'); paramPairs.forEach(pair => { const [key, value] = pair.split('='); params[key] = value }) } return params } isJSONString(str) { try { return JSON.parse(str) && typeof JSON.parse(str) === 'object' } catch (e) { return false } } isJson(obj) { var isjson = typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && !obj.length; return isjson } async sendMsg(message) { if (!message) return; if ($.isNode()) { await notify.sendNotify($.name, message) } else { $.msg($.name, '', message) } } async httpRequest(options) { let t = { ...options }; t.headers = t.headers || {}; if (t.params) { t.url += '?' + this.queryStr(t.params) } t.method = t.method.toLowerCase(); if (t.method === 'get') { delete t.headers['Content-Type']; delete t.headers['Content-Length']; delete t.headers['content-type']; delete t.headers['content-length']; delete t.body } else if (t.method === 'post') { let ContentType; if (!t.body) { t.body = "" } else if (typeof t.body === "string") { ContentType = this.isJSONString(t.body) ? 'application/json' : 'application/x-www-form-urlencoded' } else if (this.isJson(t.body)) { t.body = JSON.stringify(t.body); ContentType = 'application/json' } if (!t.headers['Content-Type'] && !t.headers['content-type']) { t.headers['Content-Type'] = ContentType } } if (this.isNode()) { this.initRequestEnv(t); if (this.requestModule === "axios" && t.method === "post") { t.data = t.body; delete t.body } let httpResult; if (this.requestModule === "got") { httpResult = await this.requset(t); if (this.isJSONString(httpResult.body)) { httpResult.body = JSON.parse(httpResult.body) } } else if (this.requestModule === "axios") { httpResult = await this.requset(t); httpResult.body = httpResult.data } return httpResult } if (this.isQuanX()) { t.method = t.method.toUpperCase(); return new Promise((resolve, reject) => { $task.fetch(t).then(response => { if (this.isJSONString(response.body)) { response.body = JSON.parse(response.body) } resolve(response) }) }) } } randomNumber(length) { const characters = '0123456789'; return Array.from({ length }, () => characters[Math.floor(Math.random() * characters.length)]).join('') } randomString(length) { const characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; return Array.from({ length }, () => characters[Math.floor(Math.random() * characters.length)]).join('') } timeStamp() { return new Date().getTime() } uuid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16) }) } time(t) { let s = { "M+": new Date().getMonth() + 1, "d+": new Date().getDate(), "H+": new Date().getHours(), "m+": new Date().getMinutes(), "s+": new Date().getSeconds(), "q+": Math.floor((new Date().getMonth() + 3) / 3), S: new Date().getMilliseconds(), }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (new Date().getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in s) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? s[e] : ("00" + s[e]).substr(("" + s[e]).length))); return t } msg(s = t, e = "", i = "", o) { const h = (t) => !t || (!this.isLoon() && this.isSurge()) ? t : "string" == typeof t ? this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : void 0 : "object" == typeof t && (t["open-url"] || t["media-url"]) ? this.isLoon() ? t["open-url"] : this.isQuanX() ? t : void 0 : void 0; this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(s, e, i, h(o)) : this.isQuanX() && $notify(s, e, i, h(o))); let logs = ['', '==============📣系统通知📣==============']; logs.push(t); e ? logs.push(e) : ''; i ? logs.push(i) : ''; console.log(logs.join('\n')); this.logs = this.logs.concat(logs) } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, s) { const e = !this.isSurge() && !this.isQuanX() && !this.isLoon(); e ? this.log("", `\u2757\ufe0f${this.name},\u9519\u8bef!`, t.stack) : this.log("", `\u2757\ufe0f${this.name},\u9519\u8bef!`, t) } wait(t) { return new Promise((s) => setTimeout(s, t)) } done(t = {}) { const s = new Date().getTime(), e = (s - this.startTime) / 1e3; this.log("", `\ud83d\udd14${this.name},\u7ed3\u675f!\ud83d\udd5b ${e}\u79d2`); this.log(); if (this.isNode()) { process.exit(1) } if (this.isQuanX()) { $done(t) } } })(t, s) } + + + + + + + + + + + +