Skip to content

Commit 987d8c5

Browse files
committed
更新[中国电信]: 修改报错问题
1 parent 4d52e0b commit 987d8c5

3 files changed

Lines changed: 64 additions & 65 deletions

File tree

‎10000/10000.cookie.js‎

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
const cookieName = '电信营业厅'
2-
const cookieKey = 'chavy_cookie_10000'
3-
const mobileKey = 'chavy_mobile_10000'
2+
const KEY_signheader = 'chavy_signheader_10000'
3+
const KEY_signbody = 'chavy_signbody_10000'
4+
const KEY_mobile = 'chavy_mobile_10000'
45
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-
}
6+
if (this.$request && this.$request.headers && this.$request.body) {
7+
const VAL_signheader = JSON.stringify($request.headers)
8+
const VAL_signbody = this.$request.body
9+
if (VAL_signheader) chavy.setdata(VAL_signheader, KEY_signheader)
10+
if (VAL_signbody) chavy.setdata(VAL_signbody, KEY_signbody)
11+
chavy.msg(cookieName, `获取Cookie: 成功`, ``)
2312
}
2413

2514
function init() {

‎10000/10000.js‎

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,57 @@
1-
const cookieName = '电信营业厅'
2-
const cookieKey = 'chavy_cookie_10000'
3-
const mobileKey = 'chavy_mobile_10000'
41
const chavy = init()
5-
const cookieVal = chavy.getdata(cookieKey)
6-
const mobileVal = chavy.getdata(mobileKey)
2+
const cookieName = '电信营业厅'
3+
const KEY_signheader = 'chavy_signheader_10000'
4+
const KEY_signbody = 'chavy_signbody_10000'
5+
const KEY_mobile = 'chavy_mobile_10000'
76

8-
sign()
7+
const signinfo = {}
8+
const VAL_signheader = chavy.getdata(KEY_signheader)
9+
const VAL_signbody = chavy.getdata(KEY_signbody)
10+
const VAL_mobileVal = chavy.getdata(KEY_mobile)
911

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-
})
12+
;(sign = async () => {
13+
chavy.log(`🔔 ${cookieName}`)
14+
await signapp()
15+
showmsg()
3616
chavy.done()
17+
})().catch((e) => chavy.log(`❌ ${cookieName} 签到失败: ${e}`), chavy.done())
18+
19+
function signapp() {
20+
return new Promise((resolve, reject) => {
21+
let url = { url: `https://wapside.189.cn:9001/api/home/sign`, body: VAL_signbody, headers: JSON.parse(VAL_signheader) }
22+
url.headers['Content-Type'] = 'application/json;charset=utf-8'
23+
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'
24+
url.headers['Host'] = 'wapside.189.cn:9001'
25+
url.headers['Origin'] = 'https://wapside.189.cn:9001'
26+
url.headers['Referer'] = 'https://wapside.189.cn:9001/resources/dist/signInActivity.html?cmpid=jt-khd-my-zygn&ticket=0ab000281b4a8139f264620ae1d8b1ce067a6587921f90a6260dca4389a4e01a&version=7.6.0'
27+
chavy.post(url, (error, response, data) => {
28+
try {
29+
signinfo.signapp = JSON.parse(data)
30+
resolve()
31+
} catch (e) {
32+
chavy.msg(cookieName, `签到结果: 失败`, `说明: ${e}`)
33+
chavy.log(`❌ ${cookieName} signapp - 签到失败: ${e}`)
34+
chavy.log(`❌ ${cookieName} signapp - response: ${JSON.stringify(response)}`)
35+
resolve()
36+
}
37+
})
38+
})
39+
}
40+
41+
function showmsg() {
42+
let subTitle = ``
43+
let detail = ``
44+
if (signinfo.signapp.data.code == 1) {
45+
subTitle = `签到结果: 成功`
46+
detail = `获得金币${signinfo.signapp.data.coin}, 金豆${signinfo.signapp.data.flow}`
47+
} else if (signinfo.signapp.data.code == 0) {
48+
subTitle = `签到结果: 重复`
49+
detail = `说明: ${signinfo.signapp.data.msg}`
50+
} else {
51+
subTitle = `签到结果: 失败`
52+
detail = `说明: ${signinfo.signapp.data.msg}`
53+
}
54+
chavy.msg(cookieName, subTitle, detail)
3755
}
3856

3957
function init() {
@@ -62,7 +80,7 @@ function init() {
6280
}
6381
if (isQuanX()) {
6482
url.method = 'GET'
65-
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
83+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
6684
}
6785
}
6886
post = (url, cb) => {
@@ -71,7 +89,7 @@ function init() {
7189
}
7290
if (isQuanX()) {
7391
url.method = 'POST'
74-
$task.fetch(url).then((resp) => cb(null, {}, resp.body))
92+
$task.fetch(url).then((resp) => cb(null, resp, resp.body))
7593
}
7694
}
7795
done = (value = {}) => {

‎10000/README.md‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# 电信营业厅
22

3-
> 代码已同时兼容 Surge & QuanX, 使用同一份签到脚本即可
4-
5-
> 不需要手动编辑脚本 (获取 Cookie 和手机号码都由脚本自动完成)
6-
7-
> 需要`两条`重写脚本, 且两条脚本`都是不同的` (请完整复制! 请完整复制! 请完整复制!)
8-
9-
> Surge 与 QuanX 的 `MITM` 不一样! 不一样! 不一样!
3+
> 2020.5.6 更新签到脚本 (正则和 rewrite 类型都有变化)
104
115
## 配置 (Surge)
126

@@ -15,8 +9,7 @@
159
wapside.189.cn:9001
1610

1711
[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
12+
http-request ^https:\/\/wapside.189.cn:9001\/api\/home\/sign script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10000/10000.cookie.js, requires-body=true
2013
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10000/10000.js
2114
```
2215

@@ -28,8 +21,7 @@ wapside.189.cn
2821

2922
[rewrite_local]
3023
# 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
24+
^https:\/\/wapside.189.cn:9001\/api\/home\/sign url script-request-body 10000.cookie.js
3325

3426
[task_local]
3527
1 0 * * * 10000.js

0 commit comments

Comments
 (0)