Skip to content

Commit 73802ca

Browse files
committed
添加[加油广东]签到脚本
1 parent 0f55f41 commit 73802ca

3 files changed

Lines changed: 222 additions & 0 deletions

File tree

‎gdoil/README.md‎

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

‎gdoil/gdoil.cookie.js‎

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

‎gdoil/gdoil.js‎

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

0 commit comments

Comments
 (0)