From 09cd7b12a44855e3595161c57d631c0a1ff342f6 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Tue, 17 May 2022 11:19:15 +0800 Subject: [PATCH] =?UTF-8?q?5-17=09=E4=BF=AE=E6=94=B9=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tlm/tlm.js | 472 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 284 insertions(+), 188 deletions(-) diff --git a/tlm/tlm.js b/tlm/tlm.js index 91a21bc..2f2ee5a 100644 --- a/tlm/tlm.js +++ b/tlm/tlm.js @@ -1,21 +1,21 @@ /** * 脚本地址: https://raw.githubusercontent.com/yml2213/javascript/master/tlm/tlm.js * 转载请留信息,谢谢 - * + * * 推了吗 链接带邀请 感谢走我的链接 * 下载地址: http://tlm.zhixiang.run/index/user/wechatLogin?uid=10202 (微信打开) - * - * cron 0-59/30 6-20 * * * yml2213_javascript_master/tlm.js - * + * + * cron 10 6-22 * * * yml2213_javascript_master/tlm.js + * * 5-9 完成 看文章领金币 任务 (每次执行 20 次,尽量模拟人工操作了) * 5-10 完成 荣誉值任务(测试中--失败) * 5-10 增加随机文章数量 * 5-10 完成 荣誉值任务2(第二版--测试中) * 5-11 荣誉值可用了--好像是每天只有一次 - * 5-12 感谢大佬的 pr @xiaox0321 - * - * - * 感谢所有测试人员 + * 5-17 修改运行次数 + * + * + * 感谢所有测试人员 * ========= 青龙--配置文件 ========= * 变量格式: export tlm_data=' 手机号&密码 @ 手机号&密码 ' 多个账号用 @分割 * @@ -32,16 +32,24 @@ let ck = ""; let token = ""; /////////////////////////////////////////////////////////////////// -let screen = '\n yml 2022/5/12 感谢大佬的 pr @xiaox0321\n' - // +`\n 感谢 xx 的投稿\n` - + `\n 脚本测试中,有bug及时反馈! 脚本测试中,有bug及时反馈!\n` -// + `\n 脚本已恢复正常状态,请及时更新! ` +let Version = '\n yml 2022/5/17 修改运行次数\n' +let thank = `\n 感谢 xx 的投稿\n` +let test = `\n 脚本测试中,有bug及时反馈! 脚本测试中,有bug及时反馈!\n` /////////////////////////////////////////////////////////////////// async function tips(ckArr) { - console.log(`${screen}`); - msg += `${screen}` + console.log(`${Version}`); + msg += `${Version}` + + // console.log(thank); + // msg += `${thank}` + + console.log(test); + msg += `${test}` + + // console.log(`\n 脚本已恢复正常状态,请及时更新! `); + // msg += `脚本已恢复正常状态,请及时更新` console.log(`\n===============================================\n 脚本执行 - 北京时间(UTC+8): ${new Date( new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000 @@ -70,28 +78,23 @@ async function tips(ckArr) { .finally(() => $.done()); - -function startTip(message) { - console.log("开始 " + message) -} - async function start() { - startTip("登录"); + console.log("开始 登录"); await login(); await $.wait(2 * 1000); - startTip("用户信息"); + console.log("开始 用户信息"); await user_info(); await $.wait(2 * 1000); - for (let index = 1; index < 21; index++) { - startTip(`第 ${index} 次 阅读文章--领金币`); + for (let index = 1; index < 11; index++) { + console.log(`开始 第 ${index} 次 阅读文章--领金币`); await start_reading(); await $.wait(5 * 1000); } - startTip(`荣誉广告`); + console.log(`开始 荣誉广告`); await honor_ad(); await $.wait(5 * 1000); @@ -100,24 +103,7 @@ 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} 失败 ❌ 了呢 ,别睡了, 起来更新了喂!`); - } -} + /** @@ -125,68 +111,106 @@ async function customHttpPost(action, path, _form = {}, callback) { * 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, `登录`); - let action = "登录" - let callback = (result) => { - if (result.code == 1) { + if (result.code == 1) { - 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 - } + console.log(`\n 登录: 欢迎光临 ${result.data.userinfo.nickname} 🎉 , 手机号: ${result.data.userinfo.username} \n`); + msg += `\n 登录: 欢迎光临 ${result.data.userinfo.nickname} 🎉 , 手机号: ${result.data.userinfo.username} \n`; - return false + token = result.data.userinfo.token; + + } else { + console.log(`\n 登录: 失败 ❌ 了呢,原因未知! ${result} \n`); + msg += `\n 登录: 失败 ❌ 了呢,原因未知! ${JSON.parse(result)} \n `; + throw new Error(`'喂 喂 --- 登录 失败 ❌ 了呢 ,别睡了, 起来更新了喂!`); } - await customHttpPost(action, '/api/user/login', { "account": ck[0], "password": ck[1] }, callback) - } + /** * 用户信息 httpPost * 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 - } - return false + 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(` 用户信息: 失败 ❌ 了呢,原因未知!`); } - await customHttpPost(action, '/api/user/userInfo', {}, callback) - } + /** * 文章列表 httpPost * http://tlm.zhixiang.run/api/article/articleList */ async function article_list() { page_num = randomInt(1, 14); - let action = "文章列表" - let callback = (result) => { - if (result.code == 1) { - console.log(`\n 文章列表: 获取成功 🎉 \n`); - msg += `\n 文章列表: 获取成功 🎉 \n`; - article_num = randomInt(1, 9); + 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, `文章列表`); - article_id = result.data[article_num].id; - console.log(`阅读文章id ${article_id}`); - return true - } + if (result.code == 1) { - return false + 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(`'喂 喂 --- 文章列表 失败 ❌ 了呢 ,别睡了, 起来更新了喂!`); } - await customHttpPost(action, '/api/article/articleList', { "type": "9000", "page": page_num }, callback) - } + + + + + + + + + /** * 开始阅读 httpPost * http://tlm.zhixiang.run/api/coin/articleReadCountDown @@ -195,31 +219,40 @@ async function start_reading() { await article_list(); - let action = "开始阅读" - let callback = async (result) => { - if (result.code == 1) { + 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, `开始阅读`); - console.log(`\n 开始阅读: 成功 ,阅读预计获得金币:${result.data.drawNum} \n`); - msg += `\n 开始阅读: 成功 ,阅读预计获得金币:${result.data.drawNum} \n`; + if (result.code === 1) { - await_num = randomInt(30, 40); - console.log(`\n 等待 ${await_num} 秒后 领取阅读奖励 \n`); - await $.wait(await_num * 1000); - console.log(`\n 开始 领取阅读奖励 \n`); - await article_coin(); + 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(); - } 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(); - } - - return result.code == 1 || result.code == 0 + } else { + console.log(`\n 开始阅读: 失败 ❌ 了呢,原因未知! \n`); + msg += `\n 开始阅读: 失败 ❌ 了呢,原因未知!\n `; + // throw new Error(`'喂 喂 --- 开始阅读 失败 ❌ 了呢 ,别睡了, 起来 找bug 了喂!`); } - await customHttpPost(action, '/api/coin/articleReadCountDown', { "article_id": article_id }, callback) - } @@ -228,7 +261,19 @@ async function start_reading() { * http://tlm.zhixiang.run/api/coin/articleReadEnd */ async function article_coin() { - await customHttpPost("阅读文章--领金币", '/api/coin/articleReadEnd', { "article_id": article_id }, () => { return true }) + + 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, `阅读文章--领金币`); } @@ -240,35 +285,44 @@ async function article_coin() { */ async function honor_ad() { - let action = "荣誉广告" - let callback = async (result) => { - if (result.code == 0) { + 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, `荣誉广告`); - 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 + if (result.code == 0) { - } else if (result.code == 1) { - console.log(`\n 荣誉广告: ${result.msg}\n`); - msg += `\n 荣誉广告: ${result.msg}\n`; - return true - } - return false + 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 了喂!`); } - await customHttpPost(action, '/api/newtask/signSubmit', {}, callback) - - } + /** * 领取荣誉值 httpPost * http://tlm.zhixiang.run/api/newtask/getBannerTimer @@ -276,32 +330,77 @@ async function honor_ad() { async function receive_honor() { // 获取开始荣誉值 做判断 - await customHttpPost("获取荣誉值 初始值", '/api/newtask/taskPageData', {}, (result) => { - if (result.code == 1) { - honor_start = result.data.user.honor; - } - return true - }) - let result = {} + 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/getBannerTimer', { "id": honor_id, "type": "1" }, (r) => { - result = r - return true - }) + 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, `领取荣誉值 开始阅读`); let num = randomInt(20, 25); console.log(`\n 等待 ${num} 秒后 结束阅读 \n`); // 结束阅读文章 - await customHttpPost("领取荣誉值 结束阅读", '/api/newtask/getBannerBack', { "id": honor_id, "type": "1" }, () => { return true }) + 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/taskPageData', {}, (result) => { - if (result.code == 1) { - honor_end = result.data.user.honor; - } - 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 了喂!`); + } + if (honor_start < honor_end) { @@ -340,22 +439,22 @@ async function getCks(ck, str) { return new Promise((resolve, reject) => { - let ckArr = [] - if (ck) { - if (ck.indexOf("@") != -1) { + let ckArr = [] + if (ck) { + if (ck.indexOf("@") != -1) { - ck.split("@").forEach((item) => { - ckArr.push(item); - }); + ck.split("@").forEach((item) => { + ckArr.push(item); + }); + } else { + ckArr.push(ck); + } + resolve(ckArr) } else { - ckArr.push(ck); + console.log(`\n 【${$.name}】:未填写变量 ${str}`) } - resolve(ckArr) - } else { - console.log(`\n 【${$.name}】:未填写变量 ${str}`) - } - } + } ) } @@ -416,7 +515,7 @@ function ts10() { } /** - * 获取当前小时数 + * 获取当前小时数 */ function local_hours() { @@ -426,7 +525,7 @@ function local_hours() { } /** - * 获取当前分钟数 + * 获取当前分钟数 */ function local_minutes() { @@ -520,9 +619,6 @@ 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); @@ -565,25 +661,25 @@ async function task111(method, url, type_name) { } $.get(url, async (err, resp, data) => { - try { - if (err) { - console.log(`${$.name}: API查询请求失败 ‼️‼️`); - console.log(JSON.stringify(err)); - $.logErr(err); - } else if (debug) { - console.log(`\n\n 【debug】===============这是 ${type_name} 返回data==============`); - console.log(data); - console.log(`======`); - console.log(JSON.parse(data)); + try { + if (err) { + console.log(`${$.name}: API查询请求失败 ‼️‼️`); + console.log(JSON.stringify(err)); + $.logErr(err); + } else if (debug) { + console.log(`\n\n 【debug】===============这是 ${type_name} 返回data==============`); + console.log(data); + console.log(`======`); + console.log(JSON.parse(data)); + } + let result = JSON.parse(data); + resolve(result); + } catch (e) { + console.log(e, resp); + } finally { + resolve(); } - let result = JSON.parse(data); - resolve(result); - } catch (e) { - console.log(e, resp); - } finally { - resolve(); - } - }, + }, ); }); } else if (method = httppost) { @@ -593,25 +689,25 @@ async function task111(method, url, type_name) { console.log(url); } $.post(url, async (err, resp, data) => { - try { - if (err) { - console.log("$.name: API查询请求失败 ‼️‼️"); - console.log(JSON.stringify(err)); - $.logErr(err); - } else if (debug) { - console.log(`\n\n 【debug】===============这是 ${type_name} 返回data==============`); - console.log(data); - console.log(`======`); - console.log(JSON.parse(data)); + try { + if (err) { + console.log("$.name: API查询请求失败 ‼️‼️"); + console.log(JSON.stringify(err)); + $.logErr(err); + } else if (debug) { + console.log(`\n\n 【debug】===============这是 ${type_name} 返回data==============`); + console.log(data); + console.log(`======`); + console.log(JSON.parse(data)); + } + let result = JSON.parse(data); + resolve(result); + } catch (e) { + console.log(e, resp); + } finally { + resolve(); } - let result = JSON.parse(data); - resolve(result); - } catch (e) { - console.log(e, resp); - } finally { - resolve(); - } - }, + }, // timeout(3000) ); });