Skip to content

Commit c1711aa

Browse files
committed
添加[懂球帝]签到脚本
1 parent 6a4eca9 commit c1711aa

File tree

3 files changed

+231
-0
lines changed

3 files changed

+231
-0
lines changed

dongqiudi/README.md

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

dongqiudi/dongqiudi.cookie.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const cookieName = '懂球帝'
2+
const cookieKey = 'chavy_cookie_dongqiudi'
3+
const chavy = init()
4+
const cookieVal = JSON.stringify({
5+
UUID: $request.headers['UUID'],
6+
Authorization: $request.headers['Authorization']
7+
})
8+
if (cookieVal && chavy.setdata(cookieVal, cookieKey)) {
9+
chavy.msg(`${cookieName}`, '获取Cookie: 成功', '')
10+
chavy.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
11+
}
12+
function init() {
13+
isSurge = () => {
14+
return undefined === this.$httpClient ? false : true
15+
}
16+
isQuanX = () => {
17+
return undefined === this.$task ? false : true
18+
}
19+
getdata = (key) => {
20+
if (isSurge()) return $persistentStore.read(key)
21+
if (isQuanX()) return $prefs.valueForKey(key)
22+
}
23+
setdata = (key, val) => {
24+
if (isSurge()) return $persistentStore.write(key, val)
25+
if (isQuanX()) return $prefs.setValueForKey(key, val)
26+
}
27+
msg = (title, subtitle, body) => {
28+
if (isSurge()) $notification.post(title, subtitle, body)
29+
if (isQuanX()) $notify(title, subtitle, body)
30+
}
31+
log = (message) => console.log(message)
32+
get = (url, cb) => {
33+
if (isSurge()) {
34+
$httpClient.get(url, cb)
35+
}
36+
if (isQuanX()) {
37+
url.method = 'GET'
38+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
39+
}
40+
}
41+
post = (url, cb) => {
42+
if (isSurge()) {
43+
$httpClient.post(url, cb)
44+
}
45+
if (isQuanX()) {
46+
url.method = 'POST'
47+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
48+
}
49+
}
50+
done = (value = {}) => {
51+
$done(value)
52+
}
53+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
54+
}
55+
chavy.done()

dongqiudi/dongqiudi.js

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
const cookieName = '懂球帝'
2+
const cookieKey = 'chavy_cookie_dongqiudi'
3+
const chavy = init()
4+
const cookieVal = JSON.parse(chavy.getdata(cookieKey))
5+
6+
sign()
7+
8+
function sign() {
9+
let url = { url: `https://api.dongqiudi.com/v3/useract/sign/tasknew/index`, headers: {} }
10+
url.headers['UUID'] = `${cookieVal.UUID}`
11+
url.headers['Authorization'] = `${cookieVal.Authorization}`
12+
url.headers['Accept-Encoding'] = `gzip, deflate, br`
13+
url.headers['Origin'] = `https://n.dongqiudi.com`
14+
url.headers['Connection'] = `keep-alive`
15+
url.headers['Accept'] = `application/json, text/plain, */*`
16+
url.headers['Referer'] = `https://n.dongqiudi.com/webapp/signIn.html`
17+
url.headers['Host'] = `api.dongqiudi.com`
18+
url.headers['User-Agent'] = `Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 NewsApp/7.3.3 NetType/NA Technology/Wifi (iPhone; iOS 13.3; Scale/2.00) dongqiudiClientApp (modelIdentifier/iPhone10,1 )`
19+
url.headers['Accept-Language'] = `zh-cn`
20+
21+
chavy.get(url, (error, response, data) => {
22+
chavy.log(`${cookieName}, data: ${data}`)
23+
let result = JSON.parse(data)
24+
const title = `${cookieName}`
25+
let subTitle = ``
26+
let detail = ``
27+
if (result.code == 0) {
28+
if (result.data.sign_gold != 0) subTitle = '签到结果: 成功'
29+
else subTitle = '签到结果: 成功 (重复签到)'
30+
detail = `连签: ${result.data.continue_sign_days}天, 金币: ${result.data.gold_num} (+${result.data.sign_gold}), 价值: ${result.data.convertible_money}元`
31+
} else {
32+
subTitle = '签到结果: 失败'
33+
detail = `编码: ${result.code}, 说明: ${result.message}`
34+
}
35+
chavy.msg(title, subTitle, detail)
36+
})
37+
chavy.done()
38+
}
39+
40+
function init() {
41+
isSurge = () => {
42+
return undefined === this.$httpClient ? false : true
43+
}
44+
isQuanX = () => {
45+
return undefined === this.$task ? false : true
46+
}
47+
getdata = (key) => {
48+
if (isSurge()) return $persistentStore.read(key)
49+
if (isQuanX()) return $prefs.valueForKey(key)
50+
}
51+
setdata = (key, val) => {
52+
if (isSurge()) return $persistentStore.write(key, val)
53+
if (isQuanX()) return $prefs.setValueForKey(key, val)
54+
}
55+
msg = (title, subtitle, body) => {
56+
if (isSurge()) $notification.post(title, subtitle, body)
57+
if (isQuanX()) $notify(title, subtitle, body)
58+
}
59+
log = (message) => console.log(message)
60+
get = (url, cb) => {
61+
if (isSurge()) {
62+
$httpClient.get(url, cb)
63+
}
64+
if (isQuanX()) {
65+
url.method = 'GET'
66+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
67+
}
68+
}
69+
post = (url, cb) => {
70+
if (isSurge()) {
71+
$httpClient.post(url, cb)
72+
}
73+
if (isQuanX()) {
74+
url.method = 'POST'
75+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
76+
}
77+
}
78+
done = (value = {}) => {
79+
$done(value)
80+
}
81+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
82+
}

0 commit comments

Comments
 (0)