@@ -2,10 +2,15 @@ const cookieName = '腾讯视频'
22const cookieKey = 'chavy_cookie_videoqq'
33const authUrlKey = 'chavy_auth_url_videoqq'
44const authHeaderKey = 'chavy_auth_header_videoqq'
5+ const msignurlKey = 'chavy_msign_url_videoqq'
6+ const msignheaderKey = 'chavy_msign_header_videoqq'
57const chavy = init ( )
68let cookieVal = chavy . getdata ( cookieKey )
79const authUrlVal = chavy . getdata ( authUrlKey )
810const authHeaderVal = chavy . getdata ( authHeaderKey )
11+ const msignurlVal = chavy . getdata ( msignurlKey )
12+ const msignheaderVal = chavy . getdata ( msignheaderKey )
13+ const signinfo = { }
914
1015sign ( )
1116
@@ -24,6 +29,7 @@ function sign() {
2429 respcookie = respcookie . replace ( / D o m a i n = ( .* ?) ; ? / g, '' )
2530 respcookie = respcookie . replace ( / ; $ / g, '' )
2631 if ( result . errcode == 0 ) {
32+ let setcookies = [ ]
2733 for ( setcookie of respcookie . split ( ';' ) ) {
2834 const setcookieKey = setcookie . split ( '=' ) [ 0 ]
2935 const setcookieVal = setcookie . split ( '=' ) [ 1 ]
@@ -32,17 +38,22 @@ function sign() {
3238 } else {
3339 cookieVal += `; ${ setcookieKey } =${ setcookieVal } `
3440 }
41+ setcookies . push ( { key : setcookieKey , val : setcookieVal } )
3542 // chavy.log(`${cookieName}, auth_refresh - set-cookie: ${setcookieKey} = ${setcookieVal}`)
3643 }
3744 for ( resultcookie in result ) {
3845 if ( cookieVal . indexOf ( resultcookie ) >= 0 ) {
3946 cookieVal = cookieVal . replace ( new RegExp ( `${ resultcookie } =[^;]*` , 'g' ) , `${ resultcookie } =${ result [ resultcookie ] } ` )
47+ setcookies . push ( { key : resultcookie , val : result [ resultcookie ] } )
4048 // chavy.log(`${cookieName}, auth_refresh - ret-cookie: ${resultcookie} = ${result[resultcookie]}`)
4149 }
4250 }
4351 // chavy.log(`${cookieName}, auth_refresh - new-cookie: ${cookieVal}`)
52+ // chavy.log(`${cookieName}, auth_refresh - setcookies: ${JSON.stringify(setcookies)}`)
4453 chavy . setdata ( cookieVal , cookieKey )
4554 signapp ( )
55+ signmobile ( setcookies )
56+ chavy . done ( )
4657 }
4758 } )
4859 } else {
@@ -78,7 +89,54 @@ function signapp() {
7889 chavy . msg ( title , subTitle , detail )
7990 }
8091 } )
81- chavy . done ( )
92+ // chavy.done()
93+ }
94+
95+ function signmobile ( cookies ) {
96+ if ( msignheaderVal ) {
97+ let msignheaderObj = JSON . parse ( msignheaderVal )
98+ let msignCookies = msignheaderObj . Cookie
99+ // chavy.log(`${cookieName} updatemobile old-cookie: ${msignCookies}`)
100+ for ( c of cookies ) {
101+ if ( msignCookies . indexOf ( c . key ) >= 0 ) {
102+ msignCookies = msignCookies . replace ( new RegExp ( `${ c . key } =[^;]*` , 'g' ) , `${ c . key } =${ c . val } ` )
103+ }
104+ }
105+ // chavy.log(`${cookieName} updatemobile new-cookie: ${msignCookies}`)
106+ msignheaderObj . Cookie = msignCookies
107+
108+ const url = { url : msignurlVal , headers : msignheaderObj }
109+ chavy . get ( url , ( error , response , data ) => {
110+ const dmatch = data . match ( / w i n d o w \. _ _ S T A T E _ _ = ( .* ?) < \/ s c r i p t > / )
111+ let result = { }
112+ result . msg = '未知'
113+ result . ret = - 9999
114+ if ( dmatch ) {
115+ try {
116+ result = JSON . parse ( dmatch [ 1 ] ) . payloads . execCheck
117+ } catch ( e ) {
118+ chavy . log ( `${ cookieName } catch - error: ${ e } ` )
119+ }
120+ }
121+ const title = `${ cookieName } (移动端)`
122+ let subtitle = ``
123+ let detail = ``
124+ if ( result . ret == - 9999 ) {
125+ // chavy.log(`${cookieName} updatemobile data: ${data}`)
126+ subtitle = `签到结果: 失败`
127+ detail = `说明: 未知`
128+ } else {
129+ if ( result . ret == 0 ) {
130+ subtitle = `签到结果: 成功`
131+ if ( result . data && result . data . show_text_1 ) detail = `说明: ${ result . data . show_text_1 } `
132+ else detail = `说明: ${ result . msg } `
133+ } else if ( result . ret == - 2021 ) {
134+ subtitle = `签到结果: 成功(重复签到)`
135+ }
136+ }
137+ chavy . msg ( title , subtitle , detail )
138+ } )
139+ }
82140}
83141
84142function getexp ( signresult ) {
0 commit comments