aliyundrive sign
// ==UserScript==
// @name aliyundrive sign
// @namespace https://bbs.tampermonkey.net.cn/
// @version 2.0.0
// @description 阿里云盘app签到,首次使用先打开阿里云盘网页版,打开控制台输入 JSON.parse(localStorage.getItem('token')).refresh_token 回车,将值输入配置框
// @author tfsn
// @crontab * * once * *
// @grant GM_xmlhttpRequest
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_log
// @grant GM_notification
// @background
// ==/UserScript==
/* ==UserConfig==
必填:
refresh_token:
title: refresh_token
description: 控制台输入JSON.parse(localStorage.getItem('token')).refresh_token
==/UserConfig== */
return new Promise((resolve, reject) => {
// Your code here...
'use strict';
const refresh_token = GM_getValue('必填.refresh_token');
if (refresh_token == undefined || refresh_token.length == 0) { resolve(GM_log('签到情况:请先配置refresh_token')); return }
const tools = {
sleep: t => new Promise(res => setTimeout(res, t)), // 箭头函数体只有一句,可以省略return
net: {
change: (str, withCookie) => {
str = str.trim(); //去除文本首位\s
let method = str.match(/(.*?)\s/)[1];
let url = str.match(/\s(.*?)\s/)[1];
str = str.replace(/.*?\n/, ''); //去除第一行
let data = /\n\s*\n\s*(.*)$/m.test(str) ? str.slice(str.match(/\n\s*\n\s*(.*)$/m).index).trim() : ''; //获取请求体,没有则返回'', 用slice截取防止请求体含有\n时出错
str = str.replace(new RegExp(data), '').trim(); //去除data
str = str.replace(/^(\s*?)(\S.*)/gm, `$2`); //去除每行行首的\s
str = str.replace(/\sContent-Length:.*/im, ''); //去除Content-Length所在行,不用/^\sContent-Length:./im, 这样做会多一个空白行避免一些问题
str = withCookie ? str : str.replace(/\s*cookie:.*/im, '') //去除cookie所在行,不用/^\s*cookie.*/im, 这样做会多一个空白行
let headers = {}, h = str.match(/(\S*?):\s*(\S.*)/mg);
// GM_log(h)
h.forEach(e => {
let t = e.match(/(\S*?):\s*(.*)/);
headers[t[1]] = t[2].replace(/\s*$/, '');//去除行尾\s,避免一下总没错吧
});
//去除浏览器默认携带的请求头
if (!/origin:/i.test(str)) headers.origin = '';//脚本猫默认有一个拓展origin,这里去掉
if (!/dnt/i.test(str)) headers.dnt = '';
if (!/referer/i.test(str)) headers.referer = '';
//if (!/accept/i.test(str)) headers.accept='';
if (!/user-agent/i.test(str)) headers['user-agent'] = '';
if (!/sec-ch-ua/i.test(str)) headers['sec-ch-ua'] = '';
if (!/sec-ch-ua-mobile/i.test(str)) headers['sec-ch-ua-mobile'] = '';
if (!/sec-ch-ua-platform/i.test(str)) headers['sec-ch-ua-platform'] = '';
if (!/sec-fetch-dest/i.test(str)) headers['sec-fetch-dest'] = '';
if (!/sec-fetch-mode/i.test(str)) headers['sec-fetch-mode'] = '';
if (!/sec-fetch-site/i.test(str)) headers['sec-fetch-site'] = '';
//if (!/accept-language/i.test(str)) headers['accept-language']='';
if (!/accept-encoding/i.test(str)) headers['accept-encoding'] = '';
return { url, method, data, headers }
},
}
};
tools.net.send = (str, onload = (xhr => xhr), anonymous = false, withCookie = false) => {
let t = tools.net.change(str, withCookie);
return new Promise((resolve, reject) => {
t.anonymous = anonymous;
t.onload = (xhr) => {
resolve(onload(xhr))
};
t.onerror = _ => { GM_log('net error') };
GM_xmlhttpRequest(t)
})
};
(async _ => {
// await tools.sleep(1000 * 60 * 2);
let receiveReward = async function (day) {
await tools.net.send(`
POST https://member.aliyundrive.com/v1/activity/sign_in_reward?_rx-s=mobile HTTP/1.1
X-Canary: client=web,app=other,version=v0.1.0
x-umt: G0EBB5E6540285A993A7A01BE6B15D80A52C1C4075F002318B2
x-ua: 225!MysJ9ozWooiUJPafZpFooizX3efvlLfT7JN+SA9xjX04yw5W5ctxXcrp8LgaPjwjLtEh//xCQ0en+gk1649doB0oueN5/eG8z3DnvlaBM2lOc+iHc5vp9DW7V/sSxalS1Uhn76GmUeh+UDjoQzadD654fodCbU4KjcI4+yYTbkZW8hulQEDdDMXhfiAt+FcRcLf4b4nV/l/+f4GoQzaKD654fizpb3QdIYzQHQaVSvLjMhhQvzaKD6X4BidlbUSKjcInaoiRDl/+f4j0Qz0KDM5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6mHI7nZFP3Htvog5e7/KVgOFH4I0I98ESVS7j82/HvjgBCSX8sOVGgPoOOFCDar2SGDxz8KCiAgZry/0YwpGC50xZeQYGvJS5aaoJo=
x-request-id: f396823d-8713-4a84-bdcf-dcd7d5f198a7
x-device-id: aeb9647c62f9574d38dc15f9498c5ba9e2e9950a51dbb0d0b5fb272ebdf54c89
X-Signature: f224bc8af53e2e7a38ebac268d0b09b1610d38574309d081bce6f6729b1a0c9b1e9f53955e18a986b65766f65c2a2b69a0eafbaed8b82c9537c0acd2fa71f30601
Content-Type: application/json
Accept: application/json
User-Agent: AliApp(AYSD/4.3.1) com.alicloud.databox/28957682 Channel/36176927979800@rimet_android_4.3.1 language/zh-CN /Android Mobile/OPPO PACM00
Referer: https://aliyundrive.com/
X-Canary: client=Android,app=adrive,version=v4.3.1
Authorization: ${refresh_token_temp}
x-sign: azRr1P002xAAKLaKsNi3EHYwDSMTSLaIuIbCDvTaVXiz1yactKwFQbMC9qDNTEEfDK2KFs299bi12nLk5rHyz2S%2FYBi2mLaItpi2iL
x-mini-wua: aMgSxNDlBW6wHQBFZUiix7e9HeOoxkIQzreehBWhTzkt%2B7SdNvzB3A%2Fl5TTQtKMfR5leL3t2IgFfddInPC6ARrASF4fICSgfRc0Q%2BfA0q65Wdj59MYpDynT61PxgvlrJNHp%2F2rVTOV98U0opGm0KsiIxMHk%2Fe8TRcukqTQeZmWIHk3g%3D%3D
x-umt: VfkBQCJLPJBYpAKHvE95e6JTyeezVDMA
x-sgext: JAcFZpgpsXweCVdVJhv5IWY0VzJeNkUxUjBRJl83RTZKMEo1SjRKNEo0SjRKNEo0SjRKMko0SjJKMko1SjJKNEo0SjRKNFY0SjRWNEo0SjVKNUo0SjxKPEo8SjVKNUo3XiZXM143UzVWMVE3RTVVZgc1VjVWM1AwVjxfYFMmUSZTJl4xRTVXNVMmVSZXJlcmVyZXJlQmVyZXJlEmVCZWJlAmViZWJlYmViZWJkVgRWMDJlYmA2MANVY0RTVWNVY1
x-bx-version: 6.5.79
Content-Length: 16
Host: member.aliyundrive.com
Connection: Keep-Alive
Accept-Encoding: gzip
{"signInDay":${day}}
`, xhr => {
let t = JSON.parse(xhr.response);
GM_notification('阿里云网盘奖励领取情况:\n' + t.success + ' ' + t?.result.notice ?? '时间未到');
//M_log(t.success + ' ' + t?.result.notice ?? '时间未到');
return t.success
}, true)
};
let refresh_token_temp = await tools.net.send(`
POST https://api.aliyundrive.com/token/refresh HTTP/1.1
Host: api.aliyundrive.com
Connection: keep-alive
Content-Length: 52
sec-ch-ua: "Not_A Brand";v="99", "Microsoft Edge";v="109", "Chromium";v="109"
DNT: 1
sec-ch-ua-mobile: ?0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.78
Content-Type: application/json
Accept: application/json, text/plain, */*
x-requested-with: XMLHttpRequest
sec-ch-ua-platform: "Windows"
Origin: https://www.aliyundrive.com
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://www.aliyundrive.com/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,ja;q=0.5
{"refresh_token": "${refresh_token}"}
`, xhr => {
let t = JSON.parse(xhr.response);
if (t.refresh_token) {
GM_setValue("必填.refresh_token", t.refresh_token);
} else {
GM_log(t.code + ' ' + t.message)
}
return t.access_token
}, true);
let rewardsMsgAndSign = await tools.net.send(`
POST https://member.aliyundrive.com/v1/activity/sign_in_list HTTP/1.1
Host: member.aliyundrive.com
X-Canary: client=web,app=other,version=v0.1.0
Authorization: Bearer ${refresh_token_temp}
x-umt: defaultFY1_fyjs_not_loaded@@https://pages.aliyundrive.com/mobile-page/web/dailycheck.html@@1675776005212
x-ua: defaultFY1_fyjs_not_loaded@@https://pages.aliyundrive.com/mobile-page/web/dailycheck.html@@1675776005212
Content-Type: application/json
Origin: https://pages.aliyundrive.com
X-Requested-With: com.alicloud.databox
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: https://pages.aliyundrive.com/
{}
`, xhr => {
let t = JSON.parse(xhr.response);
let _ = '签到情况:' + (t?.success ?? (t.code + ' ' + t.message));
GM_log(_);
GM_notification('阿里云网盘自动签到:\n' + _);
return t?.result;
}, true);
let list = [];
if (rewardsMsgAndSign) {
rewardsMsgAndSign.signInLogs.forEach(element => {
list.push([element.status, element.isReward]);
});
};
if (list.length) {
for (const [i, e] of list.entries()) {
if (e[0] == 'normal' && !e[1]) {
await tools.sleep(500);
await receiveReward(i + 1);
}
}
}
})();
resolve();
});