是的还是这个项目 asunajs/asign ,上次阿里云盘发了 5 天了,star 还是 0 。于是我决定再发个移动云盘。遇到问题可以在这里或者 Github 反馈哦
先看有什么用,想了一下好像真没有用,抱歉打扰您的时间,可以点击右上角退出了。
文档地址:https://as.js.cool
已经实现功能
- 云盘每日签到
- 公众号每日签到
- 公众号抽奖
- 每日任务-上传文件
- 每日任务-云笔记(任务已下线)
- 果园
- 邮箱每月任务(部分支持,剩下的还是需要手动)
注意:由于编辑后需要审核,帖子会长时间处于不可访问的状态,所以后续简单的通知内容将直接回复在后面,点击【只看该作者】查看,不定时将内容整合过来,当然最新内容可以看 Github,因为代码都是先走的 Github
怎么抓取鉴权信息
- 打开移动云盘的官网 yun.139.com
- 登录账号
- 按 F12 打开控制台,找到应用程序/应用/Application (在火狐某些版本是存储),然后找到 Cookie 项
- 复制 authorization 备用
看 cookie 好像是 一个月过期,但是由于网上没找到参考项目,这也没写几天,所有目前我也不知道(已经支持刷新)
怎么在本地运行
直接通过源码运行(懂得都懂,就不赘述了)
用 Node 的可以用 npm 安装 @asunajs/caiyun 这个包,青龙面板添加 Node 依赖即可
创建运行的脚本
const { run } = require('@asunajs/caiyun');
const { resolve } = require('path');
(async () => {
await run(resolve(process.cwd(), './asign.json')); // 按需修改路径
})();
配置文件的写法,auth 是之前复制的 authorization。
{
"caiyun": [
{
"auth": ""
}
]
}
怎么在金山云文档运行
列表不需要额外的设计,直接简单粗暴,A 列是当前账号的手机号,B 列是之前复制的 authorization,C 列是之前复制的 auth_token(支持多账号,放多行)
自动运行
编写过程中踩了个大坑,wps 不支持 Array.from 的第二个参数,不管写的什么,都是填充 {}
,导致本地可用云笔记,wps 一直不行,不知道这个 wps 到底运行在什么环境里的,好多奇怪的问题
推送
在原表格的基础上新建一个推送表格(一定要叫推送)
表格如图所示,每两列为一个配置单元(每个单元之间运行空列)
单元的第首行首列放置推送名,如 email,pushplus。base 比较特殊。
除第一行外,每个单元第一列为配置名称,第二列为值,中间允许空行(如 email 所示)
注意
- 不用的配置就不要写第一行,或者直接删除。
- 运行时点击工作表 1(或者其他名字,反正是你放 token 配置的那个表,不是推送配置),然后再运行代码,不然一堆报错。
- 企业微信,serverChan 也是同样的方式配置(字段名见本地配置)
wps 代码
代码如果每月及时更新,可在 Gitee 获取最新 Gitee
wps 并不适合做这个,请尽量不要使用 wps 的 airscript (打算弃坑了,wps 很多行为都与 nodejs 不一致,甚至没有解决办法,所有不再处理 wps 的问题,请转用 nodejs 平台,如青龙/云函数)
function randomHex(length) {
return Array.from({
length: length,
})
.map(() => Math.floor(Math.random() * 16).toString(16))
.join('');
}
function getXmlElement(xml, tag) {
const m = xml.match(`<${tag}>(.*)<\/${tag}>`);
return m ? m[1] : '';
}
function createLogger(options) {
const wrap = (type, ...args) => {
if (options && options.pushData) {
const msg = args.reduce((str, cur) => `${str} ${cur}`, '').substring(1);
options.pushData.push({
msg: msg,
type: type,
date: new Date(),
});
}
console[type](...args);
};
return {
info: (...args) => wrap('info', ...args),
error: (...args) => wrap('error', ...args),
debug: (...args) => wrap('info', ...args),
};
}
function getHostname(url) {
return url.split('/')[2].split('?')[0];
}
function _send({ logger, http }, name = '自定义消息', options) {
try {
const data = http.fetch(options);
const { errcode, code, err } = data;
if (errcode || err || ![0, 200, undefined].some((c) => code === c)) {
return logger.error(`${name}发送失败`, JSON.stringify(data));
}
logger.info(`${name}已发送!`);
} catch (error) {
logger.info(`${name}发送失败: ${error.message}`);
logger.error(error);
}
}
function pushCustomPost({ logger, http }, apiTemplate, title, text) {
try {
if (!apiTemplate || !apiTemplate.url) return;
const { data, timeout, headers } = apiTemplate;
const method = apiTemplate.method.toUpperCase() || 'POST';
const options = {
method: method,
timeout: timeout,
headers: headers,
url: '',
};
options.url = apiTemplate.url
.replace('{title}', encodeURIComponent(title))
.replace('{text}', encodeURIComponent(text));
// 处理data
if (data && Object.keys(data).length) {
const str = JSON.stringify(data)
.replace(/{title}/g, title)
.replace(/{text}/g, text)
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r');
options.data = JSON.parse(str);
}
http.fetch(options);
logger.info(`自定义消息已发送!`);
} catch (error) {
logger.info(`自定义消息发送失败: ${error.message}`);
logger.error(error);
}
}
function pushplus(apiOption, { token }, title, text) {
return _send(apiOption, 'pushplus', {
url: `http://www.pushplus.plus/send`,
method: 'POST',
headers: {
'content-type': 'application/json',
},
data: {
token: token,
title: title,
content: text,
},
});
}
function serverChan(apiOption, { token }, title, text) {
return _send(apiOption, 'Server酱', {
url: `https://sctapi.ftqq.com/${token}.send`,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
data: {
text: title,
desp: text,
},
});
}
/**
*
* @description https://developer.work.weixin.qq.com/document/path/90665#corpid
*/ function workWeixin(
apiOption,
{ msgtype = 'text', touser = '@all', agentid, corpid, corpsecret },
title,
text
) {
const { 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}`,
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: {
touser: touser,
msgtype: msgtype,
agentid: agentid,
[msgtype]: {
content: `${title}\n\n${text}`,
},
},
});
}
function getCookieJSON(cookie) {
if (!cookie) return {};
const matchArray = cookie.match(/([^;=]+)(?:=([^;]*))?/g);
if (!matchArray) return {};
return matchArray.reduce((pre, cur) => {
const [key, value] = cur.trim().split('=');
pre[key] = value;
return pre;
}, {});
}
function getCookieString(obj) {
const string = Object.keys(obj).reduce(
(pre, cur) => pre + `${cur}=${obj[cur]}; `,
''
);
return string.substring(0, string.length - 2 || 0);
}
function getSetCookieValue(setCookieArray) {
let cookieStr = '';
setCookieArray
.filter(Boolean)
.forEach((setCookie) => (cookieStr += setCookie.split('; ')[0] + '; '));
if (cookieStr.endsWith('; ')) {
cookieStr = cookieStr.substring(0, cookieStr.length - 2 || 0);
}
return cookieStr;
}
function getCookie(cookie = '', setCookie) {
if (!Array.isArray(setCookie)) setCookie = [setCookie];
if (!setCookie || setCookie.length === 0) return cookie;
return getCookieString({
...getCookieJSON(cookie),
...getCookieJSON(getSetCookieValue(setCookie)),
});
}
function createCookieJar(cookie = '') {
let _cookie;
_cookie = cookie;
return {
getCookieString: function () {
return _cookie;
},
setCookie: function (rawCookie) {
return getCookie(_cookie, rawCookie);
},
toJSON: function () {
return getCookieJSON(_cookie);
},
};
}
function createRequest({ cookieJar, getHeaders }) {
const get = (url, options) => {
var _resp_;
const resp = HTTP.get(url, {
headers: {
...getHeaders(url),
...(options && options.headers),
},
});
cookieJar && cookieJar.setCookie(resp.headers['set-cookie']);
if (!options) return resp.json();
return options.native
? resp
: (_resp_ = resp[options.responseType || 'json']) === null ||
_resp_ === void 0
? void 0
: _resp_.call(resp);
};
const post = (url, data, options) => {
var _resp_;
const resp = HTTP.post(url, JSON.stringify(data), {
headers: {
...getHeaders(url),
...(options && options.headers),
},
});
cookieJar && cookieJar.setCookie(resp.headers['set-cookie']);
if (!options) return resp.json();
return options.native
? resp
: (_resp_ = resp[options.responseType || 'json']) === null ||
_resp_ === void 0
? void 0
: _resp_.call(resp);
};
return {
get: get,
post: post,
};
}
function getPushConfig() {
const usedRange = Application.Sheets.Item('推送').UsedRange,
cells = usedRange.Columns.Cells,
columnEnd = Math.min(50, usedRange.ColumnEnd),
rowEnd = Math.min(50, usedRange.RowEnd);
const pushConfig = {};
for (let option = usedRange.Column; option <= columnEnd; option++) {
const t = {},
item = cells.Item(option);
if (!item.Text) continue;
pushConfig[item.Text] = t;
for (let kv = 1; kv <= rowEnd; kv++) {
const key = item.Offset(kv).Text;
if (!key.trim()) continue;
t[key] = valueHandle(item.Offset(kv, 1).Text.trim());
}
}
const base = pushConfig.base;
if (!base) return pushConfig;
delete pushConfig.base;
return {
...pushConfig,
...base,
};
function valueHandle(value) {
if (value === 'TRUE' || value === '是') return true;
if (value === 'FALSE' || value === '否') return false;
return value;
}
}
function email({ logger }, email, title, text) {
try {
if (!email || !email.pass || !email.from || !email.host) return;
const port = email.port || 465,
toUser = email.to || email.from;
const mailer = SMTP.login({
host: email.host,
port: port,
secure: port === 465,
username: email.from,
password: email.pass,
});
mailer.send({
from: `${title} <${email.from}>`,
to: toUser,
subject: title,
text: text.replace(/\n/g, '\r\n'),
});
logger.info(`邮件消息已发送`);
} catch (error) {
logger.error(`邮件消息发送失败`, error.message);
}
}
function sendNotify(op, data, title, text) {
const cbs = {
pushplus: pushplus,
serverChan: serverChan,
workWeixin: workWeixin,
email: email,
};
for (const [name, d] of Object.entries(data)) {
const cb = cbs[name];
if (!cb) continue;
cb(op, d, title, text);
}
}
function createApi(http) {
const yun139Url = 'https://yun.139.com';
const caiyunUrl = 'https://caiyun.feixin.10086.cn';
const mnoteUrl = 'https://mnote.caiyun.feixin.10086.cn';
return {
querySpecToken: function (account, toSourceId = '001005') {
return http.post(
`${yun139Url}/orchestration/auth-rebuild/token/v1.0/querySpecToken`,
{
toSourceId: toSourceId,
account: String(account),
commonAccountInfo: {
account: String(account),
accountType: 1,
},
},
{
headers: {
referer: 'https://yun.139.com/w/',
accept: 'application/json, text/plain, */*',
'content-type': 'application/json',
'accept-language': 'zh-CN,zh;q=0.9',
},
}
);
},
authTokenRefresh: function authTokenRefresh(token, account) {
return http.post(
`https://aas.caiyun.feixin.10086.cn/tellin/authTokenRefresh.do`,
`<?xml version="1.0" encoding="utf-8"?><root><token>${token}</token><account>${account}</account><clienttype>656</clienttype></root>`,
{
headers: {
accept: '*/*',
'content-type': 'application/json',
},
responseType: 'text',
}
);
},
getNoteAuthToken: function getNoteAuthToken(token, account) {
const resp = http.post(
`${mnoteUrl}/noteServer/api/authTokenRefresh.do`,
{
authToken: token,
userPhone: String(account),
},
{
headers: {
APP_CP: 'pc',
APP_NUMBER: String(account),
CP_VERSION: '7.7.1.20240115',
},
requestOptions: {
isReturnNativeResponse: true,
},
native: true,
}
);
const headers = resp.headers;
if (!headers.app_auth) return;
return {
app_auth: headers.app_auth,
app_number: headers.app_number,
note_token: headers.note_token,
};
},
syncNoteBook: function syncNoteBook(headers) {
return http.post(
`${mnoteUrl}/noteServer/api/syncNotebook.do `,
{
addNotebooks: [],
delNotebooks: [],
updateNotebooks: [],
},
{
headers: {
APP_CP: 'pc',
CP_VERSION: '7.7.1.20240115',
...headers,
},
}
);
},
createNote: function createNote(
noteId,
title,
account,
headers,
tags = []
) {
return http.post(
`${mnoteUrl}/noteServer/api/createNote.do`,
{
archived: 0,
attachmentdir: '',
attachmentdirid: '',
attachments: [],
contentid: '',
contents: [
{
data: '<span></span>',
noteId: noteId,
sortOrder: 0,
type: 'TEXT',
},
],
cp: '',
createtime: String(Date.now()),
description: '',
expands: {
noteType: 0,
},
landMark: [],
latlng: '',
location: '',
noteid: noteId,
remindtime: '',
remindtype: 0,
revision: '1',
system: '',
tags: tags,
title: title,
topmost: '0',
updatetime: String(Date.now()),
userphone: String(account),
version: '',
visitTime: String(Date.now()),
},
{
headers: {
APP_CP: 'pc',
APP_NUMBER: String(account),
CP_VERSION: '7.7.1.20240115',
...headers,
},
}
);
},
deleteNote: function (noteid, headers) {
return http.post(
`${mnoteUrl}/noteServer/api/moveToRecycleBin.do`,
{
noteids: [
{
noteid: noteid,
},
],
},
{
headers: {
APP_CP: 'pc',
CP_VERSION: '7.7.1.20240115',
...headers,
},
}
);
},
tyrzLogin: function tyrzLogin(ssoToken) {
return http.get(
`${caiyunUrl}/portal/auth/tyrzLogin.action?ssoToken=${ssoToken}`
);
},
signInInfo: function signInInfo() {
return http.get(`${caiyunUrl}/market/signin/page/info?client=app`);
},
getDrawInWx: function getDrawInWx() {
return http.get(`${caiyunUrl}/market/playoffic/drawInfo`);
},
drawInWx: function getWxDrawInfo() {
return http.get(`${caiyunUrl}/market/playoffic/draw`);
},
signInfoInWx: function signInfoInWx() {
return http.get(`${caiyunUrl}/market/playoffic/followSignInfo?isWx=true`);
},
getDisk: function getDisk(account, catalogID) {
return http.post(
`${yun139Url}/orchestration/personalCloud/catalog/v1.0/getDisk`,
{
commonAccountInfo: {
account: String(account),
},
catalogID: catalogID,
catalogType: -1,
sortDirection: 1,
catalogSortType: 0,
contentSortType: 0,
filterType: 1,
startNumber: 1,
endNumber: 40,
}
);
},
queryBatchList: function queryBatchList() {
return http.post(
`https://grdt.middle.yun.139.com/openapi/pDynamicInfo/queryBatchList`,
{
encodeData: 'WBvKN8KKSLovAM=',
encodeType: 2,
pageSize: 3,
dynamicType: 2,
}
);
},
pcUploadFileRequest: function (
account,
parentCatalogID,
contentSize,
contentName,
digest
) {
return http.post(
`${yun139Url}/orchestration/personalCloud/uploadAndDownload/v1.0/pcUploadFileRequest`,
{
commonAccountInfo: {
account: String(account),
},
fileCount: 1,
totalSize: contentSize,
uploadContentList: [
{
contentName: contentName,
contentSize: contentSize,
comlexFlag: 0,
digest: digest,
},
],
newCatalogName: '',
parentCatalogID: parentCatalogID,
operation: 0,
path: '',
manualRename: 2,
autoCreatePath: [],
tagID: '',
tagType: '',
seqNo: '',
}
);
},
createBatchOprTask: function (account, contentIds) {
return http.post(
`${yun139Url}/orchestration/personalCloud/batchOprTask/v1.0/createBatchOprTask`,
{
createBatchOprTaskReq: {
taskType: 2,
actionType: 201,
taskInfo: {
contentInfoList: contentIds,
catalogInfoList: [],
newCatalogID: '',
},
commonAccountInfo: {
account: account,
accountType: 1,
},
},
}
);
},
queryBatchOprTaskDetail: function (account, taskID) {
return http.post(
`${yun139Url}/orchestration/personalCloud/batchOprTask/v1.0/queryBatchOprTaskDetail`,
{
queryBatchOprTaskDetailReq: {
taskID: taskID,
commonAccountInfo: {
account: account,
accountType: 1,
},
},
}
);
},
clickTask: function clickTask(id) {
return http.get(
`${caiyunUrl}/market/signin/task/click?key=task&id=${id}`
);
},
getTaskList: function getTaskList(marketname = 'sign_in_3') {
return http.get(
`${caiyunUrl}/market/signin/task/taskList?marketname=${marketname}&clientVersion=`
);
},
receive: function receive() {
return http.get(`${caiyunUrl}/market/signin/page/receive`);
},
shake: function shake() {
return http.post(`${caiyunUrl}/market/shake-server/shake/shakeIt?flag=1`);
},
};
}
/**
* @description http 可能需要 headers 'X-Requested-With': 'com.chinamobile.mcloud'
*/ function createGardenApi(http) {
const gardenUrl = 'https://happy.mail.10086.cn/jsp/cn/garden';
return {
login: function (token, account) {
return http.get(
`${gardenUrl}/login/caiyunsso.do?token=${token}&account=${account}&targetSourceId=001208&sourceid=1014&enableShare=1`,
{
followRedirect: false,
requestOptions: {
isReturnNativeResponse: true,
},
}
);
},
checkinInfo: function () {
return http.get(`${gardenUrl}/task/checkinInfo.do`);
},
getTaskList: function () {
return http.get(`${gardenUrl}/task/taskList.do?clientType=PE`);
},
checkin: function () {
return http.get(`${gardenUrl}/task/checkin.do`);
},
clickCartoon: function (cartoonType) {
return http.get(
`${gardenUrl}/user/clickCartoon.do?cartoonType=${cartoonType}`
);
},
doTask: function (taskId) {
return http.get(`${gardenUrl}/task/doTask.do?taskId=${taskId}`);
},
givenWater: function (taskId) {
return http.get(`${gardenUrl}/task/givenWater.do?taskId=${taskId}`);
},
};
}
function request($, api, name, ...args) {
try {
const { code, message, msg, result } = api(...args);
if (code !== 0) {
$.logger.error(`${name}失败`, message || msg);
} else {
return result;
}
} catch (error) {
$.logger.error(`${name}异常`, error.message);
}
return {};
}
function getSsoTokenApi($, phone) {
try {
const specToken = $.api.querySpecToken(phone);
if (!specToken.success) {
$.logger.error('获取 ssoToken 失败', specToken.message);
return;
}
return specToken.data.token;
} catch (error) {
$.logger.error(`获取 ssoToken 异常`, error.message);
}
}
function getJwtTokenApi($, ssoToken) {
return request($, $.api.tyrzLogin, '获取 ssoToken ', ssoToken).token;
}
function signInApi($) {
return request($, $.api.signInInfo, '网盘签到');
}
function signInWxApi($) {
return request($, $.api.signInfoInWx, '微信签到');
}
function refreshToken($, phone) {
const ssoToken = getSsoTokenApi($, phone);
if (!ssoToken) return;
const jwtToken = getJwtTokenApi($, ssoToken);
return jwtToken;
}
function signIn($) {
const { todaySignIn, total, toReceive } = signInApi($) || {};
$.logger.info(`当前积分${total}${toReceive ? `,待领取${toReceive}` : ''}`);
if (todaySignIn === true) {
$.logger.info(`网盘今日已签到`);
return;
}
$.sleep(1000);
const info = signInApi($);
if (!info) return;
if (info.todaySignIn === false) {
$.logger.info(`网盘签到失败`);
return;
}
$.logger.info(`网盘签到成功`);
}
function signInWx($) {
const info = signInWxApi($);
if (!info) return;
if (info.todaySignIn === false) {
$.logger.error(`微信签到失败`);
if (info.isFollow === false) {
$.logger.info(`当前账号没有绑定微信公众号【中国移动云盘】`);
return;
}
}
$.logger.info(`微信签到成功`);
}
function wxDraw($) {
try {
const drawInfo = $.api.getDrawInWx();
if (drawInfo.code !== 0) {
$.logger.error(
`获取微信抽奖信息失败,跳过运行,${JSON.stringify(drawInfo)}`
);
return;
}
if (drawInfo.result.surplusNumber < 50) {
$.logger.info(
`剩余微信抽奖次数${drawInfo.result.surplusNumber},跳过执行`
);
return;
}
const draw = $.api.drawInWx();
if (draw.code !== 0) {
$.logger.error(`微信抽奖失败,${JSON.stringify(draw)}`);
return;
}
$.logger.info(`微信抽奖成功,获得【${draw.result.prizeName}】`);
} catch (error) {
$;
$.logger.error(`微信抽奖异常`, error.message);
}
}
function receive($) {
return request($, $.api.receive, '领取云朵');
}
function clickTask($, task) {
try {
const { code, msg } = $.api.clickTask(task);
if (code === 0) {
return true;
}
$.logger.error(`点击任务${task}失败`, msg);
} catch (error) {
$.logger.error(`点击任务${task}异常`, error.message);
}
return false;
}
function pcUploadFileRequest($, path) {
try {
const { success, message, data } = $.api.pcUploadFileRequest(
$.DATA.phone,
path,
0,
randomHex(4) + '.png',
'd41d8cd98f00b204e9800998ecf8427e'
);
if (success && data && data.uploadResult) {
return data.uploadResult.newContentIDList.map(
({ contentID }) => contentID
);
}
$.logger.error(`上传文件失败`, message);
} catch (error) {
$.logger.error(`上传文件异常`, error.message);
}
}
function deleteFiles($, ids) {
try {
const {
data: {
createBatchOprTaskRes: { taskID },
},
} = $.api.createBatchOprTask($.DATA.phone, ids);
$.api.queryBatchOprTaskDetail($.DATA.phone, taskID);
} catch (error) {
$.logger.error(`删除文件失败`, error.message);
}
}
function getParentCatalogID($) {
try {
const { resultCode, resultMsg, resultData } = $.api.queryBatchList();
if (resultCode === 200) {
var _listItem_dynamicContentInfos_;
const listItem = resultData.list[0];
if (!listItem) return '00019700101000000001';
const path =
(_listItem_dynamicContentInfos_ = listItem.dynamicContentInfos[0]) ===
null || _listItem_dynamicContentInfos_ === void 0
? void 0
: _listItem_dynamicContentInfos_.path;
if (path && path.includes('/')) return path.split('/')[0];
return path;
}
$.logger.error(`获取文件夹 id 失败`, resultMsg);
} catch (error) {
$.logger.error(`获取文件夹 id 异常`, error.message);
}
}
function getNoteAuthToken($) {
try {
return $.api.getNoteAuthToken($.DATA.authToken, $.DATA.phone);
} catch (error) {
$.logger.error('获取云笔记 Auth Token 异常', error.message);
}
}
function uploadFileDaily($) {
/** 106 上传任务 */ if (!clickTask($, 106)) {
$.logger.info(`接收任务失败,跳过上传任务`);
return;
}
const path = getParentCatalogID($);
if (!path) {
$.logger.info(`上传路径不存在,跳过上传任务`);
return;
}
const contentIDs = pcUploadFileRequest($, path);
contentIDs && deleteFiles($, contentIDs);
}
function createNoteDaily($) {
if (!$.DATA.authToken) {
$.logger.info(`未配置 authToken,跳过云笔记任务执行`);
return;
}
const headers = getNoteAuthToken($);
if (!headers) {
$.logger.info(`获取鉴权信息失败,跳过云笔记任务执行`);
return;
}
try {
const id = randomHex(32);
$.api.createNote(id, `${randomHex(3)}`, $.DATA.phone, headers);
$.sleep(2000);
$.api.deleteNote(id, headers);
} catch (error) {
$.logger.error(`创建云笔记异常`, error.message);
}
}
function _clickTask($, id, currstep) {
return currstep === 0 ? clickTask($, id) : true;
}
function dailyTask($) {
const { day } = request($, $.api.getTaskList, '获取任务列表');
if (!day) return;
const taskFuncList = {
106: uploadFileDaily,
107: createNoteDaily,
};
const doingList = [];
for (const taskItem of day) {
if (taskItem.state === 'FINISH') continue;
if (_clickTask($, taskItem.id, taskItem.currstep)) {
var _taskFuncList_taskItem_id;
(_taskFuncList_taskItem_id = taskFuncList[taskItem.id]) === null ||
_taskFuncList_taskItem_id === void 0
? void 0
: _taskFuncList_taskItem_id.call(taskFuncList, $);
doingList.push(taskItem.id);
}
}
if (doingList.length) {
const { day } = request($, $.api.getTaskList, '获取任务列表');
if (!day) return;
for (const taskItem of day) {
if (doingList.includes(taskItem.id) && taskItem.state === 'FINISH')
$.logger.info(`完成:${taskItem.name}`);
}
}
}
function monthTaskOnMail($) {
const { month } = request(
$,
$.api.getTaskList,
'获取任务列表',
'newsign_139mail'
);
if (!month) return;
const doingList = [];
for (const taskItem of month) {
if (![1008, 1009, 1010, 1013, 1014, 1016, 1017].includes(taskItem.id))
continue;
if (taskItem.state === 'FINISH') continue;
if (_clickTask($, taskItem.id, taskItem.currstep)) {
doingList.push(taskItem.id);
}
}
if (doingList.length) {
const { month } = request(
$,
$.api.getTaskList,
'获取任务列表',
'newsign_139mail'
);
if (!month) return;
for (const taskItem of month) {
if (doingList.includes(taskItem.id) && taskItem.state === 'FINISH')
$.logger.info(`完成:${taskItem.name}`);
}
}
}
function run($) {
const taskList = [
signIn,
signInWx,
wxDraw,
monthTaskOnMail,
dailyTask,
receive,
];
for (const task of taskList) {
task($);
$.sleep(1000);
}
}
function main(
index,
ASIGN_CAIYUN_PHONE,
ASIGN_CAIYUN_TOKEN,
ASIGN_CAIYUN_AUTH,
option
) {
const basicToken = ASIGN_CAIYUN_TOKEN.startsWith('Basic')
? ASIGN_CAIYUN_TOKEN
: `Basic ${ASIGN_CAIYUN_TOKEN}`;
const cookieJar = createCookieJar();
const logger = createLogger({
pushData: option && option.pushData,
});
const DATA = {
phone: ASIGN_CAIYUN_PHONE,
authToken: ASIGN_CAIYUN_AUTH,
};
logger.info(`--------------`);
logger.info(`你好:${ASIGN_CAIYUN_PHONE}`);
let jwtToken;
const headers = {
'user-agent':
'Mozilla/5.0 (Linux; Android 13; 22041216C Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/116.0.0.0 Mobile Safari/537.36 XWEB/1160065 MMWEBSDK/20231202 MMWEBID/6745 MicroMessenger/8.0.47.2560(0x28002F30) WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android',
charset: 'utf-8',
'content-type': 'application/json',
};
function getHeaders(url) {
if (getHostname(url) === 'caiyun.feixin.10086.cn') {
if (jwtToken)
return {
...headers,
cookie: cookieJar.getCookieString(),
jwttoken: jwtToken,
};
}
return {
...headers,
authorization: basicToken,
};
}
const $ = {
api: createApi(
createRequest({
cookieJar: cookieJar,
getHeaders: getHeaders,
})
),
logger: logger,
DATA: DATA,
sleep: Time.sleep,
};
jwtToken = refreshToken($, ASIGN_CAIYUN_PHONE);
if (!jwtToken) return;
return run($);
}
const columnA = ActiveSheet.Columns('A');
// 获取当前工作表的使用范围
const usedRange = ActiveSheet.UsedRange;
const len = usedRange.Row + usedRange.Rows.Count - 1,
BColumn = ActiveSheet.Columns('B'),
CColumn = ActiveSheet.Columns('C');
const pushData = [];
for (let i = 1; i <= len; i++) {
const cell = columnA.Rows(i);
if (cell.Text) {
console.log(`执行第 ${i} 行`);
main(i, cell.Text, BColumn.Rows(i).Text, CColumn.Rows(i).Text, {
pushData: pushData,
});
}
}
const pushConfig = getPushConfig();
if (pushData.length && pushConfig) {
if (!(pushConfig.onlyError && !pushData.some((el) => el.type === 'error'))) {
const msg = pushData
.map((m) => `[${m.type} ${m.date.toLocaleTimeString()}]${m.msg}`)
.join('\n');
msg &&
sendNotify(
{
logger: createLogger(),
http: {
fetch: (op) => {
op.data &&
typeof op.data !== 'string' &&
(op.body = JSON.stringify(op.data));
return HTTP.fetch(op.url, op).json();
},
},
},
pushConfig,
pushConfig.title || 'asign 运行推送',
msg
);
}
}
都看到这了,给个评分,star吧