mirror of
https://github.com/hex-ci/smzdm_script.git
synced 2026-10-28 19:23:43 +08:00
* 升级 `APP_VERSION` 至 `11.1.95`,并同步更新 `APP_VERSION_REV`。
* 引入服务器时间同步机制:通过 `SERVER_TIME_URL` 获取服务端时间,解决本地时间偏差导致的签名失效问题。
* 优化签名算法:改进 `signFormData` 的实现,确保参数排序与空格处理符合最新 App 逻辑。
* 增强风控对抗能力:
* 引入 `waitHuman` 模拟人类行为的等待机制,替换原有的固定 `wait`。
* 在任务执行逻辑中加入随机打乱(Shuffle)机制,降低行为模式特征。
* 增加对 WAF/风控拦截(如 403/429 错误或 HTML 验证码页)的识别与处理逻辑。
* 完善功能细节:
* 支持 `SMZDM_COMMENT` 环境变量配置多条文案(使用 `|` 分隔),实现随机评论以降低风险。
* 修复签到逻辑,支持 `CREATE_CENTER_VIEW` 和 `IS_INSTALL_ZHANGDAMA` 等新增参数。
* 优化任务列表获取,增加对 `is_install_zhangdama` 字段的支持。
* 文档更新:在 `README.md` 中补充了新增任务类型及环境变量的使用说明。
311 lines
6.6 KiB
JavaScript
311 lines
6.6 KiB
JavaScript
/*
|
|
smzdm 签到脚本
|
|
项目地址: https://github.com/hex-ci/smzdm_script
|
|
|
|
cron: 10 8 * * *
|
|
*/
|
|
|
|
const Env = require('./env');
|
|
const {
|
|
SmzdmBot,
|
|
requestApi,
|
|
removeTags,
|
|
getEnvCookies,
|
|
wait,
|
|
waitHuman,
|
|
CREATE_CENTER_VIEW,
|
|
IS_INSTALL_ZHANGDAMA
|
|
} = require('./bot');
|
|
const notify = require('./sendNotify');
|
|
const CryptoJS = require('crypto-js');
|
|
|
|
// ------------------------------------
|
|
|
|
const $ = new Env('smzdm 签到');
|
|
|
|
class SmzdmCheckinBot extends SmzdmBot {
|
|
constructor(cookie, sk) {
|
|
super(cookie);
|
|
|
|
this.sk = sk ? sk.trim() : '';
|
|
}
|
|
|
|
async run() {
|
|
const { msg: msg1 } = await this.checkin();
|
|
|
|
const { msg: msg2 } = await this.allReward();
|
|
|
|
const { msg: msg3 } = await this.extraReward();
|
|
|
|
return `${msg1}${msg2}${msg3}`;
|
|
}
|
|
|
|
async checkin() {
|
|
const { isSuccess, data, response } = await requestApi('https://user-api.smzdm.com/checkin', {
|
|
method: 'post',
|
|
headers: this.getHeaders(),
|
|
data: {
|
|
touchstone_event: '',
|
|
sk: this.sk || '1',
|
|
token: this.token,
|
|
captcha: ''
|
|
}
|
|
});
|
|
|
|
if (isSuccess) {
|
|
let msg = `⭐签到成功${data.data.daily_num}天
|
|
🏅金币: ${data.data.cgold}
|
|
🏅碎银: ${data.data.pre_re_silver}
|
|
🏅补签卡: ${data.data.cards}`;
|
|
|
|
await waitHuman(3, 10);
|
|
|
|
const vip = await this.getVipInfo();
|
|
|
|
if (vip) {
|
|
msg += `\n🏅经验: ${vip.vip.exp_current}
|
|
🏅值会员等级: ${vip.vip.exp_level}
|
|
🏅值会员经验: ${vip.vip.exp_current_level}
|
|
🏅值会员有效期至: ${vip.vip.exp_level_expire}`;
|
|
}
|
|
|
|
$.log(`${msg}\n`);
|
|
|
|
return {
|
|
isSuccess,
|
|
msg: `${msg}\n\n`
|
|
};
|
|
}
|
|
else {
|
|
$.log(`签到失败!${response}`);
|
|
|
|
return {
|
|
isSuccess,
|
|
msg: '签到失败!'
|
|
};
|
|
}
|
|
}
|
|
|
|
async allReward() {
|
|
const { isSuccess, data, response } = await requestApi('https://user-api.smzdm.com/checkin/all_reward', {
|
|
method: 'post',
|
|
headers: this.getHeaders(),
|
|
debug: process.env.SMZDM_DEBUG
|
|
});
|
|
|
|
if (isSuccess) {
|
|
const normal = data.data.normal_reward;
|
|
|
|
// reward_add 为空说明今天没有奖励增加(已领过或没有),退回展示签到卡片文案
|
|
const msg1 = normal.reward_add.title
|
|
? `${normal.reward_add.title}: ${normal.reward_add.content}`
|
|
: removeTags(normal.gift.content);
|
|
|
|
const msg2 = normal.gift.title
|
|
? `${normal.gift.title}: ${normal.gift.content_str}`
|
|
: normal.gift.sub_content;
|
|
|
|
const msg = [msg1, msg2].filter(text => text).join('\n');
|
|
|
|
$.log(`${msg}\n`);
|
|
|
|
return {
|
|
isSuccess,
|
|
msg: `${msg}\n\n`
|
|
};
|
|
}
|
|
else {
|
|
if (data.error_code != '4') {
|
|
$.log(`查询奖励失败!${response}`);
|
|
}
|
|
|
|
return {
|
|
isSuccess,
|
|
msg: ''
|
|
};
|
|
}
|
|
}
|
|
|
|
async extraReward() {
|
|
const isContinue = await this.isContinueCheckin();
|
|
|
|
if (!isContinue) {
|
|
const msg = '今天没有额外奖励';
|
|
|
|
$.log(`${msg}\n`);
|
|
|
|
return {
|
|
isSuccess: false,
|
|
msg: `${msg}\n`
|
|
};
|
|
}
|
|
|
|
await waitHuman(5, 10);
|
|
|
|
const { isSuccess, data, response } = await requestApi('https://user-api.smzdm.com/checkin/extra_reward', {
|
|
method: 'post',
|
|
headers: this.getHeaders()
|
|
});
|
|
|
|
if (isSuccess) {
|
|
const msg = `${data.data.title}: ${removeTags(data.data.gift.content)}`;
|
|
|
|
$.log(msg);
|
|
|
|
return {
|
|
isSuccess: true,
|
|
msg: `${msg}\n`
|
|
};
|
|
}
|
|
else {
|
|
$.log(`领取额外奖励失败!${response}`);
|
|
|
|
return {
|
|
isSuccess: false,
|
|
msg: ''
|
|
};
|
|
}
|
|
}
|
|
|
|
async isContinueCheckin() {
|
|
const { isSuccess, data, response } = await requestApi('https://user-api.smzdm.com/checkin/show_view_v2', {
|
|
method: 'post',
|
|
headers: this.getHeaders(),
|
|
data: {
|
|
is_install_zhangdama: IS_INSTALL_ZHANGDAMA
|
|
}
|
|
});
|
|
|
|
if (isSuccess) {
|
|
// 连续签到的卡片,直接按有没有 checkin_continue 来找
|
|
const result = data.data.rows.find(item => item.cell_data && item.cell_data.checkin_continue);
|
|
|
|
return !!(result && result.cell_data.checkin_continue.continue_checkin_reward_show);
|
|
}
|
|
else {
|
|
$.log(`查询是否有额外奖励失败!${response}`);
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
async getVipInfo() {
|
|
const { isSuccess, data, response } = await requestApi('https://user-api.smzdm.com/vip', {
|
|
method: 'post',
|
|
headers: this.getHeaders(),
|
|
data: {
|
|
token: this.token,
|
|
create_center_view: CREATE_CENTER_VIEW
|
|
}
|
|
});
|
|
|
|
if (isSuccess) {
|
|
return data.data;
|
|
}
|
|
else {
|
|
$.log(`查询信息失败!${response}`);
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
function random32() {
|
|
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
let result = '';
|
|
|
|
for (let i = 0; i < 32; i++) {
|
|
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
function getSk(cookie) {
|
|
const matchUserId = cookie.match(/smzdm_id=([^;]*)/);
|
|
|
|
if (!matchUserId) {
|
|
return ''
|
|
}
|
|
|
|
const userId = matchUserId[1];
|
|
const deviceId = getDeviceId(cookie);
|
|
const key = CryptoJS.enc.Utf8.parse('geZm53XAspb02exN');
|
|
const cipherText = CryptoJS.DES.encrypt(userId + deviceId, key, {
|
|
mode: CryptoJS.mode.ECB,
|
|
padding: CryptoJS.pad.Pkcs7
|
|
});
|
|
|
|
return cipherText.toString();
|
|
}
|
|
|
|
function getDeviceId(cookie) {
|
|
const matchDeviceId = cookie.match(/device_id=([^;]*)/);
|
|
|
|
if (matchDeviceId) {
|
|
return matchDeviceId[1];
|
|
}
|
|
|
|
return random32();
|
|
}
|
|
|
|
!(async () => {
|
|
const cookies = getEnvCookies();
|
|
|
|
if (cookies === false) {
|
|
$.log('\n请先设置 SMZDM_COOKIE 环境变量');
|
|
|
|
return;
|
|
}
|
|
|
|
let sks = [];
|
|
|
|
if (process.env.SMZDM_SK) {
|
|
if (process.env.SMZDM_SK.indexOf('&') > -1) {
|
|
sks = process.env.SMZDM_SK.split('&');
|
|
}
|
|
else if (process.env.SMZDM_SK.indexOf('\n') > -1) {
|
|
sks = process.env.SMZDM_SK.split('\n');
|
|
}
|
|
else {
|
|
sks = [process.env.SMZDM_SK];
|
|
}
|
|
}
|
|
|
|
let notifyContent = '';
|
|
|
|
for (let i = 0; i < cookies.length; i++) {
|
|
const cookie = cookies[i];
|
|
|
|
if (!cookie) {
|
|
continue;
|
|
}
|
|
|
|
let sk = sks[i];
|
|
if (!sk) {
|
|
sk = getSk(cookie)
|
|
}
|
|
|
|
if (i > 0) {
|
|
await wait(10, 30);
|
|
}
|
|
|
|
const sep = `\n****** 账号${i + 1} ******\n`;
|
|
|
|
$.log(sep);
|
|
|
|
const bot = new SmzdmCheckinBot(cookie, sk);
|
|
const msg = await bot.run();
|
|
|
|
notifyContent += sep + msg + '\n';
|
|
}
|
|
|
|
$.log();
|
|
|
|
await notify.sendNotify($.name, notifyContent);
|
|
})().catch((e) => {
|
|
$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
|
|
}).finally(() => {
|
|
$.done();
|
|
});
|