Skip to content

Commit 9c774e9

Browse files
committed
feat(sudojia_xiaomi_community.js): 新增小米社区(小程序)每日签到
1 parent 70d32ad commit 9c774e9

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* 微信小程序:小米社区
3+
*
4+
* 每日签到获得成长值
5+
*
6+
* 抓包 Host:https://api.vip.miui.com 获取请求头 Cookie
7+
* export XIAOMI_COMM_COOKIE = 'serviceToken=xxxxx'
8+
* 多账号用 & 或换行
9+
*
10+
* @author Telegram@sudojia
11+
* @site https://blog.imzjw.cn
12+
* @date 2025/04/27
13+
*
14+
* const $ = new Env('小米社区(小程序)')
15+
* cron: 48 9 * * *
16+
*/
17+
const initScript = require('../utils/initScript')
18+
const {$, notify, sudojia, checkUpdate} = initScript('小米社区(小程序)');
19+
const xiaoMiComGeList = process.env.XIAOMI_COMM_COOKIE ? process.env.XIAOMI_COMM_COOKIE.split(/[\n&]/) : [];
20+
// 消息推送
21+
let message = '';
22+
// 接口地址
23+
const baseUrl = 'https://api.vip.miui.com'
24+
// 请求头
25+
const headers = {
26+
'User-Agent': sudojia.getRandomUserAgent(),
27+
'Accept': 'application/json, text/plain, */*',
28+
'xweb_xhr': '1',
29+
'Origin': 'https://servicewechat.com',
30+
'Content-Type': 'application/x-www-form-urlencoded',
31+
'Referer': 'https://servicewechat.com/wx240a4a764023c444/3/page-frame.html',
32+
'Accept-Language': 'zh-CN,zh;q=0.9'
33+
};
34+
35+
!(async () => {
36+
await checkUpdate($.name, xiaoMiComGeList);
37+
console.log(`\n已随机分配 User-Agent\n\n${headers['user-agent'] || headers['User-Agent']}`);
38+
for (let i = 0; i < xiaoMiComGeList.length; i++) {
39+
const index = i + 1;
40+
console.log(`\n*****第[${index}]个${$.name}账号*****`);
41+
headers.Cookie = xiaoMiComGeList[i]
42+
message += `📣====${$.name}账号[${index}]====📣\n`;
43+
await main();
44+
await $.wait(sudojia.getRandomWait(2000, 2500));
45+
}
46+
if (message) {
47+
await notify.sendNotify(`「${$.name}」`, `${message}`);
48+
}
49+
})().catch((e) => $.logErr(e)).finally(() => $.done());
50+
51+
async function main() {
52+
await getUserInfo();
53+
await $.wait(sudojia.getRandomWait(1e3, 2e3));
54+
await sign();
55+
await $.wait(sudojia.getRandomWait(1e3, 2e3));
56+
await getPoints();
57+
}
58+
59+
async function getUserInfo() {
60+
try {
61+
const data = await sudojia.sendRequest(`${baseUrl}/mtop/planet/lite/userinfo`, 'get', headers);
62+
if (200 !== data.status) {
63+
return console.error(`获取用户信息失败:${data.message}`);
64+
}
65+
const {username, userId} = data?.entity;
66+
console.log(`${username}(${userId})`);
67+
message += `${username}(${userId})\n`;
68+
} catch (e) {
69+
console.error(`获取用户接口请求失败:`, e.response.data);
70+
}
71+
}
72+
73+
async function sign() {
74+
try {
75+
const data = await sudojia.sendRequest(`${baseUrl}/mtop/planet/vip/member/addCommunityGrowUpPointByActionV2`, 'post', headers, '');
76+
if (200 !== data.status) {
77+
return console.error(`签到失败:${data.message}`);
78+
}
79+
console.log(`签到成功,积分+${data?.entity?.score}`);
80+
message += `签到成功,积分+${data?.entity?.score}\n`;
81+
} catch (e) {
82+
console.error(`签到接口请求失败:`, e.response.data);
83+
}
84+
}
85+
86+
async function getPoints() {
87+
try {
88+
const data = await sudojia.sendRequest(`${baseUrl}/mtop/planet/wechat/growup/points/detail`, 'get', headers);
89+
if (200 !== data.status) {
90+
return console.error(`获取积分失败:${data.message}`);
91+
}
92+
const totalPoints = (data?.entity || []).reduce((sum, item) => {
93+
const points = parseInt(item.jumpText.replace(/\D/g, ''), 10);
94+
return sum + (isNaN(points) ? 0 : points);
95+
}, 0);
96+
console.log(`当前成长值: ${totalPoints}`);
97+
message += `当前成长值: ${totalPoints}\n\n`;
98+
} catch (e) {
99+
console.error(`获取成长值接口请求失败:`, e.response.data);
100+
}
101+
}

0 commit comments

Comments
 (0)