Skip to content

Commit 86b8630

Browse files
committed
添加[去哪儿]签到脚本
1 parent c430536 commit 86b8630

5 files changed

Lines changed: 238 additions & 0 deletions

File tree

‎QuantumultX_Local_Cookie.conf‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ hostname = wapside.189.cn, *.acfun.cn, apk.tw, *.bilibili.com, api.dongqiudi.com
5555
# 195及以后版本
5656
^https:\/\/c\.m\.163\.com\/uc\/api\/sign\/v2\/commit url script-request-body chavyleung/neteasenews/neteasenews.cookie.js
5757

58+
# 去哪儿
59+
# 189及以前版本
60+
# ^https:\/\/user.qunar.com\/webapi\/member\/signNewIndex.htm url script-response-body chavyleung/qunar/qunar.cookie.js
61+
# 190及以后版本
62+
^https:\/\/user.qunar.com\/webapi\/member\/signNewIndex.htm url script-request-header chavyleung/qunar/qunar.cookie.js
63+
5864
# 人人视频
5965
# 189及以前版本
6066
# ^https:\/\/api\.rr\.tv\/user\/profile url script-response-body chavyleung/rrtv/rrtv.cookie.js

‎QuantumultX_Local_Task.conf‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
10 0 * * * chavyleung/neteasemusic/quanx/neteasemusic.js
1919
# 网易新闻
2020
10 0 * * * chavyleung/neteasenews/neteasenews.js
21+
# 去哪儿
22+
10 0 * * * chavyleung/qunar/qunar.jsnews
2123
# 人人视频
2224
10 0 * * * chavyleung/rrtv/rrtv.js
2325
# 顺丰速运

‎qunar/README.md‎

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# 去哪儿
2+
3+
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
4+
5+
## 配置 (Surge)
6+
7+
```properties
8+
[MITM]
9+
user.qunar.com
10+
11+
[Script]
12+
http-request ^https:\/\/user.qunar.com\/webapi\/member\/signNewIndex.htm script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/qunar/qunar.cookie.js
13+
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/qunar/qunar.js
14+
```
15+
16+
## 配置 (QuanX)
17+
18+
```properties
19+
[MITM]
20+
user.qunar.com
21+
22+
[rewrite_local]
23+
# 189及以前版本
24+
^https:\/\/user.qunar.com\/webapi\/member\/signNewIndex.htm url script-response-body qunar.cookie.js
25+
# 190及以后版本
26+
^https:\/\/user.qunar.com\/webapi\/member\/signNewIndex.htm url script-request-header qunar.cookie.js
27+
28+
[task_local]
29+
1 0 * * * qunar.js
30+
```
31+
32+
## 说明
33+
34+
1. 先把`user.qunar.com`加到`[MITM]`
35+
2. 再配置重写规则:
36+
- Surge: 把两条远程脚本放到`[Script]`
37+
- QuanX: 把`qunar.cookie.js`和`qunar.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
38+
3. 打开 APP 然后手动签到 1 次:
39+
4. 系统提示: `获取Cookie: 成功`
40+
5. 最后就可以把第 1 条脚本注释掉了
41+
6. 运行一次脚本, 如果提示重复签到, 那就算成功了!
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)

‎qunar/qunar.cookie.js‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const cookieName = '去哪儿'
2+
const cookieKey = 'chavy_cookie_qunar'
3+
const chavy = init()
4+
const cookieVal = JSON.stringify($request.headers)
5+
6+
if (cookieVal) {
7+
chavy.setdata(cookieVal, cookieKey)
8+
chavy.msg(`${cookieName}`, '获取Cookie: 成功', '')
9+
chavy.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
10+
} else {
11+
chavy.msg(`${cookieName}`, '获取Cookie: 失败', '说明: 未知')
12+
chavy.log(`[${cookieName}] 获取Cookie: 失败, cookie: ${cookieVal}`)
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+
done = (value = {}) => {
54+
$done(value)
55+
}
56+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
57+
}
58+
chavy.done()

‎qunar/qunar.js‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const cookieName = '去哪儿'
2+
const cookieKey = 'chavy_cookie_qunar'
3+
const chavy = init()
4+
const cookieVal = JSON.parse(chavy.getdata(cookieKey))
5+
6+
sign()
7+
8+
function sign() {
9+
let url = { url: `https://user.qunar.com/webapi/member/signNewIndex.htm`, headers: cookieVal }
10+
url.body = `channel=app&platform=ios`
11+
chavy.post(url, (error, response, data) => {
12+
chavy.log(`${cookieName}, data: ${data}`)
13+
let result = JSON.parse(data)
14+
const title = `${cookieName}`
15+
let subTitle = ``
16+
let detail = ``
17+
if (result.errcode == 200) {
18+
if (result.data.modalInfo.title) {
19+
subTitle = '签到结果: 成功'
20+
detail = `${result.data.unit}: ${result.data.total}个, 连签: ${result.data.continuous}天, 说明: ${result.data.modalInfo.title}`
21+
} else {
22+
subTitle = '签到结果: 成功 (重复签到)'
23+
detail = `${result.data.unit}: ${result.data.total}个, 连签: ${result.data.continuous}天`
24+
}
25+
} else {
26+
subTitle = '签到结果: 失败'
27+
detail = `编码: ${result.errcode}, 说明: ${result.errmsg}`
28+
}
29+
chavy.msg(title, subTitle, detail)
30+
})
31+
32+
chavy.done()
33+
}
34+
35+
function init() {
36+
isSurge = () => {
37+
return undefined === this.$httpClient ? false : true
38+
}
39+
isQuanX = () => {
40+
return undefined === this.$task ? false : true
41+
}
42+
getdata = (key) => {
43+
if (isSurge()) return $persistentStore.read(key)
44+
if (isQuanX()) return $prefs.valueForKey(key)
45+
}
46+
setdata = (key, val) => {
47+
if (isSurge()) return $persistentStore.write(key, val)
48+
if (isQuanX()) return $prefs.setValueForKey(key, val)
49+
}
50+
msg = (title, subtitle, body) => {
51+
if (isSurge()) $notification.post(title, subtitle, body)
52+
if (isQuanX()) $notify(title, subtitle, body)
53+
}
54+
log = (message) => console.log(message)
55+
get = (url, cb) => {
56+
if (isSurge()) {
57+
$httpClient.get(url, cb)
58+
}
59+
if (isQuanX()) {
60+
url.method = 'GET'
61+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
62+
}
63+
}
64+
post = (url, cb) => {
65+
if (isSurge()) {
66+
$httpClient.post(url, cb)
67+
}
68+
if (isQuanX()) {
69+
url.method = 'POST'
70+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
71+
}
72+
}
73+
done = (value = {}) => {
74+
$done(value)
75+
}
76+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
77+
}

0 commit comments

Comments
 (0)