Skip to content

Commit

Permalink
添加脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
kscript committed Sep 30, 2024
1 parent 431b7eb commit 74bdf35
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/workflows/sign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: AutoSign
on:
workflow_dispatch:
schedule:
- cron: '45 10 * * *'

jobs:
Sign:
runs-on: windows-latest
steps:
- name: Install Node.js, NPM
uses: actions/setup-node@v1
with:
node-version: 14

- name: Check out branch
uses: actions/checkout@v2
with:
ref: master

- name: Sign
env:
WANXIANG_TOKEN: ${{ secrets.WANXIANG_TOKEN }}
WANXIANG_COOKIE: ${{ secrets.WANXIANG_COOKIE }}
YIGE_COOKIE: ${{ secrets.YIGE_COOKIE }}
YIGE_TOKEN: ${{ secrets.YIGE_TOKEN }}
run: |
npm ci
npm run start
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 自动签到定时任务
当前支持的平台有:
- 通义万相
- 文心一格

## 注意事项
1. 需要先定义好相应的环境变量, 脚本才能正常运行. 添加私有环境变量的路径在: [settings/secrets/actions/new](../../settings/secrets/actions/new).
2. 私有环境变量的名称, 见 [.githu/workflows/sign.yml](./.github/workflows/sign.yml#L22), 私有环境变量的值, 需要自行从对应平台的签到接口抓包.
73 changes: 73 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const fetch = require('node-fetch')
const wanxiang = async () => {
const token = process.env.WANXIANG_TOKEN
const cookie = process.env.WANXIANG_COOKIE
if (!token || !cookie) return
console.log('通义万相 开始签到')
return fetch('https://wanxiang.aliyun.com/wanx/api/common/inspiration/dailySignReward', {
'headers': {
'accept': 'application/json, text/plain, */*',
'accept-language': 'zh-CN,zh;q=0.9',
'content-type': 'application/json',
'priority': 'u=1, i',
'sec-ch-ua': '"Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'x-platform': 'web',
'x-xsrf-token': token,
cookie
},
'referrer': 'https://tongyi.aliyun.com/wanxiang/',
'referrerPolicy': 'no-referrer-when-downgrade',
'body': '{}',
'method': 'POST',
'mode': 'cors',
'credentials': 'include'
})
.then(res => res.json())
.then(console.log)
.catch(console.log)
}

const yige = async () => {
const token = process.env.YIGE_TOKEN
const cookie = process.env.YIGE_COOKIE
if (!token || !cookie) return
console.log('文心一格 开始签到')
return fetch(`https://yige.baidu.com/api/t2p/points/task_complete?t=${+new Date}&appname=pc&ptask_type=6`, {
'headers': {
'accept': 'application/json, text/plain, */*',
'accept-language': 'zh-CN,zh;q=0.9',
'acs-token': token,
'content-type': '*/*',
'sec-ch-ua': '"Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
cookie
},
'referrer': 'https://yige.baidu.com/personal/center',
'referrerPolicy': 'strict-origin-when-cross-origin',
'body': null,
'method': 'GET',
'mode': 'cors',
'credentials': 'include'
})
.then(res => res.json())
.then(console.log)
.catch(console.log)
}

const main = async (sign) => {
return Object.keys(sign).map(key => sign[key]())
}

main({
wanxiang,
yige
})
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"bugs": {
"url": "https://github.com/kscript/sign/issues"
},
"homepage": "https://github.com/kscript/sign#readme"
"homepage": "https://github.com/kscript/sign#readme",
"dependencies": {
"node-fetch": "^2.7.0"
}
}

0 comments on commit 74bdf35

Please sign in to comment.