Skip to content

Commit bcd556e

Browse files
author
Agentlewind
committed
添加[分期乐]签到脚本
1 parent 143bd2a commit bcd556e

3 files changed

Lines changed: 232 additions & 0 deletions

File tree

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

‎fenqile/fenqile.cookie.js‎

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

‎fenqile/fenqile.js‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
const cookieName = '美团'
2+
const signurlKey = 'senku_signurl_fenqile'
3+
const signheaderKey = 'senku_signheader_fenqile'
4+
const signbodyKey = 'senku_signbody_fenqile'
5+
const senku = init()
6+
const signurlVal = senku.getdata(signurlKey)
7+
const signheaderVal = senku.getdata(signheaderKey)
8+
const signBodyVal = senku.getdata(signbodyKey)
9+
10+
sign()
11+
12+
function sign() {
13+
const url = { url: signurlVal, headers: JSON.parse(signheaderVal), body: signBodyVal }
14+
senku.post(url, (error, response, data) => {
15+
senku.log(`${cookieName}, data: ${data}`)
16+
const res = JSON.parse(data)
17+
let subTitle = ``
18+
let detail = ``
19+
if (res.data.result == 0) {
20+
subTitle = `签到结果: 成功`
21+
detail = `账户乐星总数: ${res.data.result_rows.postStar}`
22+
} else if (res.data.result == 12130020) {
23+
subTitle = `签到结果: 成功 (重复签到)`
24+
} else {
25+
subTitle = `签到结果: 失败`
26+
detail = `编码: ${res.data.result}, 说明: ${res.data.res_info}`
27+
}
28+
senku.msg(cookieName, subTitle, detail)
29+
senku.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, 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, resp.body))
69+
}
70+
}
71+
done = (value = {}) => {
72+
$done(value)
73+
}
74+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
75+
}

0 commit comments

Comments
 (0)