Skip to content

Commit 1c2d810

Browse files
committed
添加[中国移动]签到脚本
1 parent 2c40a8e commit 1c2d810

3 files changed

Lines changed: 259 additions & 0 deletions

File tree

‎10086/10086.cookie.js‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const cookieName = '中国移动'
2+
const tokenurlKey = 'chavy_tokenurl_10086'
3+
const tokenheaderKey = 'chavy_tokenheader_10086'
4+
const signurlKey = 'chavy_signurl_10086'
5+
const signheaderKey = 'chavy_signheader_10086'
6+
const chavy = init()
7+
8+
const requrl = $request.url
9+
const reqRef = $request.headers.Referer
10+
if ($request && $request.method != 'OPTIONS' && requrl.indexOf('website/taskCenter/index') >= 0 && requrl.indexOf('mobile=') >= 0) {
11+
const tokenurlVal = requrl
12+
const tokenheaderVal = JSON.stringify($request.headers)
13+
if (tokenurlVal) chavy.setdata(tokenurlVal, tokenurlKey)
14+
if (tokenheaderVal) chavy.setdata(tokenheaderVal, tokenheaderKey)
15+
title = chavy.msg(cookieName, `获取刷新链接: 成功`, ``)
16+
} else if ($request && $request.method != 'OPTIONS' && requrl.indexOf('website/taskCenter/sign') >= 0) {
17+
const signurlVal = requrl
18+
const signheaderVal = JSON.stringify($request.headers)
19+
if (signurlVal) chavy.setdata(signurlVal, signurlKey)
20+
if (signheaderVal) chavy.setdata(signheaderVal, signheaderKey)
21+
title = chavy.msg(cookieName, `获取Cookie: 成功`, ``)
22+
}
23+
24+
function init() {
25+
isSurge = () => {
26+
return undefined === this.$httpClient ? false : true
27+
}
28+
isQuanX = () => {
29+
return undefined === this.$task ? false : true
30+
}
31+
getdata = (key) => {
32+
if (isSurge()) return $persistentStore.read(key)
33+
if (isQuanX()) return $prefs.valueForKey(key)
34+
}
35+
setdata = (key, val) => {
36+
if (isSurge()) return $persistentStore.write(key, val)
37+
if (isQuanX()) return $prefs.setValueForKey(key, val)
38+
}
39+
msg = (title, subtitle, body) => {
40+
if (isSurge()) $notification.post(title, subtitle, body)
41+
if (isQuanX()) $notify(title, subtitle, body)
42+
}
43+
log = (message) => console.log(message)
44+
get = (url, cb) => {
45+
if (isSurge()) {
46+
$httpClient.get(url, cb)
47+
}
48+
if (isQuanX()) {
49+
url.method = 'GET'
50+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
51+
}
52+
}
53+
post = (url, cb) => {
54+
if (isSurge()) {
55+
$httpClient.post(url, cb)
56+
}
57+
if (isQuanX()) {
58+
url.method = 'POST'
59+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
60+
}
61+
}
62+
done = (value = {}) => {
63+
$done(value)
64+
}
65+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
66+
}
67+
chavy.done()

‎10086/10086.js‎

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
const cookieName = '中国移动'
2+
const tokenurlKey = 'chavy_tokenurl_10086'
3+
const tokenheaderKey = 'chavy_tokenheader_10086'
4+
const signurlKey = 'chavy_signurl_10086'
5+
const signheaderKey = 'chavy_signheader_10086'
6+
const chavy = init()
7+
const tokenurlVal = chavy.getdata(tokenurlKey)
8+
const tokenheaderVal = chavy.getdata(tokenheaderKey)
9+
const signurlVal = chavy.getdata(signurlKey)
10+
let signheaderVal = chavy.getdata(signheaderKey)
11+
const signinfo = {}
12+
13+
sign()
14+
15+
function loginapp(cb) {
16+
const url = { url: tokenurlVal, headers: JSON.parse(tokenheaderVal) }
17+
chavy.get(url, (error, response, data) => {
18+
const respcookie = response.headers['Set-Cookie']
19+
const signheaderObj = JSON.parse(signheaderVal)
20+
let signcookie = signheaderObj['Cookie']
21+
signcookie = signcookie.replace(/d\.sid=([^;]*)/, respcookie.match(/d\.sid=([^;]*)/)[0])
22+
signheaderObj['Cookie'] = signcookie
23+
signheaderVal = JSON.stringify(signheaderObj)
24+
cb()
25+
})
26+
}
27+
28+
function sign() {
29+
loginapp(() => {
30+
const url = { url: signurlVal, headers: JSON.parse(signheaderVal) }
31+
chavy.get(url, (error, response, data) => {
32+
chavy.log(`${cookieName}, data: ${data}`)
33+
const result = JSON.parse(data)
34+
let subTitle = ``
35+
let detail = ``
36+
if (result.rtnCode == '0') {
37+
subTitle = `签到结果: 成功`
38+
detail = `连签: ${result.object.signDays}天`
39+
} else if (result.rtnCode == '-9999' && result.object.status == '50001') {
40+
subTitle = `签到结果: 成功 (重复签到)`
41+
detail = `说明: ${result.object.message}`
42+
} else {
43+
subTitle = `签到结果: 失败`
44+
detail = `说明: 详见日志`
45+
}
46+
chavy.msg(cookieName, subTitle, detail)
47+
chavy.done()
48+
})
49+
})
50+
}
51+
52+
function init() {
53+
isSurge = () => {
54+
return undefined === this.$httpClient ? false : true
55+
}
56+
isQuanX = () => {
57+
return undefined === this.$task ? false : true
58+
}
59+
getdata = (key) => {
60+
if (isSurge()) return $persistentStore.read(key)
61+
if (isQuanX()) return $prefs.valueForKey(key)
62+
}
63+
setdata = (key, val) => {
64+
if (isSurge()) return $persistentStore.write(key, val)
65+
if (isQuanX()) return $prefs.setValueForKey(key, val)
66+
}
67+
msg = (title, subtitle, body) => {
68+
if (isSurge()) $notification.post(title, subtitle, body)
69+
if (isQuanX()) $notify(title, subtitle, body)
70+
}
71+
log = (message) => console.log(message)
72+
get = (url, cb) => {
73+
if (isSurge()) {
74+
$httpClient.get(url, cb)
75+
}
76+
if (isQuanX()) {
77+
url.method = 'GET'
78+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
79+
}
80+
}
81+
post = (url, cb) => {
82+
if (isSurge()) {
83+
$httpClient.post(url, cb)
84+
}
85+
if (isQuanX()) {
86+
url.method = 'POST'
87+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
88+
}
89+
}
90+
done = (value = {}) => {
91+
$done(value)
92+
}
93+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
94+
}

‎10086/README.md‎

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# 中国移动
2+
3+
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
4+
5+
> 注意: 中国移动是指名字为`10086`这款的 APP [点这里下载](https://apps.apple.com/cn/app/10086-%E4%B8%AD%E5%9B%BD%E7%A7%BB%E5%8A%A8%E5%87%BA%E5%93%81/id1004816017)
6+
7+
## 配置 (Surge)
8+
9+
```properties
10+
[MITM]
11+
wx.10086.cn
12+
13+
[Script]
14+
# 注意获取Cookie有两条脚本
15+
http-request ^http:\/\/wx.10086.cn\/website\/taskCenter\/index\? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.cookie.js
16+
http-request ^http:\/\/wx.10086.cn\/website\/taskCenter\/sign\? script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.cookie.js
17+
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10086/10086.js
18+
```
19+
20+
## 配置 (QuanX)
21+
22+
```properties
23+
[MITM]
24+
wx.10086.cn
25+
26+
[rewrite_local]
27+
# 注意获取Cookie有两条脚本
28+
^http:\/\/wx.10086.cn\/website\/taskCenter\/index\? url script-request-header 10086.cookie.js
29+
^http:\/\/wx.10086.cn\/website\/taskCenter\/sign\? url script-request-header 10086.cookie.js
30+
31+
[task_local]
32+
1 0 * * * 10086.js
33+
```
34+
35+
## 说明
36+
37+
1. 先把`wx.10086.cn`加到`[MITM]`
38+
2. 再配置重写规则:
39+
- Surge: 把两条远程脚本放到`[Script]`
40+
- QuanX: 把`10086.cookie.js`和`10086.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
41+
3. 打开 APP , 进入签到页面, 系统提示: `获取刷新链接: 成功`
42+
4. 然后手动签到 1 次, 系统提示: `获取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+
[@NobyDa](https://github.com/NobyDa)
95+
96+
[@lhie1](https://github.com/lhie1)
97+
98+
[@ConnersHua](https://github.com/ConnersHua)

0 commit comments

Comments
 (0)