Skip to content

Commit c0a3387

Browse files
committed
添加[蔚来]签到
1 parent d0b1fe3 commit c0a3387

3 files changed

Lines changed: 247 additions & 0 deletions

File tree

‎nio/README.md‎

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

‎nio/nio.cookie.js‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const cookieName = '蔚来'
2+
const signurlKey = 'signurl_nextevcar'
3+
const signheaderKey = 'signheader_nextevcar'
4+
const nextevcar = init()
5+
6+
if ($request && $request.method != 'OPTIONS') {
7+
const signurlVal = $request.url
8+
const signheaderVal = JSON.stringify($request.headers)
9+
10+
if (signurlVal) nextevcar.setdata(signurlVal, signurlKey)
11+
if (signheaderVal) nextevcar.setdata(signheaderVal, signheaderKey)
12+
nextevcar.msg(cookieName, `获取Cookie: 成功`, ``)
13+
}
14+
15+
function init() {
16+
isSurge = () => {
17+
return undefined === this.$httpClient ? false : true
18+
}
19+
isQuanX = () => {
20+
return undefined === this.$task ? false : true
21+
}
22+
getdata = (key) => {
23+
if (isSurge()) return $persistentStore.read(key)
24+
if (isQuanX()) return $prefs.valueForKey(key)
25+
}
26+
setdata = (key, val) => {
27+
if (isSurge()) return $persistentStore.write(key, val)
28+
if (isQuanX()) return $prefs.setValueForKey(key, val)
29+
}
30+
msg = (title, subtitle, body) => {
31+
if (isSurge()) $notification.post(title, subtitle, body)
32+
if (isQuanX()) $notify(title, subtitle, body)
33+
}
34+
log = (message) => console.log(message)
35+
get = (url, cb) => {
36+
if (isSurge()) {
37+
$httpClient.get(url, cb)
38+
}
39+
if (isQuanX()) {
40+
url.method = 'GET'
41+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
42+
}
43+
}
44+
post = (url, cb) => {
45+
if (isSurge()) {
46+
$httpClient.post(url, cb)
47+
}
48+
if (isQuanX()) {
49+
url.method = 'POST'
50+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
51+
}
52+
}
53+
put = (url, cb) => {
54+
if (isSurge()) {
55+
$httpClient.put(url, cb)
56+
}
57+
if (isQuanX()) {
58+
url.method = 'PUT'
59+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
60+
}
61+
}
62+
done = (value = {}) => {
63+
$done(value)
64+
}
65+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, put, done }
66+
}
67+
nextevcar.done()

‎nio/nio.js‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
const cookieName = '蔚来'
2+
const signurlKey = 'signurl_nextevcar'
3+
const signheaderKey = 'signheader_nextevcar'
4+
const nextevcar = init()
5+
const signurlVal = nextevcar.getdata(signurlKey)
6+
const signheaderVal = nextevcar.getdata(signheaderKey)
7+
8+
sign()
9+
10+
function sign() {
11+
const url = { url: signurlVal, headers: JSON.parse(signheaderVal) }
12+
nextevcar.post(url, (error, response, data) => {
13+
nextevcar.log(`${cookieName}, data: ${data}`)
14+
const title = `${cookieName}`
15+
let subTitle = ''
16+
let detail = ''
17+
const result = JSON.parse(data)
18+
if (result.result_code == "success") {
19+
subTitle = `签到结果: 成功`
20+
detail = `签到积分: ${result.data.stats.credit_amount}, 连签: ${result.data.stats.continuous_checkin_days}天`
21+
} else if (result.result_code == "credit_limit_reached") {
22+
subTitle = `签到结果: 成功 (重复签到)`
23+
} else {
24+
subTitle = `签到结果: 失败`
25+
detail = `说明: ${result.debug_msg}, 请重新获取`
26+
}
27+
nextevcar.msg(title, subTitle, detail)
28+
nextevcar.done()
29+
})
30+
}
31+
32+
function init() {
33+
isSurge = () => {
34+
return undefined === this.$httpClient ? false : true
35+
}
36+
isQuanX = () => {
37+
return undefined === this.$task ? false : true
38+
}
39+
getdata = (key) => {
40+
if (isSurge()) return $persistentStore.read(key)
41+
if (isQuanX()) return $prefs.valueForKey(key)
42+
}
43+
setdata = (key, val) => {
44+
if (isSurge()) return $persistentStore.write(key, val)
45+
if (isQuanX()) return $prefs.setValueForKey(key, val)
46+
}
47+
msg = (title, subtitle, body) => {
48+
if (isSurge()) $notification.post(title, subtitle, body)
49+
if (isQuanX()) $notify(title, subtitle, body)
50+
}
51+
log = (message) => console.log(message)
52+
get = (url, cb) => {
53+
if (isSurge()) {
54+
$httpClient.get(url, cb)
55+
}
56+
if (isQuanX()) {
57+
url.method = 'GET'
58+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
59+
}
60+
}
61+
post = (url, cb) => {
62+
if (isSurge()) {
63+
$httpClient.post(url, cb)
64+
}
65+
if (isQuanX()) {
66+
url.method = 'POST'
67+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
68+
}
69+
}
70+
put = (url, cb) => {
71+
if (isSurge()) {
72+
$httpClient.put(url, cb)
73+
}
74+
if (isQuanX()) {
75+
url.method = 'PUT'
76+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
77+
}
78+
}
79+
done = (value = {}) => {
80+
$done(value)
81+
}
82+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, put, done }
83+
}

0 commit comments

Comments
 (0)