Skip to content

Commit 5b1e3d4

Browse files
committed
添加[V2EX]签到脚本 - 不完美!不完美!不完美!
1 parent fa58dbf commit 5b1e3d4

3 files changed

Lines changed: 124 additions & 0 deletions

File tree

‎smzdm/quanx/README.md‎

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

‎smzdm/quanx/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 = $prefs.setValueForKey(cookieVal, cookieKey)
7+
if (cookie) {
8+
let msg = `${cookieName}`
9+
$notify(msg, 'Cookie写入成功', '详见日志')
10+
console.log(msg)
11+
console.log(cookieVal)
12+
}
13+
}
14+
15+
$done({})

‎smzdm/quanx/smzdm.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const cookieName = '什么值得买'
2+
const cookieKey = 'chavy_cookie_smzdm'
3+
const cookieVal = $prefs.valueForKey(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+
$task.fetch(url).then((response) => {
16+
let data = response.body
17+
$notify(cookieName, '签到结果: 未知', '详见日志')
18+
console.log(`${cookieName} data: ${data}`)
19+
})
20+
}
21+
22+
sign()

0 commit comments

Comments
 (0)