mirror of
https://github.com/Giu-zhao/ios_rule_script
synced 2024-11-23 00:48:24 +08:00
471 lines
46 KiB
JavaScript
471 lines
46 KiB
JavaScript
|
const zhiyouRegex = /^https?:\/\/zhiyou\.smzdm\.com\/user$/;
|
|||
|
const smzdmCookieKey = "smzdm_cookie";
|
|||
|
const smzdmCookieIdKey = "smzdm_cookie_id";
|
|||
|
const smzdmSigninKey = "smzdm_signin";
|
|||
|
const smzdmMissionKey = "smzdm_mission";
|
|||
|
const smzdmLotteryKey = "smzdm_lottery";
|
|||
|
const smzdmSyncQinglongKey = "smzdm_sync_qinglong";
|
|||
|
const scriptName = '什么值得买';
|
|||
|
const clickFavArticleMaxTimes = 7; // 好文收藏次数
|
|||
|
|
|||
|
const $ = MagicJS(scriptName, "INFO");
|
|||
|
let currentCookie = "";
|
|||
|
|
|||
|
function randomStr() {
|
|||
|
let len = 17;
|
|||
|
let char = '0123456789';
|
|||
|
let str = ''
|
|||
|
for (i = 0; i < len; i++) {
|
|||
|
str += char.charAt(Math.floor(Math.random() * char.length));
|
|||
|
}
|
|||
|
return str;
|
|||
|
}
|
|||
|
|
|||
|
$.http.interceptors.request.use((config) => {
|
|||
|
if (!!currentCookie) {
|
|||
|
config.headers.Cookie = currentCookie;
|
|||
|
}
|
|||
|
return config;
|
|||
|
});
|
|||
|
|
|||
|
// Web端登录获取Cookie
|
|||
|
async function getWebCookie() {
|
|||
|
try {
|
|||
|
currentCookie = $.request.headers.cookie || $.request.headers.Cookie;
|
|||
|
if (currentCookie.length >= 200) {
|
|||
|
|
|||
|
$.logger.info(`当前页面获取的Cookie: ${currentCookie}`);
|
|||
|
const matchStr = currentCookie.match(/__ckguid=[^\s]*;/);
|
|||
|
const cookieId = matchStr !== null ? matchStr[0] : null;
|
|||
|
$.logger.info(`当前页面获取的CookieId\n${cookieId}`);
|
|||
|
// 获取新的session_id
|
|||
|
if (cookieId) {
|
|||
|
const userInfo = await getWebUserInfo();
|
|||
|
// 获取持久化的session_id
|
|||
|
let oldCookieId = $.data.read(smzdmCookieIdKey, "", userInfo.smzdm_id);
|
|||
|
$.logger.info(`从客户端存储池中读取的CookieId\n${oldCookieId}`);
|
|||
|
// 获取新的session_id
|
|||
|
$.logger.info(`旧的CookieId:\n${oldCookieId}\n新的CookieId:\n${cookieId}`);
|
|||
|
// 比较差异
|
|||
|
if (oldCookieId == cookieId) {
|
|||
|
$.logger.info('当前页面获取的Cookie与客户端存储的Cookie相同,无需更新。');
|
|||
|
}
|
|||
|
else {
|
|||
|
if (userInfo.blackroom_desc && userInfo.blackroom_level) {
|
|||
|
$.notification.post(`⚠️您的账户已在小黑屋中,请谨慎使用自动签到和任务!\n小黑屋类型:${userInfo.blackroom_desc}\小黑屋等级:${userInfo.blackroom_level}`);
|
|||
|
}
|
|||
|
$.data.write(smzdmCookieIdKey, cookieId, userInfo.smzdm_id);
|
|||
|
$.data.write(smzdmCookieKey, currentCookie, userInfo.smzdm_id);
|
|||
|
$.logger.info(`写入cookie\n${currentCookie}`);
|
|||
|
$.notification.post(scriptName, '', '🎈获取Cookie成功!!');
|
|||
|
}
|
|||
|
|
|||
|
// 同步到青龙面板
|
|||
|
if ($.data.read(smzdmSyncQinglongKey, false) === true) {
|
|||
|
oldCookieId = await $.qinglong.read(smzdmCookieIdKey, "", userInfo.smzdm_id);
|
|||
|
$.logger.info(`从青龙面板读取的CookieId\n${oldCookieId}`);
|
|||
|
if (oldCookieId !== cookieId) {
|
|||
|
await $.qinglong.write(smzdmCookieIdKey, cookieId, userInfo.smzdm_id);
|
|||
|
await $.qinglong.write(smzdmCookieKey, currentCookie, userInfo.smzdm_id);
|
|||
|
$.logger.info(`同步cookie\n${currentCookie}`);
|
|||
|
$.notification.post(scriptName, '', '🎈同步Cookie至青龙面板成功!!');
|
|||
|
}
|
|||
|
else {
|
|||
|
$.logger.info(`当前页面获取的Cookie与青龙面板存储的Cookie相同,无需更新。`)
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else {
|
|||
|
$.logger.warning('没有读取到有效的Cookie信息。');
|
|||
|
}
|
|||
|
}
|
|||
|
catch (err) {
|
|||
|
$.logger.error(`获取什么值得买Cookies出现异常,${err}`);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// Web端签到
|
|||
|
function webSignin() {
|
|||
|
return new Promise((resolve, reject) => {
|
|||
|
let ts = Date.parse(new Date());
|
|||
|
$.http.get({
|
|||
|
url: `https://zhiyou.smzdm.com/user/checkin/jsonp_checkin?callback=jQuery11240${randomStr()}_${ts}&_=${ts + 3}`,
|
|||
|
headers: {
|
|||
|
'Accept': '*/*',
|
|||
|
'Accept-Language': 'zh-cn',
|
|||
|
'Connection': 'keep-alive',
|
|||
|
'Host': 'zhiyou.smzdm.com',
|
|||
|
'Referer': 'https://www.smzdm.com/',
|
|||
|
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15'
|
|||
|
}
|
|||
|
}).then(resp => {
|
|||
|
let data = /\((.*)\)/.exec(resp.body);
|
|||
|
if (data) {
|
|||
|
let obj = JSON.parse(data[1]);
|
|||
|
if (!!obj && obj.hasOwnProperty('error_code')) {
|
|||
|
if (obj.error_code == -1) {
|
|||
|
$.logger.warning(`Web端签到出现异常,网络繁忙,接口返回:${data}`);
|
|||
|
reject('Web:网络繁忙');
|
|||
|
}
|
|||
|
else if (obj['error_code'] == 99) {
|
|||
|
$.logger.warning('Web端Cookie已过期');
|
|||
|
resolve([false, 'Web:Cookie过期']);
|
|||
|
}
|
|||
|
else if (obj['error_code'] == 0) {
|
|||
|
$.logger.info('Web:签到成功');
|
|||
|
resolve([true, 'Web:签到成功']);
|
|||
|
}
|
|||
|
else {
|
|||
|
$.logger.warning(`Web端签到出现异常,接口返回数据不合法:${data}`);
|
|||
|
reject('Web:返回错误');
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else {
|
|||
|
$.logger.warning(`Web端签到出现异常,接口返回数据不存在:${data}`);
|
|||
|
reject('Web:签到异常');
|
|||
|
}
|
|||
|
}).catch(err => {
|
|||
|
$.logger.error(`Web端签到出现异常,${err}`);
|
|||
|
reject('Web:签到异常');
|
|||
|
})
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
// 获取用户信息
|
|||
|
function getWebUserInfo() {
|
|||
|
let userInfo = {
|
|||
|
"smzdm_id": null, // 什么值得买Id
|
|||
|
"nick_name": null, // 昵称
|
|||
|
"avatar": null, // 头像链接
|
|||
|
"has_checkin": null, // 是否签到
|
|||
|
"daily_checkin_num": null, // 连续签到天数
|
|||
|
"unread_msg": null, // 未读消息
|
|||
|
"level": null, // 旧版等级
|
|||
|
"vip": null, // 新版VIP等级
|
|||
|
"exp": null, // 旧版经验
|
|||
|
"point": null, // 积分
|
|||
|
"gold": null, // 金币
|
|||
|
"silver": null, // 碎银子
|
|||
|
"prestige": null, // 威望
|
|||
|
"user_point_list": [], // 近期经验变动情况
|
|||
|
"blackroom_desc": "",
|
|||
|
"blackroom_level": ""
|
|||
|
}
|
|||
|
return new Promise(async resolve => {
|
|||
|
// 获取旧版用户信息
|
|||
|
await $.http.get({
|
|||
|
url: `https://zhiyou.smzdm.com/user/info/jsonp_get_current?with_avatar_ornament=1&callback=jQuery112403507528653716241_${new Date().getTime()}&_=${new Date().getTime()}`,
|
|||
|
headers: {
|
|||
|
'Accept': 'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01',
|
|||
|
'Accept-Language': 'zh-CN,zh;q=0.9',
|
|||
|
'Connection': 'keep-alive',
|
|||
|
'Host': 'zhiyou.smzdm.com',
|
|||
|
'Referer': 'https://zhiyou.smzdm.com/user/',
|
|||
|
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36'
|
|||
|
}
|
|||
|
}).then(resp => {
|
|||
|
let obj = JSON.parse(/\((.*)\)/.exec(resp.body)[1]);
|
|||
|
if (obj['smzdm_id'] !== 0) {
|
|||
|
userInfo.smzdm_id = obj['smzdm_id'];
|
|||
|
userInfo.nick_name = obj['nickname'] // 昵称
|
|||
|
userInfo.avatar = `https:${obj['avatar']}` // 头像链接
|
|||
|
userInfo.has_checkin = obj['checkin']['has_checkin'] // 是否签到
|
|||
|
userInfo.daily_checkin_num = obj['checkin']['daily_checkin_num'] // 连续签到天数
|
|||
|
userInfo.unread_msg = obj['unread']['notice']['num'] // 未读消息数
|
|||
|
userInfo.level = obj['level'] // 旧版等级
|
|||
|
userInfo.vip = obj['vip_level'] // 新版VIP等级
|
|||
|
userInfo.blackroom_desc = obj['blackroom_desc'] // 小黑屋描述
|
|||
|
userInfo.blackroom_desc = obj['blackroom_level'] // 小黑屋等级
|
|||
|
// userInfo.exp = obj['exp'] // 旧版经验
|
|||
|
// userInfo.point = obj['point'] // 积分
|
|||
|
// userInfo.gold = obj['gold'] // 金币
|
|||
|
// userInfo.silver = obj['silver'] // 碎银子
|
|||
|
}
|
|||
|
else {
|
|||
|
$.logger.warning(`获取用户信息异常,Cookie过期或接口变化:${JSON.stringify(obj)}`);
|
|||
|
}
|
|||
|
}).catch(err => {
|
|||
|
$.logger.error(`获取用户信息异常,${err}`);
|
|||
|
})
|
|||
|
// 获取新版用户信息
|
|||
|
await $.http.get({
|
|||
|
url: "https://zhiyou.smzdm.com/user/exp/",
|
|||
|
body: ''
|
|||
|
}).then(resp => {
|
|||
|
const data = resp.body;
|
|||
|
// 获取用户名
|
|||
|
userInfo.nick_name = data.match(/info-stuff-nickname.*zhiyou\.smzdm\.com\/user[^<]*>([^<]*)</)[1].trim();
|
|||
|
// 获取近期经验变动情况
|
|||
|
const pointTimeList = data.match(/<div class="scoreLeft">(.*)<\/div>/ig);
|
|||
|
const pointDetailList = data.match(/<div class=['"]scoreRight ellipsis['"]>(.*)<\/div>/ig);
|
|||
|
const minLength = pointTimeList.length > pointDetailList.length ? pointDetailList.length : pointTimeList.length;
|
|||
|
let userPointList = [];
|
|||
|
for (let i = 0; i < minLength; i++) {
|
|||
|
userPointList.push({
|
|||
|
'time': pointTimeList[i].match(/\<div class=['"]scoreLeft['"]\>(.*)\<\/div\>/)[1],
|
|||
|
'detail': pointDetailList[i].match(/\<div class=['"]scoreRight ellipsis['"]\>(.*)\<\/div\>/)[1]
|
|||
|
});
|
|||
|
}
|
|||
|
userInfo.user_point_list = userPointList;
|
|||
|
// 获取用户资源
|
|||
|
const assetsNumList = data.match(/assets-part[^<]*>(.*)</ig);
|
|||
|
userInfo.point = Number(assetsNumList[0].match(/assets-num[^<]*>(.*)</)[1]); // 积分
|
|||
|
userInfo.exp = Number(assetsNumList[2].match(/assets-num[^<]*>(.*)</)[1]); // 经验
|
|||
|
userInfo.gold = Number(assetsNumList[4].match(/assets-num[^<]*>(.*)</)[1]); // 金币
|
|||
|
userInfo.silver = Number(assetsNumList[6].match(/assets-num[^<]*>(.*)</)[1]); // 碎银子
|
|||
|
}).catch(err => {
|
|||
|
$.logger.error(`获取新版用户信息出现异常,${err}`);
|
|||
|
})
|
|||
|
// 返回结果
|
|||
|
resolve(userInfo);
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
// 每日抽奖
|
|||
|
function lotteryDraw() {
|
|||
|
return new Promise(async (resolve, reject) => {
|
|||
|
let activeId = "";
|
|||
|
await $.http.get({
|
|||
|
url: "https://m.smzdm.com/zhuanti/life/choujiang/",
|
|||
|
headers: {
|
|||
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|||
|
"Accept-Encoding": "gzip, deflate, br",
|
|||
|
"Accept-Language": "zh-cn",
|
|||
|
"Connection": "keep-alive",
|
|||
|
"Host": "m.smzdm.com",
|
|||
|
"User-Agent":
|
|||
|
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148/smzdm 9.9.6 rv:93.4 (iPhone13,4; iOS 14.5; zh_CN)/iphone_smzdmapp/9.9.6/wkwebview/jsbv_1.0.0",
|
|||
|
}
|
|||
|
}).then(resp => {
|
|||
|
let _activeId = /name\s?=\s?\"lottery_activity_id\"\s+value\s?=\s?\"([a-zA-Z0-9]*)\"/.exec(resp.body);
|
|||
|
if (_activeId) {
|
|||
|
activeId = _activeId[1];
|
|||
|
} else {
|
|||
|
$.logger.warning(`获取每日抽奖activeId失败`);
|
|||
|
}
|
|||
|
}).catch(err => {
|
|||
|
$.logger.error(`获取每日抽奖activeId失败,${err}`);
|
|||
|
})
|
|||
|
if (!!activeId) {
|
|||
|
await $.http.get({
|
|||
|
url: `https://zhiyou.smzdm.com/user/lottery/jsonp_draw?callback=jQuery34109305207178886287_${new Date().getTime()}&active_id=${activeId}&_=${new Date().getTime()}`,
|
|||
|
headers: {
|
|||
|
"Accept": "*/*",
|
|||
|
"Accept-Encoding": "gzip, deflate, br",
|
|||
|
"Accept-Language": "zh-cn",
|
|||
|
"Connection": "keep-alive",
|
|||
|
"Host": "zhiyou.smzdm.com",
|
|||
|
"Referer": "https://m.smzdm.com/zhuanti/life/choujiang/",
|
|||
|
"User-Agent":
|
|||
|
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148/smzdm 9.9.0 rv:91 (iPhone 11 Pro Max; iOS 14.2; zh_CN)/iphone_smzdmapp/9.9.0/wkwebview/jsbv_1.0.0",
|
|||
|
}
|
|||
|
}).then(resp => {
|
|||
|
let data = /\((.*)\)/.exec(resp.body);
|
|||
|
let obj = JSON.parse(data[1]);
|
|||
|
if (obj.error_code === 0 || obj.error_code === 1 || obj.error_code === 4) {
|
|||
|
resolve(obj.error_msg);
|
|||
|
} else {
|
|||
|
$.logger.error(`每日抽奖失败,接口响应异常:${data}`);
|
|||
|
resolve("每日抽奖失败,接口响应异常");
|
|||
|
}
|
|||
|
}).catch(err => {
|
|||
|
$.logger.error(`每日抽奖失败,${err}`);
|
|||
|
resolve("每日抽奖失败,接口/执行异常");
|
|||
|
})
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
// 收藏文章
|
|||
|
function clickFavArticle(articleId) {
|
|||
|
return new Promise((resolve, reject) => {
|
|||
|
$.http.post({
|
|||
|
url: "https://zhiyou.smzdm.com/user/favorites/ajax_favorite",
|
|||
|
headers: {
|
|||
|
"Accept": "application/json, text/javascript, */*; q=0.01",
|
|||
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
|||
|
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
|||
|
"Host": "zhiyou.smzdm.com",
|
|||
|
"Origin": "https://post.smzdm.com",
|
|||
|
"Referer": "https://post.smzdm.com/",
|
|||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36 Edg/85.0.564.41",
|
|||
|
},
|
|||
|
body: `article_id=${articleId}&channel_id=11&client_type=PC&event_key=%E6%94%B6%E8%97%8F&otype=%E6%94%B6%E8%97%8F&aid=${articleId}&cid=11&p=2&source=%E6%97%A0&atp=76&tagID=%E6%97%A0&sourcePage=https%3A%2F%2Fpost.smzdm.com%2F&sourceMode=%E6%97%A0`,
|
|||
|
}).then(resp => {
|
|||
|
const obj = resp.body;
|
|||
|
if (obj.error_code == 0) {
|
|||
|
$.logger.debug(`好文${articleId}收藏成功`);
|
|||
|
resolve(true);
|
|||
|
} else if (obj.error_code == 2) {
|
|||
|
$.logger.debug(`好文${articleId}取消收藏成功`);
|
|||
|
resolve(true);
|
|||
|
} else {
|
|||
|
$.logger.error(`好文${articleId}收藏失败,${JSON.stringify(obj)}`);
|
|||
|
resolve(false);
|
|||
|
}
|
|||
|
}).catch(err => {
|
|||
|
$.logger.error(`文章加入/取消收藏失败,${err}`);
|
|||
|
reject(false);
|
|||
|
})
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
// 收藏文章任务
|
|||
|
function favArticles() {
|
|||
|
return new Promise(async (resolve, reject) => {
|
|||
|
let articlesId = [];
|
|||
|
let success = 0;
|
|||
|
await $.http.get({
|
|||
|
url: "https://post.smzdm.com/",
|
|||
|
headers: {
|
|||
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
|||
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
|||
|
"Host": "post.smzdm.com",
|
|||
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36 Edg/85.0.564.41",
|
|||
|
},
|
|||
|
body: ""
|
|||
|
}).then(resp => {
|
|||
|
const articleList = resp.body.match(/data-article=".*" data-type="zan"/gi);
|
|||
|
articleList.forEach((element) => {
|
|||
|
articlesId.push(element.match(/data-article="(.*)" data-type="zan"/)[1]);
|
|||
|
});
|
|||
|
}).catch(err => {
|
|||
|
$.logger.error(`获取待收藏的文章列表失败,${err}`);
|
|||
|
reject(err);
|
|||
|
})
|
|||
|
let favArticlesId = articlesId.splice(0, clickFavArticleMaxTimes);
|
|||
|
if (favArticlesId.length > 0) {
|
|||
|
// 加入收藏
|
|||
|
for (let articleId of favArticlesId) {
|
|||
|
await $.utils.retry(clickFavArticle, 3, 500)(articleId
|
|||
|
).then(result => {
|
|||
|
if (result === true) {
|
|||
|
success += 1;
|
|||
|
}
|
|||
|
}).catch(err => {
|
|||
|
$.logger.error(`文章加入收藏失败,${err}`);
|
|||
|
})
|
|||
|
await $.utils.sleep(500);
|
|||
|
}
|
|||
|
// 取消收藏
|
|||
|
for (let articleId of articlesId) {
|
|||
|
await $.utils.retry(clickFavArticle, 3, 500)(articleId).catch(err => {
|
|||
|
$.logger.error(`文章取消收藏失败,${err}`);
|
|||
|
})
|
|||
|
}
|
|||
|
}
|
|||
|
resolve(success);
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
// 多用户签到
|
|||
|
async function multiUsersSingin() {
|
|||
|
const allSessions = $.data.allSessions(smzdmCookieKey);
|
|||
|
if (!allSessions || allSessions.length === 0) {
|
|||
|
$.logger.error(scriptName, "", "没有发现需要签到的Cookies\n请点击通知进行登录。", { "open-url": "https://zhiyou.smzdm.com/user/login?redirect_to=http://zhiyou.smzdm.com/user" });
|
|||
|
}
|
|||
|
else {
|
|||
|
$.logger.info(`当前共 ${allSessions.length} 个Cookies需要进行签到/任务。`);
|
|||
|
for (let [index, session] of allSessions.entries()) {
|
|||
|
$.logger.info(`当前正在进行第 ${index + 1} 个Cookie签到`);
|
|||
|
// 通知信息
|
|||
|
let title = '';
|
|||
|
let subTitle = '';
|
|||
|
let content = '';
|
|||
|
|
|||
|
// 获取Cookies
|
|||
|
currentCookie = $.data.read(smzdmCookieKey, "", session);
|
|||
|
|
|||
|
// 查询签到前用户数据
|
|||
|
const beforeUserInfo = await getWebUserInfo();
|
|||
|
|
|||
|
// Web端签到
|
|||
|
if ($.data.read(smzdmSigninKey, true) === true) {
|
|||
|
await $.utils.retry(webSignin, 10, 500)().catch(err => {
|
|||
|
subTitle = `Web端签到异常: ${err}`;
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
// 日常任务
|
|||
|
if ($.data.read(smzdmMissionKey, true) === true) {
|
|||
|
const success = await favArticles();
|
|||
|
const msg = `每日收藏文章任务 ${success}/${clickFavArticleMaxTimes}`;
|
|||
|
content += !!content ? `\n${msg}` : msg;
|
|||
|
$.logger.info(msg);
|
|||
|
}
|
|||
|
|
|||
|
// 抽奖
|
|||
|
if ($.data.read(smzdmLotteryKey, true) === true) {
|
|||
|
const msg = await lotteryDraw();
|
|||
|
content += !!content ? '\n' : '';
|
|||
|
content += msg;
|
|||
|
$.logger.info(msg);
|
|||
|
}
|
|||
|
|
|||
|
// 休眠
|
|||
|
await $.utils.sleep(3000);
|
|||
|
|
|||
|
// 获取签到后的用户信息
|
|||
|
const afterUserInfo = await getWebUserInfo();
|
|||
|
|
|||
|
// 重复签到
|
|||
|
if (afterUserInfo.has_checkin === true && beforeUserInfo.has_checkin === true) {
|
|||
|
subTitle = "Web端重复签到";
|
|||
|
}
|
|||
|
else {
|
|||
|
subTitle = `已连续签到${afterUserInfo.daily_checkin_num}天`;
|
|||
|
}
|
|||
|
|
|||
|
// 记录日志
|
|||
|
let msg = `昵称:${beforeUserInfo.nick_name}\nWeb端签到状态:${afterUserInfo.has_checkin}\n签到后等级${afterUserInfo.vip},积分${afterUserInfo.point},经验${afterUserInfo.exp},金币${afterUserInfo.gold},碎银子${afterUserInfo.silver},未读消息${afterUserInfo.unread_msg}`;
|
|||
|
$.logger.info(msg);
|
|||
|
|
|||
|
// 通知
|
|||
|
if (beforeUserInfo.exp && afterUserInfo.exp) {
|
|||
|
let addPoint = afterUserInfo.point - beforeUserInfo.point;
|
|||
|
let addExp = afterUserInfo.exp - beforeUserInfo.exp;
|
|||
|
let addGold = afterUserInfo.gold - beforeUserInfo.gold;
|
|||
|
let addSilver = afterUserInfo.silver - beforeUserInfo.silver;
|
|||
|
content += !!content ? '\n' : '';
|
|||
|
content += '积分' + afterUserInfo.point + (addPoint > 0 ? '(+' + addPoint + ')' : '') +
|
|||
|
' 经验' + afterUserInfo.exp + (addExp > 0 ? '(+' + addExp + ')' : '') +
|
|||
|
' 金币' + afterUserInfo.gold + (addGold > 0 ? '(+' + addGold + ')' : '') + '\n' +
|
|||
|
'碎银子' + afterUserInfo.silver + (addSilver > 0 ? '(+' + addSilver + ')' : '') +
|
|||
|
' 未读消息' + afterUserInfo.unread_msg;
|
|||
|
}
|
|||
|
title = `${scriptName} - ${afterUserInfo.nick_name} V${afterUserInfo.vip}`;
|
|||
|
$.notification.post(title, subTitle, content, { 'media-url': afterUserInfo.avatar });
|
|||
|
|
|||
|
$.logger.info(`第 ${index + 1} 个Cookie签到完毕`);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
(async () => {
|
|||
|
if ($.isRequest && zhiyouRegex.test($.request.url) && $.request.method.toUpperCase() == "GET") {
|
|||
|
await getWebCookie();
|
|||
|
}
|
|||
|
else {
|
|||
|
await multiUsersSingin();
|
|||
|
}
|
|||
|
$.done();
|
|||
|
})()
|
|||
|
|
|||
|
/**
|
|||
|
*
|
|||
|
* $$\ $$\ $$\ $$$$$\ $$$$$$\ $$$$$$\
|
|||
|
* $$$\ $$$ | \__| \__$$ |$$ __$$\ $$ ___$$\
|
|||
|
* $$$$\ $$$$ | $$$$$$\ $$$$$$\ $$\ $$$$$$$\ $$ |$$ / \__| \_/ $$ |
|
|||
|
* $$\$$\$$ $$ | \____$$\ $$ __$$\ $$ |$$ _____| $$ |\$$$$$$\ $$$$$ /
|
|||
|
* $$ \$$$ $$ | $$$$$$$ |$$ / $$ |$$ |$$ / $$\ $$ | \____$$\ \___$$\
|
|||
|
* $$ |\$ /$$ |$$ __$$ |$$ | $$ |$$ |$$ | $$ | $$ |$$\ $$ | $$\ $$ |
|
|||
|
* $$ | \_/ $$ |\$$$$$$$ |\$$$$$$$ |$$ |\$$$$$$$\\$$$$$$ |\$$$$$$ | \$$$$$$ |
|
|||
|
* \__| \__| \_______| \____$$ |\__| \_______|\______/ \______/ \______/
|
|||
|
* $$\ $$ |
|
|||
|
* \$$$$$$ |
|
|||
|
* \______/
|
|||
|
*
|
|||
|
*/
|
|||
|
function MagicJS(e="MagicJS",t="INFO"){const r=()=>{const e=typeof $loon!=="undefined";const t=typeof $task!=="undefined";const n=typeof module!=="undefined";const r=typeof $httpClient!=="undefined"&&!e;const i=typeof $storm!=="undefined";const o=typeof $environment!=="undefined"&&typeof $environment["stash-build"]!=="undefined";const s=r||e||i||o;const a=typeof importModule!=="undefined";return{isLoon:e,isQuanX:t,isNode:n,isSurge:r,isStorm:i,isStash:o,isSurgeLike:s,isScriptable:a,get name(){if(e){return"Loon"}else if(t){return"QuantumultX"}else if(n){return"NodeJS"}else if(r){return"Surge"}else if(a){return"Scriptable"}else{return"unknown"}},get build(){if(r){return $environment["surge-build"]}else if(o){return $environment["stash-build"]}else if(i){return $storm.buildVersion}},get language(){if(r||o){return $environment["language"]}},get version(){if(r){return $environment["surge-version"]}else if(o){return $environment["stash-version"]}else if(i){return $storm.appVersion}else if(n){return process.version}},get system(){if(r){return $environment["system"]}else if(n){return process.platform}},get systemVersion(){if(i){return $storm.systemVersion}},get deviceName(){if(i){return $storm.deviceName}}}};const i=(n,e="INFO")=>{let r=e;const i={SNIFFER:6,DEBUG:5,INFO:4,NOTIFY:3,WARNING:2,ERROR:1,CRITICAL:0,NONE:-1};const o={SNIFFER:"",DEBUG:"",INFO:"",NOTIFY:"",WARNING:"❗ ",ERROR:"❌ ",CRITICAL:"❌ ",NONE:""};const t=(e,t="INFO")=>{if(!(i[r]<i[t.toUpperCase()]))console.log(`[${t}] [${n}]\n${o[t.toUpperCase()]}${e}\n`)};const s=e=>{r=e};return{setLevel:s,sniffer:e=>{t(e,"SNIFFER")},debug:e=>{t(e,"DEBUG")},info:e=>{t(e,"INFO")},notify:e=>{t(e,"NOTIFY")},warning:e=>{t(e,"WARNING")},error:e=>{t(e,"ERROR")},retry:e=>{t(e,"RETRY")}}};return new class{constructor(e,t){this._startTime=Date.now();this.version="3.0.0";this.scriptName=e;this.env=r();this.logger=i(e,t);this.http=typeof MagicHttp==="function"?MagicHttp(this.env,this.logger):undefined;this.data=typeof MagicData==="function"?MagicData(this.env,this.logger):undefined;this.notification=typeof MagicNotification==="function"?MagicNotification(this.scriptName,this.env,this.logger,this.http):undefined;this.utils=typeof MagicUtils==="function"?MagicUtils(this.env,this.logger):undefined;this.qinglong=typeof MagicQingLong==="function"?MagicQingLong(this.env,this.data,this.logger):undefined;if(typeof this.data!=="undefined"){let e=this.data.read("magic_loglevel");const n=this.data.read("magic_bark_url");if(e){this.logger.setLevel(e.toUpperCase())}if(n){this.notification.setBark(n)}}}get isRequest(){return typeof $request!=="undefined"&&typeof $response==="undefined"}get isResponse(){return typeof $response!=="undefined"}get isDebug(){return this.logger.level==="DEBUG"}get request(){return typeof $request!=="undefined"?$request:undefined}get response(){if(typeof $response!=="undefined"){if($response.hasOwnProperty("status"))$response["statusCode"]=$response["status"];if($response.hasOwnProperty("statusCode"))$response["status"]=$response["statusCode"];return $response}else{return undefined}}done=(e={})=>{this._endTime=Date.now();let t=(this._endTime-this._startTime)/1e3;this.logger.info(`SCRIPT COMPLETED: ${t} S.`);if(typeof $done!=="undefined"){$done(e)}}}(e,t)}function MagicHttp(u,c){const t="Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1";const n="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36 Edg/84.0.522.59";let f;if(u.isNode){const a=require("axios");f=a.create()}class e{constructor(e=true){this.handlers=[];this.isRequest=e}use(e,t,n){this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:false,runWhen:n?n.runWhen:null});return this.handlers.length-1}eject(e){if(this.handlers[e]){this.handlers[e]=null}}forEach(t){this.handlers.forEach(e=>{if(e!==null){t(e)}})}}function r(e){let n={...e};if(!!n.params){if(!u.isNode){let e=Object.keys(n.params).map(e=>{const t=encodeURIComponent(e);n.url=n.url.replace(
|