Skip to content

Commit 7ee9520

Browse files
committed
更新[wps]: 修复 APP 首签提示失败问题 (实际已签)
1 parent 86802f0 commit 7ee9520

3 files changed

Lines changed: 21 additions & 25 deletions

File tree

chavy.box.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function getSystemApps() {
151151
{
152152
id: 'WPS',
153153
name: 'WPS',
154-
keys: ['chavy_signhomeurl_wps', 'chavy_signhomeheader_wps', 'chavy_signwxurl_wps', 'chavy_signwxheader_wps'],
154+
keys: ['chavy_signhomeurl_wps', 'chavy_signhomeheader_wps'],
155155
author: '@chavyleung',
156156
repo: 'https://github.com/chavyleung/scripts/tree/master/wps',
157157
icon: 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/a0/15/bc/a015bcec-e853-cdb3-a97b-573c15771265/AppIcon-0-1x_U007emarketing-0-7-0-0-0-0-85-220.png/492x0w.png'
@@ -625,4 +625,4 @@ function printJson() {
625625
}
626626

627627
// prettier-ignore
628-
function Env(t){this.name=t,this.logs=[],this.isSurge=(()=>"undefined"!=typeof $httpClient),this.isQuanX=(()=>"undefined"!=typeof $task),this.log=((...t)=>{this.logs=[...this.logs,...t],t?console.log(t.join("\n")):console.log(this.logs.join("\n"))}),this.msg=((t=this.name,s="",i="")=>{this.isSurge()&&$notification.post(t,s,i),this.isQuanX()&&$notify(t,s,i),this.log("==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="),t&&this.log(t),s&&this.log(s),i&&this.log(i)}),this.getdata=(t=>this.isSurge()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):void 0),this.setdata=((t,s)=>this.isSurge()?$persistentStore.write(t,s):this.isQuanX()?$prefs.setValueForKey(t,s):void 0),this.get=((t,s)=>this.send(t,"GET",s)),this.wait=((t,s=t)=>i=>setTimeout(()=>i(),Math.floor(Math.random()*(s-t+1)+t))),this.post=((t,s)=>this.send(t,"POST",s)),this.send=((t,s,i)=>{if(this.isSurge()){const e="POST"==s?$httpClient.post:$httpClient.get;e(t,(t,s,e)=>{s&&(s.body=e,s.statusCode=s.status),i(t,s,e)})}this.isQuanX()&&(t.method=s,$task.fetch(t).then(t=>{t.status=t.statusCode,i(null,t,t.body)},t=>i(t.error,t,t)))}),this.done=((t={})=>$done(t))}
628+
function Env(t){this.name=t,this.logs=[],this.isSurge=(()=>"undefined"!=typeof $httpClient),this.isQuanX=(()=>"undefined"!=typeof $task),this.log=((...t)=>{this.logs=[...this.logs,...t],t?console.log(t.join("\n")):console.log(this.logs.join("\n"))}),this.msg=((t=this.name,s="",i="")=>{this.isSurge()&&$notification.post(t,s,i),this.isQuanX()&&$notify(t,s,i);const e=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t&&e.push(t),s&&e.push(s),i&&e.push(i),console.log(e.join("\n"))}),this.getdata=(t=>this.isSurge()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):void 0),this.setdata=((t,s)=>this.isSurge()?$persistentStore.write(t,s):this.isQuanX()?$prefs.setValueForKey(t,s):void 0),this.get=((t,s)=>this.send(t,"GET",s)),this.wait=((t,s=t)=>i=>setTimeout(()=>i(),Math.floor(Math.random()*(s-t+1)+t))),this.post=((t,s)=>this.send(t,"POST",s)),this.send=((t,s,i)=>{if(this.isSurge()){const e="POST"==s?$httpClient.post:$httpClient.get;e(t,(t,s,e)=>{s&&(s.body=e,s.statusCode=s.status),i(t,s,e)})}this.isQuanX()&&(t.method=s,$task.fetch(t).then(t=>{t.status=t.statusCode,i(null,t,t.body)},t=>i(t.error,t,t)))}),this.done=((t={})=>$done(t))}

wps/wps.cookie.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@ const $ = new Env('WPS')
44
$.log('', `🔔 ${$.name}, 获取会话: 开始!`, '')
55
const VAL_url = $request.url
66
const VAL_headers = JSON.stringify($request.headers)
7-
$.log('', `❌ ${$.name}`, `url: ${$request.url}`, `headers: ${JSON.stringify($request.headers)}`, '')
8-
9-
if (VAL_url && VAL_headers && /act_list/.test(VAL_url)) {
10-
$.setdata(VAL_url, 'chavy_signhomeurl_wps')
11-
$.setdata(VAL_headers, 'chavy_signhomeheader_wps')
12-
$.subt = '获取会话: 成功 (签到)!'
13-
} else if (VAL_url && VAL_headers && /clock_in/.test(VAL_url)) {
14-
$.setdata(VAL_url, 'chavy_signwxurl_wps')
15-
$.setdata(VAL_headers, 'chavy_signwxheader_wps')
16-
$.subt = '获取会话: 成功 (打卡)!'
17-
}
7+
$.log('', `❕ ${$.name}`, `url: ${$request.url}`, `headers: ${JSON.stringify($request.headers)}`, '')
8+
$.setdata(VAL_url, 'chavy_signhomeurl_wps')
9+
$.setdata(VAL_headers, 'chavy_signhomeheader_wps')
10+
$.subt = '获取会话: 成功!'
1811
})()
1912
.catch((e) => {
2013
$.subt = '获取会话: 失败!'

wps/wps.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
const $ = new Env('WPS')
22
$.VAL_signhomeurl = $.getdata('chavy_signhomeurl_wps')
33
$.VAL_signhomeheader = $.getdata('chavy_signhomeheader_wps')
4-
$.VAL_signwxurl = $.getdata('chavy_signwxurl_wps')
5-
$.VAL_signwxheader = $.getdata('chavy_signwxheader_wps')
64

75
!(async () => {
86
$.log('', `🔔 ${$.name}, 开始!`, '')
@@ -34,8 +32,8 @@ function loginapp() {
3432
$.homeinfo = JSON.parse(data)
3533
if ($.homeinfo.result === 'ok') {
3634
const headers = JSON.parse($.VAL_signhomeheader)
37-
const [m, sid] = headers.Cookie.match(/wps_sid=(.*?)(;|,|$)/) || []
38-
$.VAL_signwxheader = JSON.stringify({ sid })
35+
const [, sid] = /wps_sid=(.*?)(;|,|$)/.exec(headers.Cookie)
36+
$.sid = sid
3937
}
4038
} catch (e) {
4139
$.log(`❗️ ${$.name}, 执行失败!`, ` error = ${error || e}`, `response = ${JSON.stringify(response)}`, `data = ${data}`, '')
@@ -108,7 +106,7 @@ async function answerwx() {
108106
// 获取问题
109107
function getquestion() {
110108
return new Promise((resove) => {
111-
const url = { url: 'https://zt.wps.cn/2018/clock_in/api/get_question?award=wps', headers: JSON.parse($.VAL_signwxheader) }
109+
const url = { url: 'https://zt.wps.cn/2018/clock_in/api/get_question?award=wps', headers: { sid: $.sid } }
112110
$.get(url, (error, response, data) => {
113111
try {
114112
if (error) throw new Error(error)
@@ -126,7 +124,7 @@ function getquestion() {
126124
function answerquestion(optIdx) {
127125
return new Promise((resove) => {
128126
const body = `answer=${optIdx}`
129-
const url = { url: 'https://zt.wps.cn/2018/clock_in/api/answer?member=wps', body, headers: JSON.parse($.VAL_signwxheader) }
127+
const url = { url: 'https://zt.wps.cn/2018/clock_in/api/answer?member=wps', body, headers: { sid: $.sid } }
130128
$.post(url, (error, response, data) => {
131129
try {
132130
if (error) throw new Error(error)
@@ -143,7 +141,7 @@ function answerquestion(optIdx) {
143141

144142
function signwx() {
145143
return new Promise((resove) => {
146-
const url = { url: 'https://zt.wps.cn/2018/clock_in/api/clock_in?award=wps', headers: JSON.parse($.VAL_signwxheader) }
144+
const url = { url: 'https://zt.wps.cn/2018/clock_in/api/clock_in?award=wps', headers: { sid: $.sid } }
147145
$.get(url, (error, response, data) => {
148146
try {
149147
if (error) throw new Error(error)
@@ -167,7 +165,7 @@ function signwx() {
167165
function signupwx() {
168166
if (!$.signwx.isSignupNeed) return null
169167
return new Promise((resove) => {
170-
const url = { url: 'http://zt.wps.cn/2018/clock_in/api/sign_up', headers: JSON.parse($.VAL_signwxheader) }
168+
const url = { url: 'http://zt.wps.cn/2018/clock_in/api/sign_up', headers: { sid: $.sid } }
171169
$.get(url, (error, response, data) => {
172170
try {
173171
if (error) throw new Error(error)
@@ -237,7 +235,7 @@ function getSignreward() {
237235
// 获取用户信息
238236
function getUserInfo() {
239237
return new Promise((resove) => {
240-
const url = { url: 'https://vip.wps.cn/userinfo', headers: JSON.parse($.VAL_signwxheader) }
238+
const url = { url: 'https://vip.wps.cn/userinfo', headers: { sid: $.sid } }
241239
$.get(url, (error, response, data) => {
242240
try {
243241
if (error) throw new Error(error)
@@ -275,7 +273,7 @@ function invite() {
275273
inviteActs.push(
276274
new Promise((resove) => {
277275
const body = `invite_userid=${$.userinfo.data.userid}`
278-
const url = { url: 'http://zt.wps.cn/2018/clock_in/api/invite', body, headers: JSON.parse($.VAL_signwxheader) }
276+
const url = { url: 'http://zt.wps.cn/2018/clock_in/api/invite', body, headers: { sid: $.sid } }
279277
$.post(url, (error, response, data) => {
280278
try {
281279
if (error) throw new Error(error)
@@ -299,8 +297,13 @@ function showmsg() {
299297
return new Promise((resove) => {
300298
$.subt = ''
301299
$.desc = []
302-
$.subt = `签到: ${/ok/.test($.signapp.result) ? '成功' : '失败'}`
303-
$.subt = `签到: ${/error/.test($.signapp.result) && /recheckin/.test($.signapp.msg) ? '重复' : '失败'}`
300+
if (/ok/.test($.signapp.result)) {
301+
$.subt = '签到: 成功'
302+
} else if (/error/.test($.signapp.result) && /recheckin/.test($.signapp.msg)) {
303+
$.subt = '签到: 重复'
304+
} else {
305+
$.subt = '签到: 失败'
306+
}
304307
if ($.signinfo && $.homeinfo.data[0]) {
305308
const current = $.homeinfo.data[0]
306309
$.desc.push(`连签: ${$.signinfo.data.max_days}天, 本期: ${current.end_date} (第${current.id}期)`)

0 commit comments

Comments
 (0)