欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 高考 > 得-物任务脚本

得-物任务脚本

2025/11/12 20:56:35 来源:https://blog.csdn.net/q2642346535/article/details/141069256  浏览:    关键词:得-物任务脚本

得某物任务脚本

该脚本主要用于自动化执行“得物”APP中的一些日常任务和活动,包括签到、任务完成、奖励领取等操作。使用了多个第三方库来加密、签名和发送请求。

  1. 任务的定时执行

脚本通过定时任务(cron)设置在每天的11:10执行。使用的依赖库包括crypto-jsjsencrypt

  1. 变量设置
  • dewuCK: 用于存储多个账号的cookie信息,包括x-auth-token、dutoken和SK。

  • UAdefult_dewu: 设置默认的User-Agent,如果环境变量中存在,则使用环境变量中的值。

  1. 任务执行流程

脚本主要分为多个部分,各部分代表不同的任务或活动:

3.1 初始化

  • 通过new Env("得物农场")创建一个环境对象,加载环境相关配置。

  • 初始化userList数组,用于存储多个用户信息。

  • 初始化taskall数组,用于存储多个任务的Promise对象。

3.2 主任务流程

  • 树任务: 包括浇水、邀请奖励、获取树信息等操作。

  • 鱼任务: 包括签到、任务列表获取、喂鱼等操作。

  • 上上签: 包括助力其他用户、获取任务列表等操作。

  • 0元抽: 获取活动列表、执行任务等操作。

-盲盒抽奖: 获取盲盒任务、刷新盲盒、抽取盲盒奖励等操作。

  • 潮金币: 获取任务列表、签到、领取奖励等操作。
  1. 任务和API请求封装
  • 脚本封装了多个请求方法,如taskRequesttaskRequest_task,用于发送HTTP请求。

  • 使用CryptoJS进行数据加密,jsencrypt进行数据签名,确保数据的安全性和完整性。

  • 提供了对返回数据的解析、处理和日志记录。

  • 在这里插入图片描述

部分源码

function 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;}async 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) this.writeFile(this.dataFile, JSON.stringify([]));const pt = e ? t : s;let r = await this.readFile(pt);return r}async writedata() {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);const o = JSON.stringify(this.data, null, 2);const pt = e ? t : i ? s : t;await writeFile(pt, o)}readFile(pt) {this.fs = this.fs ? this.fs : require("fs");return new Promise((resolve, reject) => {this.fs.readFile(pt, "utf8", (r, o) => {if (r) reject({});else o = this.isJSONString(o) ? JSON.parse(o) : o;resolve(o);});});}writeFile(pt, o) {this.fs = this.fs ? this.fs : require("fs");return new Promise((resolve, reject) => {this.fs.writeFile(pt, o, (r) => {if (r) reject(r);else resolve();});});}async getval(t) {if (this.isSurge() || this.isLoon()) {return $persistentStore.read(t);} else if (this.isQuanX()) {return $prefs.valueForKey(t);} else if (this.isNode()) {this.data = await this.loaddata();return await this.data[t];} else {return (this.data && this.data[t]) || null;}}async setval(t, s) {if (this.isSurge() || this.isLoon()) {return $persistentStore.write(t, s);} else if (this.isQuanX()) {return $prefs.setValueForKey(t, s);} else if (this.isNode()) {this.data = await this.loaddata();this.data[s] = t;await this.writedata();return true;} else {return (this.data && this.data[s]) || null;}}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) {return Object.entries(options).map(([key, value]) =>`${key}=${typeof value === "object" ? JSON.stringify(value) : value}`
).join("&");}getURLParams(url) {const params = {};const queryString = url.split("?")[1];if (queryString) {const paramPairs = queryString.split("&");paramPairs.forEach((pair) => {const [key, value] = pair.split("=");params[key] = value;});}return params;}isJSONString(str) {try {return JSON.parse(str) && typeof JSON.parse(str) === "object";} catch (e) {return false;}}isJson(obj) {var isjson =typeof obj == "object" &&Object.prototype.toString.call(obj).toLowerCase() =="[object object]" &&!obj.length;return isjson;}async sendMsg(message) {if (!message) return;if ($.isNode()) {await notify.sendNotify($.name, message);} else {$.msg($.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) {const characters = "0123456789";return Array.from({ length },() => characters[Math.floor(Math.random() * characters.length)]
).join("");}randomString(length) {const characters = "abcdefghijklmnopqrstuvwxyz0123456789";return Array.from({ length },() => characters[Math.floor(Math.random() * characters.length)]
).join("");}timeStamp() {return new Date().getTime();}uuid() {return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function (c) {var r = (Math.random() * 16) | 0,v = c == "x" ? r : (r & 0x3) | 0x8;return v.toString(16);}
);}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)));let logs = ["", "==============📣系统通知📣=============="];logs.push(t);e ? logs.push(e) : "";i ? logs.push(i) : "";console.log(logs.join("\n"));this.logs = this.logs.concat(logs);}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();if (this.isNode()) {process.exit(1);}if (this.isQuanX()) {$done(t);}}})(t, s);​

请记住,这篇介绍旨在技术分享,使用此类脚本时,请遵守相关平台的规定,感兴趣的可以交流*

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词