Skip to content

Commit 8ceba25

Browse files
committed
添加[什么值得买]签到脚本
1 parent e10ab0b commit 8ceba25

3 files changed

Lines changed: 113 additions & 0 deletions

File tree

‎smzdm/README.md‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# 什么值得买
2+
3+
## 配置
4+
5+
```properties
6+
[MITM]
7+
*.smzdm.com
8+
9+
[Script]
10+
http-request ^https:\/\/www\.smzdm\.com\/?.? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/smzdm/smzdm.cookie.js
11+
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/smzdm/smzdm.js
12+
```
13+
14+
## 说明
15+
16+
1. 先把`*.smzdm.com`加到`[MITM]`
17+
2. 再把两条远程脚本放到`[Script]`
18+
3. 浏览器访问并登录: `(先登录! 先登录! 先登录!)`
19+
4. 打开浏览器访问: https://www.smzdm.com
20+
5. `Surge`提示: `Cookie [V2EX] 写入成功`
21+
6. 最后就可以把第 1 条脚本注释掉了
22+
23+
> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了, 但请确保在`登录成功`后再获取 cookie.
24+
25+
> 第 2 条脚本是签到脚本, 每天`00:00:10`执行一次.
26+
27+
## 常见问题
28+
29+
1. 无法写入 Cookie
30+
31+
- 检查 Surge 系统通知权限放开了没
32+
- 如果你用的是 Safari, 请尝试在浏览地址栏`手动输入网址`(不要用复制粘贴)
33+
34+
2. 写入 Cookie 成功, 但签到不成功
35+
36+
- 看看是不是在登录前就写入 Cookie 了
37+
- 如果是,请确保在登录成功后,再尝试写入 Cookie
38+
39+
3. 为什么有时成功有时失败
40+
41+
- 很正常,网络问题,哪怕你是手工签到也可能失败(凌晨签到容易拥堵就容易失败)
42+
- 暂时不考虑代码级的重试机制,但咱有配置级的(暴力美学):
43+
44+
- `Surge`配置:
45+
46+
```properties
47+
# 没有什么是一顿饭解决不了的:
48+
cron "10 0 0 * * *" script-path=xxx.js # 每天00:00:10执行一次
49+
# 如果有,那就两顿:
50+
cron "20 0 0 * * *" script-path=xxx.js # 每天00:00:20执行一次
51+
# 实在不行,三顿也能接受:
52+
cron "30 0 0 * * *" script-path=xxx.js # 每天00:00:30执行一次
53+
54+
# 再粗暴点,直接:
55+
cron "* */60 * * * *" script-path=xxx.js # 每60分执行一次
56+
```
57+
58+
- `QuanX`配置:
59+
60+
```properties
61+
[task_local]
62+
1 0 * * * xxx.js # 每天00:01执行一次
63+
2 0 * * * xxx.js # 每天00:02执行一次
64+
3 0 * * * xxx.js # 每天00:03执行一次
65+
66+
*/60 * * * * xxx.js # 每60分执行一次
67+
```
68+
69+
## 感谢
70+
71+
[@NobyDa](https://github.com/NobyDa)
72+
73+
[@lhie1](https://github.com/lhie1)
74+
75+
[@ConnersHua](https://github.com/ConnersHua)

‎smzdm/smzdm.cookie.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const cookieName = '什么值得买'
2+
const cookieKey = 'chavy_cookie_smzdm'
3+
const cookieVal = $request.headers['Cookie']
4+
5+
if (cookieVal) {
6+
let cookie = $persistentStore.write(cookieVal, cookieKey)
7+
if (cookie) {
8+
let msg = `${cookieName}`
9+
$notification.post(msg, 'Cookie写入成功', '详见日志')
10+
console.log(msg)
11+
console.log(cookieVal)
12+
}
13+
}
14+
15+
$done({})

‎smzdm/smzdm.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const cookieName = '什么值得买'
2+
const cookieKey = 'chavy_cookie_smzdm'
3+
const cookieVal = $persistentStore.read(cookieKey)
4+
5+
function sign() {
6+
let url = {
7+
url: `https://zhiyou.smzdm.com/user/checkin/jsonp_checkin?callback=jQuery112405819534189067781_1474859317229&_=1474859317231`,
8+
headers: {
9+
Cookie: cookieVal
10+
}
11+
}
12+
url.headers['Referer'] = 'http://www.smzdm.com/'
13+
url.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36'
14+
15+
$httpClient.get(url, (error, response, data) => {
16+
$notification.post(cookieName, '签到结果: 未知', '详见日志')
17+
console.log(`${cookieName}, error: ${error}, response: ${response}, data: ${data}`)
18+
})
19+
20+
$done({})
21+
}
22+
23+
sign()

0 commit comments

Comments
 (0)