Skip to content

Commit 07f8c80

Browse files
committed
添加[中国联通]签到
1 parent 9283028 commit 07f8c80

5 files changed

Lines changed: 331 additions & 2 deletions

File tree

‎10010/10010.cookie.js‎

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

‎10010/10010.js‎

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
const cookieName = '中国联通'
2+
const tokenurlKey = 'chavy_tokenurl_10010'
3+
const tokenheaderKey = 'chavy_tokenheader_10010'
4+
const signurlKey = 'chavy_signurl_10010'
5+
const signheaderKey = 'chavy_signheader_10010'
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 sign() {
16+
signapp()
17+
getinfo()
18+
// getdetail()
19+
check()
20+
}
21+
22+
function gettel() {
23+
const reqheaders = JSON.parse(signheaderVal)
24+
const reqreferer = reqheaders.Referer
25+
return reqreferer.match(/desmobile=(.*?)(&|$)/)[1]
26+
}
27+
28+
function loginapp(cb) {
29+
const url = { url: tokenurlVal, headers: JSON.parse(tokenheaderVal) }
30+
chavy.get(url, (error, response, data) => {
31+
const respcookie = response.headers['Set-Cookie']
32+
const signheaderObj = JSON.parse(signheaderVal)
33+
let signcookie = signheaderObj['Cookie']
34+
signcookie = signcookie.replace(/route5=([^;]*)/, respcookie.match(/route5=([^;]*)/)[0])
35+
signcookie = signcookie.replace(/JSESSIONID=([^;]*)/, respcookie.match(/JSESSIONID=([^;]*)/)[0])
36+
signheaderObj['Cookie'] = signcookie
37+
signheaderVal = JSON.stringify(signheaderObj)
38+
cb()
39+
})
40+
}
41+
42+
function signapp() {
43+
loginapp(() => {
44+
chavy.log(`${cookieName}, signapp - signheaderVal: ${signheaderVal}`)
45+
const url = { url: signurlVal, headers: JSON.parse(signheaderVal) }
46+
url.body = `className=signinIndex`
47+
chavy.post(url, (error, response, data) => (signinfo.signapp = data))
48+
})
49+
}
50+
51+
function getinfo() {
52+
const url = { url: `https://mina.10010.com/wxapplet/bind/getIndexData/alipay/alipaymini?user_id=${gettel()}` }
53+
chavy.get(url, (error, response, data) => (signinfo.info = data))
54+
}
55+
56+
function getdetail() {
57+
const url = { url: `https://mina.10010.com/wxapplet/bind/getCombospare/alipay/alipaymini?stoken=&user_id=${gettel()}` }
58+
chavy.get(url, (error, response, data) => (signinfo.detail = data))
59+
}
60+
61+
function check(checkms = 0) {
62+
if (signinfo.signapp && signinfo.info) {
63+
chavy.log(`${cookieName}, signapp: ${signinfo.signapp}`)
64+
chavy.log(`${cookieName}, info: ${signinfo.info}`)
65+
// chavy.log(`${cookieName}, detail: ${signinfo.detail}`)
66+
signinfo.signapp = JSON.parse(signinfo.signapp)
67+
signinfo.info = JSON.parse(signinfo.info)
68+
// signinfo.detail = JSON.parse(signinfo.detail)
69+
showmsg()
70+
} else {
71+
if (checkms > 5000) {
72+
chavy.log(`${cookieName}, signapp: ${signinfo.signapp}`)
73+
chavy.log(`${cookieName}, info: ${signinfo.info}`)
74+
// chavy.log(`${cookieName}, detail: ${signinfo.detail}`)
75+
chavy.msg(`${cookieName}`, `签到失败: 超时退出`, ``)
76+
chavy.done()
77+
} else {
78+
setTimeout(() => check(checkms + 100), 100)
79+
}
80+
}
81+
}
82+
83+
function showmsg() {
84+
let subTitle = ''
85+
let detail = ''
86+
let signday = ''
87+
88+
// 签到结果
89+
if (signinfo.signapp.msgCode == '0000') {
90+
subTitle = `签到结果: 成功`
91+
signday = ` (连签${signinfo.signapp.continuCount}天)`
92+
detail = `连签: ${signinfo.signapp.continuCount}天, 积分: +${signinfo.signapp.prizeCount}`
93+
} else if (signinfo.signapp.msgCode == '0008') {
94+
subTitle = `签到结果: 成功 (重复签到)`
95+
} else {
96+
subTitle = `签到结果: 失败`
97+
}
98+
99+
// 基本信息
100+
if (signinfo.info.code == '0000') {
101+
subTitle += signday
102+
detail = detail ? `${detail}\n` : ``
103+
const free = signinfo.info.dataList[0]
104+
const flow = signinfo.info.dataList[1]
105+
const voice = signinfo.info.dataList[2]
106+
detail = `话费: ${free.number}${free.unit}, 已用: ${flow.number}${flow.unit}, 剩余: ${voice.number}${voice.unit}`
107+
}
108+
109+
// 详细信息
110+
// if (signinfo.detail.code == '0000') {
111+
// }
112+
113+
chavy.msg(cookieName, subTitle, detail)
114+
chavy.done()
115+
}
116+
117+
function init() {
118+
isSurge = () => {
119+
return undefined === this.$httpClient ? false : true
120+
}
121+
isQuanX = () => {
122+
return undefined === this.$task ? false : true
123+
}
124+
getdata = (key) => {
125+
if (isSurge()) return $persistentStore.read(key)
126+
if (isQuanX()) return $prefs.valueForKey(key)
127+
}
128+
setdata = (key, val) => {
129+
if (isSurge()) return $persistentStore.write(key, val)
130+
if (isQuanX()) return $prefs.setValueForKey(key, val)
131+
}
132+
msg = (title, subtitle, body) => {
133+
if (isSurge()) $notification.post(title, subtitle, body)
134+
if (isQuanX()) $notify(title, subtitle, body)
135+
}
136+
log = (message) => console.log(message)
137+
get = (url, cb) => {
138+
if (isSurge()) {
139+
$httpClient.get(url, cb)
140+
}
141+
if (isQuanX()) {
142+
url.method = 'GET'
143+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
144+
}
145+
}
146+
post = (url, cb) => {
147+
if (isSurge()) {
148+
$httpClient.post(url, cb)
149+
}
150+
if (isQuanX()) {
151+
url.method = 'POST'
152+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
153+
}
154+
}
155+
done = (value = {}) => {
156+
$done(value)
157+
}
158+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
159+
}

‎10010/README.md‎

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

‎QuantumultX_Local_Cookie.conf‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
hostname = *.mihoyo.com, gdws.nsenz.com, credits.bz.mgtv.com, *.csdn.net, wapside.189.cn, *.acfun.cn, apk.tw, *.bilibili.com, api.dongqiudi.com, *.feng.com, www.flyertea.com, music.163.com, *.m.163.com, user.qunar.com, *.rr.tv, *.weixinjia.net, *.smzdm.com, tieba.baidu.com, *.v2ex.com, *.video.qq.com, mobwsa.ximalaya.com, *.you.163.com, *.rrys2019.com, ios.zmzapi.com
1+
hostname = act.10010.com, *.mihoyo.com, gdws.nsenz.com, credits.bz.mgtv.com, *.csdn.net, wapside.189.cn, *.acfun.cn, apk.tw, *.bilibili.com, api.dongqiudi.com, *.feng.com, www.flyertea.com, music.163.com, *.m.163.com, user.qunar.com, *.rr.tv, *.weixinjia.net, *.smzdm.com, tieba.baidu.com, *.v2ex.com, *.video.qq.com, mobwsa.ximalaya.com, *.you.163.com, *.rrys2019.com, ios.zmzapi.com
22

33
# 电信营业厅
44
# 190及以后版本
@@ -130,4 +130,7 @@ hostname = *.mihoyo.com, gdws.nsenz.com, credits.bz.mgtv.com, *.csdn.net, wapsid
130130
# 米游社
131131
^https:\/\/api-takumi.mihoyo.com\/apihub\/api\/getGameList url script-request-header chavyleung/mihoyo/mihoyo.cookie.js
132132

133+
# 中国联通
134+
^https:\/\/act.10010.com\/SigninApp\/signin\/querySigninActivity.htm url script-request-header 10010.cookie.js
135+
^https:\/\/act.10010.com\/SigninApp\/signin\/daySign.do url script-request-header 10010.cookie.js
133136

‎QuantumultX_Local_Task.conf‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@
4545
# 芒果TV
4646
2 0 * * * chavyleung/mgtv/mgtv.js
4747
# 米游社
48-
2 0 * * * chavyleung/mihoyo/mihoyo.js
48+
2 0 * * * chavyleung/mihoyo/mihoyo.js
49+
# 中国联通
50+
9 0 * * * chavyleung/10010/10010.js

0 commit comments

Comments
 (0)