Skip to content

Commit 4558ce2

Browse files
authored
Merge pull request chavyleung#60 from danchaw/master
更新[海底捞]: 修正远程地址
2 parents 0398e44 + 41d00de commit 4558ce2

3 files changed

Lines changed: 206 additions & 1 deletion

File tree

‎haidilao/README.md‎

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

‎haidilao/hdl.js‎

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
const cookieName = '海底捞'
2+
const signurlKey = 'signurl_hdl'
3+
const signheaderKey = 'signheader_hdl'
4+
const signbodyKey = 'signbody_hdl'
5+
const hdl = init()
6+
7+
let isGetCookie = typeof $request !== 'undefined'
8+
9+
if (isGetCookie) {
10+
getcookie()
11+
} else {
12+
sign()
13+
}
14+
15+
function getcookie() {
16+
if ($request && $request.method == 'POST') {
17+
const signurlVal = $request.url
18+
const signheaderVal = JSON.stringify($request.headers)
19+
const signbodyVal = $request.body
20+
21+
if (signurlVal) hdl.setdata(signurlVal, signurlKey)
22+
if (signheaderVal) hdl.setdata(signheaderVal, signheaderKey)
23+
if (signbodyVal) hdl.setdata(signbodyVal, signbodyKey)
24+
hdl.msg(cookieName, `获取Cookie: 成功, 请禁用该脚本`, ``)
25+
}
26+
hdl.done()
27+
}
28+
29+
function sign() {
30+
const signurlVal = hdl.getdata(signurlKey)
31+
const signheaderVal = hdl.getdata(signheaderKey)
32+
const signbodyVal = hdl.getdata(signbodyKey)
33+
const url = { url: signurlVal, headers: JSON.parse(signheaderVal), body: signbodyVal }
34+
hdl.post(url, (error, response, data) => {
35+
hdl.log(`${cookieName}, data: ${data}`)
36+
const title = `${cookieName}`
37+
let subTitle = ''
38+
let detail = ''
39+
const result = JSON.parse(data)
40+
if (result.success == true && result.signInfoVO.todaySigned == true) {
41+
subTitle = `签到结果: 成功`
42+
detail = `签到奖励: ${result.customInfo.foodNum}火柴, 连签: ${result.signInfoVO.continueDay}天`
43+
} else if (result.success == false && result.signInfoVO.todaySigned == true) {
44+
subTitle = `签到结果: 成功 (重复签到)`
45+
detail = `连签: ${result.signInfoVO.continueDay}天`
46+
} else {
47+
subTitle = `签到结果: 失败`
48+
detail = `说明: ${result.message}, 请重新获取`
49+
}
50+
hdl.msg(title, subTitle, detail)
51+
hdl.done()
52+
})
53+
}
54+
55+
function init() {
56+
isSurge = () => {
57+
return undefined === this.$httpClient ? false : true
58+
}
59+
isQuanX = () => {
60+
return undefined === this.$task ? false : true
61+
}
62+
getdata = (key) => {
63+
if (isSurge()) return $persistentStore.read(key)
64+
if (isQuanX()) return $prefs.valueForKey(key)
65+
}
66+
setdata = (key, val) => {
67+
if (isSurge()) return $persistentStore.write(key, val)
68+
if (isQuanX()) return $prefs.setValueForKey(key, val)
69+
}
70+
msg = (title, subtitle, body) => {
71+
if (isSurge()) $notification.post(title, subtitle, body)
72+
if (isQuanX()) $notify(title, subtitle, body)
73+
}
74+
log = (message) => console.log(message)
75+
get = (url, cb) => {
76+
if (isSurge()) {
77+
$httpClient.get(url, cb)
78+
}
79+
if (isQuanX()) {
80+
url.method = 'GET'
81+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
82+
}
83+
}
84+
post = (url, cb) => {
85+
if (isSurge()) {
86+
$httpClient.post(url, cb)
87+
}
88+
if (isQuanX()) {
89+
url.method = 'POST'
90+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
91+
}
92+
}
93+
put = (url, cb) => {
94+
if (isSurge()) {
95+
$httpClient.put(url, cb)
96+
}
97+
if (isQuanX()) {
98+
url.method = 'PUT'
99+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
100+
}
101+
}
102+
done = (value = {}) => {
103+
$done(value)
104+
}
105+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, put, done }
106+
}

‎nio/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ app.nio.com
2525
# ^https:\/\/app\.nio\.com\/api\/1\/app\/daily_checkin url script-request-header nio.cookie.js
2626

2727
# [TestFlight] QuanX v1.0.6-build195 及以后版本
28-
^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+
^https:\/\/app\.nio\.com\/api\/1\/app\/daily_checkin url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/nio/nio.cookie.js
2929

3030
[task_local]
3131
1 0 * * * nio.js

0 commit comments

Comments
 (0)