Skip to content

Commit bf62cc5

Browse files
committed
更新[V2EX]签到脚本: 优化代码及系统通知
1 parent 94a557d commit bf62cc5

3 files changed

Lines changed: 14 additions & 34 deletions

File tree

‎v2ex/README.md‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scr
6666
*/60 * * * * xxx.js # 每60分执行一次
6767
```
6868

69-
4. 为什么百度贴吧签到没有系统通知
70-
71-
- 百度貌似用的 GBK 编码目前无法优雅地解码,所以就算提示出来吧名也是乱码的
72-
- 我有 20 个吧不想被消息轰炸
73-
- 目前考虑提示`本次成功:3, 本次失败:4, 今天共签5`这种提示形式,但代码层面受限制,还在想办法实现
74-
7569
## 感谢
7670

7771
[@NobyDa](https://github.com/NobyDa)

‎v2ex/v2ex.cookie.js‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
/**
2-
*
3-
* [MITM]
4-
* *.v2ex.com
5-
*
6-
* [Script]
7-
* http-request ^http:\/\/www\.v2ex\.com script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/v2ex/v2ex.cookie.js
8-
* cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/v2ex/v2ex.js
9-
*
10-
*/
11-
121
const cookieName = 'V2EX'
132
const cookieKey = 'chavy_cookie_v2ex'
143
const cookieVal = $request.headers['Cookie']

‎v2ex/v2ex.js‎

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
/**
2-
*
3-
* [MITM]
4-
* *.v2ex.com
5-
*
6-
* [Script]
7-
* http-request ^https://www.v2ex.com/ script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/v2ex/v2ex.cookie.js
8-
* cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/v2ex/v2ex.js
9-
*
10-
*/
11-
121
const cookieName = 'V2EX'
132
const cookieKey = 'chavy_cookie_v2ex'
143
const cookieVal = $persistentStore.read(cookieKey)
@@ -20,11 +9,13 @@ function sign() {
209
Cookie: cookieVal
2110
}
2211
}
23-
2412
$httpClient.get(url, (error, response, data) => {
2513
if (data.indexOf('每日登录奖励已领取')) {
26-
console.log(`签到跳过: ${cookieName}, 原因: 今天已经签过了`)
27-
$notification.post('签到跳过', cookieName, `原因: 今天已经签过了`)
14+
let title = `签到结果: ${cookieName}`
15+
let subTitle = `签到跳过`
16+
let detail = `今天已经签过了`
17+
console.log(`${title}, ${subTitle}, ${detail}`)
18+
$notification.post(title, subTitle, detail)
2819
} else {
2920
let regex = /<input[^>]*\/mission\/daily\/redeem\?once=(\d+)[^>]*>/g
3021
for (const code of data.matchAll(regex)) {
@@ -42,11 +33,17 @@ function signMission(code) {
4233
}
4334
$httpClient.get(url, (error, response, data) => {
4435
if (data.indexOf('每日登录奖励已领取') > 0) {
45-
console.log(`签到成功: ${cookieName}`)
46-
$notification.post('签到成功', cookieName, '')
36+
let title = `签到结果: ${cookieName}`
37+
let subTitle = `签到成功`
38+
let detail = ``
39+
console.log(`${title}, ${subTitle}, ${detail}`)
40+
$notification.post(title, subTitle, detail)
4741
} else {
42+
let title = `签到结果: ${cookieName}`
43+
let subTitle = `签到失败`
44+
let detail = `详见日志`
4845
console.log(`签到失败: ${cookieName}, error: ${error}, response: ${response}, data: ${data}`)
49-
$notification.post('签到失败', cookieName, '详见日志')
46+
$notification.post(title, subTitle, detail)
5047
}
5148
})
5249
}

0 commit comments

Comments
 (0)