├── Utils
└── Notice.json
├── README.md
├── ql.js
├── yangmao
├── miui.py
├── luoji.js
├── hdl.js
├── mxbc.js
├── hezj.js
├── bkxstx.js
├── bkxs.js
├── xmydsbs.py
└── tuchong.js
├── notify.py
└── sendNotify.py
/Utils/Notice.json:
--------------------------------------------------------------------------------
1 | {
2 | "notice":""
3 | }
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ziyong
2 | 京东家宽车
3 |
--------------------------------------------------------------------------------
/ql.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const got = require('got');
4 | require('dotenv').config();
5 | const { readFile } = require('fs/promises');
6 | const path = require('path');
7 |
8 | const qlDir = '/ql';
9 | const fs = require('fs');
10 | let Fileexists = fs.existsSync('/ql/data/config/auth.json');
11 | let authFile="";
12 | if (Fileexists)
13 | authFile="/ql/data/config/auth.json"
14 | else
15 | authFile="/ql/config/auth.json"
16 | //const authFile = path.join(qlDir, 'config/auth.json');
17 |
18 | const api = got.extend({
19 | prefixUrl: 'http://127.0.0.1:5600',
20 | retry: { limit: 0 },
21 | });
22 |
23 | async function getToken() {
24 | const authConfig = JSON.parse(await readFile(authFile));
25 | return authConfig.token;
26 | }
27 |
28 | module.exports.getEnvs = async () => {
29 | const token = await getToken();
30 | const body = await api({
31 | url: 'api/envs',
32 | searchParams: {
33 | searchValue: 'JD_COOKIE',
34 | t: Date.now(),
35 | },
36 | headers: {
37 | Accept: 'application/json',
38 | authorization: `Bearer ${token}`,
39 | },
40 | }).json();
41 | return body.data;
42 | };
43 |
44 | module.exports.getEnvsCount = async () => {
45 | const data = await this.getEnvs();
46 | return data.length;
47 | };
48 |
49 | module.exports.addEnv = async (cookie, remarks) => {
50 | const token = await getToken();
51 | const body = await api({
52 | method: 'post',
53 | url: 'api/envs',
54 | params: { t: Date.now() },
55 | json: [{
56 | name: 'JD_COOKIE',
57 | value: cookie,
58 | remarks,
59 | }],
60 | headers: {
61 | Accept: 'application/json',
62 | authorization: `Bearer ${token}`,
63 | 'Content-Type': 'application/json;charset=UTF-8',
64 | },
65 | }).json();
66 | return body;
67 | };
68 |
69 | module.exports.updateEnv = async (cookie, eid, remarks) => {
70 | const token = await getToken();
71 | const body = await api({
72 | method: 'put',
73 | url: 'api/envs',
74 | params: { t: Date.now() },
75 | json: {
76 | name: 'JD_COOKIE',
77 | value: cookie,
78 | _id: eid,
79 | remarks,
80 | },
81 | headers: {
82 | Accept: 'application/json',
83 | authorization: `Bearer ${token}`,
84 | 'Content-Type': 'application/json;charset=UTF-8',
85 | },
86 | }).json();
87 | return body;
88 | };
89 |
90 | module.exports.updateEnv11 = async (cookie, eid, remarks) => {
91 | const token = await getToken();
92 | const body = await api({
93 | method: 'put',
94 | url: 'api/envs',
95 | params: { t: Date.now() },
96 | json: {
97 | name: 'JD_COOKIE',
98 | value: cookie,
99 | id: eid,
100 | remarks,
101 | },
102 | headers: {
103 | Accept: 'application/json',
104 | authorization: `Bearer ${token}`,
105 | 'Content-Type': 'application/json;charset=UTF-8',
106 | },
107 | }).json();
108 | return body;
109 | };
110 |
111 | module.exports.DisableCk = async (eid) => {
112 | const token = await getToken();
113 | const body = await api({
114 | method: 'put',
115 | url: 'api/envs/disable',
116 | params: { t: Date.now() },
117 | body: JSON.stringify([eid]),
118 | headers: {
119 | Accept: 'application/json',
120 | authorization: `Bearer ${token}`,
121 | 'Content-Type': 'application/json;charset=UTF-8',
122 | },
123 | }).json();
124 | return body;
125 | };
126 |
127 | module.exports.EnableCk = async (eid) => {
128 | const token = await getToken();
129 | const body = await api({
130 | method: 'put',
131 | url: 'api/envs/enable',
132 | params: { t: Date.now() },
133 | body: JSON.stringify([eid]),
134 | headers: {
135 | Accept: 'application/json',
136 | authorization: `Bearer ${token}`,
137 | 'Content-Type': 'application/json;charset=UTF-8',
138 | },
139 | }).json();
140 | return body;
141 | };
142 |
143 | module.exports.getstatus = async(eid) => {
144 | const envs = await this.getEnvs();
145 | var tempid = 0;
146 | for (let i = 0; i < envs.length; i++) {
147 | tempid = 0;
148 | if (envs[i]._id) {
149 | tempid = envs[i]._id;
150 | }
151 | if (envs[i].id) {
152 | tempid = envs[i].id;
153 | }
154 | if (tempid == eid) {
155 | return envs[i].status;
156 | }
157 | }
158 | return 99;
159 | };
160 |
161 | module.exports.getEnvById = async(eid) => {
162 | const envs = await this.getEnvs();
163 | var tempid = 0;
164 | for (let i = 0; i < envs.length; i++) {
165 | tempid = 0;
166 | if (envs[i]._id) {
167 | tempid = envs[i]._id;
168 | }
169 | if (envs[i].id) {
170 | tempid = envs[i].id;
171 | }
172 | if (tempid == eid) {
173 | return envs[i].value;
174 | }
175 | }
176 | return "";
177 | };
178 |
179 | module.exports.getEnvByPtPin = async (Ptpin) => {
180 | const envs = await this.getEnvs();
181 | for (let i = 0; i < envs.length; i++) {
182 | var tempptpin = decodeURIComponent(envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/) && envs[i].value.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
183 | if(tempptpin==Ptpin){
184 | return envs[i];
185 | }
186 | }
187 | return "";
188 | };
189 |
190 | module.exports.delEnv = async (eid) => {
191 | const token = await getToken();
192 | const body = await api({
193 | method: 'delete',
194 | url: 'api/envs',
195 | params: { t: Date.now() },
196 | body: JSON.stringify([eid]),
197 | headers: {
198 | Accept: 'application/json',
199 | authorization: `Bearer ${token}`,
200 | 'Content-Type': 'application/json;charset=UTF-8',
201 | },
202 | }).json();
203 | return body;
204 | };
205 |
--------------------------------------------------------------------------------
/yangmao/miui.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | # -- coding: utf-8 --
3 | # -------------------------------
4 | # @Author : github@wd210010 https://github.com/wd210010/just_for_happy
5 | # @Time : 2023/2/27 13:23
6 | # -------------------------------
7 | # cron "30 8,10,15 * * *" script-path=xxx.py,tag=匹配cron用
8 | # const $ = new Env('小米社区任务得成长值')
9 | # 4.11 更新了请求后获取cookie失败的问题 基本一次性就可以跑完 不用多跑几次
10 |
11 | import requests, json ,time,base64,binascii,hashlib,os,re
12 |
13 | # 小米签到 小米社区任务得成长值
14 | # 配置帐号密码 一一对应 按需增删 不对上会出错 若帐号密码填写没有错误 还是报错应该是账号在非常用设备上登录, 需要验证码, 使用该设备安装图形化工具后自行前去验证https://web-alpha.vip.miui.com/page/info/mio/mio/internalTest 图形化工具怎么安装可参考https://cloud.tencent.com/developer/article/2069955
15 | # 青龙变量export mi_account='' export mi_password=''
16 |
17 | # 青龙变量 mi_account mi_password
18 | mi_account = os.getenv("mi_account").split('&')
19 | mi_password = os.getenv("mi_password").split('&')
20 |
21 | #获取cookie
22 | def Phone(account, password):
23 | md5 = hashlib.md5()
24 | md5.update(password.encode())
25 | Hash = md5.hexdigest()
26 | url = "https://account.xiaomi.com/pass/serviceLoginAuth2"
27 | headers = {
28 | "Content-Type": "application/x-www-form-urlencoded",
29 | "User-Agent":
30 | "Dalvik/2.1.0 (Linux; U; Android 12; M2007J17C Build/SKQ1.211006.001) APP/xiaomi.vipaccount APPV/220301 MK/UmVkbWkgTm90ZSA5IFBybw== PassportSDK/3.7.8 passport-ui/3.7.8",
31 | "Cookie":
32 | "deviceId=X0jMu7b0w-jcne-S; pass_o=2d25bb648d023d7f; sdkVersion=accountsdk-2020.01.09",
33 | "Host": "account.xiaomi.com",
34 | "Connection": "Keep-Alive",
35 | "Accept-Encoding": "gzip"
36 | }
37 | data = {
38 | "cc": "+86",
39 | "qs": "%3F_json%3Dtrue%26sid%3Dmiui_vip%26_locale%3Dzh_CN",
40 | "callback": "https://api.vip.miui.com/sts",
41 | "_json": "true",
42 | "user": account,
43 | "hash": Hash.upper(),
44 | "sid": "miui_vip",
45 | "_sign": "ZJxpm3Q5cu0qDOMkKdWYRPeCwps%3D",
46 | "_locale": "zh_CN"
47 | }
48 | Auth1 = requests.post(url=url, headers=headers,
49 | data=data).text.replace("&&&START&&&", "")
50 | Auth = json.loads(Auth1)
51 | ssecurity = Auth["ssecurity"]
52 | nonce = Auth["nonce"]
53 | sha1 = hashlib.sha1()
54 | Str = "nonce=" + str(nonce) + "&" + ssecurity
55 | sha1.update(Str.encode("utf-8"))
56 | clientSign = base64.encodebytes(
57 | binascii.a2b_hex(sha1.hexdigest().encode("utf-8"))).decode(
58 | encoding="utf-8").strip()
59 | nurl = Auth[
60 | "location"] + "&_userIdNeedEncrypt=true&clientSign=" + clientSign
61 |
62 | resp = requests.get(url=nurl)
63 | return requests.utils.dict_from_cookiejar(resp.cookies)
64 |
65 |
66 |
67 | for i in range(len(mi_account)):
68 | c_list = []
69 | for k in range(10):
70 | a = Phone(mi_account[i], mi_password[i])
71 | if len(a) > 0:
72 | c_list.append(a)
73 | cookie = str(c_list[-1]).replace('{','').replace('}','').replace(',',';').replace(': ','=').replace('\'','').replace(' ','')
74 | miui_vip_ph = "".join(re.findall('miui_vip_ph=(.*?);', cookie, re.S))
75 | url = 'https://api.vip.miui.com/mtop/planet/vip/user/checkin?pathname=/mio/checkIn&version=dev.1144'
76 | headers = {
77 | 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
78 | 'Cookie': f'{cookie}'
79 | }
80 | user_url = 'https://api.vip.miui.com/api/community/user/home/page'
81 | params = {
82 | 'miui_vip_ph': miui_vip_ph
83 | }
84 | html = requests.get(url=url, headers=headers,params=params)
85 | html_user = requests.get(url=user_url, headers=headers)
86 | result = json.loads(html.text)
87 | result_user = json.loads(html_user.text)
88 | userId = result_user['entity']['userId']
89 | print('*************'+'\n'+f'开始第{i + 1}个账号签到'+'\n'+'签到结果:')
90 | print(result['message'])
91 | print('userId: '+userId + ' 用户名: '+result_user['entity']['userName']+ ' 段位: '+ result_user['entity']['userGrowLevelInfo']['showLevel'])
92 |
93 | # 点赞任务
94 | print('开始加入点赞任务>>>>')
95 | for a in range(2):
96 | dzurl = 'https://api.vip.miui.com/mtop/planet/vip/content/announceThumbUp'
97 | dz_data = {
98 | 'postId': '36625780',
99 | 'sign': '36625780',
100 | 'timestamp':int(round(time.time() * 1000))
101 | }
102 | dz_html = requests.get(url=dzurl, headers=headers,data=dz_data)
103 | dz_result = json.loads(dz_html.text)
104 | if dz_result['status'] == 200:
105 | print('点赞帖子成功成功')
106 | time.sleep(1)
107 | #加入圈子
108 | print('开始加入圈子任务>>>>')
109 | unfollow_url = 'https://api.vip.miui.com/api/community/board/unfollow?boardId=558495'
110 | html_unfollow = requests.get(url=unfollow_url, headers=headers)
111 | result_unfollow = json.loads(html_user.text)
112 | if result_unfollow['status']==200:
113 | print('退出圈子成功')
114 | time.sleep(1)
115 |
116 | follow_url = 'https://api.vip.miui.com/api/community/board/follow?boardId=558495'
117 | html_follow = requests.get(url=follow_url, headers=headers)
118 | result_follow = json.loads(html_user.text)
119 | if result_follow['status']==200:
120 | print('加入圈子成功')
121 | time.sleep(1)
122 |
123 | # 浏览主页
124 | info_url =f'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByAction?userId={userId}&action=BROWSE_SPECIAL_PAGES_USER_HOME'
125 | html_info = requests.get(url=info_url, headers=headers)
126 | time.sleep(12)
127 | result_info = json.loads(html_info.text)
128 | if result_info['status'] == 200:
129 | print('浏览主页成功,获得积分: '+str(result_info['entity']['score']))
130 | else:
131 | print(result_info['message']+',今日已达上限')
132 | #浏览专题
133 | print('开始浏览专题任务>>>>')
134 | llzt_url = f'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByAction?userId={userId}&action=BROWSE_SPECIAL_PAGES_SPECIAL_PAGE'
135 | html_llzt = requests.get(url=llzt_url, headers=headers)
136 | time.sleep(12)
137 | result_llzt = json.loads(html_llzt.text)
138 | # print(result_llzt)
139 | if result_llzt['status'] == 200:
140 | print('浏览主页成功,获得积分: '+str(result_llzt['entity']['score']))
141 | else:
142 | print(result_llzt['message']+',今日已达上限')
143 |
144 | #浏览帖子
145 | print('开始浏览帖子任务>>>>')
146 | for a in range(3):
147 | watch_url = f'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByAction?userId={userId}&action=BROWSE_POST_10S'
148 | html_watch = requests.get(url=watch_url, headers=headers)
149 | time.sleep(12)
150 | result_watch = json.loads(html_watch.text)
151 | # print(result_watch)
152 | if result_watch['status'] == 200:
153 | print('浏览帖子成功,获得积分: ' + str(result_watch['entity']['score']))
154 | else:
155 | print(result_watch['message'] + ',今日已达上限')
156 | #拔萝卜
157 | carroturl ='https://api.vip.miui.com/api/carrot/pull'
158 | resp_carrot = requests.post(url=carroturl, headers=headers,params=params)
159 | r_json = resp_carrot.json()
160 | if r_json['code'] == 401:
161 | print("社区拔萝卜失败:Cookie无效")
162 | elif r_json['code'] != 200:
163 | print("社区拔萝卜失败:" + str(r_json['entity']['message']))
164 | print("社区拔萝卜结果:" + str(r_json['entity']['message']))
165 | money_count = r_json['entity']['header']['moneyCount']
166 | print("当前金币数:" + str(money_count))
--------------------------------------------------------------------------------
/yangmao/luoji.js:
--------------------------------------------------------------------------------
1 | /*
2 | 小程序:罗技粉丝俱乐部
3 | 变量 luojihd
4 | 抓包格式为请求头里的Authorization=XXXX
5 | cron: 57 6,9 * * *
6 | */
7 | const $ = new Env('罗技粉丝俱乐部');
8 | var crypto = require("crypto");
9 |
10 | let status;
11 | status = (status = ($.getval("luojistatus") || "1") ) > 1 ? `${status}` : ""; // 账号扩展字符
12 | let luojihdArr = [],luojicount = ''
13 | const notify = $.isNode() ? require('./sendNotify') : '';
14 | let luojihd= $.isNode() ? (process.env.luojihd ? process.env.luojihd : "") : ($.getdata('luojihd') ? $.getdata('luojihd') : "")
15 |
16 | let allMessage = '';
17 | let luojihds = ""
18 | const logs =0;
19 | const host='https://api.wincheers.net/'
20 | var hours = new Date().getHours();
21 | var s = new Date().getMinutes();
22 |
23 | var timestamp = Math.round(new Date().getTime()/1000).toString();
24 | !(async () => {
25 |
26 | if(!$.isNode()){
27 | luojihdArr.push($.getdata('luojihd'))
28 | let luojicount = ($.getval('luojicount') || '1');
29 | for (let i = 2; i <= luojicount; i++) {
30 | luojihdArr.push($.getdata(`luojihd${i}`))
31 | }
32 | console.log(`------------- 共${luojihdArr.length}个账号-------------\n`)
33 | for (let i = 0; i < luojihdArr.length; i++) {
34 | if (luojihdArr[i]) {
35 | luojihd = luojihdArr[i];
36 | $.index = i + 1;
37 |
38 | }
39 | }
40 | }else {
41 | if (process.env.luojihd && process.env.luojihd.indexOf('&') > -1) {
42 | luojihdArr = process.env.luojihd.split('&');
43 | console.log(`您选择的是用"&"隔开\n`)
44 | } else {
45 | luojihds = [process.env.luojihd]
46 | };
47 | Object.keys(luojihds).forEach((item) => {
48 | if (luojihds[item]) {
49 | luojihdArr.push(luojihds[item])
50 | }
51 | })
52 | console.log(`共${luojihdArr.length}个cookie`)
53 | for (let k = 0; k < luojihdArr.length; k++) {
54 | $.message = ""
55 | luojihd = luojihdArr[k]
56 | $.index = k + 1;
57 |
58 | console.log(`\n开始【罗技${$.index}】`)
59 | allMessage +=`\n开始【罗技${$.index}】`
60 | await sign()
61 |
62 | await socialComment()
63 | await socialVideo(43239)
64 | await socialVideo(110153)
65 | await socialVideo(151)
66 |
67 | await socialVideoComment(43239)
68 |
69 | await socialVideoComment(110153)
70 |
71 | await socialVideoComment(138216)
72 | await crmAccount()
73 | }
74 |
75 |
76 | }
77 |
78 | if ($.isNode() && allMessage) {
79 | await notify.sendNotify(`${$.name}`, `${allMessage}` )
80 | }
81 | })()
82 | .catch((e) => $.logErr(e))
83 | .finally(() => $.done())
84 | async function socialVideo(SocialId) {
85 | return new Promise((resolve) => {
86 |
87 | $.post(luoji(`api/services/app/socialVideoOverLog/AddLog?SocialId=${SocialId}`), async (err, resp, data) => {
88 | //$.log(data)
89 | try {
90 | if (err) {
91 | console.log(`${JSON.stringify(err)}`)
92 | console.log(`${$.name} API请求失败,请检查网路重试`)
93 | }// else {
94 | if (safeGet(data)) {
95 | data = JSON.parse(data);
96 | if(data.success == true){
97 | console.log('视频:'+data.success)
98 | allMessage +=`\n看视频成功`}
99 | else
100 | console.log('视频:'+data.success)
101 | allMessage +='视频:'+data.success
102 | }
103 |
104 | } catch (e) {
105 | $.logErr(e, resp)
106 | } finally {
107 | resolve(data);
108 | }
109 | })
110 | })
111 | }
112 | async function GetGetSocialCommentList(SocialId) {
113 | return new Promise((resolve) => {
114 | body = {"maxResultCount":10,"skipCount":0,"sorting":"CreationTime DESC","keywords":"","socialId":SocialId}
115 | $.post(luoji(`api/services/app/socialComment/GetGetSocialCommentList`,body), async (err, resp, data) => {
116 | //$.log(data)
117 | try {
118 | if (err) {
119 | console.log(`${JSON.stringify(err)}`)
120 | console.log(`${$.name} API请求失败,请检查网路重试`)
121 | }// else {
122 | if (safeGet(data)) {
123 | data = JSON.parse(data);
124 |
125 | }
126 | } catch (e) {
127 | $.logErr(e, resp)
128 | } finally {
129 | resolve(data);
130 | }
131 | })
132 | })
133 | }
134 | async function socialVideoComment(SocialId) {
135 | return new Promise((resolve) => {
136 | body = {"buyerId":0,"socialId":SocialId,"content":"666666666","zanNumber":0,"id":0}
137 | $.post(luoji(`api/services/app/socialComment/AddSocialComment `,body), async (err, resp, data) => {
138 | //$.log(data)
139 | try {
140 | if (err) {
141 | console.log(`${JSON.stringify(err)}`)
142 | console.log(`${$.name} API请求失败,请检查网路重试`)
143 | }// else {
144 | if (safeGet(data)) {
145 | data = JSON.parse(data);
146 | if(data.success == true){
147 | console.log('评论视频:'+data.success)
148 | allMessage +=`\n评论成功`}
149 | else
150 | console.log(`${JSON.stringify(data)}`)
151 | allMessage +=`\n评论:${data}`
152 | }
153 |
154 | } catch (e) {
155 | $.logErr(e, resp)
156 | } finally {
157 | resolve(data);
158 | }
159 | })
160 | })
161 | }
162 |
163 |
164 |
165 | async function socialComment() {
166 | return new Promise((resolve) => {
167 | let body ={"buyerId":1572724,"socialId":"140001","content":"66666","zanNumber":1,"id":1}
168 | $.post(luoji(`api/services/app/socialComment/AddSocialComment`,body), async (err, resp, data) => {
169 | //$.log(data)
170 | try {
171 | if (err) {
172 | console.log(`${JSON.stringify(err)}`)
173 | console.log(`${$.name} API请求失败,请检查网路重试`)
174 | }// else {
175 | if (safeGet(data)) {
176 | data = JSON.parse(data);
177 | if(data.success == true){
178 | console.log('评论:'+data.success)
179 | allMessage +=`\n评论成功`}
180 | else
181 | console.log(`${JSON.stringify(data)}`)
182 | allMessage +=`\n评论:${data}`
183 | }
184 |
185 | } catch (e) {
186 | $.logErr(e, resp)
187 | } finally {
188 | resolve(data);
189 | }
190 | })
191 | })
192 | }
193 | function sign() {
194 | return new Promise((resolve) => {
195 |
196 | $.post(luoji(`api/services/app/signIn/ContinuitySignIn`,''), async (err, resp, data) => {
197 |
198 | try {
199 | if (err) {
200 | console.log(`${JSON.stringify(err)}`)
201 | console.log(`${$.name} API请求失败,请检查网路重试`)
202 | }// else {
203 | if (safeGet(data)) {
204 | data = JSON.parse(data);
205 | if(data.success == true){
206 | console.log('签到:'+data.result)
207 | allMessage +=`\n签到:${data.result}`}
208 | else
209 | console.log('签到:请不要重复签到')
210 | allMessage +=`\n签到:请不要重复签到`
211 |
212 | }
213 |
214 | } catch (e) {
215 | $.logErr(e, resp)
216 | } finally {
217 | resolve(data);
218 | }
219 | })
220 | })
221 | }
222 |
223 | async function crmAccount() {
224 | return new Promise((resolve) => {
225 |
226 | $.post(luoji(`api/services/app/crmAccount/GetLGFanBuyerCenter`), async (err, resp, data) => {
227 | //$.log(data)
228 | try {
229 | if (err) {
230 | console.log(`${JSON.stringify(err)}`)
231 | console.log(`${$.name} API请求失败,请检查网路重试`)
232 | }// else {
233 | if (safeGet(data)) {
234 | data = JSON.parse(data);
235 | if(data.success == true){
236 | console.log('\n总积分:'+data.result.integral)
237 | console.log('\n今日积分:'+data.result.scouNumber)
238 | allMessage +='\n总积分:'+data.result.integral+'\n今日积分:'+data.result.scouNumber}
239 | else
240 | console.log(`${JSON.stringify(data)}`)
241 | allMessage +=`\n个人信息获取失败:${data}`
242 | }
243 |
244 | } catch (e) {
245 | $.logErr(e, resp)
246 | } finally {
247 | resolve(data);
248 | }
249 | })
250 | })
251 | }
252 |
253 |
254 |
255 |
256 | function luoji(a,body) {
257 | return {
258 |
259 | url: `${host}${a}`,
260 | body:JSON.stringify(body),
261 | headers: {
262 |
263 | 'Host': 'api.wincheers.net',
264 | 'Connection': 'keep-alive',
265 | 'Content-Length': '414',
266 | 'Authorization': luojihd,
267 | 'User-Agent': 'Mozilla/5.0 (Linux; Android 12; 21051182C Build/SKQ1.220303.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/4425 MMWEBSDK/20221206 Safari/537.36 MMWEBID/3637 MicroMessenger/8.0.32.2300(0x280020F8) WeChat/arm64 Weixin Android Tablet NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android',
268 | 'client_id': 'LogitechFans',
269 | 'Content-Type': 'application/json;charset=utf-8',
270 | 'Referer': 'https://servicewechat.com/wx9be0a7d24db348e8/241/page-frame.html',
271 | 'Accept-Encoding': 'gzip, deflate, br',
272 |
273 | }
274 | }
275 | }
276 |
277 | function luojiget(a) {
278 | return {
279 |
280 | url: `${host}${a}`,
281 | headers: {
282 |
283 | 'Host': 'api.wincheers.net',
284 | 'Connection': 'keep-alive',
285 | 'Authorization': luojihd,
286 | 'User-Agent': 'Mozilla/5.0 (Linux; Android 12; 21051182C Build/SKQ1.220303.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/4425 MMWEBSDK/20221206 Safari/537.36 MMWEBID/3637 MicroMessenger/8.0.32.2300(0x280020F8) WeChat/arm64 Weixin Android Tablet NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android',
287 | 'client_id': 'LogitechFans',
288 | 'content-type': 'application/json;charset=utf-8',
289 | 'Referer': 'https://servicewechat.com/wx9be0a7d24db348e8/241/page-frame.html',
290 | 'Accept-Encoding': 'gzip, deflate, br',
291 |
292 | }
293 | }
294 | }
295 | function safeGet(data) {
296 | try {
297 | if (typeof JSON.parse(data) == "object") {
298 | return true;
299 | }
300 | } catch (e) {
301 | console.log(e);
302 | console.log(`服务器访问数据为空,请检查自身设备网络情况`);
303 | return false;
304 | }
305 | }
306 | function jsonParse(str) {
307 | if (typeof str == "string") {
308 | try {
309 | return JSON.parse(str);
310 | } catch (e) {
311 | console.log(e);
312 | $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
313 | return [];
314 | }
315 | }
316 | }
317 |
318 | function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();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){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)}
319 |
--------------------------------------------------------------------------------
/yangmao/hdl.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 海底捞小程序签到
3 | * cron 9 15 * * * hdl.js
4 | *
5 | * ========= 青龙--配置文件 ===========
6 | * # 项目名称
7 | * export hdl_data='token @ token'
8 | *
9 | * 多账号用 换行 或 @ 分割
10 | * 抓包 https://superapp-public.kiwa-tech.com/activity/wxapp , 找到 _haidilao_app_token 即可
11 | * ====================================
12 | *
13 | */
14 |
15 |
16 |
17 | const $ = new Env("海底捞小程序签到");
18 | const ckName = "hdl_data";
19 | //-------------------- 一般不动变量区域 -------------------------------------
20 | const Notify = 1; //0为关闭通知,1为打开通知,默认为1
21 | let debug = 1; //Debug调试 0关闭 1开启
22 | let envSplitor = ["@", "\n"]; //多账号分隔符
23 | let ck = msg = ''; //let ck,msg
24 | let host, hostname;
25 | let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || '';
26 | let userList = [];
27 | let userIdx = 0;
28 | let userCount = 0;
29 | //---------------------- 自定义变量区域 -----------------------------------
30 | //---------------------------------------------------------
31 |
32 | async function start() {
33 |
34 |
35 | console.log('\n================== 用户CK ==================\n');
36 | taskall = [];
37 | for (let user of userList) {
38 | taskall.push(await user.user_info());
39 | await $.wait(1000); //延迟 1秒 可充分利用 $.环境函数
40 | }
41 | await Promise.all(taskall);
42 | console.log('\n================== 每日签到 ==================\n');
43 | taskall = [];
44 | for (let user of userList) {
45 | if (user.ckStatus) {
46 | taskall.push(await user.task_signin());
47 | await $.wait(1000); //延迟 1秒 可充分利用 $.环境函数
48 | }
49 | }
50 | await Promise.all(taskall);
51 |
52 |
53 |
54 | }
55 |
56 |
57 | class UserInfo {
58 | constructor(str) {
59 | this.index = ++userIdx;
60 | this.ck = str.split('&')[0]; //单账号多变量分隔符
61 | //let ck = str.split('&')
62 | //this.data1 = ck[0]
63 | this.ckStatus = true
64 |
65 | }
66 | async user_info() {
67 | try {
68 | let options = {
69 | url: `https://superapp-public.kiwa-tech.com/activity/wxapp/signin/queryFragment`,
70 | headers: {
71 | 'Host': 'superapp-public.kiwa-tech.com',
72 | 'deviceid': 'null',
73 | 'accept': 'application/json, text/plain, */*',
74 | 'Content-Type': 'application/json',
75 | 'user-agent': 'Mozilla/5.0 (Linux; Android 13; 21051182C Build/TKQ1.221013.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/107.0.5304.141 Safari/537.36 XWEB/5015 MMWEBSDK/20230202 MMWEBID/3637 MicroMessenger/8.0.33.2320(0x28002137) WeChat/arm64 Weixin Android Tablet NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android',
76 | 'reqtype': 'APPH5',
77 | '_haidilao_app_token': this.ck,
78 | 'origin': 'https://superapp-public.kiwa-tech.com',
79 | 'x-requested-with': 'com.tencent.mm',
80 | 'sec-fetch-site': 'same-origin',
81 | 'sec-fetch-mode': 'cors',
82 | 'sec-fetch-dest': 'empty',
83 | 'referer': 'https://superapp-public.kiwa-tech.com/app-sign-in/?SignInToken=TOKEN_APP_43d25436-b429-4233-b8b2-1154d2f20cb1&source=MiniApp',
84 | //'accept-encoding': 'gzip, deflate',
85 | //'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
86 | //'cookie': 'acw_tc=276077d816790340702268060ebd6e7110d795d232fb1ab1f149da5eab9f10'
87 | },
88 | body: ''
89 | }
90 | //console.log(options);
91 | let result = await httpRequest(options);
92 | //console.log(result);
93 | if (result.success == true) {
94 | DoubleLog(`账号[${this.index}] ck验证成功: 剩余[${result.data.total}] `);
95 | this.ckStatus = true
96 |
97 | } else {
98 | DoubleLog(`账号[${this.index}] ck验证失效:,原因未知!`);
99 | this.ckStatus = false
100 |
101 | console.log(result);
102 | }
103 | } catch (e) {
104 | console.log(e);
105 | }
106 | }
107 | async task_signin() {
108 | try {
109 | let options = {
110 | url: `https://superapp-public.kiwa-tech.com/activity/wxapp/signin/signin`,
111 | headers: {
112 | 'Host': 'superapp-public.kiwa-tech.com',
113 | 'deviceid': 'null',
114 | 'accept': 'application/json, text/plain, */*',
115 | 'Content-Type': 'application/json',
116 | 'user-agent': 'Mozilla/5.0 (Linux; Android 13; 21051182C Build/TKQ1.221013.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/107.0.5304.141 Safari/537.36 XWEB/5015 MMWEBSDK/20230202 MMWEBID/3637 MicroMessenger/8.0.33.2320(0x28002137) WeChat/arm64 Weixin Android Tablet NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android',
117 | 'reqtype': 'APPH5',
118 | '_haidilao_app_token': this.ck,
119 | 'origin': 'https://superapp-public.kiwa-tech.com',
120 | 'x-requested-with': 'com.tencent.mm',
121 | 'sec-fetch-site': 'same-origin',
122 | 'sec-fetch-mode': 'cors',
123 | 'sec-fetch-dest': 'empty',
124 | 'referer': 'https://superapp-public.kiwa-tech.com/app-sign-in/?SignInToken=TOKEN_APP_43d25436-b429-4233-b8b2-1154d2f20cb1&source=MiniApp',
125 | //'accept-encoding': 'gzip, deflate',
126 | //'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
127 | //'cookie': 'acw_tc=276077d816790340702268060ebd6e7110d795d232fb1ab1f149da5eab9f10'
128 | },
129 | body: JSON.stringify({ "signinSource": "MiniApp" })
130 | }
131 | //console.log(options);
132 | let result = await httpRequest(options);
133 | //console.log(result);
134 | if (result.success == true) {
135 | DoubleLog(`账号[${this.index}] 签到成功: [${result.data.signinQueryDetailList[0].dailyDate}] [${result.data.signinQueryDetailList[1].dailyDate}] `);
136 |
137 | } else {
138 | DoubleLog(`账号[${this.index}] 签到失效:,原因未知!`);
139 | console.log(result);
140 | }
141 | } catch (e) {
142 | console.log(e);
143 | }
144 | }
145 |
146 |
147 |
148 |
149 | }
150 |
151 | !(async () => {
152 | if (!(await checkEnv())) return;
153 | if (userList.length > 0) {
154 | await start();
155 | }
156 | await SendMsg(msg);
157 | })()
158 | .catch((e) => console.log(e))
159 | .finally(() => $.done());
160 |
161 |
162 | //********************************************************
163 | // 变量检查与处理
164 | async function checkEnv() {
165 | if (userCookie) {
166 | // console.log(userCookie);
167 | let e = envSplitor[0];
168 | for (let o of envSplitor)
169 | if (userCookie.indexOf(o) > -1) {
170 | e = o;
171 | break;
172 | }
173 | for (let n of userCookie.split(e)) n && userList.push(new UserInfo(n));
174 | userCount = userList.length;
175 | } else {
176 | console.log("未找到CK");
177 | return;
178 | }
179 | return console.log(`共找到${userCount}个账号`), true;//true == !0
180 | }
181 | /////////////////////////////////////////////////////////////////////////////////////
182 |
183 | function httpRequest(options, method) {
184 | //options = changeCode(options)
185 | typeof (method) === 'undefined' ? ('body' in options ? method = 'post' : method = 'get') : method = method
186 | return new Promise((resolve) => {
187 | $[method](options, (err, resp, data) => {
188 | try {
189 | if (err) {
190 | console.log(`${method}请求失败`);
191 | //console.log(JSON.parse(err));
192 | $.logErr(err);
193 | //throw new Error(err);
194 | //console.log(err);
195 | } else {
196 | //httpResult = data;
197 | //httpResponse = resp;
198 | if (data) {
199 | //console.log(data);
200 | data = JSON.parse(data);
201 | resolve(data)
202 | } else {
203 | console.log(`请求api返回数据为空,请检查自身原因`)
204 | }
205 | }
206 | } catch (e) {
207 | //console.log(e, resp);
208 | $.logErr(e, resp);
209 | } finally {
210 | resolve();
211 | }
212 | })
213 | })
214 | }
215 | // 双平台log输出
216 | function DoubleLog(data) {
217 | if ($.isNode()) {
218 | if (data) {
219 | console.log(`${data}`);
220 | msg += `\n${data}`
221 | }
222 | } else {
223 | console.log(`${data}`);
224 | msg += `\n${data}`
225 | }
226 | }
227 | // 发送消息
228 | async function SendMsg(message) {
229 | if (!message) return;
230 | if (Notify > 0) {
231 | if ($.isNode()) {
232 | var notify = require("./sendNotify");
233 | await notify.sendNotify($.name, message)
234 | } else {
235 | $.msg($.name, '', message)
236 | }
237 | } else {
238 | console.log(message)
239 | }
240 | }
241 | // 完整 Env
242 | 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) }
243 |
--------------------------------------------------------------------------------
/yangmao/mxbc.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 蜜雪冰城
3 | * cron 11 12 * * * mxbc.js
4 | * 感谢大佬的代码
5 | * ========= 青龙--配置文件 ===========
6 | * # 项目名称
7 | * export mxbc_data='token @ token'
8 | *
9 | * 多账号用 换行 或 @ 分割
10 | * 抓包 mxsa.mxbc.net/api , 找到 Access-Token 即可
11 | * ====================================
12 | *
13 | */
14 |
15 |
16 |
17 | const $ = new Env("蜜雪冰城");
18 | const ckName = "mxbc_data";
19 | //-------------------- 一般不动变量区域 -------------------------------------
20 | const Notify = 1; //0为关闭通知,1为打开通知,默认为1
21 | let debug = 1; //Debug调试 0关闭 1开启
22 | let envSplitor = ["@", "\n"]; //多账号分隔符
23 | let ck = msg = ''; //let ck,msg
24 | let host, hostname;
25 | let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || '';
26 | let userList = [];
27 | let userIdx = 0;
28 | let userCount = 0;
29 | //---------------------- 自定义变量区域 -----------------------------------
30 | //---------------------------------------------------------
31 |
32 | async function start() {
33 |
34 |
35 | console.log('\n================== 用户CK ==================\n');
36 | taskall = [];
37 | for (let user of userList) {
38 | taskall.push(await user.user_info());
39 | await $.wait(1000); //延迟 1秒 可充分利用 $.环境函数
40 | }
41 | await Promise.all(taskall);
42 | console.log('\n================== 每日签到 ==================\n');
43 | taskall = [];
44 | for (let user of userList) {
45 | if (user.ckStatus) {
46 | taskall.push(await user.task_signin());
47 | await $.wait(1000); //延迟 1秒 可充分利用 $.环境函数
48 | }
49 | }
50 | await Promise.all(taskall);
51 |
52 |
53 |
54 | }
55 |
56 |
57 | class UserInfo {
58 | constructor(str) {
59 | this.index = ++userIdx;
60 | this.ck = str.split('&')[0]; //单账号多变量分隔符
61 | //let ck = str.split('&')
62 | //this.data1 = ck[0]
63 | this.ckStatus = true
64 |
65 | }
66 | async user_info() {
67 | try {
68 | let options = {
69 | url: `https://mxsa.mxbc.net/api/v1/customer/info?appId=d82be6bbc1da11eb9dd000163e122ecb&t=${ts13()}&sign=${getSHA256withRSA('appId=d82be6bbc1da11eb9dd000163e122ecb&t=' + ts13())}`,
70 | headers: {
71 | 'app': 'mxbc',
72 | 'appchannel': 'xiaomi',
73 | 'appversion': '3.0.3',
74 | 'Access-Token': this.ck,
75 | 'Host': 'mxsa.mxbc.net',
76 | 'Connection': 'Keep-Alive',
77 | //'Accept-Encoding': 'gzip',
78 | 'User-Agent': 'okhttp/4.4.1'
79 | }
80 | }
81 | //console.log(options);
82 | let result = await httpRequest(options);
83 | //console.log(result);
84 | if (result.code == 0) {
85 | DoubleLog(`账号[${this.index}] 用户CK有效: [${result.data.mobilePhone}] 雪王币剩余[${result.data.customerPoint}]`);
86 | this.ckStatus = true
87 |
88 | } else {
89 | DoubleLog(`账号[${this.index}] 用户CK失效:,原因未知!`);
90 | this.ckStatus = false
91 |
92 | console.log(result);
93 | }
94 | } catch (e) {
95 | console.log(e);
96 | }
97 | }
98 | async task_signin() {
99 | try {
100 | let options = {
101 | url: `https://mxsa.mxbc.net/api/v1/customer/signin?appId=d82be6bbc1da11eb9dd000163e122ecb&t=${ts13()}&sign=${getSHA256withRSA('appId=d82be6bbc1da11eb9dd000163e122ecb&t=' + ts13())}`,
102 | headers: {
103 | 'app': 'mxbc',
104 | 'appchannel': 'xiaomi',
105 | 'appversion': '3.0.3',
106 | 'Access-Token': this.ck,
107 | 'Host': 'mxsa.mxbc.net',
108 | 'Connection': 'Keep-Alive',
109 | //'Accept-Encoding': 'gzip',
110 | 'User-Agent': 'okhttp/4.4.1'
111 | }
112 | }
113 | //console.log(options);
114 | let result = await httpRequest(options);
115 | //console.log(result);
116 | if (result.code == 0) {
117 | DoubleLog(`账号[${this.index}] 签到成功:累计签到 [${result.data.ruleValueGrowth}]天 本次获得[${result.data.ruleValuePoint}]币`);
118 | this.ckStatus = true
119 |
120 | } else {
121 | DoubleLog(`账号[${this.index}] 签到:失败 ❌ 了呢,原因未知!`);
122 | console.log(result);
123 | }
124 | } catch (e) {
125 | console.log(e);
126 | }
127 | }
128 |
129 |
130 |
131 |
132 | }
133 |
134 | !(async () => {
135 | if (!(await checkEnv())) return;
136 | if (userList.length > 0) {
137 | await start();
138 | }
139 | await SendMsg(msg);
140 | })()
141 | .catch((e) => console.log(e))
142 | .finally(() => $.done());
143 |
144 |
145 | //********************************************************
146 | // 变量检查与处理
147 | async function checkEnv() {
148 | if (userCookie) {
149 | // console.log(userCookie);
150 | let e = envSplitor[0];
151 | for (let o of envSplitor)
152 | if (userCookie.indexOf(o) > -1) {
153 | e = o;
154 | break;
155 | }
156 | for (let n of userCookie.split(e)) n && userList.push(new UserInfo(n));
157 | userCount = userList.length;
158 | } else {
159 | console.log("未找到CK");
160 | return;
161 | }
162 | return console.log(`共找到${userCount}个账号`), true;//true == !0
163 | }
164 | /////////////////////////////////////////////////////////////////////////////////////
165 | var rs = require("jsrsasign");
166 |
167 | var privateKeyString = `-----BEGIN PRIVATE KEY-----
168 | MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCtypUdHZJKlQ9L
169 | L6lIJSphnhqjke7HclgWuWDRWvzov30du235cCm13mqJ3zziqLCwstdQkuXo9sOP
170 | Ih94t6nzBHTuqYA1whrUnQrKfv9X4/h3QVkzwT+xWflE+KubJZoe+daLKkDeZjVW
171 | nUku8ov0E5vwADACfntEhAwiSZUALX9UgNDTPbj5ESeII+VztZ/KOFsRHMTfDb1G
172 | IR/dAc1mL5uYbh0h2Fa/fxRPgf7eJOeWGiygesl3CWj0Ue13qwX9PcG7klJXfToI
173 | 576MY+A7027a0aZ49QhKnysMGhTdtFCksYG0lwPz3bIR16NvlxNLKanc2h+ILTFQ
174 | bMW/Y3DRAgMBAAECggEBAJGTfX6rE6zX2bzASsu9HhgxKN1VU6/L70/xrtEPp4SL
175 | SpHKO9/S/Y1zpsigr86pQYBx/nxm4KFZewx9p+El7/06AX0djOD7HCB2/+AJq3iC
176 | 5NF4cvEwclrsJCqLJqxKPiSuYPGnzji9YvaPwArMb0Ff36KVdaHRMw58kfFys5Y2
177 | HvDqh4x+sgMUS7kSEQT4YDzCDPlAoEFgF9rlXnh0UVS6pZtvq3cR7pR4A9hvDgX9
178 | wU6zn1dGdy4MEXIpckuZkhwbqDLmfoHHeJc5RIjRP7WIRh2CodjetgPFE+SV7Sdj
179 | ECmvYJbet4YLg+Qil0OKR9s9S1BbObgcbC9WxUcrTgECgYEA/Yj8BDfxcsPK5ebE
180 | 9N2teBFUJuDcHEuM1xp4/tFisoFH90JZJMkVbO19rddAMmdYLTGivWTyPVsM1+9s
181 | tq/NwsFJWHRUiMK7dttGiXuZry+xvq/SAZoitgI8tXdDXMw7368vatr0g6m7ucBK
182 | jZWxSHjK9/KVquVr7BoXFm+YxaECgYEAr3sgVNbr5ovx17YriTqe1FLTLMD5gPrz
183 | ugJj7nypDYY59hLlkrA/TtWbfzE+vfrN3oRIz5OMi9iFk3KXFVJMjGg+M5eO9Y8m
184 | 14e791/q1jUuuUH4mc6HttNRNh7TdLg/OGKivE+56LEyFPir45zw/dqwQM3jiwIz
185 | yPz/+bzmfTECgYATxrOhwJtc0FjrReznDMOTMgbWYYPJ0TrTLIVzmvGP6vWqG8rI
186 | S8cYEA5VmQyw4c7G97AyBcW/c3K1BT/9oAj0wA7wj2JoqIfm5YPDBZkfSSEcNqqy
187 | 5Ur/13zUytC+VE/3SrrwItQf0QWLn6wxDxQdCw8J+CokgnDAoehbH6lTAQKBgQCE
188 | 67T/zpR9279i8CBmIDszBVHkcoALzQtU+H6NpWvATM4WsRWoWUx7AJ56Z+joqtPK
189 | G1WztkYdn/L+TyxWADLvn/6Nwd2N79MyKyScKtGNVFeCCJCwoJp4R/UaE5uErBNn
190 | OH+gOJvPwHj5HavGC5kYENC1Jb+YCiEDu3CB0S6d4QKBgQDGYGEFMZYWqO6+LrfQ
191 | ZNDBLCI2G4+UFP+8ZEuBKy5NkDVqXQhHRbqr9S/OkFu+kEjHLuYSpQsclh6XSDks
192 | 5x/hQJNQszLPJoxvGECvz5TN2lJhuyCupS50aGKGqTxKYtiPHpWa8jZyjmanMKnE
193 | dOGyw/X4SFyodv8AEloqd81yGg==
194 | -----END PRIVATE KEY-----
195 | `;
196 | function getSHA256withRSA(content) {
197 | const key = rs.KEYUTIL.getKey(privateKeyString);
198 |
199 | const signature = new rs.KJUR.crypto.Signature({ alg: "SHA256withRSA" });
200 |
201 | signature.init(key);
202 |
203 | signature.updateString(content);
204 |
205 | const originSign = signature.sign();
206 | const sign64u = rs.hextob64u(originSign);
207 |
208 | return sign64u;
209 | }
210 | function ts13() {
211 | return Math.round(new Date().getTime()).toString();
212 | }
213 |
214 | function httpRequest(options, method) {
215 | //options = changeCode(options)
216 | typeof (method) === 'undefined' ? ('body' in options ? method = 'post' : method = 'get') : method = method
217 | return new Promise((resolve) => {
218 | $[method](options, (err, resp, data) => {
219 | try {
220 | if (err) {
221 | console.log(`${method}请求失败`);
222 | //console.log(JSON.parse(err));
223 | $.logErr(err);
224 | //throw new Error(err);
225 | //console.log(err);
226 | } else {
227 | //httpResult = data;
228 | //httpResponse = resp;
229 | if (data) {
230 | //console.log(data);
231 | data = JSON.parse(data);
232 | resolve(data)
233 | } else {
234 | console.log(`请求api返回数据为空,请检查自身原因`)
235 | }
236 | }
237 | } catch (e) {
238 | //console.log(e, resp);
239 | $.logErr(e, resp);
240 | } finally {
241 | resolve();
242 | }
243 | })
244 | })
245 | }
246 | // 双平台log输出
247 | function DoubleLog(data) {
248 | if ($.isNode()) {
249 | if (data) {
250 | console.log(`${data}`);
251 | msg += `\n${data}`
252 | }
253 | } else {
254 | console.log(`${data}`);
255 | msg += `\n${data}`
256 | }
257 | }
258 | // 发送消息
259 | async function SendMsg(message) {
260 | if (!message) return;
261 | if (Notify > 0) {
262 | if ($.isNode()) {
263 | var notify = require("./sendNotify");
264 | await notify.sendNotify($.name, message)
265 | } else {
266 | $.msg($.name, '', message)
267 | }
268 | } else {
269 | console.log(message)
270 | }
271 | }
272 | // 完整 Env
273 | 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) }
274 |
--------------------------------------------------------------------------------
/yangmao/hezj.js:
--------------------------------------------------------------------------------
1 | /**
2 | * 海尔智家
3 | * cron 8 1 * * * hezj.js
4 | * 活动入口 首页 智慧小屋
5 | * 2023/03/18 修复BUG
6 | * ========= 青龙--配置文件 ===========
7 | * # 项目名称
8 | * export hezj_data='token&clientId @ token&clientId '
9 | *
10 | * 多账号用 换行 或 @ 分割
11 | * 抓包 https://mps.haiersmarthomes.com/api-gw , 找到accounttoken/accesstoken & clientId即可
12 | * ====================================
13 | *
14 | */
15 |
16 |
17 |
18 | const $ = new Env("海尔智家");
19 | const ckName = "hezj_data";
20 | //-------------------- 一般不动变量区域 -------------------------------------
21 | const Notify = 1; //0为关闭通知,1为打开通知,默认为1
22 | let debug = 1; //Debug调试 0关闭 1开启
23 | let envSplitor = ["@", "\n"]; //多账号分隔符
24 | let ck = msg = ''; //let ck,msg
25 | let host, hostname;
26 | let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || '';
27 | let userList = [];
28 | let userIdx = 0;
29 | let userCount = 0;
30 | //---------------------- 自定义变量区域 -----------------------------------
31 | //---------------------------------------------------------
32 |
33 | async function start() {
34 |
35 | console.log('\n================== 用户CK ==================\n');
36 | taskall = [];
37 | for (let user of userList) {
38 | taskall.push(await user.task_userinfo());
39 | await $.wait(3000); //延迟 1秒 可充分利用 $.环境函数
40 | }
41 | await Promise.all(taskall);
42 | console.log('\n================== 用户签到 ==================\n');
43 | taskall = [];
44 | for (let user of userList) {
45 | if (user.ckStatus) {
46 |
47 | taskall.push(await user.task_signin());
48 | await $.wait(3000); //延迟 1秒 可充分利用 $.环境函数
49 | }
50 | }
51 | await Promise.all(taskall);
52 | console.log('\n================== 获取任务列表 ==================\n');
53 | taskall = [];
54 | for (let user of userList) {
55 | if (user.ckStatus) {
56 | taskall.push(await user.task_list());
57 | await $.wait(3000); //延迟 1秒 可充分利用 $.环境函数
58 | }
59 | }
60 | await Promise.all(taskall);
61 | console.log('\n================== 执行任务 ==================\n');
62 | taskall = [];
63 | for (let user of userList) {
64 | if (user.ckStatus) {
65 | for (let num in user.taskList) {
66 | if (user.taskList[num].taskStatus == 0) {
67 | taskall.push(await user.task_do(user.taskList[num].taskCode));
68 | } else {
69 | console.log('当前任务已完成');
70 | }
71 | }
72 | await $.wait(5000); //延迟 1秒 可充分利用 $.环境函数
73 | }
74 | }
75 | await Promise.all(taskall);
76 |
77 |
78 |
79 | }
80 |
81 |
82 | class UserInfo {
83 | constructor(str) {
84 | this.index = ++userIdx;
85 | this.ck = str.split('&')[0]; //单账号多变量分隔符
86 | this.clientid = str.split('&')[1];
87 | //let ck = str.split('&')
88 | //this.data1 = ck[0]
89 | this.ckStatus = true
90 | this.taskList = '';
91 | this.headersPost = {
92 | 'Host': 'mps.haiersmarthomes.com',
93 | 'accesstoken': this.ck,
94 | 'origin': 'https://zjrs.haier.net',
95 | 'user-agent': 'Mozilla/5.0 (Linux; U; Android 13; zh-CN; 21051182C Build/TKQ1.221013.002) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/69.0.3497.100 UWS/3.22.2.55 Mobile Safari/537.36 UCBS/3.22.2.55_220929181439 ChannelId(2) NebulaSDK/1.8.100112 Nebula App/Uplus Nebula mPaaSClient',
96 | 'Content-Type': 'application/json;charset=UTF-8',
97 | 'accept': 'application/json, text/plain, */*',
98 | 'clientid': this.clientid,
99 | 'timestamp': ts13(),
100 | 'accounttoken': this.ck,
101 | 'appid': 'MB-UZHSH-0000',
102 | 'appkey': 'f50c76fbc8271d361e1f6b5973f54585',
103 | 'appversion': '7.19.1',
104 | 'referer': 'https://zjrs.haier.net/haierActivitys/intelligentHouse/index.html?container_type=3&hybrid_navbar_hidden=true&needAuthLogin=1&needLogin=1&needShare=1&checkGuestMode=1',
105 | //'accept-encoding: 'gzip, deflate'
106 | //'accept-language': 'zh-CN,en-US;q=0.9'
107 | 'x-requested-with': 'com.haier.uhome.uplus'
108 | }
109 |
110 | }
111 | async task_userinfo() {//userinfo
112 | try {
113 | let options = {
114 | url: `https://mps.haiersmarthomes.com/api-gw/wisdomHouseActivity/activity/index`,
115 | headers: this.headersPost,
116 | body: JSON.stringify({ "sourceClient": 1 })
117 | }
118 | //console.log(options);
119 | let result = await httpRequest(options);
120 | //console.log(result);
121 | if (result.retCode == '00000') {
122 | DoubleLog(`账号[${this.index}] ck验证成功: [${result.data.nickName}] 当前贝壳 [${result.data.wisdomStarBalance}] `);
123 | this.ckStatus = true
124 | } else {
125 | DoubleLog(`账号[${this.index}] ck验证失效,原因未知!`);
126 | this.ckStatus = false
127 | console.log(result);
128 | }
129 | } catch (e) {
130 | console.log(e);
131 | }
132 | }
133 | async task_signin() {
134 | try {
135 | let options = {
136 | url: `https://mps.haiersmarthomes.com/api-gw/wisdomHouseActivity/sign/signIn`,
137 | headers: this.headersPost,
138 | body: JSON.stringify({ "sourceClient": 1 })
139 | }
140 | //console.log(options);
141 | let result = await httpRequest(options);
142 | //console.log(result);
143 | if (result.retCode == '00000') {
144 | DoubleLog(`账号[${this.index}] 签到成功: 累计签到[${result.data.signDays}] `);
145 | } else {
146 | DoubleLog(`账号[${this.index}] 签到失效,原因未知!`);
147 |
148 | console.log(result);
149 | }
150 | } catch (e) {
151 | console.log(e);
152 | }
153 | }
154 | async task_list() {//任务列表
155 | try {
156 | let options = {
157 | url: `https://mps.haiersmarthomes.com/api-gw/wisdomHouseActivity/task/queryTask`,
158 | headers: this.headersPost,
159 | body: JSON.stringify({ "publishType": 2, "sourceClient": 1 })
160 | }
161 | //console.log(options);
162 | let result = await httpRequest(options);
163 | //console.log(result);
164 | if (result.retCode == '00000') {
165 | this.taskList = result.data.taskList
166 | } else {
167 | console.log(result);
168 | }
169 | } catch (e) {
170 | console.log(e);
171 | }
172 | }
173 | async task_do(taskCode) {//任务列表
174 | try {
175 | let options = {
176 | url: `https://mps.haiersmarthomes.com/api-gw/wisdomHouseActivity/task/doTask`,
177 | headers: this.headersPost,
178 | body: JSON.stringify({ "taskCode": taskCode, "sourceClient": 1 })
179 | }
180 | //console.log(options);
181 | let result = await httpRequest(options);
182 | //console.log(result);
183 | if (result.retCode == '00000') {
184 | DoubleLog(`账号[${this.index}] 任务执行成功: [${taskCode}] `);
185 |
186 | } else {
187 | DoubleLog(`账号[${this.index}] 任务执行失效:,原因未知!`);
188 | console.log(result);
189 | }
190 | } catch (e) {
191 | console.log(e);
192 | }
193 | }
194 |
195 |
196 |
197 | }
198 |
199 | !(async () => {
200 | if (!(await checkEnv())) return;
201 | if (userList.length > 0) {
202 | await start();
203 | }
204 | await SendMsg(msg);
205 | })()
206 | .catch((e) => console.log(e))
207 | .finally(() => $.done());
208 |
209 |
210 | //********************************************************
211 | // 变量检查与处理
212 | async function checkEnv() {
213 | if (userCookie) {
214 | // console.log(userCookie);
215 | let e = envSplitor[0];
216 | for (let o of envSplitor)
217 | if (userCookie.indexOf(o) > -1) {
218 | e = o;
219 | break;
220 | }
221 | for (let n of userCookie.split(e)) n && userList.push(new UserInfo(n));
222 | userCount = userList.length;
223 | } else {
224 | console.log("未找到CK");
225 | return;
226 | }
227 | return console.log(`共找到${userCount}个账号`), true;//true == !0
228 | }
229 | /////////////////////////////////////////////////////////////////////////////////////
230 |
231 | function httpRequest(options, method) {
232 | //options = changeCode(options)
233 | typeof (method) === 'undefined' ? ('body' in options ? method = 'post' : method = 'get') : method = method
234 | return new Promise((resolve) => {
235 | $[method](options, (err, resp, data) => {
236 | try {
237 | if (err) {
238 | console.log(`${method}请求失败`);
239 | //console.log(JSON.parse(err));
240 | $.logErr(err);
241 | //throw new Error(err);
242 | //console.log(err);
243 | } else {
244 | //httpResult = data;
245 | //httpResponse = resp;
246 | if (data) {
247 | //console.log(data);
248 | data = JSON.parse(data);
249 | resolve(data)
250 | } else {
251 | console.log(`请求api返回数据为空,请检查自身原因`)
252 | }
253 | }
254 | } catch (e) {
255 | //console.log(e, resp);
256 | $.logErr(e, resp);
257 | } finally {
258 | resolve();
259 | }
260 | })
261 | })
262 | }
263 | function ts13() {
264 | return Math.round(new Date().getTime()).toString();
265 | }
266 | // 双平台log输出
267 | function DoubleLog(data) {
268 | if ($.isNode()) {
269 | if (data) {
270 | console.log(`${data}`);
271 | msg += `\n${data}`
272 | }
273 | } else {
274 | console.log(`${data}`);
275 | msg += `\n${data}`
276 | }
277 | }
278 | // 发送消息
279 | async function SendMsg(message) {
280 | if (!message) return;
281 | if (Notify > 0) {
282 | if ($.isNode()) {
283 | var notify = require("./sendNotify");
284 | await notify.sendNotify($.name, message)
285 | } else {
286 | $.msg($.name, '', message)
287 | }
288 | } else {
289 | console.log(message)
290 | }
291 | }
292 | // 完整 Env
293 | 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) }
294 |
--------------------------------------------------------------------------------
/notify.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # _*_ coding:utf-8 _*_
3 | import base64
4 | import hashlib
5 | import hmac
6 | import json
7 | import os
8 | import re
9 | import threading
10 | import time
11 | import urllib.parse
12 |
13 | import requests
14 |
15 | # 原先的 print 函数和主线程的锁
16 | _print = print
17 | mutex = threading.Lock()
18 |
19 |
20 | # 定义新的 print 函数
21 | def print(text, *args, **kw):
22 | """
23 | 使输出有序进行,不出现多线程同一时间输出导致错乱的问题。
24 | """
25 | with mutex:
26 | _print(text, *args, **kw)
27 |
28 |
29 | # 通知服务
30 | # fmt: off
31 | push_config = {
32 | 'HITOKOTO': False, # 启用一言(随机句子)
33 |
34 | 'BARK_PUSH': '', # bark IP 或设备码,例:https://api.day.app/DxHcxxxxxRxxxxxxcm/
35 | 'BARK_ARCHIVE': '', # bark 推送是否存档
36 | 'BARK_GROUP': '', # bark 推送分组
37 | 'BARK_SOUND': '', # bark 推送声音
38 | 'BARK_ICON': '', # bark 推送图标
39 |
40 | 'CONSOLE': True, # 控制台输出
41 |
42 | 'DD_BOT_SECRET': '', # 钉钉机器人的 DD_BOT_SECRET
43 | 'DD_BOT_TOKEN': '', # 钉钉机器人的 DD_BOT_TOKEN
44 |
45 | 'FSKEY': '', # 飞书机器人的 FSKEY
46 |
47 | 'GOBOT_URL': '', # go-cqhttp
48 | # 推送到个人QQ:http://127.0.0.1/send_private_msg
49 | # 群:http://127.0.0.1/send_group_msg
50 | 'GOBOT_QQ': '', # go-cqhttp 的推送群或用户
51 | # GOBOT_URL 设置 /send_private_msg 时填入 user_id=个人QQ
52 | # /send_group_msg 时填入 group_id=QQ群
53 | 'GOBOT_TOKEN': '', # go-cqhttp 的 access_token
54 |
55 | 'GOTIFY_URL': '', # gotify地址,如https://push.example.de:8080
56 | 'GOTIFY_TOKEN': '', # gotify的消息应用token
57 | 'GOTIFY_PRIORITY': 0, # 推送消息优先级,默认为0
58 |
59 | 'IGOT_PUSH_KEY': '', # iGot 聚合推送的 IGOT_PUSH_KEY
60 |
61 | 'PUSH_KEY': '', # server 酱的 PUSH_KEY,兼容旧版与 Turbo 版
62 |
63 | 'PUSH_PLUS_TOKEN': '', # push+ 微信推送的用户令牌
64 | 'PUSH_PLUS_USER': '', # push+ 微信推送的群组编码
65 |
66 | 'QMSG_KEY': '', # qmsg 酱的 QMSG_KEY
67 | 'QMSG_TYPE': '', # qmsg 酱的 QMSG_TYPE
68 |
69 | 'QYWX_AM': '', # 企业微信应用
70 |
71 | 'QYWX_KEY': '', # 企业微信机器人
72 |
73 | 'TG_BOT_TOKEN': '', # tg 机器人的 TG_BOT_TOKEN,例:1407203283:AAG9rt-6RDaaX0HBLZQq0laNOh898iFYaRQ
74 | 'TG_USER_ID': '', # tg 机器人的 TG_USER_ID,例:1434078534
75 | 'TG_API_HOST': '', # tg 代理 api
76 | 'TG_PROXY_AUTH': '', # tg 代理认证参数
77 | 'TG_PROXY_HOST': '', # tg 机器人的 TG_PROXY_HOST
78 | 'TG_PROXY_PORT': '', # tg 机器人的 TG_PROXY_PORT
79 | }
80 | notify_function = []
81 | # fmt: on
82 |
83 | # 首先读取 面板变量 或者 github action 运行变量
84 | for k in push_config:
85 | if os.getenv(k):
86 | v = os.getenv(k)
87 | push_config[k] = v
88 |
89 |
90 | def bark(title: str, content: str) -> None:
91 | """
92 | 使用 bark 推送消息。
93 | """
94 | if not push_config.get("BARK_PUSH"):
95 | print("bark 服务的 BARK_PUSH 未设置!!\n取消推送")
96 | return
97 | print("bark 服务启动")
98 |
99 | if push_config.get("BARK_PUSH").startswith("http"):
100 | url = f'{push_config.get("BARK_PUSH")}/{urllib.parse.quote_plus(title)}/{urllib.parse.quote_plus(content)}'
101 | else:
102 | url = f'https://api.day.app/{push_config.get("BARK_PUSH")}/{urllib.parse.quote_plus(title)}/{urllib.parse.quote_plus(content)}'
103 |
104 | bark_params = {
105 | "BARK_ARCHIVE": "isArchive",
106 | "BARK_GROUP": "group",
107 | "BARK_SOUND": "sound",
108 | "BARK_ICON": "icon",
109 | }
110 | params = ""
111 | for pair in filter(
112 | lambda pairs: pairs[0].startswith("BARK_")
113 | and pairs[0] != "BARK_PUSH"
114 | and pairs[1]
115 | and bark_params.get(pairs[0]),
116 | push_config.items(),
117 | ):
118 | params += f"{bark_params.get(pair[0])}={pair[1]}&"
119 | if params:
120 | url = url + "?" + params.rstrip("&")
121 | response = requests.get(url).json()
122 |
123 | if response["code"] == 200:
124 | print("bark 推送成功!")
125 | else:
126 | print("bark 推送失败!")
127 |
128 |
129 | def console(title: str, content: str) -> None:
130 | """
131 | 使用 控制台 推送消息。
132 | """
133 | print(f"{title}\n\n{content}")
134 |
135 |
136 | def dingding_bot(title: str, content: str) -> None:
137 | """
138 | 使用 钉钉机器人 推送消息。
139 | """
140 | if not push_config.get("DD_BOT_SECRET") or not push_config.get("DD_BOT_TOKEN"):
141 | print("钉钉机器人 服务的 DD_BOT_SECRET 或者 DD_BOT_TOKEN 未设置!!\n取消推送")
142 | return
143 | print("钉钉机器人 服务启动")
144 |
145 | timestamp = str(round(time.time() * 1000))
146 | secret_enc = push_config.get("DD_BOT_SECRET").encode("utf-8")
147 | string_to_sign = "{}\n{}".format(timestamp, push_config.get("DD_BOT_SECRET"))
148 | string_to_sign_enc = string_to_sign.encode("utf-8")
149 | hmac_code = hmac.new(
150 | secret_enc, string_to_sign_enc, digestmod=hashlib.sha256
151 | ).digest()
152 | sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
153 | url = f'https://oapi.dingtalk.com/robot/send?access_token={push_config.get("DD_BOT_TOKEN")}×tamp={timestamp}&sign={sign}'
154 | headers = {"Content-Type": "application/json;charset=utf-8"}
155 | data = {"msgtype": "text", "text": {"content": f"{title}\n\n{content}"}}
156 | response = requests.post(
157 | url=url, data=json.dumps(data), headers=headers, timeout=15
158 | ).json()
159 |
160 | if not response["errcode"]:
161 | print("钉钉机器人 推送成功!")
162 | else:
163 | print("钉钉机器人 推送失败!")
164 |
165 |
166 | def feishu_bot(title: str, content: str) -> None:
167 | """
168 | 使用 飞书机器人 推送消息。
169 | """
170 | if not push_config.get("FSKEY"):
171 | print("飞书 服务的 FSKEY 未设置!!\n取消推送")
172 | return
173 | print("飞书 服务启动")
174 |
175 | url = f'https://open.feishu.cn/open-apis/bot/v2/hook/{push_config.get("FSKEY")}'
176 | data = {"msg_type": "text", "content": {"text": f"{title}\n\n{content}"}}
177 | response = requests.post(url, data=json.dumps(data)).json()
178 |
179 | if response.get("StatusCode") == 0:
180 | print("飞书 推送成功!")
181 | else:
182 | print("飞书 推送失败!错误信息如下:\n", response)
183 |
184 |
185 | def go_cqhttp(title: str, content: str) -> None:
186 | """
187 | 使用 go_cqhttp 推送消息。
188 | """
189 | if not push_config.get("GOBOT_URL") or not push_config.get("GOBOT_QQ"):
190 | print("go-cqhttp 服务的 GOBOT_URL 或 GOBOT_QQ 未设置!!\n取消推送")
191 | return
192 | print("go-cqhttp 服务启动")
193 |
194 | url = f'{push_config.get("GOBOT_URL")}?access_token={push_config.get("GOBOT_TOKEN")}&{push_config.get("GOBOT_QQ")}&message=标题:{title}\n内容:{content}'
195 | response = requests.get(url).json()
196 |
197 | if response["status"] == "ok":
198 | print("go-cqhttp 推送成功!")
199 | else:
200 | print("go-cqhttp 推送失败!")
201 |
202 |
203 | def gotify(title:str,content:str) -> None:
204 | """
205 | 使用 gotify 推送消息。
206 | """
207 | if not push_config.get("GOTIFY_URL") or not push_config.get("GOTIFY_TOKEN"):
208 | print("gotify 服务的 GOTIFY_URL 或 GOTIFY_TOKEN 未设置!!\n取消推送")
209 | return
210 | print("gotify 服务启动")
211 |
212 | url = f'{push_config.get("GOTIFY_URL")}/message?token={push_config.get("GOTIFY_TOKEN")}'
213 | data = {"title": title,"message": content,"priority": push_config.get("GOTIFY_PRIORITY")}
214 | response = requests.post(url,data=data).json()
215 |
216 | if response.get("id"):
217 | print("gotify 推送成功!")
218 | else:
219 | print("gotify 推送失败!")
220 |
221 |
222 | def iGot(title: str, content: str) -> None:
223 | """
224 | 使用 iGot 推送消息。
225 | """
226 | if not push_config.get("IGOT_PUSH_KEY"):
227 | print("iGot 服务的 IGOT_PUSH_KEY 未设置!!\n取消推送")
228 | return
229 | print("iGot 服务启动")
230 |
231 | url = f'https://push.hellyw.com/{push_config.get("IGOT_PUSH_KEY")}'
232 | data = {"title": title, "content": content}
233 | headers = {"Content-Type": "application/x-www-form-urlencoded"}
234 | response = requests.post(url, data=data, headers=headers).json()
235 |
236 | if response["ret"] == 0:
237 | print("iGot 推送成功!")
238 | else:
239 | print(f'iGot 推送失败!{response["errMsg"]}')
240 |
241 |
242 | def serverJ(title: str, content: str) -> None:
243 | """
244 | 通过 serverJ 推送消息。
245 | """
246 | if not push_config.get("PUSH_KEY"):
247 | print("serverJ 服务的 PUSH_KEY 未设置!!\n取消推送")
248 | return
249 | print("serverJ 服务启动")
250 |
251 | data = {"text": title, "desp": content.replace("\n", "\n\n")}
252 | if push_config.get("PUSH_KEY").index("SCT") != -1:
253 | url = f'https://sctapi.ftqq.com/{push_config.get("PUSH_KEY")}.send'
254 | else:
255 | url = f'https://sc.ftqq.com/${push_config.get("PUSH_KEY")}.send'
256 | response = requests.post(url, data=data).json()
257 |
258 | if response.get("errno") == 0 or response.get("code") == 0:
259 | print("serverJ 推送成功!")
260 | else:
261 | print(f'serverJ 推送失败!错误码:{response["message"]}')
262 |
263 |
264 | def pushplus_bot(title: str, content: str) -> None:
265 | """
266 | 通过 push+ 推送消息。
267 | """
268 | if not push_config.get("PUSH_PLUS_TOKEN"):
269 | print("PUSHPLUS 服务的 PUSH_PLUS_TOKEN 未设置!!\n取消推送")
270 | return
271 | print("PUSHPLUS 服务启动")
272 |
273 | url = "http://www.pushplus.plus/send"
274 | data = {
275 | "token": push_config.get("PUSH_PLUS_TOKEN"),
276 | "title": title,
277 | "content": content,
278 | "topic": push_config.get("PUSH_PLUS_USER"),
279 | }
280 | body = json.dumps(data).encode(encoding="utf-8")
281 | headers = {"Content-Type": "application/json"}
282 | response = requests.post(url=url, data=body, headers=headers).json()
283 |
284 | if response["code"] == 200:
285 | print("PUSHPLUS 推送成功!")
286 |
287 | else:
288 |
289 | url_old = "http://pushplus.hxtrip.com/send"
290 | headers["Accept"] = "application/json"
291 | response = requests.post(url=url_old, data=body, headers=headers).json()
292 |
293 | if response["code"] == 200:
294 | print("PUSHPLUS(hxtrip) 推送成功!")
295 |
296 | else:
297 | print("PUSHPLUS 推送失败!")
298 |
299 |
300 | def qmsg_bot(title: str, content: str) -> None:
301 | """
302 | 使用 qmsg 推送消息。
303 | """
304 | if not push_config.get("QMSG_KEY") or not push_config.get("QMSG_TYPE"):
305 | print("qmsg 的 QMSG_KEY 或者 QMSG_TYPE 未设置!!\n取消推送")
306 | return
307 | print("qmsg 服务启动")
308 |
309 | url = f'https://qmsg.zendee.cn/{push_config.get("QMSG_TYPE")}/{push_config.get("QMSG_KEY")}'
310 | payload = {"msg": f'{title}\n\n{content.replace("----", "-")}'.encode("utf-8")}
311 | response = requests.post(url=url, params=payload).json()
312 |
313 | if response["code"] == 0:
314 | print("qmsg 推送成功!")
315 | else:
316 | print(f'qmsg 推送失败!{response["reason"]}')
317 |
318 |
319 | def wecom_app(title: str, content: str) -> None:
320 | """
321 | 通过 企业微信 APP 推送消息。
322 | """
323 | if not push_config.get("QYWX_AM"):
324 | print("QYWX_AM 未设置!!\n取消推送")
325 | return
326 | QYWX_AM_AY = re.split(",", push_config.get("QYWX_AM"))
327 | if 4 < len(QYWX_AM_AY) > 5:
328 | print("QYWX_AM 设置错误!!\n取消推送")
329 | return
330 | print("企业微信 APP 服务启动")
331 |
332 | corpid = QYWX_AM_AY[0]
333 | corpsecret = QYWX_AM_AY[1]
334 | touser = QYWX_AM_AY[2]
335 | agentid = QYWX_AM_AY[3]
336 | try:
337 | media_id = QYWX_AM_AY[4]
338 | except IndexError:
339 | media_id = ""
340 | wx = WeCom(corpid, corpsecret, agentid)
341 | # 如果没有配置 media_id 默认就以 text 方式发送
342 | if not media_id:
343 | message = title + "\n\n" + content
344 | response = wx.send_text(message, touser)
345 | else:
346 | response = wx.send_mpnews(title, content, media_id, touser)
347 |
348 | if response == "ok":
349 | print("企业微信推送成功!")
350 | else:
351 | print("企业微信推送失败!错误信息如下:\n", response)
352 |
353 |
354 | class WeCom:
355 | def __init__(self, corpid, corpsecret, agentid):
356 | self.CORPID = corpid
357 | self.CORPSECRET = corpsecret
358 | self.AGENTID = agentid
359 |
360 | def get_access_token(self):
361 | url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken"
362 | values = {
363 | "corpid": self.CORPID,
364 | "corpsecret": self.CORPSECRET,
365 | }
366 | req = requests.post(url, params=values)
367 | data = json.loads(req.text)
368 | return data["access_token"]
369 |
370 | def send_text(self, message, touser="@all"):
371 | send_url = (
372 | "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="
373 | + self.get_access_token()
374 | )
375 | send_values = {
376 | "touser": touser,
377 | "msgtype": "text",
378 | "agentid": self.AGENTID,
379 | "text": {"content": message},
380 | "safe": "0",
381 | }
382 | send_msges = bytes(json.dumps(send_values), "utf-8")
383 | respone = requests.post(send_url, send_msges)
384 | respone = respone.json()
385 | return respone["errmsg"]
386 |
387 | def send_mpnews(self, title, message, media_id, touser="@all"):
388 | send_url = (
389 | "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="
390 | + self.get_access_token()
391 | )
392 | send_values = {
393 | "touser": touser,
394 | "msgtype": "mpnews",
395 | "agentid": self.AGENTID,
396 | "mpnews": {
397 | "articles": [
398 | {
399 | "title": title,
400 | "thumb_media_id": media_id,
401 | "author": "Author",
402 | "content_source_url": "",
403 | "content": message.replace("\n", "
"),
404 | "digest": message,
405 | }
406 | ]
407 | },
408 | }
409 | send_msges = bytes(json.dumps(send_values), "utf-8")
410 | respone = requests.post(send_url, send_msges)
411 | respone = respone.json()
412 | return respone["errmsg"]
413 |
414 |
415 | def wecom_bot(title: str, content: str) -> None:
416 | """
417 | 通过 企业微信机器人 推送消息。
418 | """
419 | if not push_config.get("QYWX_KEY"):
420 | print("企业微信机器人 服务的 QYWX_KEY 未设置!!\n取消推送")
421 | return
422 | print("企业微信机器人服务启动")
423 |
424 | url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={push_config.get('QYWX_KEY')}"
425 | headers = {"Content-Type": "application/json;charset=utf-8"}
426 | data = {"msgtype": "text", "text": {"content": f"{title}\n\n{content}"}}
427 | response = requests.post(
428 | url=url, data=json.dumps(data), headers=headers, timeout=15
429 | ).json()
430 |
431 | if response["errcode"] == 0:
432 | print("企业微信机器人推送成功!")
433 | else:
434 | print("企业微信机器人推送失败!")
435 |
436 |
437 | def telegram_bot(title: str, content: str) -> None:
438 | """
439 | 使用 telegram 机器人 推送消息。
440 | """
441 | if not push_config.get("TG_BOT_TOKEN") or not push_config.get("TG_USER_ID"):
442 | print("tg 服务的 bot_token 或者 user_id 未设置!!\n取消推送")
443 | return
444 | print("tg 服务启动")
445 |
446 | if push_config.get("TG_API_HOST"):
447 | url = f"https://{push_config.get('TG_API_HOST')}/bot{push_config.get('TG_BOT_TOKEN')}/sendMessage"
448 | else:
449 | url = (
450 | f"https://api.telegram.org/bot{push_config.get('TG_BOT_TOKEN')}/sendMessage"
451 | )
452 | headers = {"Content-Type": "application/x-www-form-urlencoded"}
453 | payload = {
454 | "chat_id": str(push_config.get("TG_USER_ID")),
455 | "text": f"{title}\n\n{content}",
456 | "disable_web_page_preview": "true",
457 | }
458 | proxies = None
459 | if push_config.get("TG_PROXY_HOST") and push_config.get("TG_PROXY_PORT"):
460 | if push_config.get("TG_PROXY_AUTH") is not None and "@" not in push_config.get(
461 | "TG_PROXY_HOST"
462 | ):
463 | push_config["TG_PROXY_HOST"] = (
464 | push_config.get("TG_PROXY_AUTH")
465 | + "@"
466 | + push_config.get("TG_PROXY_HOST")
467 | )
468 | proxyStr = "http://{}:{}".format(
469 | push_config.get("TG_PROXY_HOST"), push_config.get("TG_PROXY_PORT")
470 | )
471 | proxies = {"http": proxyStr, "https": proxyStr}
472 | response = requests.post(
473 | url=url, headers=headers, params=payload, proxies=proxies
474 | ).json()
475 |
476 | if response["ok"]:
477 | print("tg 推送成功!")
478 | else:
479 | print("tg 推送失败!")
480 |
481 |
482 | def one() -> str:
483 | """
484 | 获取一条一言。
485 | :return:
486 | """
487 | url = "https://v1.hitokoto.cn/"
488 | res = requests.get(url).json()
489 | return res["hitokoto"] + " ----" + res["from"]
490 |
491 |
492 | if push_config.get("BARK_PUSH"):
493 | notify_function.append(bark)
494 | if push_config.get("CONSOLE"):
495 | notify_function.append(console)
496 | if push_config.get("DD_BOT_TOKEN") and push_config.get("DD_BOT_SECRET"):
497 | notify_function.append(dingding_bot)
498 | if push_config.get("FSKEY"):
499 | notify_function.append(feishu_bot)
500 | if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"):
501 | notify_function.append(go_cqhttp)
502 | if push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"):
503 | notify_function.append(gotify)
504 | if push_config.get("IGOT_PUSH_KEY"):
505 | notify_function.append(iGot)
506 | if push_config.get("PUSH_KEY"):
507 | notify_function.append(serverJ)
508 | if push_config.get("PUSH_PLUS_TOKEN"):
509 | notify_function.append(pushplus_bot)
510 | if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"):
511 | notify_function.append(qmsg_bot)
512 | if push_config.get("QYWX_AM"):
513 | notify_function.append(wecom_app)
514 | if push_config.get("QYWX_KEY"):
515 | notify_function.append(wecom_bot)
516 | if push_config.get("TG_BOT_TOKEN") and push_config.get("TG_USER_ID"):
517 | notify_function.append(telegram_bot)
518 |
519 |
520 | def send(title: str, content: str) -> None:
521 | if not content:
522 | print(f"{title} 推送内容为空!")
523 | return
524 |
525 | hitokoto = push_config.get("HITOKOTO")
526 |
527 | text = one() if hitokoto else ""
528 | content += "\n\n" + text
529 |
530 | ts = [
531 | threading.Thread(target=mode, args=(title, content), name=mode.__name__)
532 | for mode in notify_function
533 | ]
534 | [t.start() for t in ts]
535 | [t.join() for t in ts]
536 |
537 |
538 | def main():
539 | send("title", "content")
540 |
541 |
542 | if __name__ == "__main__":
543 | main()
544 |
--------------------------------------------------------------------------------
/sendNotify.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # _*_ coding:utf-8 _*_
3 | import base64
4 | import hashlib
5 | import hmac
6 | import json
7 | import os
8 | import re
9 | import threading
10 | import time
11 | import urllib.parse
12 |
13 | import requests
14 |
15 | # 原先的 print 函数和主线程的锁
16 | _print = print
17 | mutex = threading.Lock()
18 |
19 |
20 | # 定义新的 print 函数
21 | def print(text, *args, **kw):
22 | """
23 | 使输出有序进行,不出现多线程同一时间输出导致错乱的问题。
24 | """
25 | with mutex:
26 | _print(text, *args, **kw)
27 |
28 |
29 | # 通知服务
30 | # fmt: off
31 | push_config = {
32 | 'HITOKOTO': False, # 启用一言(随机句子)
33 |
34 | 'BARK_PUSH': '', # bark IP 或设备码,例:https://api.day.app/DxHcxxxxxRxxxxxxcm/
35 | 'BARK_ARCHIVE': '', # bark 推送是否存档
36 | 'BARK_GROUP': '', # bark 推送分组
37 | 'BARK_SOUND': '', # bark 推送声音
38 | 'BARK_ICON': '', # bark 推送图标
39 |
40 | 'CONSOLE': True, # 控制台输出
41 |
42 | 'DD_BOT_SECRET': '', # 钉钉机器人的 DD_BOT_SECRET
43 | 'DD_BOT_TOKEN': '', # 钉钉机器人的 DD_BOT_TOKEN
44 |
45 | 'FSKEY': '', # 飞书机器人的 FSKEY
46 |
47 | 'GOBOT_URL': '', # go-cqhttp
48 | # 推送到个人QQ:http://127.0.0.1/send_private_msg
49 | # 群:http://127.0.0.1/send_group_msg
50 | 'GOBOT_QQ': '', # go-cqhttp 的推送群或用户
51 | # GOBOT_URL 设置 /send_private_msg 时填入 user_id=个人QQ
52 | # /send_group_msg 时填入 group_id=QQ群
53 | 'GOBOT_TOKEN': '', # go-cqhttp 的 access_token
54 |
55 | 'GOTIFY_URL': '', # gotify地址,如https://push.example.de:8080
56 | 'GOTIFY_TOKEN': '', # gotify的消息应用token
57 | 'GOTIFY_PRIORITY': 0, # 推送消息优先级,默认为0
58 |
59 | 'IGOT_PUSH_KEY': '', # iGot 聚合推送的 IGOT_PUSH_KEY
60 |
61 | 'PUSH_KEY': '', # server 酱的 PUSH_KEY,兼容旧版与 Turbo 版
62 |
63 | 'PUSH_PLUS_TOKEN': '', # push+ 微信推送的用户令牌
64 | 'PUSH_PLUS_USER': '', # push+ 微信推送的群组编码
65 |
66 | 'QMSG_KEY': '', # qmsg 酱的 QMSG_KEY
67 | 'QMSG_TYPE': '', # qmsg 酱的 QMSG_TYPE
68 |
69 | 'QYWX_AM': '', # 企业微信应用
70 |
71 | 'QYWX_KEY': '', # 企业微信机器人
72 |
73 | 'TG_BOT_TOKEN': '', # tg 机器人的 TG_BOT_TOKEN,例:1407203283:AAG9rt-6RDaaX0HBLZQq0laNOh898iFYaRQ
74 | 'TG_USER_ID': '', # tg 机器人的 TG_USER_ID,例:1434078534
75 | 'TG_API_HOST': '', # tg 代理 api
76 | 'TG_PROXY_AUTH': '', # tg 代理认证参数
77 | 'TG_PROXY_HOST': '', # tg 机器人的 TG_PROXY_HOST
78 | 'TG_PROXY_PORT': '', # tg 机器人的 TG_PROXY_PORT
79 | }
80 | notify_function = []
81 | # fmt: on
82 |
83 | # 首先读取 面板变量 或者 github action 运行变量
84 | for k in push_config:
85 | if os.getenv(k):
86 | v = os.getenv(k)
87 | push_config[k] = v
88 |
89 |
90 | def bark(title: str, content: str) -> None:
91 | """
92 | 使用 bark 推送消息。
93 | """
94 | if not push_config.get("BARK_PUSH"):
95 | print("bark 服务的 BARK_PUSH 未设置!!\n取消推送")
96 | return
97 | print("bark 服务启动")
98 |
99 | if push_config.get("BARK_PUSH").startswith("http"):
100 | url = f'{push_config.get("BARK_PUSH")}/{urllib.parse.quote_plus(title)}/{urllib.parse.quote_plus(content)}'
101 | else:
102 | url = f'https://api.day.app/{push_config.get("BARK_PUSH")}/{urllib.parse.quote_plus(title)}/{urllib.parse.quote_plus(content)}'
103 |
104 | bark_params = {
105 | "BARK_ARCHIVE": "isArchive",
106 | "BARK_GROUP": "group",
107 | "BARK_SOUND": "sound",
108 | "BARK_ICON": "icon",
109 | }
110 | params = ""
111 | for pair in filter(
112 | lambda pairs: pairs[0].startswith("BARK_")
113 | and pairs[0] != "BARK_PUSH"
114 | and pairs[1]
115 | and bark_params.get(pairs[0]),
116 | push_config.items(),
117 | ):
118 | params += f"{bark_params.get(pair[0])}={pair[1]}&"
119 | if params:
120 | url = url + "?" + params.rstrip("&")
121 | response = requests.get(url).json()
122 |
123 | if response["code"] == 200:
124 | print("bark 推送成功!")
125 | else:
126 | print("bark 推送失败!")
127 |
128 |
129 | def console(title: str, content: str) -> None:
130 | """
131 | 使用 控制台 推送消息。
132 | """
133 | print(f"{title}\n\n{content}")
134 |
135 |
136 | def dingding_bot(title: str, content: str) -> None:
137 | """
138 | 使用 钉钉机器人 推送消息。
139 | """
140 | if not push_config.get("DD_BOT_SECRET") or not push_config.get("DD_BOT_TOKEN"):
141 | print("钉钉机器人 服务的 DD_BOT_SECRET 或者 DD_BOT_TOKEN 未设置!!\n取消推送")
142 | return
143 | print("钉钉机器人 服务启动")
144 |
145 | timestamp = str(round(time.time() * 1000))
146 | secret_enc = push_config.get("DD_BOT_SECRET").encode("utf-8")
147 | string_to_sign = "{}\n{}".format(timestamp, push_config.get("DD_BOT_SECRET"))
148 | string_to_sign_enc = string_to_sign.encode("utf-8")
149 | hmac_code = hmac.new(
150 | secret_enc, string_to_sign_enc, digestmod=hashlib.sha256
151 | ).digest()
152 | sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
153 | url = f'https://oapi.dingtalk.com/robot/send?access_token={push_config.get("DD_BOT_TOKEN")}×tamp={timestamp}&sign={sign}'
154 | headers = {"Content-Type": "application/json;charset=utf-8"}
155 | data = {"msgtype": "text", "text": {"content": f"{title}\n\n{content}"}}
156 | response = requests.post(
157 | url=url, data=json.dumps(data), headers=headers, timeout=15
158 | ).json()
159 |
160 | if not response["errcode"]:
161 | print("钉钉机器人 推送成功!")
162 | else:
163 | print("钉钉机器人 推送失败!")
164 |
165 |
166 | def feishu_bot(title: str, content: str) -> None:
167 | """
168 | 使用 飞书机器人 推送消息。
169 | """
170 | if not push_config.get("FSKEY"):
171 | print("飞书 服务的 FSKEY 未设置!!\n取消推送")
172 | return
173 | print("飞书 服务启动")
174 |
175 | url = f'https://open.feishu.cn/open-apis/bot/v2/hook/{push_config.get("FSKEY")}'
176 | data = {"msg_type": "text", "content": {"text": f"{title}\n\n{content}"}}
177 | response = requests.post(url, data=json.dumps(data)).json()
178 |
179 | if response.get("StatusCode") == 0:
180 | print("飞书 推送成功!")
181 | else:
182 | print("飞书 推送失败!错误信息如下:\n", response)
183 |
184 |
185 | def go_cqhttp(title: str, content: str) -> None:
186 | """
187 | 使用 go_cqhttp 推送消息。
188 | """
189 | if not push_config.get("GOBOT_URL") or not push_config.get("GOBOT_QQ"):
190 | print("go-cqhttp 服务的 GOBOT_URL 或 GOBOT_QQ 未设置!!\n取消推送")
191 | return
192 | print("go-cqhttp 服务启动")
193 |
194 | url = f'{push_config.get("GOBOT_URL")}?access_token={push_config.get("GOBOT_TOKEN")}&{push_config.get("GOBOT_QQ")}&message=标题:{title}\n内容:{content}'
195 | response = requests.get(url).json()
196 |
197 | if response["status"] == "ok":
198 | print("go-cqhttp 推送成功!")
199 | else:
200 | print("go-cqhttp 推送失败!")
201 |
202 |
203 | def gotify(title:str,content:str) -> None:
204 | """
205 | 使用 gotify 推送消息。
206 | """
207 | if not push_config.get("GOTIFY_URL") or not push_config.get("GOTIFY_TOKEN"):
208 | print("gotify 服务的 GOTIFY_URL 或 GOTIFY_TOKEN 未设置!!\n取消推送")
209 | return
210 | print("gotify 服务启动")
211 |
212 | url = f'{push_config.get("GOTIFY_URL")}/message?token={push_config.get("GOTIFY_TOKEN")}'
213 | data = {"title": title,"message": content,"priority": push_config.get("GOTIFY_PRIORITY")}
214 | response = requests.post(url,data=data).json()
215 |
216 | if response.get("id"):
217 | print("gotify 推送成功!")
218 | else:
219 | print("gotify 推送失败!")
220 |
221 |
222 | def iGot(title: str, content: str) -> None:
223 | """
224 | 使用 iGot 推送消息。
225 | """
226 | if not push_config.get("IGOT_PUSH_KEY"):
227 | print("iGot 服务的 IGOT_PUSH_KEY 未设置!!\n取消推送")
228 | return
229 | print("iGot 服务启动")
230 |
231 | url = f'https://push.hellyw.com/{push_config.get("IGOT_PUSH_KEY")}'
232 | data = {"title": title, "content": content}
233 | headers = {"Content-Type": "application/x-www-form-urlencoded"}
234 | response = requests.post(url, data=data, headers=headers).json()
235 |
236 | if response["ret"] == 0:
237 | print("iGot 推送成功!")
238 | else:
239 | print(f'iGot 推送失败!{response["errMsg"]}')
240 |
241 |
242 | def serverJ(title: str, content: str) -> None:
243 | """
244 | 通过 serverJ 推送消息。
245 | """
246 | if not push_config.get("PUSH_KEY"):
247 | print("serverJ 服务的 PUSH_KEY 未设置!!\n取消推送")
248 | return
249 | print("serverJ 服务启动")
250 |
251 | data = {"text": title, "desp": content.replace("\n", "\n\n")}
252 | if push_config.get("PUSH_KEY").index("SCT") != -1:
253 | url = f'https://sctapi.ftqq.com/{push_config.get("PUSH_KEY")}.send'
254 | else:
255 | url = f'https://sc.ftqq.com/${push_config.get("PUSH_KEY")}.send'
256 | response = requests.post(url, data=data).json()
257 |
258 | if response.get("errno") == 0 or response.get("code") == 0:
259 | print("serverJ 推送成功!")
260 | else:
261 | print(f'serverJ 推送失败!错误码:{response["message"]}')
262 |
263 |
264 | def pushplus_bot(title: str, content: str) -> None:
265 | """
266 | 通过 push+ 推送消息。
267 | """
268 | if not push_config.get("PUSH_PLUS_TOKEN"):
269 | print("PUSHPLUS 服务的 PUSH_PLUS_TOKEN 未设置!!\n取消推送")
270 | return
271 | print("PUSHPLUS 服务启动")
272 |
273 | url = "http://www.pushplus.plus/send"
274 | data = {
275 | "token": push_config.get("PUSH_PLUS_TOKEN"),
276 | "title": title,
277 | "content": content,
278 | "topic": push_config.get("PUSH_PLUS_USER"),
279 | }
280 | body = json.dumps(data).encode(encoding="utf-8")
281 | headers = {"Content-Type": "application/json"}
282 | response = requests.post(url=url, data=body, headers=headers).json()
283 |
284 | if response["code"] == 200:
285 | print("PUSHPLUS 推送成功!")
286 |
287 | else:
288 |
289 | url_old = "http://pushplus.hxtrip.com/send"
290 | headers["Accept"] = "application/json"
291 | response = requests.post(url=url_old, data=body, headers=headers).json()
292 |
293 | if response["code"] == 200:
294 | print("PUSHPLUS(hxtrip) 推送成功!")
295 |
296 | else:
297 | print("PUSHPLUS 推送失败!")
298 |
299 |
300 | def qmsg_bot(title: str, content: str) -> None:
301 | """
302 | 使用 qmsg 推送消息。
303 | """
304 | if not push_config.get("QMSG_KEY") or not push_config.get("QMSG_TYPE"):
305 | print("qmsg 的 QMSG_KEY 或者 QMSG_TYPE 未设置!!\n取消推送")
306 | return
307 | print("qmsg 服务启动")
308 |
309 | url = f'https://qmsg.zendee.cn/{push_config.get("QMSG_TYPE")}/{push_config.get("QMSG_KEY")}'
310 | payload = {"msg": f'{title}\n\n{content.replace("----", "-")}'.encode("utf-8")}
311 | response = requests.post(url=url, params=payload).json()
312 |
313 | if response["code"] == 0:
314 | print("qmsg 推送成功!")
315 | else:
316 | print(f'qmsg 推送失败!{response["reason"]}')
317 |
318 |
319 | def wecom_app(title: str, content: str) -> None:
320 | """
321 | 通过 企业微信 APP 推送消息。
322 | """
323 | if not push_config.get("QYWX_AM"):
324 | print("QYWX_AM 未设置!!\n取消推送")
325 | return
326 | QYWX_AM_AY = re.split(",", push_config.get("QYWX_AM"))
327 | if 4 < len(QYWX_AM_AY) > 5:
328 | print("QYWX_AM 设置错误!!\n取消推送")
329 | return
330 | print("企业微信 APP 服务启动")
331 |
332 | corpid = QYWX_AM_AY[0]
333 | corpsecret = QYWX_AM_AY[1]
334 | touser = QYWX_AM_AY[2]
335 | agentid = QYWX_AM_AY[3]
336 | try:
337 | media_id = QYWX_AM_AY[4]
338 | except IndexError:
339 | media_id = ""
340 | wx = WeCom(corpid, corpsecret, agentid)
341 | # 如果没有配置 media_id 默认就以 text 方式发送
342 | if not media_id:
343 | message = title + "\n\n" + content
344 | response = wx.send_text(message, touser)
345 | else:
346 | response = wx.send_mpnews(title, content, media_id, touser)
347 |
348 | if response == "ok":
349 | print("企业微信推送成功!")
350 | else:
351 | print("企业微信推送失败!错误信息如下:\n", response)
352 |
353 |
354 | class WeCom:
355 | def __init__(self, corpid, corpsecret, agentid):
356 | self.CORPID = corpid
357 | self.CORPSECRET = corpsecret
358 | self.AGENTID = agentid
359 |
360 | def get_access_token(self):
361 | url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken"
362 | values = {
363 | "corpid": self.CORPID,
364 | "corpsecret": self.CORPSECRET,
365 | }
366 | req = requests.post(url, params=values)
367 | data = json.loads(req.text)
368 | return data["access_token"]
369 |
370 | def send_text(self, message, touser="@all"):
371 | send_url = (
372 | "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="
373 | + self.get_access_token()
374 | )
375 | send_values = {
376 | "touser": touser,
377 | "msgtype": "text",
378 | "agentid": self.AGENTID,
379 | "text": {"content": message},
380 | "safe": "0",
381 | }
382 | send_msges = bytes(json.dumps(send_values), "utf-8")
383 | respone = requests.post(send_url, send_msges)
384 | respone = respone.json()
385 | return respone["errmsg"]
386 |
387 | def send_mpnews(self, title, message, media_id, touser="@all"):
388 | send_url = (
389 | "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="
390 | + self.get_access_token()
391 | )
392 | send_values = {
393 | "touser": touser,
394 | "msgtype": "mpnews",
395 | "agentid": self.AGENTID,
396 | "mpnews": {
397 | "articles": [
398 | {
399 | "title": title,
400 | "thumb_media_id": media_id,
401 | "author": "Author",
402 | "content_source_url": "",
403 | "content": message.replace("\n", "
"),
404 | "digest": message,
405 | }
406 | ]
407 | },
408 | }
409 | send_msges = bytes(json.dumps(send_values), "utf-8")
410 | respone = requests.post(send_url, send_msges)
411 | respone = respone.json()
412 | return respone["errmsg"]
413 |
414 |
415 | def wecom_bot(title: str, content: str) -> None:
416 | """
417 | 通过 企业微信机器人 推送消息。
418 | """
419 | if not push_config.get("QYWX_KEY"):
420 | print("企业微信机器人 服务的 QYWX_KEY 未设置!!\n取消推送")
421 | return
422 | print("企业微信机器人服务启动")
423 |
424 | url = f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={push_config.get('QYWX_KEY')}"
425 | headers = {"Content-Type": "application/json;charset=utf-8"}
426 | data = {"msgtype": "text", "text": {"content": f"{title}\n\n{content}"}}
427 | response = requests.post(
428 | url=url, data=json.dumps(data), headers=headers, timeout=15
429 | ).json()
430 |
431 | if response["errcode"] == 0:
432 | print("企业微信机器人推送成功!")
433 | else:
434 | print("企业微信机器人推送失败!")
435 |
436 |
437 | def telegram_bot(title: str, content: str) -> None:
438 | """
439 | 使用 telegram 机器人 推送消息。
440 | """
441 | if not push_config.get("TG_BOT_TOKEN") or not push_config.get("TG_USER_ID"):
442 | print("tg 服务的 bot_token 或者 user_id 未设置!!\n取消推送")
443 | return
444 | print("tg 服务启动")
445 |
446 | if push_config.get("TG_API_HOST"):
447 | url = f"https://{push_config.get('TG_API_HOST')}/bot{push_config.get('TG_BOT_TOKEN')}/sendMessage"
448 | else:
449 | url = (
450 | f"https://api.telegram.org/bot{push_config.get('TG_BOT_TOKEN')}/sendMessage"
451 | )
452 | headers = {"Content-Type": "application/x-www-form-urlencoded"}
453 | payload = {
454 | "chat_id": str(push_config.get("TG_USER_ID")),
455 | "text": f"{title}\n\n{content}",
456 | "disable_web_page_preview": "true",
457 | }
458 | proxies = None
459 | if push_config.get("TG_PROXY_HOST") and push_config.get("TG_PROXY_PORT"):
460 | if push_config.get("TG_PROXY_AUTH") is not None and "@" not in push_config.get(
461 | "TG_PROXY_HOST"
462 | ):
463 | push_config["TG_PROXY_HOST"] = (
464 | push_config.get("TG_PROXY_AUTH")
465 | + "@"
466 | + push_config.get("TG_PROXY_HOST")
467 | )
468 | proxyStr = "http://{}:{}".format(
469 | push_config.get("TG_PROXY_HOST"), push_config.get("TG_PROXY_PORT")
470 | )
471 | proxies = {"http": proxyStr, "https": proxyStr}
472 | response = requests.post(
473 | url=url, headers=headers, params=payload, proxies=proxies
474 | ).json()
475 |
476 | if response["ok"]:
477 | print("tg 推送成功!")
478 | else:
479 | print("tg 推送失败!")
480 |
481 |
482 | def one() -> str:
483 | """
484 | 获取一条一言。
485 | :return:
486 | """
487 | url = "https://v1.hitokoto.cn/"
488 | res = requests.get(url).json()
489 | return res["hitokoto"] + " ----" + res["from"]
490 |
491 |
492 | if push_config.get("BARK_PUSH"):
493 | notify_function.append(bark)
494 | if push_config.get("CONSOLE"):
495 | notify_function.append(console)
496 | if push_config.get("DD_BOT_TOKEN") and push_config.get("DD_BOT_SECRET"):
497 | notify_function.append(dingding_bot)
498 | if push_config.get("FSKEY"):
499 | notify_function.append(feishu_bot)
500 | if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"):
501 | notify_function.append(go_cqhttp)
502 | if push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"):
503 | notify_function.append(gotify)
504 | if push_config.get("IGOT_PUSH_KEY"):
505 | notify_function.append(iGot)
506 | if push_config.get("PUSH_KEY"):
507 | notify_function.append(serverJ)
508 | if push_config.get("PUSH_PLUS_TOKEN"):
509 | notify_function.append(pushplus_bot)
510 | if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"):
511 | notify_function.append(qmsg_bot)
512 | if push_config.get("QYWX_AM"):
513 | notify_function.append(wecom_app)
514 | if push_config.get("QYWX_KEY"):
515 | notify_function.append(wecom_bot)
516 | if push_config.get("TG_BOT_TOKEN") and push_config.get("TG_USER_ID"):
517 | notify_function.append(telegram_bot)
518 |
519 |
520 | def send(title: str, content: str) -> None:
521 | if not content:
522 | print(f"{title} 推送内容为空!")
523 | return
524 | content += '\nBy: 过客'
525 |
526 | hitokoto = push_config.get("HITOKOTO")
527 |
528 | text = one() if hitokoto else ""
529 | content += "\n\n" + text
530 |
531 | ts = [
532 | threading.Thread(target=mode, args=(title, content), name=mode.__name__)
533 | for mode in notify_function
534 | ]
535 | [t.start() for t in ts]
536 | [t.join() for t in ts]
537 |
538 |
539 | def main():
540 | send("title", "content")
541 |
542 |
543 | if __name__ == "__main__":
544 | main()
--------------------------------------------------------------------------------
/yangmao/bkxstx.js:
--------------------------------------------------------------------------------
1 | /*
2 | APP:必看小说
3 | 变量 如
4 | bkxshd='sessionid=6e52cab4cefa43c193f3a466b0c33111'
5 | 抓包点我的 关键字 info
6 | 查看请求头COOKIE里的 只需要sessionid=XXXXXX这一段
7 | 多账号用艾特隔开@
8 | 提现变量为withdraws
9 | withdraws='' 1为1元 2为5元 3为10元 4为30元 5为50元 6为100元
10 | 每天额度是每天刷新的10点吧
11 | 建议一天别跑多了 怕黑
12 | cron 0 1,10 * * * bkxs.js
13 | */
14 |
15 | const $ = new Env('必看小说TX');
16 | var crypto = require("crypto");
17 | let status;
18 | status = (status = ($.getval("bkxsstatus") || "1") ) > 1 ? `${status}` : ""; // 账号扩展字符
19 | let bkxshdArr = [],bkxscount = ''
20 | const notify = $.isNode() ? require('./sendNotify') : '';
21 | let bkxshd= $.isNode() ? (process.env.bkxshd ? process.env.bkxshd : "") : ($.getdata('bkxshd') ? $.getdata('bkxshd') : "")
22 | let withdraws=$.isNode() ? (process.env.withdraws ? process.env.withdraws : "") : ($.getdata('withdraws') ? $.getdata('withdraws') : "")
23 | let allMessage = '';
24 | let bkxshds = ""
25 | const logs =0;
26 | const host='https://api.ibreader.com/'
27 | var hours = new Date().getHours();
28 | var s = new Date().getMinutes();
29 |
30 | var timestamp = Math.round(new Date().getTime()/1000).toString();
31 | !(async () => {
32 |
33 | if(!$.isNode()){
34 | bkxshdArr.push($.getdata('bkxshd'))
35 | let bkxscount = ($.getval('bkxscount') || '1');
36 | for (let i = 2; i <= bkxscount; i++) {
37 | bkxshdArr.push($.getdata(`bkxshd${i}`))
38 | }
39 | console.log(`------------- 共${bkxshdArr.length}个账号-------------\n`)
40 | for (let i = 0; i < bkxshdArr.length; i++) {
41 | if (bkxshdArr[i]) {
42 | bkxshd = bkxshdArr[i];
43 | $.index = i + 1;
44 |
45 | }
46 | }
47 | }else {
48 | if (process.env.bkxshd && process.env.bkxshd.indexOf('@') > -1) {
49 | bkxshdArr = process.env.bkxshd.split('@');
50 | console.log(`您选择的是用"@"隔开\n`)
51 | } else {
52 | bkxshds = [process.env.bkxshd]
53 | };
54 | Object.keys(bkxshds).forEach((item) => {
55 | if (bkxshds[item]) {
56 | bkxshdArr.push(bkxshds[item])
57 | }
58 | })
59 | console.log(`共${bkxshdArr.length}个cookie`)
60 | for (let k = 0; k < bkxshdArr.length; k++) {
61 | $.message = ""
62 | bkxshd = bkxshdArr[k]
63 | $.index = k + 1;
64 |
65 | console.log(`\n开始【必看小说TX${$.index}】`)
66 | //allMessage +=`\n开始【必看小说${$.index}】`
67 |
68 | await withdraw(withdraws)
69 |
70 |
71 | }
72 |
73 |
74 | }
75 |
76 | if ($.isNode() && allMessage) {
77 | await notify.sendNotify(`${$.name}`, `${allMessage}` )
78 | }
79 | })()
80 | .catch((e) => $.logErr(e))
81 | .finally(() => $.done())
82 | function info() {
83 | return new Promise((resolve) => {
84 |
85 | $.post(bkxs(`api/task/v1/wallet/user/info`,'encrypted_param=DVf%2Frs12MOEFrDOSEPa98erYQ0eqbyQj%2FNpp0H2FxjNTHT9XGY1Hr2LwJ26bkcg4CbE2eO4gFNM1fM2nv%2FsPgzX3zqJklKx2JNqZKuv2ibOUK7WiY46v%2B2zq9IjD9lNas4v6j8pbAJP%2FmAYUon%2FrvSUnT%2FDle%2BpoN3S%2Fg%2BQJBfI%3D&sign=84601349ea093486774c54e62f005b7b&'), async (err, resp, data) => {
86 | //$.log(data)
87 | try {
88 | if (err) {
89 | console.log(`${JSON.stringify(err)}`)
90 | console.log(`${$.name} API请求失败,请检查网路重试`)
91 | }// else {
92 | if (safeGet(data)) {
93 | data = JSON.parse(data);
94 | if(data.code==100){
95 |
96 | $.log("Total: "+data.data.total+"\n")
97 | $.log("Today: "+data.data.today+"\n")
98 | $.log("Cash: "+data.data.cash+"\n")
99 |
100 | }
101 | else if(data.code !== 100){
102 | console.log(data.msg+"\n")
103 | //allMessage +='\n'+data.msg+'\n'
104 | }
105 | }
106 |
107 | } catch (e) {
108 | $.logErr(e, resp)
109 | } finally {
110 | resolve(data);
111 | }
112 | })
113 | })
114 | }
115 | function list() {
116 | return new Promise((resolve) => {
117 |
118 | $.post(bkxs(`task_api/task/list`,'sign=75F761FEACAA604E19A0F4FEFABE556E&time=1654363935000'), async (err, resp, data) => {
119 | //$.log(data)
120 | try {
121 | if (err) {
122 | console.log(`${JSON.stringify(err)}`)
123 | console.log(`${$.name} API请求失败,请检查网路重试`)
124 | }// else {
125 | if (safeGet(data)) {
126 | data = JSON.parse(data);
127 | if(data.code==100){
128 |
129 | taskVOS = data.data
130 | for(let i=0;i {
158 |
159 | $.post(bkxs(`task_api/task/getServiceAreaTaskList`,'chapterCoinRate=10&readChapterCount=0&sign=59DE7B94F2B947C52EF8E1DCFA699597&time=1654363936000'), async (err, resp, data) => {
160 |
161 | try {
162 | if (err) {
163 | console.log(`${JSON.stringify(err)}`)
164 | console.log(`${$.name} API请求失败,请检查网路重试`)
165 | }// else {
166 | if (safeGet(data)) {
167 | data = JSON.parse(data);
168 | if(data.code==100){
169 | console.log('\n叼毛:'+data.data.userInfoBO.clientInfo.user.nickname+"\n")
170 | taskVOS = data.data.taskVOS
171 | for(let i=0;i {
200 |
201 | $.post(bkxs(`task_api/task/getChapterTaskList`,'time=1654363108019&sign=c57423f4fd93025efc42c048ff96f5b0&'), async (err, resp, data) => {
202 | //$.log(data)
203 | try {
204 | if (err) {
205 | console.log(`${JSON.stringify(err)}`)
206 | console.log(`${$.name} API请求失败,请检查网路重试`)
207 | }// else {
208 | if (safeGet(data)) {
209 | data = JSON.parse(data);
210 | if(data.code==100){
211 | console.log('\n叼毛:'+data.data.userInfoBO.clientInfo.user.nickname+"\n")
212 | taskVOS = data.data.taskVOS
213 | for(let i=0;i {
241 | sign =md5('7b7fpld4roey0e6e&taskId='+taskId+'&time='+timestamp)
242 | $.post(bkxs(`task_api/task/finish`,`time=${timestamp}&sign=${sign}&taskId=${taskId}&`), async (err, resp, data) => {
243 | //$.log(data)
244 | try {
245 | if (err) {
246 | console.log(`${JSON.stringify(err)}`)
247 | console.log(`${$.name} API请求失败,请检查网路重试`)
248 | }// else {
249 | if (safeGet(data)) {
250 | data = JSON.parse(data);
251 | if(data.code==100){
252 | console.log('\nTask:'+data.msg + ' rewardNum:'+data.data.rewardNum+"\n")
253 |
254 |
255 |
256 | }
257 | else if(data.code !== 100){
258 | console.log(data.msg+"\n")
259 | //allMessage +='\n'+data.msg+'\n'
260 | }
261 | }
262 |
263 | } catch (e) {
264 | $.logErr(e, resp)
265 | } finally {
266 | resolve(data);
267 | }
268 | })
269 | })
270 | }
271 | function withdraw(itemId) {
272 | return new Promise((resolve) => {
273 | sign =md5('7b7fpld4roey0e6e&itemId='+itemId+'&platform=0&time='+timestamp)
274 | $.post(bkxs(`task_api/task/v1/withdraw/submit`,`itemId=${itemId}&platform=0&sign=${sign}&time=${timestamp}`), async (err, resp, data) => {
275 | //$.log(data)
276 | try {
277 | if (err) {
278 | console.log(`${JSON.stringify(err)}`)
279 | console.log(`${$.name} API请求失败,请检查网路重试`)
280 | }// else {
281 | if (safeGet(data)) {
282 | data = JSON.parse(data);
283 | if(data.code==100){
284 | console.log('\nWithdraw:'+data.msg+"\n")
285 |
286 |
287 |
288 | }
289 | else if(data.code !== 100){
290 | console.log(data.msg+"\n")
291 | //allMessage +='\n'+data.msg+'\n'
292 | }
293 | }
294 |
295 | } catch (e) {
296 | $.logErr(e, resp)
297 | } finally {
298 | resolve(data);
299 | }
300 | })
301 | })
302 | }
303 | function bkxs(a,body) {
304 | return {
305 |
306 | url: `${host}${a}`,
307 | body:`${body}`,
308 | headers: {
309 | 'Connection': 'Keep-Alive',
310 | 'Content-Type': 'application/x-www-form-urlencoded; Charset=UTF-8',
311 | 'Accept': '*/*',
312 | 'Accept-Language': 'zh-cn',
313 | 'Cookie': bkxshd,
314 | 'Host': 'api.ibreader.com',
315 | 'Referer': 'https://api.ibreader.com/task_api/task/getChapterTaskList',
316 | 'User-Agent': 'Mozilla/5.0 (Linux; Android 7.1.2; PCAM00 Build/NGI77B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/62.0.3202.84 Mobile Safari/537.36',
317 | 'X-Client': 'sv=7.1.2;pm=PCAM00;ss=1080*2196;version=5.1.86.18.130500001;vId=60752445880d4366988c18aa9d9f6b80;signVersion=2;webVersion=new;oaid=null;pkv=1;ddid=DUzp43Y2YF9X-5bmS5YXSEZcB3nELTOxTV04RFV6cDQzWTJZRjlYLTVibVM1WVhTRVpjQjNuRUxUT3hUVjA0c2h1;androidosv=25;os=0;muk=ui98HJmkunswcEuBWDlg3A%3D%3D;firm=OPPO;duk=Bv6b4gAgfXcjaj%2BBwEtH32pUNNCFZYDKNOv%2Boplr96Q%3D;',
318 | 'Accept-Encoding': 'gzip, deflate',
319 |
320 | }
321 | }
322 | }
323 | function bkxsget(a) {
324 | return {
325 |
326 | url: `${host}${a}`,
327 | headers: {
328 | 'User-Agent': 'Mozilla/5.0 (Linux; Android 7.1.2; PCAM00 Build/NGI77B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/62.0.3202.84 Mobile Safari/537.36',
329 | 'Connection': 'keep-alive',
330 | 'Content-Type': 'application/x-www-form-urlencoded',
331 | 'COOKIE': bkxs,
332 | 'X-Client': 'sv=7.1.2;pm=PCAM00;ss=1080*2196;version=5.1.86.18.130500001;vId=60752445880d4366988c18aa9d9f6b80;signVersion=2;webVersion=new;oaid=null;pkv=1;ddid=DUzp43Y2YF9X-5bmS5YXSEZcB3nELTOxTV04RFV6cDQzWTJZRjlYLTVibVM1WVhTRVpjQjNuRUxUT3hUVjA0c2h1;androidosv=25;os=0;muk=ui98HJmkunswcEuBWDlg3A%3D%3D;firm=OPPO;duk=Bv6b4gAgfXcjaj%2BBwEtH32pUNNCFZYDKNOv%2Boplr96Q%3D;',
333 | 'Host': 'api.ibreader.com',
334 | 'Accept-Encoding': 'gzip, deflate',
335 |
336 |
337 | }
338 | }
339 | }
340 |
341 |
342 | function md5(s) {
343 |
344 | return crypto.createHash('md5').update(String(s)).digest('hex').toUpperCase();
345 | }
346 |
347 | function safeGet(data) {
348 | try {
349 | if (typeof JSON.parse(data) == "object") {
350 | return true;
351 | }
352 | } catch (e) {
353 | console.log(e);
354 | console.log(`京东服务器访问数据为空,请检查自身设备网络情况`);
355 | return false;
356 | }
357 | }
358 | function jsonParse(str) {
359 | if (typeof str == "string") {
360 | try {
361 | return JSON.parse(str);
362 | } catch (e) {
363 | console.log(e);
364 | $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
365 | return [];
366 | }
367 | }
368 | }
369 |
370 | function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();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){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)}
371 |
--------------------------------------------------------------------------------
/yangmao/bkxs.js:
--------------------------------------------------------------------------------
1 | /*
2 | APP:必看小说
3 | 变量 如
4 | bkxshd='sessionid=6e52cab4cefa43c193f3a466b0c33111'
5 | 抓包点我的 关键字 info
6 | 查看请求头COOKIE里的 只需要sessionid=XXXXXX这一段
7 | 多账号用艾特隔开@
8 | 提现变量为withdraws
9 | withdraws='' 1为1元 2为5元 3为10元 4为30元 5为50元 6为100元
10 | 每天额度是每天刷新的10点吧
11 | 建议一天别跑多了 怕黑
12 | cron 0 1,10 * * * bkxs.js
13 | */
14 |
15 | const $ = new Env('必看小说');
16 | var crypto = require("crypto");
17 | let status;
18 | status = (status = ($.getval("bkxsstatus") || "1")) > 1 ? `${status}` : ""; // 账号扩展字符
19 | let bkxshdArr = [],
20 | bkxscount = ''
21 | const notify = $.isNode() ? require('./sendNotify') : '';
22 |
23 | let bkxshd = $.isNode() ? (process.env.bkxshd ? process.env.bkxshd : "") : ($.getdata('bkxshd') ? $.getdata('bkxshd') : "")
24 |
25 | let withdraws = $.isNode() ? (process.env.withdraws ? process.env.withdraws : "") : ($.getdata('withdraws') ? $.getdata('withdraws') : "")
26 | let allMessage = '';
27 | let bkxshds = ""
28 | const logs = 0;
29 | const host = 'https://api.ibreader.com/'
30 | var hours = new Date().getHours();
31 | var s = new Date().getMinutes();
32 |
33 | var timestamp = Math.round(new Date().getTime() / 1000).toString();
34 | !(async () => {
35 |
36 | if (!$.isNode()) {
37 | bkxshdArr.push($.getdata('bkxshd'))
38 | let bkxscount = ($.getval('bkxscount') || '1');
39 | for (let i = 2; i <= bkxscount; i++) {
40 | bkxshdArr.push($.getdata(`bkxshd${i}`))
41 | }
42 | console.log(`------------- 共${bkxshdArr.length}个账号-------------\n`)
43 | for (let i = 0; i < bkxshdArr.length; i++) {
44 | if (bkxshdArr[i]) {
45 | bkxshd = bkxshdArr[i];
46 | $.index = i + 1;
47 |
48 | }
49 | }
50 | } else {
51 | if (process.env.bkxshd && process.env.bkxshd.indexOf('@') > -1) {
52 | bkxshdArr = process.env.bkxshd.split('@');
53 | console.log(`您选择的是用"@"隔开\n`)
54 | } else {
55 | bkxshds = [process.env.bkxshd]
56 | };
57 |
58 | Object.keys(bkxshds).forEach((item) => {
59 | if (bkxshds[item]) {
60 | bkxshdArr.push(bkxshds[item])
61 | }
62 | })
63 | console.log(`共${bkxshdArr.length}个cookie`)
64 | for (let k = 0; k < bkxshdArr.length; k++) {
65 | $.message = ""
66 | bkxshd = bkxshdArr[k]
67 | $.index = k + 1;
68 |
69 | console.log(`\n开始【必看&洋葱小说${$.index}】${bkxshd}`)
70 | await userInfoQuickApp(1)
71 |
72 |
73 | await finish(1)
74 | await finish(449)
75 | await finish(457)
76 | await finish(458)
77 | await finish(464)
78 | await finish(473)
79 | await finish(474)
80 | await finish(475)
81 | for (let i = 477; i < 486; i++) {
82 | await finish(i)
83 | }
84 | await info()
85 | await withdraw()
86 |
87 |
88 | }
89 |
90 |
91 | }
92 |
93 | if ($.isNode() && allMessage) {
94 | //await notify.sendNotify(`${$.name}`, `${allMessage}`)
95 | }
96 | })()
97 | .catch((e) => $.logErr(e))
98 | .finally(() => $.done())
99 | function userInfoQuickApp(taskId) {
100 | return new Promise((resolve) => {
101 | sign = md5('7b7fpld4roey0e6e&taskId=' + taskId + '&time=' + timestamp)
102 | $.post(bkxs1(`task_api/task/record`, `time=${timestamp}&sign=${sign}&taskId=${taskId}&`), async (err, resp, data) => {
103 |
104 | try {
105 | if (err) {
106 | console.log(`${JSON.stringify(err)}`)
107 | console.log(`${$.name} API请求失败,请检查网路重试`)
108 | } // else {
109 | if (safeGet(data)) {
110 | data = JSON.parse(data);
111 | if (data.code == 100) {
112 | $.log(`已签到:${data.data.extraData.checkInDays}天`)
113 | $.log(`离提50还差:${40-data.data.extraData.checkInDays}天`)
114 | $.log(`离提100还差:${50-data.data.extraData.checkInDays}天`)
115 | allMessage +=`已签到:${data.data.extraData.checkInDays}天`
116 | allMessage +=`离提50还差:${40-data.data.extraData.checkInDays}天`
117 | allMessage +=`离提100还差:${50-data.data.extraData.checkInDays}天`
118 | } else if (data.code !== 100) {
119 | //console.log(data.msg + "\n")
120 | //allMessage +='\n'+data.msg+'\n'
121 | }
122 | }
123 |
124 | } catch (e) {
125 | $.logErr(e, resp)
126 | } finally {
127 | resolve(data);
128 | }
129 | })
130 | })
131 | }
132 | function withdraw() {
133 | return new Promise((resolve) => {
134 | sign = md5('7b7fpld4roey0e6e'+'&time=' + timestamp)
135 | $.post(bkxs1(`task_api/task/v1/withdraw/list`, `sign=${sign}&time=${timestamp}`), async (err, resp, data) => {
136 |
137 | try {
138 | if (err) {
139 | console.log(`${JSON.stringify(err)}`)
140 | console.log(`${$.name} API请求失败,请检查网路重试`)
141 | } // else {
142 | if (safeGet(data)) {
143 | data = JSON.parse(data);
144 | if (data.code == 100) {
145 | for (var i in data.data.list) {
146 | var title = data.data.list[i].title;
147 | if (title == '100元') {
148 | console.log(title+' 账号还未提过')
149 | }
150 | }
151 | } else if (data.code !== 100) {
152 | //console.log(data.msg + "\n")
153 | //allMessage +='\n'+data.msg+'\n'
154 | }
155 | }
156 |
157 | } catch (e) {
158 | $.logErr(e, resp)
159 | } finally {
160 | resolve(data);
161 | }
162 | })
163 | })
164 | }
165 | function info() {
166 | return new Promise((resolve) => {
167 |
168 | $.post(bkxs(`api/task/v1/wallet/user/info`, 'encrypted_param=DVf%2Frs12MOEFrDOSEPa98erYQ0eqbyQj%2FNpp0H2FxjNTHT9XGY1Hr2LwJ26bkcg4CbE2eO4gFNM1fM2nv%2FsPgzX3zqJklKx2JNqZKuv2ibOUK7WiY46v%2B2zq9IjD9lNas4v6j8pbAJP%2FmAYUon%2FrvSUnT%2FDle%2BpoN3S%2Fg%2BQJBfI%3D&sign=84601349ea093486774c54e62f005b7b&'), async (err, resp, data) => {
169 |
170 | try {
171 | if (err) {
172 | console.log(`${JSON.stringify(err)}`)
173 | console.log(`${$.name} API请求失败,请检查网路重试`)
174 | } // else {
175 | if (safeGet(data)) {
176 | data = JSON.parse(data);
177 | if (data.code == 100) {
178 |
179 | Today = data.data.today
180 | $.log("Total: " + data.data.total + "\n")
181 | $.log("Today: " + data.data.today + "\n")
182 | $.log("Cash: " + data.data.cash + "\n")
183 | allMessage +='\n'+"Total: " + data.data.total+'\n'+'\n'+"Today: " + data.data.today+'\n'+'\n'+"Cash: " + data.data.cash+'\n'
184 | } else if (data.code !== 100) {
185 | //console.log(data.msg + "\n")
186 | //allMessage +='\n'+data.msg+'\n'
187 | }
188 | }
189 |
190 | } catch (e) {
191 | $.logErr(e, resp)
192 | } finally {
193 | resolve(data);
194 | }
195 | })
196 | })
197 | }
198 |
199 | function finish(taskId) {
200 | return new Promise((resolve) => {
201 | sign = md5('7b7fpld4roey0e6e&taskId=' + taskId + '&time=' + timestamp)
202 | $.post(bkxs(`task_api/task/finish`, `time=${timestamp}&sign=${sign}&taskId=${taskId}&`), async (err, resp, data) => {
203 | //$.log(data)
204 | try {
205 | if (err) {
206 | console.log(`${JSON.stringify(err)}`)
207 | console.log(`${$.name} API请求失败,请检查网路重试`)
208 | } // else {
209 | if (safeGet(data)) {
210 | data = JSON.parse(data);
211 | if (data.code == 100) {
212 | console.log('\n'+'rewardNum:' + data.data.rewardNum)
213 |
214 |
215 |
216 | } else if (data.code !== 100) {
217 | //console.log(data.msg + "\n")
218 | //allMessage +='\n'+data.msg+'\n'
219 | }
220 | }
221 |
222 | } catch (e) {
223 | $.logErr(e, resp)
224 | } finally {
225 | resolve(data);
226 | }
227 | })
228 | })
229 | }
230 |
231 | function bkxs(a, body) {
232 | return {
233 |
234 | url: `${host}${a}`,
235 | body: `${body}`,
236 | headers: {
237 | 'Connection': 'Keep-Alive',
238 | 'Content-Type': 'application/x-www-form-urlencoded; Charset=UTF-8',
239 | 'Accept': '*/*',
240 | 'Accept-Language': 'zh-cn',
241 | 'Cookie': bkxshd,
242 | 'Host': 'api.ibreader.com',
243 | 'Referer': 'https://api.ibreader.com/task_api/task/getChapterTaskList',
244 | 'User-Agent': 'Mozilla/5.0 (Linux; Android 7.1.2; PCAM00 Build/NGI77B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/62.0.3202.84 Mobile Safari/537.36',
245 | 'X-Client': 'sv=7.1.2;pm=PCAM00;ss=1080*2196;version=5.1.86.18.130500001;vId=60752445880d4366988c18aa9d9f6b80;signVersion=2;webVersion=new;oaid=null;pkv=1;ddid=DUzp43Y2YF9X-5bmS5YXSEZcB3nELTOxTV04RFV6cDQzWTJZRjlYLTVibVM1WVhTRVpjQjNuRUxUT3hUVjA0c2h1;androidosv=25;os=0;muk=ui98HJmkunswcEuBWDlg3A%3D%3D;firm=OPPO;duk=Bv6b4gAgfXcjaj%2BBwEtH32pUNNCFZYDKNOv%2Boplr96Q%3D;',
246 | 'Accept-Encoding': 'gzip, deflate',
247 |
248 | }
249 | }
250 | }
251 | function bkxs1(a,body) {
252 | return {
253 |
254 | url: `https://increase.ibreader.com/${a}`,
255 | body: `${body}`,
256 | headers: {
257 | 'Connection': 'Keep-Alive',
258 | 'Content-Type': 'application/x-www-form-urlencoded; Charset=UTF-8',
259 | 'Accept': '*/*',
260 | 'Accept-Language': 'zh-cn',
261 | 'Cookie': bkxshd,
262 | 'Host': 'increase.ibreader.com',
263 | 'Referer': 'https://api.ibreader.com/task_api/task/getChapterTaskList',
264 | 'User-Agent': 'Mozilla/5.0 (Linux; Android 7.1.2; PCAM00 Build/NGI77B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/62.0.3202.84 Mobile Safari/537.36',
265 | 'X-Client': 'sv=7.1.2;pm=PCAM00;ss=1080*2196;version=5.1.86.18.130500001;vId=60752445880d4366988c18aa9d9f6b80;signVersion=2;webVersion=new;oaid=null;pkv=1;ddid=DUzp43Y2YF9X-5bmS5YXSEZcB3nELTOxTV04RFV6cDQzWTJZRjlYLTVibVM1WVhTRVpjQjNuRUxUT3hUVjA0c2h1;androidosv=25;os=0;muk=ui98HJmkunswcEuBWDlg3A%3D%3D;firm=OPPO;duk=Bv6b4gAgfXcjaj%2BBwEtH32pUNNCFZYDKNOv%2Boplr96Q%3D;',
266 | 'Accept-Encoding': 'gzip, deflate',
267 |
268 | }
269 | }
270 | }
271 |
272 |
273 | function md5(s) {
274 |
275 | return crypto.createHash('md5').update(String(s)).digest('hex').toUpperCase();
276 | }
277 |
278 | function safeGet(data) {
279 | try {
280 | if (typeof JSON.parse(data) == "object") {
281 | return true;
282 | }
283 | } catch (e) {
284 | console.log(e);
285 | console.log(`服务器访问数据为空,请检查自身设备网络情况`);
286 | return false;
287 | }
288 | }
289 |
290 | function jsonParse(str) {
291 | if (typeof str == "string") {
292 | try {
293 | return JSON.parse(str);
294 | } catch (e) {
295 | console.log(e);
296 | $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie')
297 | return [];
298 | }
299 | }
300 | }
301 |
302 | function Env(t, e) {
303 | class s {
304 | constructor(t) {
305 | this.env = t
306 | }
307 | send(t, e = "GET") {
308 | t = "string" == typeof t ? {
309 | url: t
310 | } : t;
311 | let s = this.get;
312 | return "POST" === e && (s = this.post), new Promise((e, i) => {
313 | s.call(this, t, (t, s, r) => {
314 | t ? i(t) : e(s)
315 | })
316 | })
317 | }
318 | get(t) {
319 | return this.send.call(this.env, t)
320 | }
321 | post(t) {
322 | return this.send.call(this.env, t, "POST")
323 | }
324 | }
325 | return new class {
326 | constructor(t, e) {
327 | 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}, 开始!`)
328 | }
329 | isNode() {
330 | return "undefined" != typeof module && !!module.exports
331 | }
332 | isQuanX() {
333 | return "undefined" != typeof $task
334 | }
335 | isSurge() {
336 | return "undefined" != typeof $httpClient && "undefined" == typeof $loon
337 | }
338 | isLoon() {
339 | return "undefined" != typeof $loon
340 | }
341 | toObj(t, e = null) {
342 | try {
343 | return JSON.parse(t)
344 | } catch {
345 | return e
346 | }
347 | }
348 | toStr(t, e = null) {
349 | try {
350 | return JSON.stringify(t)
351 | } catch {
352 | return e
353 | }
354 | }
355 | getjson(t, e) {
356 | let s = e;
357 | const i = this.getdata(t);
358 | if (i) try {
359 | s = JSON.parse(this.getdata(t))
360 | } catch {}
361 | return s
362 | }
363 | setjson(t, e) {
364 | try {
365 | return this.setdata(JSON.stringify(t), e)
366 | } catch {
367 | return !1
368 | }
369 | }
370 | getScript(t) {
371 | return new Promise(e => {
372 | this.get({
373 | url: t
374 | }, (t, s, i) => e(i))
375 | })
376 | }
377 | runScript(t, e) {
378 | return new Promise(s => {
379 | let i = this.getdata("@chavy_boxjs_userCfgs.httpapi");
380 | i = i ? i.replace(/\n/g, "").trim() : i;
381 | let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");
382 | r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r;
383 | const [o, h] = i.split("@"), a = {
384 | url: `http://${h}/v1/scripting/evaluate`,
385 | body: {
386 | script_text: t,
387 | mock_type: "cron",
388 | timeout: r
389 | },
390 | headers: {
391 | "X-Key": o,
392 | Accept: "*/*"
393 | }
394 | };
395 | this.post(a, (t, e, i) => s(i))
396 | }).catch(t => this.logErr(t))
397 | }
398 | loaddata() {
399 | if (!this.isNode()) return {}; {
400 | this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
401 | const t = this.path.resolve(this.dataFile),
402 | e = this.path.resolve(process.cwd(), this.dataFile),
403 | s = this.fs.existsSync(t),
404 | i = !s && this.fs.existsSync(e);
405 | if (!s && !i) return {}; {
406 | const i = s ? t : e;
407 | try {
408 | return JSON.parse(this.fs.readFileSync(i))
409 | } catch (t) {
410 | return {}
411 | }
412 | }
413 | }
414 | }
415 | writedata() {
416 | if (this.isNode()) {
417 | this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
418 | const t = this.path.resolve(this.dataFile),
419 | e = this.path.resolve(process.cwd(), this.dataFile),
420 | s = this.fs.existsSync(t),
421 | i = !s && this.fs.existsSync(e),
422 | r = JSON.stringify(this.data);
423 | s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r)
424 | }
425 | }
426 | lodash_get(t, e, s) {
427 | const i = e.replace(/\[(\d+)\]/g, ".$1").split(".");
428 | let r = t;
429 | for (const t of i)
430 | if (r = Object(r)[t], void 0 === r) return s;
431 | return r
432 | }
433 | lodash_set(t, e, s) {
434 | 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)
435 | }
436 | getdata(t) {
437 | let e = this.getval(t);
438 | if (/^@/.test(t)) {
439 | const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : "";
440 | if (r) try {
441 | const t = JSON.parse(r);
442 | e = t ? this.lodash_get(t, i, "") : e
443 | } catch (t) {
444 | e = ""
445 | }
446 | }
447 | return e
448 | }
449 | setdata(t, e) {
450 | let s = !1;
451 | if (/^@/.test(e)) {
452 | const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}";
453 | try {
454 | const e = JSON.parse(h);
455 | this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i)
456 | } catch (e) {
457 | const o = {};
458 | this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i)
459 | }
460 | } else s = this.setval(t, e);
461 | return s
462 | }
463 | getval(t) {
464 | 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
465 | }
466 | setval(t, e) {
467 | 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
468 | }
469 | initGotEnv(t) {
470 | 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))
471 | }
472 | get(t, e = (() => {})) {
473 | 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, {
474 | "X-Surge-Skip-Scripting": !1
475 | })), $httpClient.get(t, (t, s, i) => {
476 | !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i)
477 | })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {
478 | hints: !1
479 | })), $task.fetch(t).then(t => {
480 | const {
481 | statusCode: s,
482 | statusCode: i,
483 | headers: r,
484 | body: o
485 | } = t;
486 | e(null, {
487 | status: s,
488 | statusCode: i,
489 | headers: r,
490 | body: o
491 | }, o)
492 | }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => {
493 | try {
494 | if (t.headers["set-cookie"]) {
495 | const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();
496 | s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar
497 | }
498 | } catch (t) {
499 | this.logErr(t)
500 | }
501 | }).then(t => {
502 | const {
503 | statusCode: s,
504 | statusCode: i,
505 | headers: r,
506 | body: o
507 | } = t;
508 | e(null, {
509 | status: s,
510 | statusCode: i,
511 | headers: r,
512 | body: o
513 | }, o)
514 | }, t => {
515 | const {
516 | message: s,
517 | response: i
518 | } = t;
519 | e(s, i, i && i.body)
520 | }))
521 | }
522 | post(t, e = (() => {})) {
523 | 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, {
524 | "X-Surge-Skip-Scripting": !1
525 | })), $httpClient.post(t, (t, s, i) => {
526 | !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i)
527 | });
528 | else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {
529 | hints: !1
530 | })), $task.fetch(t).then(t => {
531 | const {
532 | statusCode: s,
533 | statusCode: i,
534 | headers: r,
535 | body: o
536 | } = t;
537 | e(null, {
538 | status: s,
539 | statusCode: i,
540 | headers: r,
541 | body: o
542 | }, o)
543 | }, t => e(t));
544 | else if (this.isNode()) {
545 | this.initGotEnv(t);
546 | const {
547 | url: s,
548 | ...i
549 | } = t;
550 | this.got.post(s, i).then(t => {
551 | const {
552 | statusCode: s,
553 | statusCode: i,
554 | headers: r,
555 | body: o
556 | } = t;
557 | e(null, {
558 | status: s,
559 | statusCode: i,
560 | headers: r,
561 | body: o
562 | }, o)
563 | }, t => {
564 | const {
565 | message: s,
566 | response: i
567 | } = t;
568 | e(s, i, i && i.body)
569 | })
570 | }
571 | }
572 | time(t) {
573 | let e = {
574 | "M+": (new Date).getMonth() + 1,
575 | "d+": (new Date).getDate(),
576 | "H+": (new Date).getHours(),
577 | "m+": (new Date).getMinutes(),
578 | "s+": (new Date).getSeconds(),
579 | "q+": Math.floor(((new Date).getMonth() + 3) / 3),
580 | S: (new Date).getMilliseconds()
581 | };
582 | /(y+)/.test(t) && (t = t.replace(RegExp.$1, ((new Date).getFullYear() + "").substr(4 - RegExp.$1.length)));
583 | 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)));
584 | return t
585 | }
586 | msg(e = t, s = "", i = "", r) {
587 | const o = t => {
588 | if (!t) return t;
589 | if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? {
590 | "open-url": t
591 | } : this.isSurge() ? {
592 | url: t
593 | } : void 0;
594 | if ("object" == typeof t) {
595 | if (this.isLoon()) {
596 | let e = t.openUrl || t.url || t["open-url"],
597 | s = t.mediaUrl || t["media-url"];
598 | return {
599 | openUrl: e,
600 | mediaUrl: s
601 | }
602 | }
603 | if (this.isQuanX()) {
604 | let e = t["open-url"] || t.url || t.openUrl,
605 | s = t["media-url"] || t.mediaUrl;
606 | return {
607 | "open-url": e,
608 | "media-url": s
609 | }
610 | }
611 | if (this.isSurge()) {
612 | let e = t.url || t.openUrl || t["open-url"];
613 | return {
614 | url: e
615 | }
616 | }
617 | }
618 | };
619 | if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) {
620 | let t = ["", "==============📣系统通知📣=============="];
621 | t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t)
622 | }
623 | }
624 | log(...t) {
625 | t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator))
626 | }
627 | logErr(t, e) {
628 | const s = !this.isSurge() && !this.isQuanX() && !this.isLoon();
629 | s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t)
630 | }
631 | wait(t) {
632 | return new Promise(e => setTimeout(e, t))
633 | }
634 | done(t = {}) {
635 | const e = (new Date).getTime(),
636 | s = (e - this.startTime) / 1e3;
637 | this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t)
638 | }
639 | }(t, e)
640 | }
641 |
--------------------------------------------------------------------------------
/yangmao/xmydsbs.py:
--------------------------------------------------------------------------------
1 | # !/bin/env python3
2 | # -*- coding: utf-8 -*
3 | """
4 | cron: 57 18 * * *
5 | const $ = new Env("小米运动刷步数");
6 |
7 | 变量格式:
8 | export xmydsbs_step="23333" 或者 "20000,30000"
9 | export xmydsbs_api="false" 本地提交失败后禁用api提交(默认开启),注释这行或将改为ture启动api提交
10 | export xmydsbs_sleep="10" 多账号之间延迟默认 10秒
11 | export xmydsbs_data="手机号&密码#邮箱&密码" 多账号用 换行 或 # 分割
12 |
13 | 23333为固定步数写法 20000,30000随机步数写法
14 |
15 | """
16 |
17 | try:
18 | import requests
19 | import json
20 | import sys
21 | import os
22 | import re
23 | import time
24 | import random
25 | import asyncio
26 | except Exception as e:
27 | print(e)
28 | requests.packages.urllib3.disable_warnings()
29 | # --------------------------------------------------------------------------------------------
30 | Script_Name = "小米运动刷步数"
31 | Name_Pinyin = "xmydsbs"
32 | Script_Change = "提交成功统计优化标题栏通知,多账号之间脚本休眠默认10秒,手机号和邮箱均可本地✔✔✔,若出现❌❌❌会使用默认api提交(可更改),适配青龙环境变量、通知和版本更新等"
33 | Script_Version = "1.0.3"
34 | # --------------------------------------------------------------------------------------------
35 | async def start():
36 | global ckArr,step,count_success_dict
37 | if f"{Name_Pinyin}_sleep" in os.environ and str(os.environ[f"{Name_Pinyin}_sleep"]).isdigit():
38 | sleepTime = int(os.environ[f"{Name_Pinyin}_sleep"])
39 | else:
40 | sleepTime = 10 # 默认休眠时间 10秒
41 | msg(f"📌 本次刷步数脚本休眠时间为 {sleepTime} 秒")
42 |
43 | count_success_dict = {'success': 0, '步数提交成功': 0} #response返回的字符串,api增加可以修改该字典值
44 |
45 | for inx, data in enumerate(ckArr):
46 | msg("============= 开始第" + str(inx + 1) + "个账号 =============")
47 | ck = data.split("&")
48 |
49 | step_name = f"{Name_Pinyin}_step"
50 | if step_name in os.environ:
51 | _step = os.environ[f"{Name_Pinyin}_step"]
52 | if _step.isdigit():
53 | msg(f"🥾本次刷步数为{_step}")
54 | step = _step
55 | else:
56 | _step = re.findall("\d+", _step)
57 | msg(f"🥾本次刷步数为{_step[0]}-{_step[1]}的随机步数")
58 | step = random.randint(int(_step[0]), int(_step[1]))
59 | else:
60 | msg("🥾本次刷步数为20000-30000的随机步数")
61 | step = str(random.randint(20000,30000))
62 |
63 | istel = re.match(r"^1[35678]\d{9}$", ck[0])
64 | await sbs_info(ck[0], ck[1], step, istel)
65 |
66 | time.sleep(sleepTime)
67 |
68 | def ql_env(name):
69 | global ckArr,step
70 | if name in os.environ:
71 | ckArr = []
72 | _data = os.environ[name]
73 | if "#" in _data:
74 | _ck = _data.split("#")
75 | ckArr = _ck
76 | elif "\n" in _data:
77 | _ck = _data.splitlines()
78 | ckArr = _ck
79 | else:
80 | ckArr = _data.split("+")
81 |
82 | #获取登录code
83 | def get_code(location):
84 | code_pattern = re.compile("(?<=access=).*?(?=&)")
85 | code = code_pattern.findall(location)[0]
86 | return code
87 |
88 | #登录
89 | async def login(user, password, istel):
90 | if istel:
91 | user = "+86" + user
92 | registrations_url = "https://api-user.huami.com/registrations/" + user + "/tokens"
93 | headers = {
94 | "Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",
95 | "User-Agent":"MiFit/6.3.5 (iPhone; iOS 14.0.1; Scale/2.00)"
96 | }
97 | data1 = {
98 | "client_id":"HuaMi",
99 | "password":f"{password}",
100 | "redirect_uri":"https://s3-us-west-2.amazonaws.com/hm-registration/successsignin.html",
101 | "token":"access"
102 | }
103 | res1 = requests.post(registrations_url,data=data1,headers=headers,allow_redirects=False)
104 | if str(res1) == '':
105 | msg("❌登录次数过多请稍后")
106 | login_token = 0
107 | userid = 0
108 | return login_token,userid
109 | else:
110 | location = res1.headers["Location"]
111 | try:
112 | code = get_code(location)
113 | except:
114 | return 0, 0
115 | login_url = "https://account.huami.com/v2/client/login"
116 | data2 = {
117 | "app_name":"com.xiaomi.hm.health",
118 | "app_version":"4.6.0",
119 | "code":f"{code}",
120 | "country_code":"CN",
121 | "device_id":"2C8B4939-0CCD-4E94-8CBA-CB8EA6E613A1",
122 | "device_model":"phone",
123 | "grant_type":"access_token",
124 | "third_name":"huami_phone" if istel != None else "email"
125 | }
126 | try:
127 | res = requests.post(login_url,data=data2,headers=headers).json()
128 | login_token = res["token_info"]["login_token"]
129 | userid = res["token_info"]["user_id"]
130 | return login_token,userid
131 | except Exception as err:
132 | print(err)
133 |
134 | # 13位时间戳
135 | def gettimestamp():
136 | return str(int(time.time() * 1000))
137 |
138 | #获取app_token
139 | async def get_app_token(login_token):
140 | url = f"https://account-cn.huami.com/v1/client/app_tokens?app_name=com.xiaomi.hm.health&dn=api-user.huami.com%2Capi-mifit.huami.com%2Capp-analytics.huami.com&login_token={login_token}"
141 | headers = {
142 | 'User-Agent': 'MiFit/6.3.5 (iPhone; iOS 14.0.1; Scale/2.00)'
143 | }
144 | try:
145 | res = requests.get(url,headers=headers).json()
146 | app_token = res['token_info']['app_token']
147 | return app_token
148 | except Exception as err:
149 | print(err)
150 |
151 | #登录
152 | async def sbs_info(user, password, step, istel):
153 | global count_success_dict
154 | user = str(user)
155 | password = str(password)
156 | step = str(step)
157 |
158 | login_token = 0
159 | login_token,userid = await login(user, password, istel)
160 | if login_token == 0:
161 | use_api_name = f"{Name_Pinyin}_api"
162 | if use_api_name in os.environ:
163 | use_api = os.environ[f"{Name_Pinyin}_api"]
164 | if use_api == "false":
165 | msg("❌登录失败,退出该账号")
166 | else:
167 | msg("❌登录失败,即将使用api重试")
168 | await sbs_api_info(user, password, step, istel)
169 | else:
170 | msg("❌登录失败,即将使用api重试")
171 | await sbs_api_info(user, password, step, istel)
172 | else:
173 | msg("🍗获取login_token和userid成功!")
174 |
175 | app_token = await get_app_token(login_token)
176 | if app_token == 0:
177 | msg("获取app_token失败")
178 | else:
179 | msg("🍗获取app_token成功!")
180 | today = time.strftime("%F")
181 | data_json = '%5B%7B%22data_hr%22%3A%22%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F9L%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5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%5C%22%3A0%2C%5C%22to%5C%22%3A0%2C%5C%22dt%5C%22%3A0%2C%5C%22rhr%5C%22%3A0%2C%5C%22ss%5C%22%3A0%7D%2C%5C%22stp%5C%22%3A%7B%5C%22ttl%5C%22%3A18272%2C%5C%22dis%5C%22%3A10627%2C%5C%22cal%5C%22%3A510%2C%5C%22wk%5C%22%3A41%2C%5C%22rn%5C%22%3A50%2C%5C%22runDist%5C%22%3A7654%2C%5C%22runCal%5C%22%3A397%2C%5C%22stage%5C%22%3A%5B%7B%5C%22start%5C%22%3A327%2C%5C%22stop%5C%22%3A341%2C%5C%22mode%5C%22%3A1%2C%5C%22dis%5C%22%3A481%2C%5C%22cal%5C%22%3A13%2C%5C%22step%5C%22%3A680%7D%2C%7B%5C%22start%5C%22%3A342%2C%5C%22stop%5C%22%3A367%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A2295%2C%5C%22cal%5C%22%3A95%2C%5C%22step%5C%22%3A2874%7D%2C%7B%5C%22start%5C%22%3A368%2C%5C%22stop%5C%22%3A377%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1592%2C%5C%22cal%5C%22%3A88%2C%5C%22step%5C%22%3A1664%7D%2C%7B%5C%22start%5C%22%3A378%2C%5C%22stop%5C%22%3A386%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1072%2C%5C%22cal%5C%22%3A51%2C%5C%22step%5C%22%3A1245%7D%2C%7B%5C%22start%5C%22%3A387%2C%5C%22stop%5C%22%3A393%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1036%2C%5C%22cal%5C%22%3A57%2C%5C%22step%5C%22%3A1124%7D%2C%7B%5C%22start%5C%22%3A394%2C%5C%22stop%5C%22%3A398%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A488%2C%5C%22cal%5C%22%3A19%2C%5C%22step%5C%22%3A607%7D%2C%7B%5C%22start%5C%22%3A399%2C%5C%22stop%5C%22%3A414%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A2220%2C%5C%22cal%5C%22%3A120%2C%5C%22step%5C%22%3A2371%7D%2C%7B%5C%22start%5C%22%3A415%2C%5C%22stop%5C%22%3A427%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1268%2C%5C%22cal%5C%22%3A59%2C%5C%22step%5C%22%3A1489%7D%2C%7B%5C%22start%5C%22%3A428%2C%5C%22stop%5C%22%3A433%2C%5C%22mode%5C%22%3A1%2C%5C%22dis%5C%22%3A152%2C%5C%22cal%5C%22%3A4%2C%5C%22step%5C%22%3A238%7D%2C%7B%5C%22start%5C%22%3A434%2C%5C%22stop%5C%22%3A444%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A2295%2C%5C%22cal%5C%22%3A95%2C%5C%22step%5C%22%3A2874%7D%2C%7B%5C%22start%5C%22%3A445%2C%5C%22stop%5C%22%3A455%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1592%2C%5C%22cal%5C%22%3A88%2C%5C%22step%5C%22%3A1664%7D%2C%7B%5C%22start%5C%22%3A456%2C%5C%22stop%5C%22%3A466%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1072%2C%5C%22cal%5C%22%3A51%2C%5C%22step%5C%22%3A1245%7D%2C%7B%5C%22start%5C%22%3A467%2C%5C%22stop%5C%22%3A477%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1036%2C%5C%22cal%5C%22%3A57%2C%5C%22step%5C%22%3A1124%7D%2C%7B%5C%22start%5C%22%3A478%2C%5C%22stop%5C%22%3A488%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A488%2C%5C%22cal%5C%22%3A19%2C%5C%22step%5C%22%3A607%7D%2C%7B%5C%22start%5C%22%3A489%2C%5C%22stop%5C%22%3A499%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A2220%2C%5C%22cal%5C%22%3A120%2C%5C%22step%5C%22%3A2371%7D%2C%7B%5C%22start%5C%22%3A500%2C%5C%22stop%5C%22%3A511%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1268%2C%5C%22cal%5C%22%3A59%2C%5C%22step%5C%22%3A1489%7D%2C%7B%5C%22start%5C%22%3A512%2C%5C%22stop%5C%22%3A522%2C%5C%22mode%5C%22%3A1%2C%5C%22dis%5C%22%3A152%2C%5C%22cal%5C%22%3A4%2C%5C%22step%5C%22%3A238%7D%5D%7D%2C%5C%22goal%5C%22%3A8000%2C%5C%22tz%5C%22%3A%5C%2228800%5C%22%7D%22%2C%22source%22%3A24%2C%22type%22%3A0%7D%5D'
182 |
183 | finddate = re.compile(r'.*?date%22%3A%22(.*?)%22%2C%22data.*?')
184 | findstep = re.compile(r'.*?ttl%5C%22%3A(.*?)%2C%5C%22dis.*?')
185 | data_json = re.sub(finddate.findall(data_json)[0], today, str(data_json))
186 | data_json = re.sub(findstep.findall(data_json)[0], step, str(data_json))
187 |
188 | url = f'https://api-mifit-cn.huami.com/v1/data/band_data.json?&t={gettimestamp()}'
189 | head = {
190 | "apptoken": app_token,
191 | "Content-Type": "application/x-www-form-urlencoded"
192 | }
193 |
194 | data = f'userid={userid}&last_sync_data_time=1597306380&device_type=0&last_deviceid=DA932FFFFE8816E7&data_json={data_json}'
195 | try:
196 | response = requests.post(url, data=data, headers=head).json()
197 | _type = f"手机账号*******{user[-4:]}" if istel != None else f"邮箱账号{user[:4]}*******"
198 | result = f"🎈{_type}: 修改步数{step} "+ response['message']
199 | msg(result)
200 | if response['message'] in count_success_dict:#统计
201 | count_success_dict[response['message']] += 1
202 | except Exception as err:
203 | print(err)
204 |
205 | #api登录
206 | async def sbs_api_info(user, password, step ,istel):
207 | global count_success_dict
208 | base_url = f"https://apis.jxcxin.cn/api/mi?user={user}&password={password}&step={step}"
209 | headers = {
210 | 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0',
211 | 'host': 'apis.jxcxin.cn',
212 | 'Accept': '*/*',
213 | }
214 | try:
215 | response = requests.get(base_url, headers=headers).json()
216 | _type = f"手机账号*******{user[-4:]}" if istel != None else f"邮箱账号{user[:4]}*******"
217 | result = f"🎈{_type}: 修改步数{step} "+ response['msg']
218 | msg(result)
219 | if response['msg'] in count_success_dict:#统计
220 | count_success_dict[response['msg']] += 1
221 | except Exception as err:
222 | print(err)
223 |
224 | # ====================================================================
225 | def last_version(name, mold):
226 | url = ''
227 | if mold == 1:
228 | url = f"https://raw.gh.fakev.cn/miranda0111/xmydsbs/main//{name}.py"
229 | try:
230 | _url = url
231 | _headers = {}
232 | resp = requests.get(url=_url, headers=_headers, verify=False)
233 | result = resp.text
234 | resp.close()
235 | r = re.compile(r'Script_Version = "(.*?)"')
236 | _data = r.findall(result)
237 | if not _data:
238 | return "出现未知错误 ,请稍后重试!"
239 | else:
240 | return _data[0]
241 | except Exception as err:
242 | print(err)
243 |
244 | # 通知服务
245 | class Msg(object):
246 | def __init__(self, m=''):
247 | self.str_msg = m
248 | self.message()
249 |
250 | # noinspection PyMethodMayBeStatic
251 | def get_sendnotify(self):
252 | if not os.path.exists("sendNotify.py"):
253 | cur_path = os.getcwd()
254 | print(f"未找到通知依赖文件,将于脚本执行目录({cur_path})新建:sendNotify.py (url为https://raw.githubusercontent.com/)")
255 | try:
256 | url = 'https://raw.githubusercontent.com/miranda0111/xmydsbs/main/sendNotify.py'
257 | response = requests.get(url)
258 | with open('sendNotify.py', "w+", encoding="utf-8") as f:
259 | f.write(response.text)
260 | except Exception as err:
261 | print(err)
262 | else:
263 | print("文件已存在,跳过")
264 | pass
265 | pass
266 |
267 | def message(self):
268 | global msg_info
269 | print(self.str_msg)
270 | try:
271 | # msg_info = ''
272 | msg_info = f"{msg_info}\n{self.str_msg}"
273 | except Exception as err:
274 | print(err)
275 | msg_info = "{}".format(self.str_msg)
276 | sys.stdout.flush()
277 | # 这代码的作用就是刷新缓冲区。
278 | # 当我们打印一些字符时 ,并不是调用print函数后就立即打印的。一般会先将字符送到缓冲区 ,然后再打印。
279 | # 这就存在一个问题 ,如果你想等时间间隔的打印一些字符 ,但由于缓冲区没满 ,不会打印。就需要采取一些手段。如每次打印后强行刷新缓冲区。
280 |
281 | def main(self):
282 | global send
283 | cur_path = os.getcwd()
284 | # print(cur_path)
285 | if os.path.exists(cur_path + "/sendNotify.py"):
286 | # noinspection PyBroadException
287 | try:
288 | from sendNotify import send
289 | except Exception as err:
290 | self.get_sendnotify()
291 | print(err)
292 | try:
293 | from sendNotify import send
294 | except Exception as err:
295 | print(err)
296 | print("加载通知服务失败~")
297 | else:
298 | self.get_sendnotify()
299 | try:
300 | from sendNotify import send
301 | except Exception as err:
302 | print(err)
303 | print("加载通知服务失败~")
304 |
305 | Msg().main()
306 |
307 | def msg(data):
308 | Msg(data)
309 |
310 | ql_env(f"{Name_Pinyin}_data")
311 |
312 | def tip():
313 | print("================ 脚本只支持青龙 =================")
314 | print("============ 具体教程以请自行查看顶部教程 =============")
315 |
316 | msg(f"🔔 {Script_Name},开始! ")
317 | #origin_version = last_version(Name_Pinyin, 1)
318 | #msg(f"📌 本地脚本: {Script_Version}\n 远程仓库版本: {origin_version}")
319 | #if str(Script_Version) == str(origin_version):
320 | # msg(f"📌 🆙 脚本版本一致,完成内容: {Script_Change}")
321 | #else:
322 | # msg('📌 📌 📌 发现版本更新!请尽快更新!📌 📌 📌 \n')
323 | # msg(f"📌 🆙 更新内容: {Script_Change}")
324 | # msg('📌感谢@yml2213的镜像站')
325 |
326 | # msg(f"📌 本地脚本版本: {Script_Version}")
327 | msg(f"📌 共发现 {str(len(ckArr))} 个账号")
328 |
329 | if __name__ == '__main__':
330 | global ckArr, step, msg_info, send, count_success_dict
331 | tip()
332 | asyncio.run(start())
333 | print(count_success_dict)
334 | if int(len(ckArr)) == count_success_dict['success'] + count_success_dict['步数提交成功']:
335 | complete = '成功'
336 | else:
337 | complete = '失败'
338 | send(f"{Script_Name}{str(len(ckArr))}个{complete}", msg_info)
339 |
--------------------------------------------------------------------------------
/yangmao/tuchong.js:
--------------------------------------------------------------------------------
1 | /*
2 | APP:图虫 邀请码;eq8XBz71KoS
3 | 抓域名tuchong.com
4 | 任意一条请求头的token
5 | 变量
6 | export tchd=''
7 | 多号@或换行
8 | */
9 |
10 |
11 | const $ = new Env('图虫');
12 | const axios = require('axios');
13 | let request = require("request");
14 | request = request.defaults({
15 | jar: true
16 | });
17 | const {
18 | log
19 | } = console;
20 | const Notify = 1; //0为关闭通知,1为打开通知,默认为1
21 | const debug = 0; //0为关闭调试,1为打开调试,默认为0
22 | let tchd = ($.isNode() ? process.env.tchd : $.getdata("tchd")) || ""
23 | let tchdArr = [];
24 | let data = '';
25 | let msg = '';
26 | var hours = new Date().getMonth();
27 |
28 | var timestamp = Math.round(new Date().getTime()).toString();
29 | !(async () => {
30 | if (typeof $request !== "undefined") {
31 | await GetRewrite();
32 | } else {
33 | if (!(await Envs()))
34 | return;
35 | else {
36 |
37 | log(`\n\n============================================= \n脚本执行 - 北京时间(UTC+8):${new Date(
38 | new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 +
39 | 8 * 60 * 60 * 1000).toLocaleString()} \n=============================================\n`);
40 |
41 |
42 | log(`\n=================== 共找到 ${tchdArr.length} 个账号 ===================`)
43 | if (debug) {
44 | log(`【debug】 这是你的全部账号数组:\n ${tchdArr}`);
45 | }
46 | for (let index = 0; index < tchdArr.length; index++) {
47 |
48 | let num = index + 1
49 | addNotifyStr(`\n==== 开始【第 ${num} 个账号】====\n`, true)
50 |
51 | tchd = tchdArr[index];
52 | await req('tuchonggapi/reward/point/box')
53 | await req('tuchongrest/point/check-in')
54 | await reqlik('gapi/interactive/like?video_id=25888&language=zh&resolution=1080*2208&device_type=PCAM00&device_platform=android&os_api=29&device_brand=OPPO&_rticket=1671019431708&version_code=7400&version_name=7.40.0&ac=wifi&os=android&aid=1130&dpi=480&iid=1632128525153271&cdid=8405a1ce-3998-4402-8f0a-1cd9e8030838&device_id=4081809011261261&ssmix=a&os_version=10&channel=oppo&app_name=tuchong&update_version_code=7400&manifest_version_code=7400')
55 | await reqlik('gapi/interactive/follow?site_id=3406040&language=zh&resolution=1080*2208&device_type=PCAM00&device_platform=android&os_api=29&device_brand=OPPO&_rticket=1671019662445&version_code=7400&version_name=7.40.0&ac=wifi&os=android&aid=1130&dpi=480&iid=1632128525153271&cdid=8405a1ce-3998-4402-8f0a-1cd9e8030838&device_id=4081809011261261&ssmix=a&os_version=10&channel=oppo&app_name=tuchong&update_version_code=7400&manifest_version_code=7400')
56 | await reqpost('share/recall?language=zh&resolution=1080*2196&device_type=PCAM00&device_platform=android&os_api=28&device_brand=OPPO&_rticket=1670944907517&version_code=7400&version_name=7.40.0&ac=4g&os=android&aid=1130&dpi=480&iid=1632128525153271&cdid=8405a1ce-3998-4402-8f0a-1cd9e8030838&device_id=4081809011261261&ssmix=a&os_version=9&channel=oppo&app_name=tuchong&update_version_code=7400&manifest_version_code=7400','share_id=4903&content_type=video&author_id=1621801&platform=WechatFriend')
57 | await reqpost1('gapi/interactive/like?language=zh&resolution=1080*2208&device_type=PCAM00&device_platform=android&os_api=29&device_brand=OPPO&_rticket=1671019328120&version_code=7400&version_name=7.40.0&ac=wifi&os=android&aid=1130&dpi=480&iid=1632128525153271&cdid=8405a1ce-3998-4402-8f0a-1cd9e8030838&device_id=4081809011261261&ssmix=a&os_version=10&channel=oppo&app_name=tuchong&update_version_code=7400&manifest_version_code=7400','video_id=25888')
58 | await reqpost1('gapi/interactive/follow?language=zh&resolution=1080*2208&device_type=PCAM00&device_platform=android&os_api=29&device_brand=OPPO&_rticket=1671019646538&version_code=7400&version_name=7.40.0&ac=wifi&os=android&aid=1130&dpi=480&iid=1632128525153271&cdid=8405a1ce-3998-4402-8f0a-1cd9e8030838&device_id=4081809011261261&ssmix=a&os_version=10&channel=oppo&app_name=tuchong&update_version_code=7400&manifest_version_code=7400','site_id=3406040')
59 | await reqpost('2/videos/4903/comments?language=zh&resolution=1080*2196&device_type=PCAM00&device_platform=android&os_api=28&device_brand=OPPO&_rticket=1670944931049&version_code=7400&version_name=7.40.0&ac=4g&os=android&aid=1130&dpi=480&iid=1632128525153271&cdid=8405a1ce-3998-4402-8f0a-1cd9e8030838&device_id=4081809011261261&ssmix=a&os_version=9&channel=oppo&app_name=tuchong&update_version_code=7400&manifest_version_code=7400','parent_note_id=0&content=%5B%E9%BC%93%E6%8E%8C%5D%5B%E9%BC%93%E6%8E%8C%5D%5B%E9%BC%93%E6%8E%8C%5D%5B%E9%BC%93%E6%8E%8C%5D%5B%E9%BC%93%E6%8E%8C%5D%5B%E7%8E%AB%E7%91%B0%5D%5B%E7%8E%AB%E7%91%B0%5D%5B%E7%8E%AB%E7%91%B0%5D&reply_to_note_id=0')
60 | await req('tuchongrest/prize/latestreceive')
61 | }
62 | //await SendMsg(msg);
63 | }
64 | }
65 | })()
66 | .catch((e) => log(e))
67 | .finally(() => $.done())
68 | async function reqlik(api) {
69 | return new Promise((resolve) => {
70 | var options = {
71 | method: 'DELETE',
72 | url: 'https://tuchong.com/'+api,
73 | headers: {
74 |
75 | 'Host': 'tuchong.com',
76 | 'token':tchd,
77 |
78 | 'User-Agent': 'okhttp/3.8.1',
79 | 'version': 7400,
80 | 'channel': 'oppo',
81 |
82 | 'platform': 'android',
83 | 'content-type': 'application/x-www-form-urlencoded',
84 | 'host-address': '123.6.30.188',
85 | 'host-name': 'tuchong.com',
86 | },
87 |
88 | };
89 | if (debug) {
90 | log(`\n【debug】=============== 这是 请求 url ===============`);
91 | log(JSON.stringify(options));
92 | }
93 | axios.request(options).then(async function(response) {
94 | try {
95 | data = response.data;
96 | if (debug) {
97 | log(`\n\n【debug】===============这是 返回data==============`);
98 | authcode = data.listdata.authcode
99 | }
100 | if (data.code == 0) {
101 | log(JSON.stringify(response.data));
102 | } else
103 | log(JSON.stringify(response.data));
104 |
105 |
106 |
107 | } catch (e) {
108 | //log(`异常:${data},原因:${data}`)
109 | //log(JSON.stringify(data));
110 | }
111 | }).catch(function(error) {
112 | console.error(error);
113 | }).then(res => {
114 | //这里处理正确返回
115 | resolve();
116 | });
117 | })
118 |
119 | }
120 | async function req(api) {
121 | return new Promise((resolve) => {
122 | var options = {
123 | method: 'GET',
124 | url: 'https://m.tuchong.com/'+api,
125 | headers: {
126 | 'Content-Type': 'application/json, text/plain, */*',
127 | 'x-requested-with': 'com.ss.android.tuchong',
128 | 'Host': 'm.tuchong.com',
129 | 'token':tchd,
130 | 'Cookie':'token='+tchd,
131 | 'User-Agent': 'okhttp/3.8.1'
132 | },
133 |
134 | };
135 | if (debug) {
136 | log(`\n【debug】=============== 这是 请求 url ===============`);
137 | log(JSON.stringify(options));
138 | }
139 | axios.request(options).then(async function(response) {
140 | try {
141 | data = response.data;
142 | if (debug) {
143 | log(`\n\n【debug】===============这是 返回data==============`);
144 | authcode = data.listdata.authcode
145 | }
146 | if (data.code == 0) {
147 | log(JSON.stringify(response.data));
148 | } else
149 | log(JSON.stringify(response.data));
150 |
151 |
152 |
153 | } catch (e) {
154 | //log(`异常:${data},原因:${data}`)
155 | //log(JSON.stringify(data));
156 | }
157 | }).catch(function(error) {
158 | console.error(error);
159 | }).then(res => {
160 | //这里处理正确返回
161 | resolve();
162 | });
163 | })
164 |
165 | }
166 | async function reqpost(api,body) {
167 | return new Promise((resolve) => {
168 | var options = {
169 | method: 'POST',
170 | url: 'https://api.tuchong.com/'+api,
171 | headers: {
172 |
173 |
174 | 'Host': 'api.tuchong.com',
175 | 'token':tchd,
176 |
177 | 'User-Agent': 'okhttp/3.8.1',
178 | 'version': 7400,
179 | 'channel': 'oppo',
180 |
181 | 'platform': 'android',
182 | 'content-type': 'application/x-www-form-urlencoded',
183 | 'host-address': '123.6.30.188',
184 | 'host-name': 'api.tuchong.com',
185 | },
186 | data:body
187 | };
188 | if (debug) {
189 | log(`\n【debug】=============== 这是 请求 url ===============`);
190 | log(JSON.stringify(options));
191 | }
192 | axios.request(options).then(async function(response) {
193 | try {
194 | data = response.data;
195 | if (debug) {
196 | log(`\n\n【debug】===============这是 返回data==============`);
197 | authcode = data.listdata.authcode
198 | }
199 | if (data.code == 0) {
200 | log(JSON.stringify(response.data));
201 | } else
202 | log(JSON.stringify(response.data));
203 |
204 |
205 |
206 | } catch (e) {
207 | //log(`异常:${data},原因:${data}`)
208 | //log(JSON.stringify(data));
209 | }
210 | }).catch(function(error) {
211 | console.error(error);
212 | }).then(res => {
213 | //这里处理正确返回
214 | resolve();
215 | });
216 | })
217 |
218 | }
219 | async function reqpost1(api,body) {
220 | return new Promise((resolve) => {
221 | var options = {
222 | method: 'PUT',
223 | url: 'https://tuchong.com/'+api,
224 | headers: {
225 |
226 |
227 | 'Host': 'tuchong.com',
228 | 'token':tchd,
229 |
230 | 'User-Agent': 'okhttp/3.8.1',
231 | 'version': 7400,
232 | 'channel': 'oppo',
233 |
234 | 'platform': 'android',
235 | 'content-type': 'application/x-www-form-urlencoded',
236 | 'host-address': '123.6.30.188',
237 | 'host-name': 'tuchong.com',
238 | },
239 | data:body
240 | };
241 | if (debug) {
242 | log(`\n【debug】=============== 这是 请求 url ===============`);
243 | log(JSON.stringify(options));
244 | }
245 | axios.request(options).then(async function(response) {
246 | try {
247 | data = response.data;
248 | if (debug) {
249 | log(`\n\n【debug】===============这是 返回data==============`);
250 | authcode = data.listdata.authcode
251 | }
252 | if (data.code == 0) {
253 | log(JSON.stringify(response.data));
254 | } else
255 | log(JSON.stringify(response.data));
256 |
257 |
258 |
259 | } catch (e) {
260 | //log(`异常:${data},原因:${data}`)
261 | //log(JSON.stringify(data));
262 | }
263 | }).catch(function(error) {
264 | console.error(error);
265 | }).then(res => {
266 | //这里处理正确返回
267 | resolve();
268 | });
269 | })
270 |
271 | }
272 | async function Envs() {
273 | if (tchd) {
274 | if (tchd.indexOf("@") != -1) {
275 | tchd.split("@").forEach((item) => {
276 |
277 | tchdArr.push(item);
278 | });
279 | } else if (tchd.indexOf("\n") != -1) {
280 | tchd.split("\n").forEach((item) => {
281 | tchdArr.push(item);
282 | });
283 | } else {
284 | tchdArr.push(tchd);
285 | }
286 | } else {
287 | log(`\n 【${$.name}】:未填写变量 tchd`)
288 | return;
289 | }
290 |
291 | return true;
292 | }
293 | function addNotifyStr(str, is_log = true) {
294 | if (is_log) {
295 | log(`${str}\n`)
296 | }
297 | msg += `${str}\n`
298 | }
299 |
300 | // ============================================发送消息============================================ \\
301 | async function SendMsg(message) {
302 | if (!message)
303 | return;
304 |
305 | if (Notify > 0) {
306 | if ($.isNode()) {
307 | var notify = require('./sendNotify');
308 | await notify.sendNotify($.name, message);
309 | } else {
310 | $.msg(message);
311 | }
312 | } else {
313 | log(message);
314 | }
315 | }
316 | function Env(t, e) {
317 | "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0);
318 |
319 | class s {
320 | constructor(t) {
321 | this.env = t
322 | }
323 |
324 | send(t, e = "GET") {
325 | t = "string" == typeof t ? {
326 | url: t
327 | } : t;
328 | let s = this.get;
329 | return "POST" === e && (s = this.post), new Promise((e, i) => {
330 | s.call(this, t, (t, s, r) => {
331 | t ? i(t) : e(s)
332 | })
333 | })
334 | }
335 |
336 | get(t) {
337 | return this.send.call(this.env, t)
338 | }
339 |
340 | post(t) {
341 | return this.send.call(this.env, t, "POST")
342 | }
343 | }
344 |
345 | return new class {
346 | constructor(t, e) {
347 | 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}, 开始!`)
348 | }
349 |
350 | isNode() {
351 | return "undefined" != typeof module && !!module.exports
352 | }
353 |
354 | isQuanX() {
355 | return "undefined" != typeof $task
356 | }
357 |
358 | isSurge() {
359 | return "undefined" != typeof $httpClient && "undefined" == typeof $loon
360 | }
361 |
362 | isLoon() {
363 | return "undefined" != typeof $loon
364 | }
365 |
366 | toObj(t, e = null) {
367 | try {
368 | return JSON.parse(t)
369 | } catch {
370 | return e
371 | }
372 | }
373 |
374 | toStr(t, e = null) {
375 | try {
376 | return JSON.stringify(t)
377 | } catch {
378 | return e
379 | }
380 | }
381 |
382 | getjson(t, e) {
383 | let s = e;
384 | const i = this.getdata(t);
385 | if (i) try {
386 | s = JSON.parse(this.getdata(t))
387 | } catch {}
388 | return s
389 | }
390 |
391 | setjson(t, e) {
392 | try {
393 | return this.setdata(JSON.stringify(t), e)
394 | } catch {
395 | return !1
396 | }
397 | }
398 |
399 | getScript(t) {
400 | return new Promise(e => {
401 | this.get({
402 | url: t
403 | }, (t, s, i) => e(i))
404 | })
405 | }
406 |
407 | runScript(t, e) {
408 | return new Promise(s => {
409 | let i = this.getdata("@chavy_boxjs_userCfgs.httpapi");
410 | i = i ? i.replace(/\n/g, "").trim() : i;
411 | let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");
412 | r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r;
413 | const [o, h] = i.split("@"), n = {
414 | url: `http://${h}/v1/scripting/evaluate`,
415 | body: {
416 | script_text: t,
417 | mock_type: "cron",
418 | timeout: r
419 | },
420 | headers: {
421 | "X-Key": o,
422 | Accept: "*/*"
423 | }
424 | };
425 | this.post(n, (t, e, i) => s(i))
426 | }).catch(t => this.logErr(t))
427 | }
428 |
429 | loaddata() {
430 | if (!this.isNode()) return {}; {
431 | this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
432 | const t = this.path.resolve(this.dataFile),
433 | e = this.path.resolve(process.cwd(), this.dataFile),
434 | s = this.fs.existsSync(t),
435 | i = !s && this.fs.existsSync(e);
436 | if (!s && !i) return {}; {
437 | const i = s ? t : e;
438 | try {
439 | return JSON.parse(this.fs.readFileSync(i))
440 | } catch (t) {
441 | return {}
442 | }
443 | }
444 | }
445 | }
446 |
447 | writedata() {
448 | if (this.isNode()) {
449 | this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
450 | const t = this.path.resolve(this.dataFile),
451 | e = this.path.resolve(process.cwd(), this.dataFile),
452 | s = this.fs.existsSync(t),
453 | i = !s && this.fs.existsSync(e),
454 | r = JSON.stringify(this.data);
455 | s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r)
456 | }
457 | }
458 |
459 | lodash_get(t, e, s) {
460 | const i = e.replace(/\[(\d+)\]/g, ".$1").split(".");
461 | let r = t;
462 | for (const t of i)
463 | if (r = Object(r)[t], void 0 === r) return s;
464 | return r
465 | }
466 |
467 | lodash_set(t, e, s) {
468 | 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)
469 | }
470 |
471 | getdata(t) {
472 | let e = this.getval(t);
473 | if (/^@/.test(t)) {
474 | const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : "";
475 | if (r) try {
476 | const t = JSON.parse(r);
477 | e = t ? this.lodash_get(t, i, "") : e
478 | } catch (t) {
479 | e = ""
480 | }
481 | }
482 | return e
483 | }
484 |
485 | setdata(t, e) {
486 | let s = !1;
487 | if (/^@/.test(e)) {
488 | const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i),
489 | h = i ? "null" === o ? null : o || "{}" : "{}";
490 | try {
491 | const e = JSON.parse(h);
492 | this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i)
493 | } catch (e) {
494 | const o = {};
495 | this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i)
496 | }
497 | } else s = this.setval(t, e);
498 | return s
499 | }
500 |
501 | getval(t) {
502 | 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
503 | }
504 |
505 | setval(t, e) {
506 | 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
507 | }
508 |
509 | initGotEnv(t) {
510 | 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))
511 | }
512 |
513 | get(t, e = (() => {})) {
514 | 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, {
515 | "X-Surge-Skip-Scripting": !1
516 | })), $httpClient.get(t, (t, s, i) => {
517 | !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i)
518 | })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {
519 | hints: !1
520 | })), $task.fetch(t).then(t => {
521 | const {
522 | statusCode: s,
523 | statusCode: i,
524 | headers: r,
525 | body: o
526 | } = t;
527 | e(null, {
528 | status: s,
529 | statusCode: i,
530 | headers: r,
531 | body: o
532 | }, o)
533 | }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => {
534 | try {
535 | if (t.headers["set-cookie"]) {
536 | const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();
537 | s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar
538 | }
539 | } catch (t) {
540 | this.logErr(t)
541 | }
542 | }).then(t => {
543 | const {
544 | statusCode: s,
545 | statusCode: i,
546 | headers: r,
547 | body: o
548 | } = t;
549 | e(null, {
550 | status: s,
551 | statusCode: i,
552 | headers: r,
553 | body: o
554 | }, o)
555 | }, t => {
556 | const {
557 | message: s,
558 | response: i
559 | } = t;
560 | e(s, i, i && i.body)
561 | }))
562 | }
563 |
564 | post(t, e = (() => {})) {
565 | 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, {
566 | "X-Surge-Skip-Scripting": !1
567 | })), $httpClient.post(t, (t, s, i) => {
568 | !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i)
569 | });
570 | else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {
571 | hints: !1
572 | })), $task.fetch(t).then(t => {
573 | const {
574 | statusCode: s,
575 | statusCode: i,
576 | headers: r,
577 | body: o
578 | } = t;
579 | e(null, {
580 | status: s,
581 | statusCode: i,
582 | headers: r,
583 | body: o
584 | }, o)
585 | }, t => e(t));
586 | else if (this.isNode()) {
587 | this.initGotEnv(t);
588 | const {
589 | url: s,
590 | ...i
591 | } = t;
592 | this.got.post(s, i).then(t => {
593 | const {
594 | statusCode: s,
595 | statusCode: i,
596 | headers: r,
597 | body: o
598 | } = t;
599 | e(null, {
600 | status: s,
601 | statusCode: i,
602 | headers: r,
603 | body: o
604 | }, o)
605 | }, t => {
606 | const {
607 | message: s,
608 | response: i
609 | } = t;
610 | e(s, i, i && i.body)
611 | })
612 | }
613 | }
614 |
615 | time(t, e = null) {
616 | const s = e ? new Date(e) : new Date;
617 | let i = {
618 | "M+": s.getMonth() + 1,
619 | "d+": s.getDate(),
620 | "H+": s.getHours(),
621 | "m+": s.getMinutes(),
622 | "s+": s.getSeconds(),
623 | "q+": Math.floor((s.getMonth() + 3) / 3),
624 | S: s.getMilliseconds()
625 | };
626 | /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length)));
627 | 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)));
628 | return t
629 | }
630 |
631 | msg(e = t, s = "", i = "", r) {
632 | const o = t => {
633 | if (!t) return t;
634 | if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? {
635 | "open-url": t
636 | } : this.isSurge() ? {
637 | url: t
638 | } : void 0;
639 | if ("object" == typeof t) {
640 | if (this.isLoon()) {
641 | let e = t.openUrl || t.url || t["open-url"],
642 | s = t.mediaUrl || t["media-url"];
643 | return {
644 | openUrl: e,
645 | mediaUrl: s
646 | }
647 | }
648 | if (this.isQuanX()) {
649 | let e = t["open-url"] || t.url || t.openUrl,
650 | s = t["media-url"] || t.mediaUrl;
651 | return {
652 | "open-url": e,
653 | "media-url": s
654 | }
655 | }
656 | if (this.isSurge()) {
657 | let e = t.url || t.openUrl || t["open-url"];
658 | return {
659 | url: e
660 | }
661 | }
662 | }
663 | };
664 | if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) {
665 | let t = ["", "==============📣系统通知📣=============="];
666 | t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t)
667 | }
668 | }
669 |
670 | log(...t) {
671 | t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator))
672 | }
673 |
674 | logErr(t, e) {
675 | const s = !this.isSurge() && !this.isQuanX() && !this.isLoon();
676 | s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t)
677 | }
678 |
679 | wait(t) {
680 | return new Promise(e => setTimeout(e, t))
681 | }
682 |
683 | done(t = {}) {
684 | const e = (new Date).getTime(),
685 | s = (e - this.startTime) / 1e3;
686 | this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t)
687 | }
688 | }(t, e)
689 | }
690 |
--------------------------------------------------------------------------------