感谢大佬的 pr @xiaox0321

This commit is contained in:
yml2213
2022-05-12 10:11:14 +08:00
parent 502af2cbed
commit 3d9167e4f5
+130 -225
View File
@@ -12,6 +12,7 @@
* 5-10 增加随机文章数量
* 5-10 完成 荣誉值任务2(第二版--测试中)
* 5-11 荣誉值可用了--好像是每天只有一次
* 5-12 感谢大佬的 pr @xiaox0321
*
*
* 感谢所有测试人员
@@ -31,24 +32,16 @@ let ck = "";
let token = "";
///////////////////////////////////////////////////////////////////
let Version = '\n yml 2022/5/11 荣誉值可用了--好像是每天只有一次\n'
let thank = `\n 感谢 xx 的投稿\n`
let test = `\n 脚本测试中,有bug及时反馈! 脚本测试中,有bug及时反馈!\n`
let screen = '\n yml 2022/5/12 感谢大佬的 pr @xiaox0321\n'
// +`\n 感谢 xx 的投稿\n`
+ `\n 脚本测试中,有bug及时反馈! 脚本测试中,有bug及时反馈!\n`
// + `\n 脚本已恢复正常状态,请及时更新! `
///////////////////////////////////////////////////////////////////
async function tips(ckArr) {
console.log(`${Version}`);
msg += `${Version}`
// console.log(thank);
// msg += `${thank}`
console.log(test);
msg += `${test}`
// console.log(`\n 脚本已恢复正常状态,请及时更新! `);
// msg += `脚本已恢复正常状态,请及时更新`
console.log(`${screen}`);
msg += `${screen}`
console.log(`\n===============================================\n 脚本执行 - 北京时间(UTC+8): ${new Date(
new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000
@@ -77,23 +70,28 @@ async function tips(ckArr) {
.finally(() => $.done());
function startTip(message) {
console.log("开始 " + message)
}
async function start() {
console.log("开始 登录");
startTip("登录");
await login();
await $.wait(2 * 1000);
console.log("开始 用户信息");
startTip("用户信息");
await user_info();
await $.wait(2 * 1000);
for (let index = 1; index < 21; index++) {
console.log(`开始 第 ${index} 次 阅读文章--领金币`);
startTip(`第 ${index} 次 阅读文章--领金币`);
await start_reading();
await $.wait(5 * 1000);
}
console.log(`开始 荣誉广告`);
startTip(`荣誉广告`);
await honor_ad();
await $.wait(5 * 1000);
@@ -102,7 +100,24 @@ async function start() {
}
async function customHttpPost(action, path, _form = {}, callback) {
let url = {
url: `http://tlm.zhixiang.run${path}`,
headers: {
"token": token,
"Accept": "application/json",
"Host": "tlm.zhixiang.run",
"Content-Type": "application/x-www-form-urlencoded"
},
form: _form
};
let result = await httpPost(url, action);
if (!await callback(result)) {
console.log(`\n ${action}: 失败 ❌ 了呢,原因未知! ${JSON.stringify(result)} \n`);
msg += `\n ${action}: 失败 ❌ 了呢,原因未知! ${JSON.stringify(result)} \n `;
throw new Error(`'喂 喂 --- ${action} 失败 ❌ 了呢 ,别睡了, 起来更新了喂!`);
}
}
/**
@@ -110,31 +125,22 @@ async function start() {
* http://tlm.zhixiang.run/api/user/login
*/
async function login() {
let url = {
url: `http://tlm.zhixiang.run/api/user/login`,
headers: {
"Accept": "application/json",
"Host": "tlm.zhixiang.run",
"Content-Type": "application/x-www-form-urlencoded"
},
form: { "account": ck[0], "password": ck[1] }
};
let result = await httpPost(url, `登录`);
if (result.code == 1) {
let action = "登录"
let callback = (result) => {
if (result.code == 1) {
console.log(`\n 登录: 欢迎光临 ${result.data.userinfo.nickname} 🎉 , 手机号: ${result.data.userinfo.username} \n`);
msg += `\n 登录: 欢迎光临 ${result.data.userinfo.nickname} 🎉 , 手机号: ${result.data.userinfo.username} \n`;
console.log(`\n ${action}: 欢迎光临 ${result.data.userinfo.nickname} 🎉 , 手机号: ${result.data.userinfo.username} \n`);
msg += `\n ${action}: 欢迎光临 ${result.data.userinfo.nickname} 🎉 , 手机号: ${result.data.userinfo.username} \n`;
token = result.data.userinfo.token;
return true
}
token = result.data.userinfo.token;
} else {
console.log(`\n 登录: 失败 ❌ 了呢,原因未知! ${result} \n`);
msg += `\n 登录: 失败 ❌ 了呢,原因未知! ${JSON.parse(result)} \n `;
throw new Error(`'喂 喂 --- 登录 失败 ❌ 了呢 ,别睡了, 起来更新了喂!`);
return false
}
}
await customHttpPost(action, '/api/user/login', { "account": ck[0], "password": ck[1] }, callback)
}
/**
@@ -142,29 +148,19 @@ async function login() {
* http://tlm.zhixiang.run/api/user/userInfo
*/
async function user_info() {
let action = "用户信息"
let callback = (result) => {
if (result.code == 1) {
console.log(`\n 用户信息: 成功 , 等级: ${result.data.levelName}, 金币: ${result.data.coin} , 荣誉值: ${result.data.honor} \n`);
msg += `\n 用户信息: 成功 , 等级: ${result.data.levelName}, 金币: ${result.data.coin} , 荣誉值: ${result.data.honor} \n`
return true
}
let url = {
url: `http://tlm.zhixiang.run/api/user/userInfo`,
headers: {
"token": token,
"Accept": "application/json",
"Host": "tlm.zhixiang.run",
"Content-Type": "application/x-www-form-urlencoded"
},
form: {},
};
let result = await httpPost(url, `用户信息`);
if (result.code == 1) {
console.log(`\n 用户信息: 成功 , 等级: ${result.data.levelName}, 金币: ${result.data.coin} , 荣誉值: ${result.data.honor} \n`);
msg += `\n 用户信息: 成功 , 等级: ${result.data.levelName}, 金币: ${result.data.coin} , 荣誉值: ${result.data.honor} \n`
} else {
console.log(`\n 用户信息: 失败 ❌ 了呢,原因未知! ${result}\n `);
msg += `\n 用户信息: 失败 ❌ 了呢,原因未知! \n `
throw new Error(` 用户信息: 失败 ❌ 了呢,原因未知!`);
return false
}
}
await customHttpPost(action, '/api/user/userInfo', {}, callback)
}
/**
@@ -173,43 +169,24 @@ async function user_info() {
*/
async function article_list() {
page_num = randomInt(1, 14);
let url = {
url: `http://tlm.zhixiang.run/api/article/articleList`,
headers: {
"token": token,
"Accept": "application/json",
"Host": "tlm.zhixiang.run",
"Content-Type": "application/x-www-form-urlencoded"
},
form: { "type": "9000", "page": page_num },
};
let result = await httpPost(url, `文章列表`);
let action = "文章列表"
let callback = (result) => {
if (result.code == 1) {
console.log(`\n 文章列表: 获取成功 🎉 \n`);
msg += `\n 文章列表: 获取成功 🎉 \n`;
article_num = randomInt(1, 9);
if (result.code == 1) {
article_id = result.data[article_num].id;
console.log(`阅读文章id ${article_id}`);
return true
}
console.log(`\n 文章列表: 获取成功 🎉 \n`);
msg += `\n 文章列表: 获取成功 🎉 \n`;
article_num = randomInt(1, 9);
article_id = result.data[article_num].id;
console.log(`阅读文章id ${article_id}`);
} else {
console.log(`\n 文章列表: 失败 ❌ 了呢,原因未知! ${result} \n`);
msg += `\n 文章列表: 失败 ❌ 了呢,原因未知! ${JSON.parse(result)} \n `;
throw new Error(`'喂 喂 --- 文章列表 失败 ❌ 了呢 ,别睡了, 起来更新了喂!`);
return false
}
await customHttpPost(action, '/api/article/articleList', { "type": "9000", "page": page_num }, callback)
}
/**
* 开始阅读 httpPost
* http://tlm.zhixiang.run/api/coin/articleReadCountDown
@@ -218,40 +195,31 @@ async function start_reading() {
await article_list();
let url = {
url: `http://tlm.zhixiang.run/api/coin/articleReadCountDown`,
headers: {
"token": token,
"Accept": "application/json",
"Host": "tlm.zhixiang.run",
"Content-Type": "application/x-www-form-urlencoded"
},
form: { "article_id": article_id },
};
let result = await httpPost(url, `开始阅读`);
let action = "开始阅读"
let callback = async (result) => {
if (result.code == 1) {
if (result.code == 1) {
console.log(`\n 开始阅读: 成功 ,阅读预计获得金币:${result.data.drawNum} \n`);
msg += `\n 开始阅读: 成功 ,阅读预计获得金币:${result.data.drawNum} \n`;
console.log(`\n 开始阅读: 成功 ,阅读预计获得金币:${result.data.drawNum} \n`);
msg += `\n 开始阅读: 成功 ,阅读预计获得金币:${result.data.drawNum} \n`;
await_num = randomInt(60, 65);
console.log(`\n 等待 ${await_num} 秒后 领取阅读奖励 \n`);
await $.wait(await_num * 1000);
console.log(`\n 开始 领取阅读奖励 \n`);
await article_coin();
await_num = randomInt(30, 40);
console.log(`\n 等待 ${await_num} 秒后 领取阅读奖励 \n`);
await $.wait(await_num * 1000);
console.log(`\n 开始 领取阅读奖励 \n`);
await article_coin();
} else if (result.code == 0) {
console.log(`\n 这篇文章读过了! 让我们跳过他!\n`);
await $.wait(20 * 1000);
await article_coin();
} else if (result.code == 0) {
console.log(`\n 这篇文章读过了! 让我们跳过他!\n`);
await $.wait(20 * 1000);
await article_coin();
} else {
console.log(`\n 开始阅读: 失败 ❌ 了呢,原因未知! \n`);
msg += `\n 开始阅读: 失败 ❌ 了呢,原因未知!\n `;
// throw new Error(`'喂 喂 --- 开始阅读 失败 ❌ 了呢 ,别睡了, 起来 找bug 了喂!`);
}
return result.code == 1 || result.code == 0
}
await customHttpPost(action, '/api/coin/articleReadCountDown', { "article_id": article_id }, callback)
}
@@ -260,19 +228,7 @@ async function start_reading() {
* http://tlm.zhixiang.run/api/coin/articleReadEnd
*/
async function article_coin() {
let url = {
url: `http://tlm.zhixiang.run/api/coin/articleReadEnd`,
headers: {
"token": token,
"Accept": "application/json",
"Host": "tlm.zhixiang.run",
"Content-Type": "application/x-www-form-urlencoded"
},
form: { "article_id": article_id },
};
let result = await httpPost(url, `阅读文章--领金币`);
await customHttpPost("阅读文章--领金币", '/api/coin/articleReadEnd', { "article_id": article_id }, () => { return true })
}
@@ -284,41 +240,32 @@ async function article_coin() {
*/
async function honor_ad() {
let url = {
url: `http://tlm.zhixiang.run/api/newtask/signSubmit`,
headers: {
"token": token,
"Accept": "application/json",
"Host": "tlm.zhixiang.run",
"Content-Type": "application/x-www-form-urlencoded"
},
form: {},
};
let result = await httpPost(url, `荣誉广告`);
let action = "荣誉广告"
let callback = async (result) => {
if (result.code == 0) {
if (result.code == 0) {
console.log(`\n 荣誉广告: 成功 ,开始阅读广告: ${result.data.title} \n`);
msg += `\n 荣誉广告: 成功 ,开始阅读广告: ${result.data.title} \n`;
honor_id = result.data.id;
let num = randomInt(20, 25);
console.log(`\n 等待 ${num} 秒后 领取荣誉值 \n`);
await $.wait(num * 1000);
console.log(`\n 开始 领取荣誉值 \n`);
await receive_honor();
return true
console.log(`\n 荣誉广告: 成功 ,开始阅读广告: ${result.data.title} \n`);
msg += `\n 荣誉广告: 成功 ,开始阅读广告: ${result.data.title} \n`;
honor_id = result.data.id;
let num = randomInt(20, 25);
console.log(`\n 等待 ${num} 秒后 领取荣誉值 \n`);
await $.wait(num * 1000);
console.log(`\n 开始 领取荣誉值 \n`);
await receive_honor();
} else if (result.code == 1) {
console.log(`\n 荣誉广告: ${result.msg}\n`);
msg += `\n 荣誉广告: ${result.msg}\n`;
} else {
console.log(`\n 荣誉广告: 失败 ❌ 了呢,原因未知! \n`);
msg += `\n 荣誉广告: 失败 ❌ 了呢,原因未知!\n `;
// throw new Error(`'喂 喂 --- 荣誉广告 失败 ❌ 了呢 ,别睡了, 起来 找bug 了喂!`);
} else if (result.code == 1) {
console.log(`\n 荣誉广告: ${result.msg}\n`);
msg += `\n 荣誉广告: ${result.msg}\n`;
return true
}
return false
}
}
await customHttpPost(action, '/api/newtask/signSubmit', {}, callback)
}
@@ -329,77 +276,32 @@ async function honor_ad() {
async function receive_honor() {
// 获取开始荣誉值 做判断
let url_start = {
url: `http://tlm.zhixiang.run/api/newtask/taskPageData`,
headers: {
"token": token,
"Accept": "application/json",
"Host": "tlm.zhixiang.run",
"Content-Type": "application/x-www-form-urlencoded"
},
form: {},
};
let result_start = await httpPost(url_start, `获取荣誉值 初始值`);
if (result_start.code == 1) {
honor_start = result_start.data.user.honor;
} else {
console.log(`\n 获取荣誉值 初始值: 失败 ❌ 了呢,原因未知! \n`);
msg += `\n 获取荣誉值 初始值: 失败 ❌ 了呢,原因未知!\n `;
// throw new Error(`'喂 喂 --- 领取荣誉值 失败 ❌ 了呢 ,别睡了, 起来 找bug 了喂!`);
}
await customHttpPost("获取荣誉值 初始值", '/api/newtask/taskPageData', {}, (result) => {
if (result.code == 1) {
honor_start = result.data.user.honor;
}
return true
})
let result = {}
// 开始阅读文章
let url = {
url: `http://tlm.zhixiang.run/api/newtask/getBannerTimer`,
headers: {
"token": token,
"Accept": "application/json",
"Host": "tlm.zhixiang.run",
"Content-Type": "application/x-www-form-urlencoded"
},
form: { "id": honor_id, "type": "1" },
};
let result = await httpPost(url, `领取荣誉值 开始阅读`);
await customHttpPost("领取荣誉值 开始阅读", '/api/newtask/getBannerTimer', { "id": honor_id, "type": "1" }, (r) => {
result = r
return true
})
let num = randomInt(20, 25);
console.log(`\n 等待 ${num} 秒后 结束阅读 \n`);
// 结束阅读文章
let url_read_end = {
url: `http://tlm.zhixiang.run/api/newtask/getBannerBack`,
headers: {
"token": token,
"Accept": "application/json",
"Host": "tlm.zhixiang.run",
"Content-Type": "application/x-www-form-urlencoded"
},
form: { "id": honor_id, "type": "1" },
};
let result_read_end = await httpPost(url_read_end, `领取荣誉值 结束阅读`);
await customHttpPost("领取荣誉值 结束阅读", '/api/newtask/getBannerBack', { "id": honor_id, "type": "1" }, () => { return true })
// 获取结束荣誉值 做判断
let url_end = {
url: `http://tlm.zhixiang.run/api/newtask/taskPageData`,
headers: {
"token": token,
"Accept": "application/json",
"Host": "tlm.zhixiang.run",
"Content-Type": "application/x-www-form-urlencoded"
},
form: {},
};
let result_end = await httpPost(url_end, `获取荣誉值 结束值`);
if (result_end.code == 1) {
honor_end = result_end.data.user.honor;
} else {
console.log(`\n 获取荣誉值 结束值: 失败 ❌ 了呢,原因未知! \n`);
msg += `\n 获取荣誉值 结束值: 失败 ❌ 了呢,原因未知!\n `;
// throw new Error(`'喂 喂 --- 领取荣誉值 失败 ❌ 了呢 ,别睡了, 起来 找bug 了喂!`);
}
await customHttpPost("获取荣誉值 结束值", '/api/newtask/taskPageData', {}, (result) => {
if (result.code == 1) {
honor_end = result.data.user.honor;
}
return true
})
if (honor_start < honor_end) {
@@ -618,6 +520,9 @@ async function httpPost(postUrlObject, tip, timeout = 3 * 1000) {
url,
async (err, resp, data) => {
try {
data = data.replaceAll("null", "\"\"")
if (debug) {
console.log(`\n\n 【debug】===============这是 ${tip} 返回data==============`);
console.log(data);