效果展示
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_28bf00c6666cf2081615ebb0d0d5297e.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_28bf00c6666cf2081615ebb0d0d5297e.jpg)
今天逛知乎看到了一篇很有意思的文章,不需要服务器部署一个自动签到的功能,我立马就来了兴趣,赶紧在自己电脑上试试,正好我目前也在使用阿里云盘。
知乎文章:https://zhuanlan.zhihu.com/p/629476969
用到了金山云在线文档,然后把作者写的js脚本放进去,使用定时任务每天执行脚本来自动签到。由于没有smtp服务器,所以不能每天发送邮箱给我不过没关系,我只要知道了他每天签到了就行。哈哈哈
作者更新了
现在不需要smtp服务器发送邮箱了,可以用pushplus微信推送
进入金山云在线文档,新建excel表格右上角效率 ---> 高级开发 ---> javascript脚本编辑
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_e96e490e6abf71a1711ce332de89d01f.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_e96e490e6abf71a1711ce332de89d01f.jpg)
创建脚本 --- > 文件共享脚本
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_49fd9fe20ea8c09d03a8f471202ccc9f.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_49fd9fe20ea8c09d03a8f471202ccc9f.jpg)
服务授权 ---> 添加服务 --> 把这三个服务全部添加
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_27b70acab371102f08403e007a8ae3c1.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_27b70acab371102f08403e007a8ae3c1.jpg)
把以下代码复制进去吧
```javasvript
var myDate = new Date();
var data_time = myDate.toLocaleDateString()

function sleep(d){
for(var t = Date.now();Date.now() - t <= d;); } var value= "" for (let ii = 2; ii <= 20; ii++){ dyg = "A"+ii var refresh_token = Application.Range(dyg).Text if(refresh_token != ""){ // 发起网络请求-获取token let data = HTTP.post("https://auth.aliyundrive.com/v2/account/token", JSON.stringify({ "grant_type": "refresh_token", "refresh_token":refresh_token }) ) data = data.json() var access_token = data['access_token'] var phone = data["user_name"] if (access_token == undefined){ var value =value+"\n"+"单元格【"+dyg+"】内的token值错误或已过期,程序执行失败,请重新复制正确的token值"+"
"
}else{
try{
var access_token2 = 'Bearer '+access_token
// 签到
let data2 = HTTP.post("https://member.aliyundrive.com/v1/activity/sign_in_list",
JSON.stringify({"_rx-s": "mobile"}),
{headers:{"Authorization":access_token2}}
)
data2=data2.json()
var signin_count = data2['result']['signInCount']
var value =value+ "账号:"+data["user_name"]+"-签到成功, 本月累计签到"+ signin_count+"天"

}catch{
var value ="单元格【"+dyg+"】内的token签到失败"+"
"
return
}
sleep(1000)

var sflq = Application.Range("B"+ii).Text
if (sflq == "是"){
try{
// 领取奖励
let data3 = HTTP.post(
"https://member.aliyundrive.com/v1/activity/sign_in_reward?_rx-s=mobile",
JSON.stringify({"signInDay": signin_count}),
{headers:{"Authorization":access_token2}}
)
data3=data3.json()
var value = value +"本次签到获得"+data3["result"]["name"] +","+data3["result"]["description"]+"
"
}catch{
var value = value+ "账号:"+data["user_name"]+"-领取奖励失败\n"+"
"
}
}else{
value = value +" 奖励待领取"+"
"
}
}
}
}
console.log(value)
var sftz = Application.Range("E"+1).Text
if (sftz=="是"){
var token = Application.Range("E"+2).Text
// 发起网络请求
var title = "阿里云盘-签到通知"
var content = value
var url = "http://www.pushplus.plus/send?token="+token+"&title="+title+"&content="+content+"&template=html"
let resp = HTTP.get(url)
// 检查response的状态
if(resp.status!==200){
throw new Error("fetch err! status is "+resp.status())
}
console.log(resp.text())
}
```
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_2da64e6282feef9422a839e7cd44c6d9.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_2da64e6282feef9422a839e7cd44c6d9.jpg)
保存 运行脚本
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_25ea65150f9492723bef7c55c4a543dc.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_25ea65150f9492723bef7c55c4a543dc.jpg)
填写表格 在A2到A20这个单元填写你的阿里网盘refresh_token
下面我教怎么获取token
打开阿里云盘网页版---> f12打开开发者工具--->应用程序--->本地存储--->第二个网址 -->密钥-->往下翻有个token 把他复制到表格里面即可 后面的和我填的一致即可
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_0de05cd9681c41b4d6d796e1759de179.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_0de05cd9681c41b4d6d796e1759de179.jpg)
后面有个微信通知的token 我们访问这个网站https://www.pushplus.plus/
注册登录 ---> 发送消息 ---> 一对一消息
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_ac53d02e18a5576f71d61aaf4fedb5cd.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_ac53d02e18a5576f71d61aaf4fedb5cd.jpg)
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_f3a30b79cdb3385e499453983205033f.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_f3a30b79cdb3385e499453983205033f.jpg)
把表格填好运行一遍测试结果
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_bc8d1e8af89951754a41108f0e2a5d48.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_bc8d1e8af89951754a41108f0e2a5d48.jpg)
表格样式:
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_e4b36af541a53ade620300997c405374.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_e4b36af541a53ade620300997c405374.jpg)
现在我们把他加入定时任务,让他每天0点30分执行一次这个脚本进行签到
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_2fc6a7de1531cb289ab579ff901d5f40.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_2fc6a7de1531cb289ab579ff901d5f40.jpg)
[![](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_7c3f16248669956ffc326e7e3c2fda2a.jpg)](http://101.37.22.37/wp-content/uploads/2023/12/wp_editor_md_7c3f16248669956ffc326e7e3c2fda2a.jpg)
好了至此我搭好了,你们也去试试吧!!!

  • alipay_img
  • wechat_img
一朝风月,万古长空
最后更新于 2023-12-17