Skip to content

Commit 86802f0

Browse files
committed
更新[WPS]: 不需要单独从小程序获取 Cookie, 添加自动报名脚本
1 parent ff91079 commit 86802f0

5 files changed

Lines changed: 43 additions & 16 deletions

File tree

QuantumultX_AppStore_Local_Cookie.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ https:\/\/www.maomicd.com\/plugin.php\?id=k_misign:sign&operation=qiandao url sc
131131

132132
# WPS
133133
^https:\/\/zt.wps.cn\/2018\/docer_check_in\/api\/act_list url script-request-header chavyleung/wps/wps.cookie.js
134-
^https:\/\/zt.wps.cn\/2018\/clock_in\/api\/clock_in url script-request-header chavyleung/wps/wps.cookie.js
135134

136135
#智行火车
137136
^https:\/\/m\.ctrip\.com/restapi/soa2/14593/json/attendanceDay? url script-request-body chavyleung/zxhc/zxhc.cookie.js

QuantumultX_Local_Cookie.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ https:\/\/www.maomicd.com\/plugin.php\?id=k_misign:sign&operation=qiandao url sc
127127

128128
# WPS
129129
^https:\/\/zt.wps.cn\/2018\/docer_check_in\/api\/act_list url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/wps/wps.cookie.js
130-
^https:\/\/zt.wps.cn\/2018\/clock_in\/api\/clock_in url script-request-header https://raw.githubusercontent.com/chavyleung/scripts/master/wps/wps.cookie.js
131130

132131
#智行火车
133132
^https:\/\/m\.ctrip\.com/restapi/soa2/14593/json/attendanceDay? url script-request-body https://raw.githubusercontent.com/chavyleung/scripts/master/zxhc/zxhc.cookie.js

surge.cookies.sgmodule

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Rewrite: BiliBili = type=http-request,pattern=^https:\/\/(www|live)\.bilibili\.c
1414
Rewrite: CSDN = type=http-request,pattern=^https:\/\/gw.csdn.net\/mini-app\/v2\/lucky_draw\/login\/sign_in\?,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/csdn/csdn.cookie.js
1515
Rewrite: CSDN = type=http-request,pattern=^https:\/\/passport.csdn.net\/v2\/api\/app\/login\/checkAndRefreshToken,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/csdn/csdn.cookie.js
1616
Rewrite: V2EX = type=http-request,pattern=^https:\/\/www\.v2ex\.com\/mission\/daily,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/v2ex/v2ex.cookie.js
17-
Rewrite: WPS = type=http-request,pattern=^https:\/\/zt.wps.cn\/2018\/clock_in\/api\/clock_in,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/wps/wps.cookie.js
1817
Rewrite: WPS = type=http-request,pattern=^https:\/\/zt.wps.cn\/2018\/docer_check_in\/api\/act_list,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/wps/wps.cookie.js
1918
Rewrite: 懂球帝 = type=http-request,pattern=^https:\/\/api\.dongqiudi\.com\/v2\/user\/is_login,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/dongqiudi/dongqiudi.cookie.js
2019
Rewrite: 电信营业厅 = type=http-request,pattern=^https:\/\/wapside.189.cn:9001\/api\/home\/sign,script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/10000/10000.cookie.js,requires-body=true

wps/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
> 注意 1: 获取 Cookie 的正则有变动, 但不用重取 Cookie
99
> 注意 2: 把签到时间调整为 06:00 - 13:00 之间
1010
11+
> 2020.6.11 不需要单独从小程序获取 Cookie, 添加自动报名脚本
12+
1113
## 配置 (Surge)
1214

1315
```properties
@@ -16,7 +18,6 @@ hostname = zt.wps.cn
1618

1719
[Script]
1820
http-request ^https:\/\/zt.wps.cn\/2018\/docer_check_in\/api\/act_list script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/wps/wps.cookie.js
19-
http-request ^https:\/\/zt.wps.cn\/2018\/clock_in\/api\/clock_in script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/wps/wps.cookie.js
2021
cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/wps/wps.js
2122
```
2223

@@ -28,7 +29,6 @@ hostname = 110.43.90.61, zt.wps.cn
2829

2930
[rewrite_local]
3031
^https:\/\/zt.wps.cn\/2018\/docer_check_in\/api\/act_list url script-request-header wps.cookie.js
31-
^https:\/\/zt.wps.cn\/2018\/clock_in\/api\/clock_in url script-request-header wps.cookie.js
3232

3333
[task_local]
3434
1 0 * * * wps.js
@@ -42,10 +42,9 @@ hostname = 110.43.90.61, zt.wps.cn
4242
2. 再配置重写规则:
4343
- Surge: 把两条远程脚本放到`[Script]`
4444
- QuanX: 把`wps.cookie.js``wps.js`传到`On My iPhone - Quantumult X - Scripts` (传到 iCloud 相同目录也可, 注意要打开 quanx 的 iCloud 开关)
45-
3. 打开 APP , 进入签到页面, 系统提示: `获取Cookie: 成功 (APP)` (不用手动签到)
46-
4. 打开 `我的WPS会员` 小程序 , 进入签到页面并手动签到, 系统提示: `获取Cookie: 成功 (小程序)` (手动签到)
47-
5. 最后就可以把两条获取 Cookie 的脚本注释掉了
48-
6. 运行一次脚本, 如果提示重复签到, 那就算成功了!
45+
3. 打开 APP , 进入签到页面, 系统提示: `获取会话: 成功 (签到)` (不用手动签到)
46+
4. 最后就可以把两条获取 Cookie 的脚本注释掉了
47+
5. 运行一次脚本, 如果提示重复签到, 那就算成功了!
4948

5049
> 第 1 条脚本是用来获取 cookie 的, 用浏览器访问一次获取 cookie 成功后就可以删掉或注释掉了, 但请确保在`登录成功`后再获取 cookie.
5150

wps/wps.js

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $.VAL_signwxheader = $.getdata('chavy_signwxheader_wps')
1111
await getquestion()
1212
await answerwx()
1313
await signwx()
14+
await signupwx()
1415
await getUserInfo()
1516
await invite()
1617
await getSigninfo()
@@ -31,6 +32,11 @@ function loginapp() {
3132
try {
3233
if (error) throw new Error(error)
3334
$.homeinfo = JSON.parse(data)
35+
if ($.homeinfo.result === 'ok') {
36+
const headers = JSON.parse($.VAL_signhomeheader)
37+
const [m, sid] = headers.Cookie.match(/wps_sid=(.*?)(;|,|$)/) || []
38+
$.VAL_signwxheader = JSON.stringify({ sid })
39+
}
3440
} catch (e) {
3541
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
3642
} finally {
@@ -49,7 +55,6 @@ function signapp() {
4955
url.headers['Origin'] = 'https://zt.wps.cn'
5056
url.headers['Connection'] = 'keep-alive'
5157
url.headers['Host'] = 'zt.wps.cn'
52-
url.headers['Content-Length'] = '0'
5358
url.headers['Referer'] = 'https://zt.wps.cn/static/2019/docer_check_in_ios/dist/?position=member_ios'
5459
url.headers['Accept-Language'] = 'zh-cn'
5560
url.headers['X-Requested-With'] = 'XMLHttpRequest'
@@ -120,7 +125,7 @@ function getquestion() {
120125
// 回答问题
121126
function answerquestion(optIdx) {
122127
return new Promise((resove) => {
123-
const body = JSON.stringify({ answer: optIdx })
128+
const body = `answer=${optIdx}`
124129
const url = { url: 'https://zt.wps.cn/2018/clock_in/api/answer?member=wps', body, headers: JSON.parse($.VAL_signwxheader) }
125130
$.post(url, (error, response, data) => {
126131
try {
@@ -145,8 +150,31 @@ function signwx() {
145150
const _data = JSON.parse(data)
146151
$.signwx = {
147152
_raw: _data,
148-
isSuc: _data.result === 'ok' || (_data.result === 'error' && _data.msg === '已打卡'),
153+
isSuc: _data.result === 'ok' || (_data.result === 'error' && '已打卡' === _data.msg),
149154
isRepeat: _data.result === 'error' && _data.msg === '已打卡',
155+
isSignupNeed: _data.result === 'error' && _data.msg === '前一天未报名',
156+
msg: _data.msg
157+
}
158+
} catch (e) {
159+
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
160+
} finally {
161+
resove()
162+
}
163+
})
164+
})
165+
}
166+
167+
function signupwx() {
168+
if (!$.signwx.isSignupNeed) return null
169+
return new Promise((resove) => {
170+
const url = { url: 'http://zt.wps.cn/2018/clock_in/api/sign_up', headers: JSON.parse($.VAL_signwxheader) }
171+
$.get(url, (error, response, data) => {
172+
try {
173+
if (error) throw new Error(error)
174+
const _data = JSON.parse(data)
175+
$.signupwx = {
176+
_raw: _data,
177+
isSuc: _data.result === 'ok',
150178
msg: _data.msg
151179
}
152180
} catch (e) {
@@ -209,8 +237,7 @@ function getSignreward() {
209237
// 获取用户信息
210238
function getUserInfo() {
211239
return new Promise((resove) => {
212-
const headers = { sid: JSON.parse($.VAL_signwxheader).sid }
213-
const url = { url: 'https://vip.wps.cn/userinfo', headers }
240+
const url = { url: 'https://vip.wps.cn/userinfo', headers: JSON.parse($.VAL_signwxheader) }
214241
$.get(url, (error, response, data) => {
215242
try {
216243
if (error) throw new Error(error)
@@ -247,9 +274,8 @@ function invite() {
247274
for (let sidIdx = 0; sidIdx < sids.length; sidIdx++) {
248275
inviteActs.push(
249276
new Promise((resove) => {
250-
const headers = { sid: sids[sidIdx] }
251277
const body = `invite_userid=${$.userinfo.data.userid}`
252-
const url = { url: 'http://zt.wps.cn/2018/clock_in/api/invite', body, headers }
278+
const url = { url: 'http://zt.wps.cn/2018/clock_in/api/invite', body, headers: JSON.parse($.VAL_signwxheader) }
253279
$.post(url, (error, response, data) => {
254280
try {
255281
if (error) throw new Error(error)
@@ -284,8 +310,13 @@ function showmsg() {
284310
$.subt += ', '
285311
if ($.signwx.isSuc && !$.signwx.isRepeat) $.subt += `打卡: 成功`
286312
else if ($.signwx.isSuc && $.signwx.isRepeat) $.subt += `打卡: 重复`
313+
else if (!$.signwx.isSuc && $.signwx.isSignupNeed && $.signupwx.isSuc) $.subt += `打卡: 报名成功`
314+
else if (!$.signwx.isSuc && $.signwx.isSignupNeed && !$.signupwx.isSuc) $.subt += `打卡: 报名失败`
287315
else $.subt += `打卡: 失败`
288316
$.desc.push(`打卡: ${$.signwx.msg}`)
317+
if ($.signwx.isSignupNeed) {
318+
$.desc.push(`报名: ${$.signupwx.isSuc ? '成功' : `失败! 原因: ${$.signupwx.msg}`}`)
319+
}
289320
$.desc.push(`问题: ${$.question.title}`)
290321
$.desc.push(`答案: ${$.answer.optionIdx + 1}.${$.question.options[$.answer.optionIdx]}`)
291322
}

0 commit comments

Comments
 (0)