Skip to content

Commit dbedf29

Browse files
committed
添加[电信营业厅]签到
1 parent 24d5209 commit dbedf29

3 files changed

Lines changed: 253 additions & 0 deletions

File tree

10000/10000.cookie.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
const cookieName = '电信营业厅'
2+
const cookieKey = 'chavy_cookie_10000'
3+
const mobileKey = 'chavy_mobile_10000'
4+
const chavy = init()
5+
if (this.$request && this.$request.headers) {
6+
const cookieVal = $request.headers['Cookie']
7+
if (cookieVal) {
8+
if (chavy.setdata(cookieVal, cookieKey)) {
9+
chavy.msg(`${cookieName}`, '获取Cookie: 成功', '')
10+
chavy.log(`[${cookieName}] 获取Cookie: 成功, cookie: ${cookieVal}`)
11+
}
12+
}
13+
}
14+
if (this.$response) {
15+
chavy.log(JSON.parse($response.body).data.userInfo.mobile)
16+
const mobileVal = JSON.parse($response.body).data.userInfo.mobile
17+
if (mobileVal) {
18+
if (chavy.setdata(mobileVal, mobileKey)) {
19+
chavy.msg(`${cookieName}`, `获取号码: 成功 (${mobileVal})`, ``)
20+
chavy.log(`[${cookieName}] 获取号码: 成功, 号码: ${mobileVal}`)
21+
}
22+
}
23+
}
24+
25+
function init() {
26+
isSurge = () => {
27+
return undefined === this.$httpClient ? false : true
28+
}
29+
isQuanX = () => {
30+
return undefined === this.$task ? false : true
31+
}
32+
getdata = (key) => {
33+
if (isSurge()) return $persistentStore.read(key)
34+
if (isQuanX()) return $prefs.valueForKey(key)
35+
}
36+
setdata = (key, val) => {
37+
if (isSurge()) return $persistentStore.write(key, val)
38+
if (isQuanX()) return $prefs.setValueForKey(key, val)
39+
}
40+
msg = (title, subtitle, body) => {
41+
if (isSurge()) $notification.post(title, subtitle, body)
42+
if (isQuanX()) $notify(title, subtitle, body)
43+
}
44+
log = (message) => console.log(message)
45+
get = (url, cb) => {
46+
if (isSurge()) {
47+
$httpClient.get(url, cb)
48+
}
49+
if (isQuanX()) {
50+
url.method = 'GET'
51+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
52+
}
53+
}
54+
post = (url, cb) => {
55+
if (isSurge()) {
56+
$httpClient.post(url, cb)
57+
}
58+
if (isQuanX()) {
59+
url.method = 'POST'
60+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
61+
}
62+
}
63+
done = (value = {}) => {
64+
$done(value)
65+
}
66+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
67+
}
68+
chavy.done()

10000/10000.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
const cookieName = '电信营业厅'
2+
const cookieKey = 'chavy_cookie_10000'
3+
const mobileKey = 'chavy_mobile_10000'
4+
const chavy = init()
5+
const cookieVal = chavy.getdata(cookieKey)
6+
const mobileVal = chavy.getdata(mobileKey)
7+
8+
sign()
9+
10+
function sign() {
11+
let url = { url: `https://wapside.189.cn:9001/api/home/sign`, headers: { Cookie: cookieVal } }
12+
url.headers['Content-Type'] = 'application/json;charset=utf-8'
13+
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;CtClient;7.6.0;iOS;13.3;iPhone XR'
14+
url.headers['Host'] = 'wapside.189.cn:9001'
15+
url.headers['Origin'] = 'https://wapside.189.cn:9001'
16+
url.headers['Referer'] = 'https://wapside.189.cn:9001/resources/dist/signInActivity.html?cmpid=jt-khd-my-zygn&ticket=0ab000281b4a8139f264620ae1d8b1ce067a6587921f90a6260dca4389a4e01a&version=7.6.0'
17+
url.body = JSON.stringify({ phone: mobileVal })
18+
chavy.post(url, (error, response, data) => {
19+
chavy.log(`${cookieName}, data: ${data}`)
20+
let result = JSON.parse(data)
21+
const title = `${cookieName}`
22+
let subTitle = ``
23+
let detail = ``
24+
if (result.data.code == 1) {
25+
subTitle = `签到结果: 成功 (${mobileVal})`
26+
detail = `获得金币${result.data.coin}, 金豆${result.data.flow}`
27+
} else if (result.data.code == 0) {
28+
subTitle = `签到结果: 重复 (${mobileVal})`
29+
detail = `说明: ${result.data.msg}`
30+
} else {
31+
subTitle = `签到结果: 失败 (${mobileVal})`
32+
detail = `说明: ${result.data.msg}`
33+
}
34+
chavy.msg(title, subTitle, detail)
35+
})
36+
chavy.done()
37+
}
38+
39+
function init() {
40+
isSurge = () => {
41+
return undefined === this.$httpClient ? false : true
42+
}
43+
isQuanX = () => {
44+
return undefined === this.$task ? false : true
45+
}
46+
getdata = (key) => {
47+
if (isSurge()) return $persistentStore.read(key)
48+
if (isQuanX()) return $prefs.valueForKey(key)
49+
}
50+
setdata = (key, val) => {
51+
if (isSurge()) return $persistentStore.write(key, val)
52+
if (isQuanX()) return $prefs.setValueForKey(key, val)
53+
}
54+
msg = (title, subtitle, body) => {
55+
if (isSurge()) $notification.post(title, subtitle, body)
56+
if (isQuanX()) $notify(title, subtitle, body)
57+
}
58+
log = (message) => console.log(message)
59+
get = (url, cb) => {
60+
if (isSurge()) {
61+
$httpClient.get(url, cb)
62+
}
63+
if (isQuanX()) {
64+
url.method = 'GET'
65+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
66+
}
67+
}
68+
post = (url, cb) => {
69+
if (isSurge()) {
70+
$httpClient.post(url, cb)
71+
}
72+
if (isQuanX()) {
73+
url.method = 'POST'
74+
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
75+
}
76+
}
77+
done = (value = {}) => {
78+
$done(value)
79+
}
80+
return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done }
81+
}

10000/README.md

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

0 commit comments

Comments
 (0)