Skip to content

Commit

Permalink
添加自动获取游戏奖励
Browse files Browse the repository at this point in the history
  • Loading branch information
hccluck committed Jan 26, 2022
1 parent 42fa15d commit ce22c9d
Show file tree
Hide file tree
Showing 11 changed files with 784 additions and 52 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/juejin_helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ jobs:
USER: ${{ secrets.USER }}
PASS: ${{ secrets.PASS }}
TO: ${{ secrets.TO }}
run: npm ci && node index.js "${COOKIE}" "${USER}" "${PASS}" "${TO}"
UID: ${{ secrets.UID }}
run: npm ci && node index.js "${COOKIE}" "${USER}" "${PASS}" "${TO}" "${UID}"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 定时任务脚本

掘金自动签到 签到后会获得一次免费抽奖机会,自动触发免费抽奖,自动触发沾喜气。
掘金自动签到 签到后会获得一次免费抽奖机会,自动触发免费抽奖,自动触发沾喜气,自动获取游戏奖励
执行结束发送邮件通知签到结果。

使用方法:fork 本仓库
Expand All @@ -14,6 +14,7 @@
| USER | 发送邮件的邮箱地址,该邮箱需要开启 SMTP | 否,如不想邮件提醒,则可随意填一个值 |
| PASS | 该邮箱的 SMTP 密码 | 否,如不想邮件提醒,则可随意填一个值 |
| TO | 接收邮件的邮箱 | 否,如不想邮件提醒,则可随意填一个值 |
| UID | 游戏id `控制台执行( window.__NUXT__.state.auth.user.id )获得` ||

`注意:掘金的cookie大概有一个月以上的有效期,所以需要定期更新Secret`

Expand Down
48 changes: 29 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
const fetch = require('node-fetch');
const sign_in = require('./src/signIn');
const draw = require('./src/draw');
const dipLucky = require('./src/dipLucky');
const sendMail = require('./src/sendMail');
const getPoint = require('./src/getPoint');

const { headers } = require('./src/config');
const { autoGame } = require('./src/game/autoGame');

(async () => {
// 上次分数
const yesterday_score = await getPoint();

console.log(`昨日矿石:${yesterday_score}`);

let sign_res = '';

try {
Expand All @@ -26,14 +31,17 @@ const { headers } = require('./src/config');

console.log(draw_res);

let game_res = '挖矿成功!';
try {
await autoGame();
} catch (error) {
game_res = '挖矿失败!';
}

// 当前分数
const { data } = await fetch('https://api.juejin.cn/growth_api/v1/get_cur_point', {
headers,
method: 'GET',
credentials: 'include'
}).then((res) => res.json());
const now_score = await getPoint();

console.log(`当前矿石:${data}`);
console.log(`当前矿石:${now_score}`);

let dip_res;
try {
Expand All @@ -45,17 +53,19 @@ const { headers } = require('./src/config');
console.log(dip_res);

try {
await sendMail({
from: '掘金',
subject: '定时任务',
html: `
<h1 style="text-align: center">自动签到通知</h1>
<p style="text-indent: 2em">签到结果:${sign_res}</p>
<p style="text-indent: 2em">抽奖结果:${draw_res}</p>
<p style="text-indent: 2em">沾喜气结果:${dip_res}</p>
<p style="text-indent: 2em">当前矿石:${data}</p><br/>
`
});
const html = `
<h1 style="text-align: center">自动签到通知</h1>
<p style="text-indent: 2em">沾喜气结果:${dip_res}</p>
<p style="text-indent: 2em">当前矿石:${now_score}</p>
<p style="text-indent: 2em">较昨日增长:${now_score - yesterday_score}</p>
<p style="text-indent: 2em">签到结果:${sign_res}</p>
<p style="text-indent: 2em">抽奖结果:${draw_res}</p>
<p style="text-indent: 2em">游戏结果:${game_res}</p><br/>
`;

console.log(html);

await sendMail({ from: '掘金', subject: '定时任务', html });

console.log('邮件发送成功!');
} catch (error) {
Expand Down
Loading

0 comments on commit ce22c9d

Please sign in to comment.