Skip to content

Commit 5a03586

Browse files
committed
添加[掌上飞车]签到
1 parent c203f59 commit 5a03586

2 files changed

Lines changed: 249 additions & 0 deletions

File tree

‎zsfc/README.md‎

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

‎zsfc/zsfc.js‎

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
Regex: ^https:\/\/mwegame\.qq\.com\/ams\/sign\/doSign\/month
3+
Host: mwegame.qq.com
4+
*/
5+
var appName = '掌上飞车'
6+
var speed = init()
7+
var URL = speed.getdata("UrlFC")
8+
var KEY = speed.getdata("CookieFC")
9+
10+
let isGetCookie = typeof $request !== 'undefined'
11+
12+
if (isGetCookie) {
13+
getcookie()
14+
} else {
15+
sign()
16+
}
17+
18+
function getcookie() {
19+
var url = $request.url;
20+
if (url) {
21+
var UrlKeyFC = "UrlFC";
22+
var UrlValueFC = url;
23+
if (speed.getdata(UrlKeyFC) != (undefined || null)) {
24+
if (speed.getdata(UrlKeyFC) != UrlValueFC) {
25+
var url = speed.setdata(UrlValueFC, UrlKeyFC);
26+
if (!url) {
27+
speed.msg("更新" + appName + "Url失败‼️", "", "");
28+
} else {
29+
speed.msg("更新" + appName + "Url成功🎉", "", "");
30+
}
31+
} else {
32+
speed.msg(appName + "Url未变化❗️", "", "");
33+
}
34+
} else {
35+
var url = speed.setdata(UrlValueFC, UrlKeyFC);
36+
if (!url) {
37+
speed.msg("首次写入" + appName + "Url失败‼️", "", "");
38+
} else {
39+
speed.msg("首次写入" + appName + "Url成功🎉", "", "");
40+
}
41+
}
42+
} else {
43+
speed.msg("写入" + appName + "Url失败‼️", "", "配置错误, 无法读取URL, ");
44+
}
45+
if ($request.headers) {
46+
var CookieKeyFC = "CookieFC";
47+
var CookieValueFC = JSON.stringify($request.headers);
48+
if (speed.getdata(CookieKeyFC) != (undefined || null)) {
49+
if (speed.getdata(CookieKeyFC) != CookieValueFC) {
50+
var cookie = speed.setdata(CookieValueFC, CookieKeyFC);
51+
if (!cookie) {
52+
speed.msg("更新" + appName + "Cookie失败‼️", "", "");
53+
} else {
54+
speed.msg("更新" + appName + "Cookie成功🎉", "", "");
55+
}
56+
} else {
57+
speed.msg(appName + "Cookie未变化❗️", "", "");
58+
}
59+
} else {
60+
var cookie = speed.setdata(CookieValueFC, CookieKeyFC);
61+
if (!cookie) {
62+
speed.msg("首次写入" + appName + "Cookie失败‼️", "", "");
63+
} else {
64+
speed.msg("首次写入" + appName + "Cookie成功🎉", "", "");
65+
}
66+
}
67+
} else {
68+
speed.msg("写入" + appName + "Cookie失败‼️", "", "配置错误, 无法读取请求头, ");
69+
}
70+
speed.done()
71+
}
72+
73+
function sign() {
74+
const url = { url: URL, headers: JSON.parse(KEY) }
75+
speed.get(url, (error, response, data) => {
76+
speed.log(`${appName}, data: ${data}`)
77+
const title = `${appName}`
78+
let subTitle = ''
79+
let detail = ''
80+
const obj = JSON.parse(data)
81+
if (obj.status == 1 && obj.data == 1) {
82+
subTitle = `签到结果: 成功`
83+
} else if (obj.status == 11 && obj.data == false) {
84+
subTitle = `签到结果: 成功(重复)`
85+
detail = `说明: ${obj.message}`
86+
} else {
87+
subTitle = `签到结果: 失败`
88+
detail = `说明: ${obj.message}`
89+
}
90+
speed.msg(title, subTitle, detail)
91+
speed.done()
92+
})
93+
}
94+
95+
function init() {
96+
isSurge = () => {
97+
return undefined === this.$httpClient ? false : true
98+
}
99+
isQuanX = () => {
100+
return undefined === this.$task ? false : true
101+
}
102+
getdata = (key) => {
103+
if (isSurge()) return $persistentStore.read(key)
104+
if (isQuanX()) return $prefs.valueForKey(key)
105+
}
106+
setdata = (key, val) => {
107+
if (isSurge()) return $persistentStore.write(key, val)
108+
if (isQuanX()) return $prefs.setValueForKey(key, val)
109+
}
110+
msg = (title, subtitle, body) => {
111+
if (isSurge()) $notification.post(title, subtitle, body)
112+
if (isQuanX()) $notify(title, subtitle, body)
113+
}
114+
log = (message) => console.log(message)
115+
get = (url, cb) => {
116+
if (isSurge()) {
117+
$httpClient.get(url, cb)
118+
}
119+
if (isQuanX()) {
120+
url.method = 'GET'
121+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
122+
}
123+
}
124+
post = (url, cb) => {
125+
if (isSurge()) {
126+
$httpClient.post(url, cb)
127+
}
128+
if (isQuanX()) {
129+
url.method = 'POST'
130+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
131+
}
132+
}
133+
put = (url, cb) => {
134+
if (isSurge()) {
135+
$httpClient.put(url, cb)
136+
}
137+
if (isQuanX()) {
138+
url.method = 'PUT'
139+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
140+
}
141+
}
142+
done = (value = {}) => {
143+
$done(value)
144+
}
145+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, put, done }
146+
}

0 commit comments

Comments
 (0)