Skip to content

Commit 91540de

Browse files
committed
HYCAN合创签到
1 parent b70df67 commit 91540de

3 files changed

Lines changed: 249 additions & 0 deletions

File tree

‎hycan/README.md‎

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# HYCAN合创
2+
3+
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
4+
5+
## 配置 (Surge)
6+
7+
```properties
8+
[MITM]
9+
wxprdapplet.gac-nio.com
10+
11+
[Script]
12+
http-request ^https:\/\/wxprdapplet\.gac-nio\.com\/community\/userSignIn\/simpleAuth\/front\/v3\.1\.3\.5\/signV2$ script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/hycan/hycan.cookie.js
13+
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/hycan/hycan.js
14+
```
15+
16+
## 配置 (QuanX)
17+
18+
```properties
19+
[MITM]
20+
wxprdapplet.gac-nio.com
21+
22+
[rewrite_local]
23+
24+
# [商店版] QuanX v1.0.6-build194 及更早版本
25+
# 不支持
26+
27+
# [TestFlight] QuanX v1.0.6-build195 及以后版本
28+
^https:\/\/wxprdapplet\.gac-nio\.com\/community\/userSignIn\/simpleAuth\/front\/v3\.1\.3\.5\/signV2$ url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/hycan/hycan.cookie.js
29+
30+
[task_local]
31+
1 0 * * * hycan.js
32+
```
33+
34+
## 说明
35+
36+
1. 先把`wxprdapplet.gac-nio.com`加到`[MITM]`
37+
2. 再配置重写规则:
38+
- Surge: 把两条远程脚本放到`[Script]`
39+
- QuanX: 把`hycan.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
40+
3. 打开 APP 然后手动签到 1 次, 系统提示: `获取Cookie: 成功`
41+
4. 最后就可以把第 1 条脚本注释掉了
42+
5. 运行一次脚本, 如果提示重复签到, 那就算成功了!
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)
97+
98+
[@Chavy](https://github.com/chavyleung)

‎hycan/hycan.cookie.js‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const cookieName = 'HYCAN合创'
2+
const signurlKey = 'signurl_hycan'
3+
const signheaderKey = 'signheader_hycan'
4+
const hycan = init()
5+
6+
if ($request && $request.method != 'OPTIONS') {
7+
const signurlVal = $request.url
8+
const signheaderVal = JSON.stringify($request.headers)
9+
10+
if (signurlVal) hycan.setdata(signurlVal, signurlKey)
11+
if (signheaderVal) hycan.setdata(signheaderVal, signheaderKey)
12+
hycan.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+
hycan.done()

‎hycan/hycan.js‎

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

0 commit comments

Comments
 (0)