2024年12月24日星期二

奇瑞汽车EV任务脚本

1.购买服务器

阿里云:

服务器购买地址

https://t.aliyun.com/U/nxyLKd

若失效,可用地址

https://www.aliyun.com/activity/wuying/dj?source=5176.29345612&userCode=49hts92d

腾讯云:

https://curl.qcloud.com/wJpWmSfU

若失效,可用地址

https://cloud.tencent.com/act/cps/redirect?redirect=2446&cps_key=ad201ee2ef3b771157f72ee5464b1fea&from=console

2.部署教程

2024年最新青龙面板跑脚本教程(一)持续更新中

3.代码如下

/** * cron 5 15 * * *  V3.js * Show: * 变量名:cheryev * 变量值:midend.icar-ecology.com Headers中 token的值 多账号换行或者 @ 分隔  */
const $ = new Env("奇瑞Ev");const ckName = "cheryev";let envSplitor = ["@", "\n"]; //多账号分隔符let strSplitor = "&"; //多变量分隔符let userIdx = 0;let userList = [];class UserInfo { constructor(str) { this.index = ++userIdx; this.ck = str.split(strSplitor)[0]; //单账号多变量分隔符 this.ckStatus = true; } async main() { await this.user_info(); } async user_info() { try { let options = { url: `https://midend.icar-ecology.com/credits/task/app/v1/attendance`, headers: { "app": "cheryev", "authorization": `Bearer ${this.ck}`, "app-v": "2.9.0", //"uid": "1721053872548581377", "net-type": "wifi", "lng": 0.00, "channel": 2, "dev-id": "29f8b4555e18235b6b1ef94fa59541f7a", "platform": 7, "dev-model": "MI8Lite", "lat": 0.00, "token": `${this.ck}`, "Content-Length": 0, "Host": "midend.icar-ecology.com", "Connection": "Keep-Alive", "Accept-Encoding": "gzip", "User-Agent": "okhttp/4.10.0" }, body: JSON.stringify({}) }, result = await httpRequest(options); //console.log(options); //console.log(result); if (result.data.success == true) { console.log(`✅账号[${this.index}] 签到成功 => 获得${result.data.rewardPoints}🎉`); } else { console.log(`❌账号[${this.index}] 签到 => 失败`); console.log(JSON.stringify(result)); } } catch (e) { console.log(e); } }}
async function start() { let taskall = []; for (let user of userList) { if (user.ckStatus) { taskall.push(await user.main()); } } await Promise.all(taskall);}
!(async () => { if (!(await checkEnv())) return; if (userList.length > 0) { await start(); }})() .catch((e) => console.log(e)) .finally(() => $.done());
//********************************************************/** * 变量检查与处理 * @returns */async function checkEnv() { let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || ""; if (userCookie) { console.log(userCookie); let e = envSplitor[0]; for (let o of envSplitor) if (userCookie.indexOf(o) > -1) { e = o; break; } for (let n of userCookie.split(e)) n && userList.push(new UserInfo(n)); } else { console.log("未找到CK"); return; } return console.log(`共找到${userList.length}个账号`), true; //true == !0}
/////////////////////////////////////////////////////////////////////////////////////function httpRequest(options, timeout = 5 * 1000) { method = options.method ? options.method.toLowerCase() : options.body ? "post" : "get"; return new Promise((resolve) => { setTimeout(() => { $[method](options, (err, resp, data) => { try { if (err) { console.log(JSON.stringify(err)); $.logErr(err); } else { try { data = JSON.parse(data); } catch (error) { } } } catch (e) { console.log(e); $.logErr(e, resp); } finally { resolve(data); } }); }, timeout); });}// prettier-ignorefunction Env(t, s) { return new (class { constructor(t, s) { (this.name = t), (this.data = null), (this.dataFile = "box.dat"), (this.logs = []), (this.logSeparator = "\n"), (this.startTime = new Date().getTime()), Object.assign(this, s), this.log("", `\ud83d\udd14${this.name},\u5f00\u59cb!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } getScript(t) { return new Promise((s) => { this.get({ url: t }, (t, e, i) => s(i)) }) } runScript(t, s) { return new Promise((e) => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let o = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); (o = o ? 1 * o : 20), (o = s && s.timeout ? s.timeout : o); const [h, a] = i.split("@"), r = { url: `http://${a}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: o }, headers: { "X-Key": h, Accept: "*/*" }, }; this.post(r, (t, s, i) => e(i)) }).catch((t) => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { (this.fs = this.fs ? this.fs : require("fs")), (this.path = this.path ? this.path : require("path")); const t = this.path.resolve(this.dataFile), s = this.path.resolve(process.cwd(), this.dataFile), e = this.fs.existsSync(t), i = !e && this.fs.existsSync(s); if (!e && !i) return {}; { const i = e ? t : s; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { (this.fs = this.fs ? this.fs : require("fs")), (this.path = this.path ? this.path : require("path")); const t = this.path.resolve(this.dataFile), s = this.path.resolve(process.cwd(), this.dataFile), e = this.fs.existsSync(t), i = !e && this.fs.existsSync(s), o = JSON.stringify(this.data); e ? this.fs.writeFileSync(t, o) : i ? this.fs.writeFileSync(s, o) : this.fs.writeFileSync(t, o) } } lodash_get(t, s, e) { const i = s.replace(/\[(\d+)\]/g, ".$1").split("."); let o = t; for (const t of i) if (((o = Object(o)[t]), void 0 === o)) return e; return o } lodash_set(t, s, e) { return Object(t) !== t ? t : (Array.isArray(s) || (s = s.toString().match(/[^.[\]]+/g) || []), (s.slice(0, -1).reduce((t, e, i) => Object(t[e]) === t[e] ? t[e] : (t[e] = Math.abs(s[i + 1]) >> 0 == +s[i + 1] ? [] : {}), t)[s[s.length - 1]] = e), t) } getdata(t) { let s = this.getval(t); if (/^@/.test(t)) { const [, e, i] = /^@(.*?)\.(.*?)$/.exec(t), o = e ? this.getval(e) : ""; if (o) try { const t = JSON.parse(o); s = t ? this.lodash_get(t, i, "") : s } catch (t) { s = "" } } return s } setdata(t, s) { let e = !1; if (/^@/.test(s)) { const [, i, o] = /^@(.*?)\.(.*?)$/.exec(s), h = this.getval(i), a = i ? ("null" === h ? null : h || "{}") : "{}"; try { const s = JSON.parse(a); this.lodash_set(s, o, t), (e = this.setval(JSON.stringify(s), i)) } catch (s) { const h = {}; this.lodash_set(h, o, t), (e = this.setval(JSON.stringify(h), i)) } } else e = this.setval(t, s); return e } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? ((this.data = this.loaddata()), this.data[t]) : (this.data && this.data[t]) || null } setval(t, s) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, s) : this.isQuanX() ? $prefs.setValueForKey(t, s) : this.isNode() ? ((this.data = this.loaddata()), (this.data[s] = t), this.writedata(), !0) : (this.data && this.data[s]) || null } initGotEnv(t) { (this.got = this.got ? this.got : require("got")), (this.cktough = this.cktough ? this.cktough : require("tough-cookie")), (this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar()), t && ((t.headers = t.headers ? t.headers : {}), void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, s = () => { }) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? $httpClient.get(t, (t, e, i) => { !t && e && ((e.body = i), (e.statusCode = e.status)), s(t, e, i) }) : this.isQuanX() ? $task.fetch(t).then((t) => { const { statusCode: e, statusCode: i, headers: o, body: h } = t; s(null, { status: e, statusCode: i, headers: o, body: h }, h) }, (t) => s(t)) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, s) => { try { const e = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); this.ckjar.setCookieSync(e, null), (s.cookieJar = this.ckjar) } catch (t) { this.logErr(t) } }).then((t) => { const { statusCode: e, statusCode: i, headers: o, body: h, } = t; s(null, { status: e, statusCode: i, headers: o, body: h }, h) }, (t) => s(t))) } post(t, s = () => { }) { if ((t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), delete t.headers["Content-Length"], this.isSurge() || this.isLoon())) $httpClient.post(t, (t, e, i) => { !t && e && ((e.body = i), (e.statusCode = e.status)), s(t, e, i) }); else if (this.isQuanX()) (t.method = "POST"), $task.fetch(t).then((t) => { const { statusCode: e, statusCode: i, headers: o, body: h } = t; s(null, { status: e, statusCode: i, headers: o, body: h }, h) }, (t) => s(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: e, ...i } = t; this.got.post(e, i).then((t) => { const { statusCode: e, statusCode: i, headers: o, body: h } = t; s(null, { status: e, statusCode: i, headers: o, body: h }, h) }, (t) => s(t)) } } time(t) { let s = { "M+": new Date().getMonth() + 1, "d+": new Date().getDate(), "H+": new Date().getHours(), "m+": new Date().getMinutes(), "s+": new Date().getSeconds(), "q+": Math.floor((new Date().getMonth() + 3) / 3), S: new Date().getMilliseconds(), }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (new Date().getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in s) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? s[e] : ("00" + s[e]).substr(("" + s[e]).length))); return t } msg(s = t, e = "", i = "", o) { const h = (t) => !t || (!this.isLoon() && this.isSurge()) ? t : "string" == typeof t ? this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : void 0 : "object" == typeof t && (t["open-url"] || t["media-url"]) ? this.isLoon() ? t["open-url"] : this.isQuanX() ? t : void 0 : void 0; this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(s, e, i, h(o)) : this.isQuanX() && $notify(s, e, i, h(o))), this.logs.push("", "==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="), this.logs.push(s), e && this.logs.push(e), i && this.logs.push(i) } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, s) { const e = !this.isSurge() && !this.isQuanX() && !this.isLoon(); e ? this.log("", `\u2757\ufe0f${this.name},\u9519\u8bef!`, t.stack) : this.log("", `\u2757\ufe0f${this.name},\u9519\u8bef!`, t) } wait(t) { return new Promise((s) => setTimeout(s, t)) } done(t = {}) { const s = new Date().getTime(), e = (s - this.startTime) / 1e3; this.log("", `\ud83d\udd14${this.name},\u7ed3\u675f!\ud83d\udd5b ${e}\u79d2`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } })(t, s) }

解析

这脚本是一个用于 奇瑞汽车EV(Chery EV)的自动签到脚本。该脚本的功能主要是通过调用特定的API接口,模拟用户签到的操作,并返回签到的结果(例如获得奖励积分等)。脚本中的主要操作包括从多个账号中提取 token,使用这些 token 执行签到请求,并根据返回的结果输出成功或失败的信息。

主要作用

  • 自动化签到:该脚本通过调用奇瑞EV平台的签到接口

    https://midend.icar-ecology.com/credits/task/app/v1/attendance


  • 实现自动签到功能。这通常用于在每日的定时任务中,通过脚本自动执行签到,获取签到奖励。

  • 支持多账号操作:脚本支持处理多个用户账号。用户可以提供多个 token,通过 @ 或换行符分隔,脚本会自动将这些 token 解析并循环执行签到。

  • 动态检查环境变量:脚本会检查环境变量中是否存在有效的 token,如果存在,则解析出多个账号信息,并执行签到操作。对于每个账号,都会生成一个 UserInfo 实例,利用这个实例来发起签到请求。

  • 成功与失败反馈:脚本会在执行签到任务后,输出每个账号的签到结果。如果签到成功,会输出奖励积分的数量;如果签到失败,则会输出失败信息,并尝试提供相关错误的反馈。

关键功能

  1. 多账号支持

    • 用户可以一次性提供多个账号的 token,这些账号通过指定分隔符(如 @ 或换行符)进行分隔。脚本会解析这些 token,并自动执行签到任务。

  2. 用户信息封装UserInfo 类):

    • 每个账号通过 UserInfo 类进行封装,存储账号的 token,并通过 user_info() 方法执行签到请求。

    • 请求成功后,脚本会记录奖励积分数量。

  3. API 请求

    • httpRequest() 方法封装了对奇瑞EV平台接口的调用,支持发送带有 Bearer token 的请求,从而完成签到操作。

  4. 错误处理与日志记录

    • 脚本会捕获 API 请求中的错误,并记录相应的日志,输出成功或失败的结果,帮助用户了解每个账号的签到状态。

  5. 定时任务

    • 通过 cron 配置,脚本可以定时执行签到任务,确保每个账号按时进行签到,通常会设置为每天的特定时间。

  6. 环境变量管理

    • 脚本会检查并处理环境变量,确保脚本能够正确读取和解析用户提供的账号信息(即 token)。

适用场景

  • 日常签到:此脚本适合用来自动化处理奇瑞EV用户的日常签到任务,省去了手动签到的麻烦。

  • 多个账号管理:如果用户有多个奇瑞EV账号,使用这个脚本可以一次性为多个账号执行签到操作,并获取相应的奖励积分。

  • 自动化任务:适用于希望将日常任务自动化的用户,特别是在涉及多个账号时,通过脚本来提高工作效率。

这种自动签到脚本通常用于增强用户的体验,节省时间,特别是在需要频繁执行签到操作的情况下。

注意

本文部分变量已做脱敏处理,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。技术层面需要提供帮助,可以通过打赏的方式进行探讨。




没有评论:

发表评论

Tiktok难民进入小红书当天变现万粉,OMG,还是中国人会赚钱。

前两天不是说Tiktok老外都跑进啦了,最近有被中国人想出很意思的玩法。反向带货。 还不不知道TK难民的看这个帖子。 TK难民进入小红书,对于我们跨境卖家有啥机会?原创 讲讲这个玩法的结果。这个玩法属于反向带货,适合非跨境卖家。 粉丝过万,品牌方发邀请,申请带货。 讲讲这个玩...