mirror of
https://github.com/smallfawn/QLScriptPublic.git
synced 2025-12-17 23:35:02 +08:00
Update lenovoapp.js
This commit is contained in:
153
lenovoapp.js
153
lenovoapp.js
@@ -22,12 +22,28 @@ class Task {
|
|||||||
this.token = str.split(strSplitor)[1];
|
this.token = str.split(strSplitor)[1];
|
||||||
}
|
}
|
||||||
async main() {
|
async main() {
|
||||||
await this.isSignIn()
|
await this.userInfo()
|
||||||
await this.getUserTaskList();
|
if (this.ckStatus) {
|
||||||
|
await this.isSignIn()
|
||||||
|
await this.getUserTaskList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
async userInfo() {
|
||||||
|
let result = await this.taskRequest({ method: "POST", url: `https://mmembership.lenovo.com.cn/member-hp-webapi/v1/userBenefit/getMyAssets` })
|
||||||
|
//console.log(result);
|
||||||
|
if (result.code == "0") {
|
||||||
|
$.log(`✅账号[${this.index}] 获取用户信息成功===>[${result.data.userId}]乐豆[${result.data.ledouNum}]`);
|
||||||
|
this.ckStatus = true
|
||||||
|
} else {
|
||||||
|
$.log(`❌账号[${this.index}] 获取用户状态失败`);
|
||||||
|
this.ckStatus = false
|
||||||
|
//console.log(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
async isSignIn() {
|
async isSignIn() {
|
||||||
let result = await this.taskRequest("post", `https://mmembership.lenovo.com.cn/member-hp-task-center/v1/task/getCheckInList?lenovoId=10219183246`)
|
let result = await this.taskRequest({ method: "POST", url: `https://mmembership.lenovo.com.cn/member-hp-task-center/v1/task/getCheckInList?lenovoId=10219183246` })
|
||||||
//console.log(result);
|
//console.log(result);
|
||||||
if (result.code == "0") {
|
if (result.code == "0") {
|
||||||
if (result.data.flag == !1) {
|
if (result.data.flag == !1) {
|
||||||
@@ -41,7 +57,7 @@ class Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async checkIn() {
|
async checkIn() {
|
||||||
let result = await this.taskRequest("post", `https://mmembership.lenovo.com.cn/member-hp-task-center/v1/task/checkIn?lenovoId=10219183246&OSType=10011`)
|
let result = await this.taskRequest({ method: "POST", url: `https://mmembership.lenovo.com.cn/member-hp-task-center/v1/task/checkIn?lenovoId=10219183246&OSType=10011` })
|
||||||
//console.log(result);
|
//console.log(result);
|
||||||
if (result.code == "0") {
|
if (result.code == "0") {
|
||||||
$.log(`✅账号[${this.index}] 签到成功🎉`)
|
$.log(`✅账号[${this.index}] 签到成功🎉`)
|
||||||
@@ -51,16 +67,17 @@ class Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async getUserTaskList() {
|
async getUserTaskList() {
|
||||||
let result = await this.taskRequest("post", `https://mmembership.lenovo.com.cn/member-hp-task-center/v1/task/getUserTaskList`)
|
let result = await this.taskRequest({ method: "POST", url: `https://mmembership.lenovo.com.cn/member-hp-task-center/v1/task/getUserTaskList` })
|
||||||
//console.log(result);
|
//console.log(result);
|
||||||
if (result.code == "0") {
|
if (result.code == "0") {
|
||||||
$.log(`✅账号[${this.index}] 获取任务列表成功🎉`)
|
$.log(`✅账号[${this.index}] 获取任务列表成功🎉`)
|
||||||
for (let i = 0; i < result.data.length; i++) {
|
for (let i = 0; i < result.data.length; i++) {
|
||||||
let task = result.data[i];
|
let task = result.data[i];
|
||||||
if (task.taskState == 0&&task.type !== 13) {
|
if (task.taskState == 0 && task.type !== 13) {
|
||||||
await $.wait(5000)
|
await $.wait(5000)
|
||||||
await this.doTask(task.taskId);
|
await this.doTask(task.taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$.log(`❌账号[${this.index}] 获取任务列表失败`);
|
$.log(`❌账号[${this.index}] 获取任务列表失败`);
|
||||||
@@ -68,9 +85,9 @@ class Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async doTask(id) {
|
async doTask(id) {
|
||||||
let result_ = await this.taskRequest("post", `https://mmembership.lenovo.com.cn/member-hp-task-center/v1/checkin/selectTaskPrize?taskId=${id}&channelId=1`)
|
let result_ = await this.taskRequest({ method: "POST", url: `https://mmembership.lenovo.com.cn/member-hp-task-center/v1/checkin/selectTaskPrize?taskId=${id}&channelId=1` })
|
||||||
if (result_.code == "0") {
|
if (result_.code == "0") {
|
||||||
let result = await this.taskRequest("post", `https://mmembership.lenovo.com.cn/member-hp-task-center/v1/Task/userFinishTask?taskId=${id}&channelId=1&state=1`)
|
let result = await this.taskRequest({ method: "POST", url: `https://mmembership.lenovo.com.cn/member-hp-task-center/v1/Task/userFinishTask?taskId=${id}&channelId=1&state=1` })
|
||||||
//console.log(result);
|
//console.log(result);
|
||||||
if (result.code == "0") {
|
if (result.code == "0") {
|
||||||
$.log(`✅账号[${this.index}] 任务执行成功🎉`)
|
$.log(`✅账号[${this.index}] 任务执行成功🎉`)
|
||||||
@@ -84,14 +101,15 @@ class Task {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async taskRequest(method, url, body = "") {
|
async taskRequest(options) {
|
||||||
|
const axios = require('axios');
|
||||||
let headers = {
|
let headers = {
|
||||||
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; MI 8 Lite Build/QKQ1.190910.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/80.0.3987.99 Mobile Safari/537.36/lenovoofficialapp/9e4bb0e5bc326fb1_10219183246/newversion/versioncode-1000112/',
|
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; MI 8 Lite Build/QKQ1.190910.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/80.0.3987.99 Mobile Safari/537.36/lenovoofficialapp/9e4bb0e5bc326fb1_10219183246/newversion/versioncode-1000112/',
|
||||||
'Accept-Encoding': 'gzip, deflate',
|
'Accept-Encoding': 'gzip, deflate',
|
||||||
'pragma': 'no-cache',
|
'pragma': 'no-cache',
|
||||||
'cache-control': 'no-cache',
|
'cache-control': 'no-cache',
|
||||||
'origin': 'https://mmembership.lenovo.com.cn',
|
'origin': 'https://mmembership.lenovo.com.cn',
|
||||||
'servicetoken': 'Bearer '+this.token,
|
'servicetoken': 'Bearer ' + this.token,
|
||||||
'sec-fetch-dest': 'empty',
|
'sec-fetch-dest': 'empty',
|
||||||
'lenovoid': this.ck,
|
'lenovoid': this.ck,
|
||||||
'clientid': '2',
|
'clientid': '2',
|
||||||
@@ -101,13 +119,8 @@ class Task {
|
|||||||
'referer': 'https://mmembership.lenovo.com.cn/app?pmf_source=P0000005611M0002',
|
'referer': 'https://mmembership.lenovo.com.cn/app?pmf_source=P0000005611M0002',
|
||||||
'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
|
'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
|
||||||
}
|
}
|
||||||
const reqeuestOptions = {
|
Object.assign(options, { headers })
|
||||||
url: url,
|
let { data: result } = await axios.request(options)
|
||||||
method: method,
|
|
||||||
headers: headers,
|
|
||||||
body: body
|
|
||||||
}
|
|
||||||
let { body: result } = await $.httpRequest(reqeuestOptions)
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,33 +189,7 @@ function Env(t, s) {
|
|||||||
isQuanX() {
|
isQuanX() {
|
||||||
return "undefined" != typeof $task;
|
return "undefined" != typeof $task;
|
||||||
}
|
}
|
||||||
isSurge() {
|
|
||||||
return "undefined" != typeof $httpClient && "undefined" == typeof $loon;
|
|
||||||
}
|
|
||||||
isLoon() {
|
|
||||||
return "undefined" != typeof $loon;
|
|
||||||
}
|
|
||||||
initRequestEnv(t) {
|
|
||||||
try {
|
|
||||||
require.resolve("got") &&
|
|
||||||
((this.requset = require("got")), (this.requestModule = "got"));
|
|
||||||
} catch (e) { }
|
|
||||||
try {
|
|
||||||
require.resolve("axios") &&
|
|
||||||
((this.requset = require("axios")), (this.requestModule = "axios"));
|
|
||||||
} catch (e) { }
|
|
||||||
this.cktough = this.cktough ? this.cktough : require("tough-cookie");
|
|
||||||
this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar();
|
|
||||||
if (t) {
|
|
||||||
t.headers = t.headers ? t.headers : {};
|
|
||||||
if (
|
|
||||||
typeof t.headers.Cookie === "undefined" &&
|
|
||||||
typeof t.cookieJar === "undefined"
|
|
||||||
) {
|
|
||||||
t.cookieJar = this.ckjar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
queryStr(options) {
|
queryStr(options) {
|
||||||
return Object.entries(options)
|
return Object.entries(options)
|
||||||
.map(
|
.map(
|
||||||
@@ -247,65 +234,7 @@ function Env(t, s) {
|
|||||||
this.msg(this.name, "", message);
|
this.msg(this.name, "", message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async httpRequest(options) {
|
|
||||||
let t = { ...options };
|
|
||||||
t.headers = t.headers || {};
|
|
||||||
if (t.params) {
|
|
||||||
t.url += "?" + this.queryStr(t.params);
|
|
||||||
}
|
|
||||||
t.method = t.method.toLowerCase();
|
|
||||||
if (t.method === "get") {
|
|
||||||
delete t.headers["Content-Type"];
|
|
||||||
delete t.headers["Content-Length"];
|
|
||||||
delete t.headers["content-type"];
|
|
||||||
delete t.headers["content-length"];
|
|
||||||
delete t.body;
|
|
||||||
} else if (t.method === "post") {
|
|
||||||
let ContentType;
|
|
||||||
if (!t.body) {
|
|
||||||
t.body = "";
|
|
||||||
} else if (typeof t.body === "string") {
|
|
||||||
ContentType = this.isJSONString(t.body)
|
|
||||||
? "application/json"
|
|
||||||
: "application/x-www-form-urlencoded";
|
|
||||||
} else if (this.isJson(t.body)) {
|
|
||||||
t.body = JSON.stringify(t.body);
|
|
||||||
ContentType = "application/json";
|
|
||||||
}
|
|
||||||
if (!t.headers["Content-Type"] && !t.headers["content-type"]) {
|
|
||||||
t.headers["Content-Type"] = ContentType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.isNode()) {
|
|
||||||
this.initRequestEnv(t);
|
|
||||||
if (this.requestModule === "axios" && t.method === "post") {
|
|
||||||
t.data = t.body;
|
|
||||||
delete t.body;
|
|
||||||
}
|
|
||||||
let httpResult;
|
|
||||||
if (this.requestModule === "got") {
|
|
||||||
httpResult = await this.requset(t);
|
|
||||||
if (this.isJSONString(httpResult.body)) {
|
|
||||||
httpResult.body = JSON.parse(httpResult.body);
|
|
||||||
}
|
|
||||||
} else if (this.requestModule === "axios") {
|
|
||||||
httpResult = await this.requset(t);
|
|
||||||
httpResult.body = httpResult.data;
|
|
||||||
}
|
|
||||||
return httpResult;
|
|
||||||
}
|
|
||||||
if (this.isQuanX()) {
|
|
||||||
t.method = t.method.toUpperCase();
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
$task.fetch(t).then((response) => {
|
|
||||||
if (this.isJSONString(response.body)) {
|
|
||||||
response.body = JSON.parse(response.body);
|
|
||||||
}
|
|
||||||
resolve(response);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
randomNumber(length) {
|
randomNumber(length) {
|
||||||
const characters = "0123456789";
|
const characters = "0123456789";
|
||||||
return Array.from(
|
return Array.from(
|
||||||
@@ -351,20 +280,16 @@ function Env(t, s) {
|
|||||||
};
|
};
|
||||||
msg(title = t, subtitle = "", body = "", options) {
|
msg(title = t, subtitle = "", body = "", options) {
|
||||||
const formatOptions = (options) => {
|
const formatOptions = (options) => {
|
||||||
if (!options || (!this.isLoon() && this.isSurge())) {
|
if (!options) {
|
||||||
return options;
|
return options;
|
||||||
} else if (typeof options === "string") {
|
} else if (typeof options === "string") {
|
||||||
if (this.isLoon()) {
|
if (this.isQuanX()) {
|
||||||
return options;
|
|
||||||
} else if (this.isQuanX()) {
|
|
||||||
return { "open-url": options };
|
return { "open-url": options };
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
} else if (typeof options === "object" && (options["open-url"] || options["media-url"])) {
|
} else if (typeof options === "object" && (options["open-url"] || options["media-url"])) {
|
||||||
if (this.isLoon()) {
|
if (this.isQuanX()) {
|
||||||
return options["open-url"];
|
|
||||||
} else if (this.isQuanX()) {
|
|
||||||
return options;
|
return options;
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -373,15 +298,11 @@ function Env(t, s) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!this.isMute) {
|
if (!this.isMute) {
|
||||||
if (this.isSurge() || this.isLoon()) {
|
if (this.isQuanX()) {
|
||||||
$notification.post(title, subtitle, body, formatOptions(options));
|
|
||||||
} else if (this.isQuanX()) {
|
|
||||||
$notify(title, subtitle, body, formatOptions(options));
|
$notify(title, subtitle, body, formatOptions(options));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let logs = ["", "==============📣系统通知📣=============="];
|
let logs = ["", "==============📣系统通知📣=============="];
|
||||||
logs.push(title);
|
logs.push(title);
|
||||||
subtitle ? logs.push(subtitle) : "";
|
subtitle ? logs.push(subtitle) : "";
|
||||||
@@ -394,7 +315,7 @@ function Env(t, s) {
|
|||||||
console.log(t.join(this.logSeparator));
|
console.log(t.join(this.logSeparator));
|
||||||
}
|
}
|
||||||
logErr(t, s) {
|
logErr(t, s) {
|
||||||
const e = !this.isSurge() && !this.isQuanX() && !this.isLoon();
|
const e = !this.isQuanX();
|
||||||
e
|
e
|
||||||
? this.log("", `\u2757\ufe0f${this.name},\u9519\u8bef!`, t.stack)
|
? this.log("", `\u2757\ufe0f${this.name},\u9519\u8bef!`, t.stack)
|
||||||
: this.log("", `\u2757\ufe0f${this.name},\u9519\u8bef!`, t);
|
: this.log("", `\u2757\ufe0f${this.name},\u9519\u8bef!`, t);
|
||||||
|
|||||||
Reference in New Issue
Block a user