Skip to content

Commit fb60fef

Browse files
committed
添加[顺丰速运]签到脚本
1 parent e90dfa2 commit fb60fef

3 files changed

Lines changed: 238 additions & 0 deletions

File tree

‎sfexpress/README.md‎

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# 顺丰速运
2+
3+
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
4+
5+
> 2020.1.11 QuanX 在`190`版本开始, 获取 Cookie 方式需要从`script-response-body`改为`script-request-header`
6+
7+
## 配置 (Surge)
8+
9+
```properties
10+
[MITM]
11+
*.weixinjia.net
12+
13+
[Script]
14+
^https:\/\/sf\-integral\-sign\-in\.weixinjia\.net\/app\/init script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/sfexpress/sfexpress.cookie.js
15+
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/sfexpress/sfexpress.js
16+
```
17+
18+
## 配置 (QuanX)
19+
20+
```properties
21+
[MITM]
22+
*.weixinjia.net
23+
24+
[rewrite_local]
25+
# 189及以前版本
26+
^https:\/\/sf\-integral\-sign\-in\.weixinjia\.net\/app\/init url script-response-body sfexpress.cookie.js
27+
# 190及以后版本
28+
^https:\/\/sf\-integral\-sign\-in\.weixinjia\.net\/app\/init url script-request-header sfexpress.cookie.js
29+
30+
[task_local]
31+
1 0 * * * sfexpress.js
32+
```
33+
34+
## 说明
35+
36+
1. 先把`*.weixinjia.net`加到`[MITM]`
37+
2. 再配置重写规则:
38+
- Surge: 把两条远程脚本放到`[Script]`
39+
- QuanX: 把`sfexpress.cookie.js`和`sfexpress.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
40+
3. 打开 APP, 访问下`我的顺丰` > `去签到` (访问下`去签到`的页面即可, 不用点`签到`)
41+
4. 系统提示: `获取Cookie: 成功` (如果不提示获取成功, 尝试杀进程再进签到页面)
42+
5. 最后就可以把第 1 条脚本注释掉了
43+
44+
> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了, 但请确保在`登录成功`后再获取 cookie.
45+
46+
> 第 2 条脚本是签到脚本, 每天`00:00:10`执行一次.
47+
48+
## 常见问题
49+
50+
1. 无法写入 Cookie
51+
52+
- 检查 Surge 系统通知权限放开了没
53+
- 如果你用的是 Safari, 请尝试在浏览地址栏`手动输入网址`(不要用复制粘贴)
54+
55+
2. 写入 Cookie 成功, 但签到不成功
56+
57+
- 看看是不是在登录前就写入 Cookie 了
58+
- 如果是,请确保在登录成功后,再尝试写入 Cookie
59+
60+
3. 为什么有时成功有时失败
61+
62+
- 很正常,网络问题,哪怕你是手工签到也可能失败(凌晨签到容易拥堵就容易失败)
63+
- 暂时不考虑代码级的重试机制,但咱有配置级的(暴力美学):
64+
65+
- `Surge`配置:
66+
67+
```properties
68+
# 没有什么是一顿饭解决不了的:
69+
cron "10 0 0 * * *" script-path=xxx.js # 每天00:00:10执行一次
70+
# 如果有,那就两顿:
71+
cron "20 0 0 * * *" script-path=xxx.js # 每天00:00:20执行一次
72+
# 实在不行,三顿也能接受:
73+
cron "30 0 0 * * *" script-path=xxx.js # 每天00:00:30执行一次
74+
75+
# 再粗暴点,直接:
76+
cron "* */60 * * * *" script-path=xxx.js # 每60分执行一次
77+
```
78+
79+
- `QuanX`配置:
80+
81+
```properties
82+
[task_local]
83+
1 0 * * * xxx.js # 每天00:01执行一次
84+
2 0 * * * xxx.js # 每天00:02执行一次
85+
3 0 * * * xxx.js # 每天00:03执行一次
86+
87+
*/60 * * * * xxx.js # 每60分执行一次
88+
```
89+
90+
## 感谢
91+
92+
[@NobyDa](https://github.com/NobyDa)
93+
94+
[@lhie1](https://github.com/lhie1)
95+
96+
[@ConnersHua](https://github.com/ConnersHua)

‎sfexpress/sfexpress.cookie.js‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const cookieName = '顺丰速运'
2+
const cookieKey = 'chavy_cookie_sfexpress'
3+
const chavy = init()
4+
const cookieVal = $request.headers['Cookie']
5+
if (cookieVal) {
6+
if (chavy.setdata(cookieVal, cookieKey)) {
7+
chavy.msg(`${cookieName}`, '获取Cookie: 成功', '')
8+
chavy.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
9+
}
10+
}
11+
12+
function init() {
13+
isSurge = () => {
14+
return undefined === this.$httpClient ? false : true
15+
}
16+
isQuanX = () => {
17+
return undefined === this.$task ? false : true
18+
}
19+
getdata = (key) => {
20+
if (isSurge()) return $persistentStore.read(key)
21+
if (isQuanX()) return $prefs.valueForKey(key)
22+
}
23+
setdata = (key, val) => {
24+
if (isSurge()) return $persistentStore.write(key, val)
25+
if (isQuanX()) return $prefs.setValueForKey(key, val)
26+
}
27+
msg = (title, subtitle, body) => {
28+
if (isSurge()) $notification.post(title, subtitle, body)
29+
if (isQuanX()) $notify(title, subtitle, body)
30+
}
31+
log = (message) => console.log(message)
32+
get = (url, cb) => {
33+
if (isSurge()) {
34+
$httpClient.get(url, cb)
35+
}
36+
if (isQuanX()) {
37+
url.method = 'GET'
38+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
39+
}
40+
}
41+
post = (url, cb) => {
42+
if (isSurge()) {
43+
$httpClient.post(url, cb)
44+
}
45+
if (isQuanX()) {
46+
url.method = 'POST'
47+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
48+
}
49+
}
50+
done = (value = {}) => {
51+
$done(value)
52+
}
53+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
54+
}
55+
chavy.done()

‎sfexpress/sfexpress.js‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
const cookieName = '顺丰速运'
2+
const cookieKey = 'chavy_cookie_sfexpress'
3+
const chavy = init()
4+
let cookieVal = chavy.getdata(cookieKey)
5+
6+
sign()
7+
8+
function sign() {
9+
chavy.log(`${cookieName}, Cookie: ${cookieVal}`)
10+
let url = { url: `https://sf-integral-sign-in.weixinjia.net/app/signin`, headers: { Cookie: cookieVal } }
11+
url.headers['Origin'] = `https://sf-integral-sign-in.weixinjia.net`
12+
url.headers['Connection'] = `keep-alive`
13+
url.headers['Content-Type'] = `application/x-www-form-urlencoded`
14+
url.headers['Accept'] = `application/json, text/plain, */*`
15+
url.headers['Host'] = `sf-integral-sign-in.weixinjia.net`
16+
url.headers['User-Agent'] = `Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 mediaCode=SFEXPRESSAPP-iOS-ML`
17+
url.headers['ontent-Length'] = `15`
18+
url.headers['Accept-Language'] = `zh-cn`
19+
url.headers['Accept-Encoding'] = `gzip, deflate, br`
20+
url.body = `date=${new Date().getFullYear()}-${new Date().getMonth() + 1}-${new Date().getDate()}`
21+
chavy.log(`${cookieName}, body: ${url.body}`)
22+
chavy.post(url, (error, response, data) => {
23+
chavy.log(`${cookieName}, data: ${data}`)
24+
const result = JSON.parse(data)
25+
const title = `${cookieName}`
26+
let subTitle = ``
27+
let detail = ``
28+
if (result.code == 0 && result.msg == 'success') {
29+
subTitle = `签到结果: 成功`
30+
} else if (result.code == -1) {
31+
if (result.msg == 'ALREADY_CHECK') {
32+
subTitle = `签到结果: 成功 (重复签到)`
33+
} else {
34+
subTitle = `签到结果: 失败`
35+
}
36+
} else {
37+
subTitle = `签到结果: 未知`
38+
detail = `说明: ${result.msg}`
39+
}
40+
chavy.msg(title, subTitle, detail)
41+
})
42+
chavy.done()
43+
}
44+
45+
function init() {
46+
isSurge = () => {
47+
return undefined === this.$httpClient ? false : true
48+
}
49+
isQuanX = () => {
50+
return undefined === this.$task ? false : true
51+
}
52+
getdata = (key) => {
53+
if (isSurge()) return $persistentStore.read(key)
54+
if (isQuanX()) return $prefs.valueForKey(key)
55+
}
56+
setdata = (key, val) => {
57+
if (isSurge()) return $persistentStore.write(key, val)
58+
if (isQuanX()) return $prefs.setValueForKey(key, val)
59+
}
60+
msg = (title, subtitle, body) => {
61+
if (isSurge()) $notification.post(title, subtitle, body)
62+
if (isQuanX()) $notify(title, subtitle, body)
63+
}
64+
log = (message) => console.log(message)
65+
get = (url, cb) => {
66+
if (isSurge()) {
67+
$httpClient.get(url, cb)
68+
}
69+
if (isQuanX()) {
70+
url.method = 'GET'
71+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
72+
}
73+
}
74+
post = (url, cb) => {
75+
if (isSurge()) {
76+
$httpClient.post(url, cb)
77+
}
78+
if (isQuanX()) {
79+
url.method = 'POST'
80+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
81+
}
82+
}
83+
done = (value = {}) => {
84+
$done(value)
85+
}
86+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
87+
}

0 commit comments

Comments
 (0)