Skip to content

Commit df55e02

Browse files
committed
Merge branch 'master' of https://github.com/chavyleung/scripts
2 parents 5459326 + 533fd6c commit df55e02

13 files changed

Lines changed: 111 additions & 132 deletions

‎.vscode/settings.json‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
22
"editor.formatOnPaste": true,
33
"editor.formatOnSave": true,
4-
"editor.formatOnType": true
4+
"editor.formatOnType": true,
5+
"minify.minifyExistingOnSave": true,
6+
"minify.js": {
7+
"mangle": true,
8+
"output": {
9+
"ascii_only": true,
10+
"comments": true
11+
}
12+
}
513
}

‎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

‎10010/10010.cookie.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ if ($request && $request.method != 'OPTIONS' && $request.url.indexOf('querySigni
1414
const tokenheaderVal = JSON.stringify($request.headers)
1515
if (tokenurlVal) chavy.setdata(tokenurlVal, tokenurlKey)
1616
if (tokenheaderVal) chavy.setdata(tokenheaderVal, tokenheaderKey)
17-
title = chavy.msg(cookieName, `获取刷新链接: 成功`, ``)
18-
} else if ($request && $request.method != 'OPTIONS' && $request.url.indexOf('daySign.do') >= 0) {
17+
chavy.msg(cookieName, `获取刷新链接: 成功`, ``)
18+
} else if ($request && $request.method != 'OPTIONS' && $request.url.endsWith('daySign') >= 0) {
1919
const signurlVal = $request.url
2020
const signheaderVal = JSON.stringify($request.headers)
2121
if (signurlVal) chavy.setdata(signurlVal, signurlKey)
2222
if (signheaderVal) chavy.setdata(signheaderVal, signheaderKey)
23-
title = chavy.msg(cookieName, `获取Cookie: 成功 (每日签到)`, ``)
23+
chavy.msg(cookieName, `获取Cookie: 成功 (每日签到)`, ``)
2424
} else if ($request && $request.method != 'OPTIONS' && $request.url.indexOf('userLogin') >= 0) {
2525
const loginlotteryurlVal = $request.url
2626
const loginlotteryheaderVal = JSON.stringify($request.headers)
2727
if (loginlotteryurlVal) chavy.setdata(loginlotteryurlVal, loginlotteryurlKey)
2828
if (loginlotteryheaderVal) chavy.setdata(loginlotteryheaderVal, loginlotteryheaderKey)
29-
title = chavy.msg(cookieName, `获取Cookie: 成功 (登录抽奖)`, ``)
29+
chavy.msg(cookieName, `获取Cookie: 成功 (登录抽奖)`, ``)
3030
} else if ($request && $request.method != 'OPTIONS' && $request.url.indexOf('findActivityInfo') >= 0) {
3131
const findlotteryurlVal = $request.url
3232
const findlotteryheaderVal = JSON.stringify($request.headers)
3333
if (findlotteryurlVal) chavy.setdata(findlotteryurlVal, findlotteryurlKey)
3434
if (findlotteryheaderVal) chavy.setdata(findlotteryheaderVal, findlotteryheaderKey)
35-
title = chavy.msg(cookieName, `获取Cookie: 成功 (抽奖次数)`, ``)
35+
chavy.msg(cookieName, `获取Cookie: 成功 (抽奖次数)`, ``)
3636
}
3737

3838
function init() {

‎10010/10010.js‎

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ function loginapp() {
4242
const url = { url: VAL_loginurl, headers: JSON.parse(VAL_loginheader) }
4343
chavy.post(url, (error, response, data) => {
4444
try {
45-
updateSignAppCookies(response.headers['Set-Cookie'])
4645
resolve()
4746
} catch (e) {
4847
chavy.msg(cookieName, `登录结果: 失败`, `说明: ${e}`)
@@ -54,35 +53,10 @@ function loginapp() {
5453
})
5554
}
5655

57-
function updateSignAppCookies(respcookie) {
58-
if (VAL_signheader) {
59-
const OBJ_signheader = JSON.parse(VAL_signheader)
60-
let signcookie = OBJ_signheader['Cookie']
61-
signcookie = signcookie.replace(/route5=([^;]*)/, respcookie.match(/route5=([^;]*)/)[0])
62-
signcookie = signcookie.replace(/JSESSIONID=([^;]*)/, respcookie.match(/JSESSIONID=([^;]*)/)[0])
63-
OBJ_signheader['Cookie'] = signcookie
64-
VAL_signheader = JSON.stringify(OBJ_signheader)
65-
} else {
66-
chavy.log(`⚠ ${cookieName} updateSignAppCookies: 请先获取 Cookies`)
67-
}
68-
}
69-
70-
function updateLotteryAppCookies(respcookie) {
71-
if (VAL_lotteryheader) {
72-
const OBJ_lotteryheader = JSON.parse(VAL_lotteryheader)
73-
let lotterycookie = OBJ_lotteryheader['Cookie']
74-
lotterycookie = lotterycookie.replace(/route5=([^;]*)/, respcookie.match(/route5=([^;]*)/)[0])
75-
lotterycookie = lotterycookie.replace(/JSESSIONID=([^;]*)/, respcookie.match(/JSESSIONID=([^;]*)/)[0])
76-
OBJ_lotteryheader['Cookie'] = lotterycookie
77-
VAL_lotteryheader = JSON.stringify(OBJ_lotteryheader)
78-
} else {
79-
chavy.log(`⚠ ${cookieName} updatelotteryAppCookies: 请先获取 Cookies`)
80-
}
81-
}
82-
8356
function signapp() {
8457
return new Promise((resolve, reject) => {
85-
const url = { url: VAL_signurl, body: '{}', headers: JSON.parse(VAL_signheader) }
58+
if (VAL_signurl.endsWith('.do')) VAL_signurl = VAL_signurl.replace('.do', '')
59+
const url = { url: 'https://act.10010.com/SigninApp/signin/daySign', headers: JSON.parse(VAL_signheader) }
8660
chavy.post(url, (error, response, data) => {
8761
try {
8862
signinfo.signapp = JSON.parse(data)
@@ -105,7 +79,6 @@ function loginlottery() {
10579
const encryptmobileMatch = data.match(/encryptmobile=([^('|")]*)/)
10680
if (encryptmobileMatch) {
10781
signinfo.encryptmobile = encryptmobileMatch[1]
108-
chavy.log(`❌ ${cookieName} loginlottery - encryptmobile: ${signinfo.encryptmobile}`)
10982
} else {
11083
chavy.msg(cookieName, `获取抽奖令牌: 失败`, `说明: ${e}`)
11184
chavy.log(`❌ ${cookieName} loginlottery - 获取抽奖令牌失败: ${e}`)
@@ -124,14 +97,11 @@ function loginlottery() {
12497

12598
function findlottery() {
12699
return new Promise((resolve, reject) => {
127-
chavy.log(`❌ ${cookieName} findlottery - OLD - VAL_findlotteryurl: ${VAL_findlotteryurl}}`)
128100
VAL_findlotteryurl = VAL_findlotteryurl.replace(/encryptmobile=[^(&|$)]*/, `encryptmobile=${signinfo.encryptmobile}`)
129101
VAL_findlotteryurl = VAL_findlotteryurl.replace(/mobile=[^(&|$)]*/, `mobile=${signinfo.encryptmobile}`)
130-
chavy.log(`❌ ${cookieName} findlottery - NEW - VAL_findlotteryurl: ${VAL_findlotteryurl}}`)
131102
const url = { url: VAL_findlotteryurl, headers: JSON.parse(VAL_findlotteryheader) }
132103
chavy.get(url, (error, response, data) => {
133104
try {
134-
chavy.log(`❌ ${cookieName} findlottery - response: ${JSON.stringify(response)}`)
135105
signinfo.findlottery = JSON.parse(data)
136106
resolve()
137107
} catch (e) {
@@ -150,7 +120,6 @@ function lottery() {
150120
url.headers['Referer'] = `https://m.client.10010.com/dailylottery/static/doubleball/firstpage?encryptmobile=${signinfo.encryptmobile}`
151121
chavy.post(url, (error, response, data) => {
152122
try {
153-
chavy.log(`❌ ${cookieName} lottery - response: ${JSON.stringify(response)}`)
154123
signinfo.lotterylist = signinfo.lotterylist ? signinfo.lotterylist : []
155124
signinfo.lotterylist.push(JSON.parse(data))
156125
resolve()
@@ -194,44 +163,41 @@ function getinfo() {
194163
function showmsg() {
195164
let subTitle = ''
196165
let detail = ''
197-
let signday = ''
198166

199167
// 签到结果
200-
if (signinfo.signapp.msgCode == '0000') {
168+
if (signinfo.signapp.signinMedal) {
201169
subTitle = `签到: 成功`
202-
signday = `; 连签: ${signinfo.signapp.continuCount}天`
203-
detail = `连签: ${signinfo.signapp.continuCount}天, 积分: +${signinfo.signapp.prizeCount}`
204-
} else if (signinfo.signapp.msgCode == '0008') {
170+
detail = `积分: +${signinfo.signapp.prizeCount}, 成长值: +${signinfo.signapp.growthV}, 鲜花: +${signinfo.signapp.flowerCount}`
171+
} else if (JSON.stringify(signinfo.signapp) == '{}') {
205172
subTitle = `签到: 重复`
206173
} else {
207174
subTitle = `签到: 失败`
175+
chavy.log(`❌ ${cookieName} signapp - response: ${JSON.stringify(signinfo.signapp)}`)
208176
}
209177

210178
if (signinfo.info.code == '0000') {
211179
// 基本信息
212-
subTitle += signday
213180
detail = detail ? `${detail}\n` : ``
214181
const free = signinfo.info.dataList[0]
215182
const flow = signinfo.info.dataList[1]
216183
const voice = signinfo.info.dataList[2]
217184
detail = `话费: ${free.number}${free.unit}, 已用: ${flow.number}${flow.unit}, 剩余: ${voice.number}${voice.unit}`
185+
} else {
186+
chavy.log(`❌ ${cookieName} signapp - response: ${JSON.stringify(signinfo.info)}`)
218187
}
219188

220189
if (signinfo.findlottery && signinfo.findlottery.acFrequency && signinfo.lotterylist) {
221190
subTitle += `; 抽奖: ${signinfo.findlottery.acFrequency.usableAcFreq}次`
222-
detail += '\n查看抽奖详情\n'
191+
detail += '\n查看详情\n'
223192

224193
for (let i = 0; i < signinfo.findlottery.acFrequency.usableAcFreq; i++) {
225-
detail += `\n抽奖 (${i}): ${signinfo.lotterylist[i].RspMsg}`
194+
detail += `\n抽奖 (${i + 1}): ${signinfo.lotterylist[i].RspMsg}`
226195
}
196+
} else {
197+
chavy.log(`❌ ${cookieName} signapp - response: ${JSON.stringify(signinfo.findlottery)}`)
227198
}
228199

229-
// 详细信息
230-
// if (signinfo.detail.code == '0000') {
231-
// }
232-
233200
chavy.msg(cookieName, subTitle, detail)
234-
chavy.done()
235201
}
236202

237203
function init() {

‎10010/README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
99
> 2020.3.12 增加每日抽奖 (需要进抽奖页面获取 Cookie) (进抽奖页会弹两个获取 Cookie 成功的消息) (签到 Cookie 不用重新获取) (增加了 rewrite 和 mitm), 注意看操作步骤说明
1010
11+
> 2020.5.6 修复签到报错问题
12+
1113
## 配置 (Surge)
1214

1315
```properties
@@ -17,7 +19,7 @@ hostname = act.10010.com, m.client.10010.com
1719
[Script]
1820
# 注意获取Cookie有两条脚本
1921
http-request ^https:\/\/act.10010.com\/SigninApp\/signin\/querySigninActivity.htm script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.cookie.js
20-
http-request ^https:\/\/act.10010.com\/SigninApp(.*?)\/signin\/daySign.do script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.cookie.js
22+
http-request ^https:\/\/act.10010.com\/SigninApp(.*?)\/signin\/daySign script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.cookie.js
2123
http-request ^https:\/\/m.client.10010.com\/dailylottery\/static\/(textdl\/userLogin|active\/findActivityInfo) script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.cookie.js
2224
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10010/10010.js
2325
```
@@ -31,7 +33,7 @@ hostname = act.10010.com, m.client.10010.com
3133
[rewrite_local]
3234
# 注意获取Cookie有两条脚本
3335
^https:\/\/act.10010.com\/SigninApp\/signin\/querySigninActivity.htm url script-request-header 10010.cookie.js
34-
^https:\/\/act.10010.com\/SigninApp(.*?)\/signin\/daySign.do url script-request-header 10010.cookie.js
36+
^https:\/\/act.10010.com\/SigninApp(.*?)\/signin\/daySign url script-request-header 10010.cookie.js
3537
^https:\/\/m.client.10010.com\/dailylottery\/static\/(textdl\/userLogin|active\/findActivityInfo) url script-request-header 10010.cookie.js
3638

3739
[task_local]

0 commit comments

Comments
 (0)