之前分享过利用WPS的AirScript实现【阿里云盘的全自动签到】,今天再来分享一下【夸克网盘】全自动签到获取永久容量的方法。
准备工作,先来获取夸克Cookie,教程如下:
1.电脑浏览器打开夸克网盘,先不登录的情况下 按 F12 ,选择“网络”,如图所示:
扫码登录后,请选择”sort?pr=ucpro&fr=pc“名称文件,并下滑找到”Cookie“所对应的值就是你的Cookie,如下图所示。
如果你需要复用之前阿里云盘签到配置的推送,可以直接在之前创建的表格中新建一个名为 夸克网盘
的工作表。再把新建一个脚本粘贴下方的代码,再把获取到的夸克网盘Cookie 放在 A 列即可,支持多账号,一行一个。
源码开源地址:https://registry.npmmirror.com/@asunajs/dist/0.0.3/files/quark.wps.js
完整代码如下:
// ../../core/quark/api.ts function createApi(http) { let driveUrl = "https://drive-m.quark.cn/1/clouddrive/capacity/growth"; return { getInfo: function() { return http.get(`${driveUrl}/info?pr=ucpro&fr=pc&uc_param_str=`); }, sign: function() { return http.post(`${driveUrl}/sign?pr=ucpro&fr=pc&uc_param_str=`, { sign_cyclic: !0 }); } }; } // ../../core/quark/index.ts function getInfo($) { try { let { data, code, status, message } = $.api.getInfo(); if (code !== 0) { $.logger.info("获取用户信息失败", code, status, message); return; } return data.cap_sign; } catch (error) { $.logger.error("获取用户信息异常", error.message); } } function signIn($) { try { let { data, code, status, message } = $.api.sign(); if (code !== 0) { $.logger.info("签到失败", code, status, message); return; } return data.sign_daily_reward; } catch (error) { $.logger.error("签到异常", error.message); } } function run($) { try { let info = getInfo($); if (!info) { $.logger.error("登录失败"); return; } let { sign_progress, sign_rewards, sign_target, sign_daily } = info; if (sign_daily) { $.logger.info(`\u4ECA\u65E5\u5DF2\u7B7E\u5230${sign_rewards[sign_progress - 1].name}\uFF0C\u8FDE\u7B7E\u8FDB\u5EA6${sign_progress}/${sign_target}\u3002`); return; } let dailyReward = signIn($); dailyReward && $.logger.info(`\u7B7E\u5230\u6210\u529F\uFF0C\u83B7\u5F97${dailyReward / 1048576}M\uFF0C\u8FDE\u7B7E\u8FDB\u5EA6${sign_progress + 1}/${sign_target}\u3002`); } catch (error) { $.logger.error("运行异常", error.message); } } // ../../packages/utils-pure/index.ts function createLogger(options) { let wrap = (type, ...args)=>{ if (options && options.pushData) { let msg = args.reduce((str, cur)=>`${str} ${cur}`, "").substring(1); options.pushData.push({ msg: msg, type: type, date: /* @__PURE__ */ new Date() }); } console[type](...args); }; return { info: (...args)=>wrap("info", ...args), error: (...args)=>wrap("error", ...args), debug: (...args)=>wrap("info", ...args) }; } // ../../core/push/index.ts function _send({ logger, http }, name = "自定义消息", options) { try { let requestOptions = { method: "POST", headers: { "Content-Type": "application/json" }, timeout: 1e4, ...options }; Reflect.has(options, "data") && Reflect.has(options.data, "agent") && (requestOptions.agent = options.data.agent, delete options.data.agent); let data = http.fetch(requestOptions), { errcode, code, err } = data; if (errcode || err || ![ 0, 200, void 0 ].some((c)=>code === c)) return logger.error(`${name}\u53D1\u9001\u5931\u8D25`, JSON.stringify(data)); logger.info(`${name}\u5DF2\u53D1\u9001\uFF01`); } catch (error) { logger.info(`${name}\u53D1\u9001\u5931\u8D25: ${error.message}`); } } function pushplus(apiOption, { token, ...option }, title, text) { return _send(apiOption, "pushplus", { url: "http://www.pushplus.plus/send", method: "POST", data: { token: token, title: title, content: text, ...option } }); } function serverChan(apiOption, { token, ...option }, title, text) { return _send(apiOption, "Server酱", { url: `https://sctapi.ftqq.com/${token}.send`, headers: { "content-type": "application/x-www-form-urlencoded" }, data: { text: title, desp: text.replaceAll(` `, ` `), ...option } }); } function workWeixin(apiOption, { msgtype = "text", touser = "@all", agentid, corpid, corpsecret, ...option }, title, text) { try { let { access_token } = apiOption.http.fetch({ url: "https://qyapi.weixin.qq.com/cgi-bin/gettoken", method: "POST", data: { corpid: corpid, corpsecret: corpsecret }, headers: { "Content-Type": "application/json" } }); return _send(apiOption, "企业微信推送", { url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${access_token}`, data: { touser: touser, msgtype: msgtype, agentid: agentid, [msgtype]: { content: `${title} ${text}` }, ...option } }); } catch (error) { apiOption.logger.error("企业微信推送失败"), apiOption.logger.error(error); } } function workWeixinBot(apiOption, { url, msgtype = "text", ...option }, title, text) { return _send(apiOption, "企业微信Bot推送", { url: url, data: { msgtype: msgtype, [msgtype]: { centent: `${title} ${text}` }, ...option } }); } function bark(apiOption, { key, level = "passive", ...options }, title, text) { return _send(apiOption, "Bark ios 推送", { url: `https://api.day.app/${key}`, data: { body: text, title: title, level: level, ...options } }); } function twoIm(apiOption, { key, sid, query, msgtype = "text", ...options }, title, text) { let urlSearch = new URLSearchParams({ key: key, sid: sid }); return query && Object.entries(query).forEach(([key2, value])=>{ urlSearch.append(key2, String(value)); }), _send(apiOption, "Bark ios 推送", { url: `https://api.2im.cn/push?${urlSearch.toString()}`, data: { msgtype: msgtype, content: text, title: title, ...options } }); } // ../utils/index.ts function createSimpleRequest(headers) { return { get: (url)=>HTTP.get(url, { headers: headers }).json(), post: (url, data)=>HTTP.post(url, typeof data == "string" ? data : JSON.stringify(data), { headers: headers }).json() }; } function getPushConfig() { let usedRange2 = Application.Sheets.Item("推送").UsedRange; if (!usedRange2) return console.log("未开启推送"), {}; let cells = usedRange2.Columns.Cells, columnEnd = Math.min(50, usedRange2.ColumnEnd), rowEnd = Math.min(50, usedRange2.RowEnd), pushConfig = {}; for(let option = usedRange2.Column; option <= columnEnd; option++){ let t = {}, item = cells.Item(option); if (item.Text) { pushConfig[item.Text] = t; for(let kv = 1; kv <= rowEnd; kv++){ let key = item.Offset(kv).Text; key.trim() && (t[key] = valueHandle(item.Offset(kv, 1).Text.trim())); } } } let base = pushConfig.base; if (!base) return pushConfig; return delete pushConfig.base, { ...pushConfig, ...base }; function valueHandle(value) { return value === "TRUE" || value === "是" ? !0 : value === "FALSE" || value === "否" ? !1 : value; } } function email({ logger }, email2, title, text) { try { if (!email2 || !email2.pass || !email2.from || !email2.host) return; let port = email2.port || 465, toUser = email2.to || email2.from; SMTP.login({ host: email2.host, // 域名 port: port, // 端口 secure: port === 465, // TLS username: email2.from, // 账户名 password: email2.pass }).send({ from: `${title} <${email2.from}>`, to: toUser, subject: title, text: text.replace(/\n/g, `\r `) }), logger.info("邮件消息已发送"); } catch (error) { logger.error("邮件消息发送失败", error.message); } } function sendNotify(op, data, title, text) { let cbs = { pushplus: pushplus, serverChan: serverChan, workWeixin: workWeixin, email: email, workWeixinBot: workWeixinBot, bark: bark, twoIm: twoIm }; for (let [name, d] of Object.entries(data)){ let cb = cbs[name]; cb && cb(op, d, title, text); } } function sendWpsNotify(pushData2, pushConfig) { if (pushData2.length && pushConfig && !(pushConfig.onlyError && !pushData2.some((el)=>el.type === "error"))) { let msg = pushData2.map((m)=>`[${m.type} ${m.date.toLocaleTimeString()}]${m.msg}`).join(` `); msg && sendNotify({ logger: createLogger(), http: { fetch: (op)=>(op.data && typeof op.data != "string" && (op.body = JSON.stringify(op.data)), HTTP.fetch(op.url, op).json()) } }, pushConfig, pushConfig.title || "asign 运行推送", msg); } } // index.ts function main(cookie, option) { if (!cookie) return; let logger = createLogger({ pushData: option && option.pushData }), $ = { api: createApi(createSimpleRequest({ "content-type": "application/json", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0", cookie: cookie })), logger: logger, sleep: Time.sleep }; $.logger.info("--------------"), run($); } var sheet = Application.Sheets.Item("夸克网盘") || Application.Sheets.Item("quark") || ActiveSheet, usedRange = sheet.UsedRange, columnA = sheet.Columns("A"), len = usedRange.Row + usedRange.Rows.Count - 1, pushData = []; for(let i = 1; i <= len; i++){ let cell = columnA.Rows(i); cell.Text && (console.log(`\u6267\u884C\u7B2C ${i} \u884C`), main(cell.Text, { pushData: pushData })); } sendWpsNotify(pushData, getPushConfig());