1- /**
2- *
3- * [MITM]
4- * music.163.com
5- *
6- * [Script]
7- * http-request ^http:\/\/music\.163\.com script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/neteasemusic.cookie.js
8- * cron "10 0 0 * * *" script-path=https://raw.githubusercontent.com/chavyleung/scripts/master/neteasemusic/neteasemusic.js
9- *
10- */
11-
121const cookieName = '网易云音乐'
132const cookieKey = 'chavy_cookie_neteasemusic'
143const cookieVal = $persistentStore . read ( cookieKey )
@@ -24,31 +13,65 @@ function sign() {
2413 }
2514 }
2615
16+ let signinfo = { }
17+
2718 url . url = pc
2819 $httpClient . post ( url , ( error , response , data ) => {
29- log ( '网易云音乐(PC端)' , data )
20+ let result = JSON . parse ( data )
21+ signinfo . pc = {
22+ title : `网易云音乐(PC)` ,
23+ success : result . code == 200 || result . code == - 2 ? true : false ,
24+ skiped : result . code == - 2 ? true : false ,
25+ resultCode : result . code ,
26+ resultMsg : result . msg
27+ }
28+ console . log ( `开始签到: ${ signinfo . pc . title } , 编码: ${ result . code } , 原因: ${ result . msg } ` )
3029 } )
3130
3231 url . url = mobile
3332 $httpClient . post ( url , ( error , response , data ) => {
34- log ( '网易云音乐(移动端)' , data )
33+ let result = JSON . parse ( data )
34+ signinfo . app = {
35+ title : `网易云音乐(APP)` ,
36+ success : result . code == 200 || result . code == - 2 ? true : false ,
37+ skiped : result . code == - 2 ? true : false ,
38+ resultCode : result . code ,
39+ resultMsg : result . msg
40+ }
41+ console . log ( `开始签到: ${ signinfo . app . title } , 编码: ${ result . code } , 原因: ${ result . msg } ` )
3542 } )
43+ check ( signinfo )
44+ }
3645
37- $done ( { } )
46+ function check ( signinfo , checkms = 0 ) {
47+ if ( signinfo . pc && signinfo . app ) {
48+ log ( signinfo )
49+ $done ( { } )
50+ } else {
51+ if ( checkms > 5000 ) {
52+ $done ( { } )
53+ } else {
54+ setTimeout ( ( ) => check ( signinfo , checkms + 100 ) , 100 )
55+ }
56+ }
3857}
3958
40- function log ( title , data ) {
41- let result = JSON . parse ( data )
42- if ( result . code == 200 ) {
43- console . log ( `签到成功: ${ title } ` )
44- $notification . post ( '签到成功' , title , '' )
45- } else if ( result . code == - 2 ) {
46- console . log ( `签到跳过: ${ title } , 编码: ${ result . code } , 原因: ${ result . msg } ` )
47- $notification . post ( '签到跳过' , title , `原因: ${ result . msg } ` )
59+ function log ( signinfo ) {
60+ let title = `签到结果: ${ cookieName } `
61+ let subTitle = ``
62+ let detail = `今日共签: ${ signinfo . signedCnt } , 本次成功: ${ signinfo . successCnt } , 失败: ${ signinfo . failedCnt } , 跳过: ${ signinfo . skipedCnt } `
63+
64+ if ( signinfo . pc . success && signinfo . app . success ) {
65+ subTitle = `全部签到成功`
66+ detail = `PC: ${ signinfo . pc . success ? '成功' : '失败' } , APP: ${ signinfo . app . success ? '成功' : '失败' } `
67+ } else if ( ! signinfo . pc . success && ! signinfo . app . success ) {
68+ subTitle = `全部签到失败`
69+ detail = `PC: ${ signinfo . pc . success ? '成功' : '失败' } , APP: ${ signinfo . app . success ? '成功' : '失败' } , 详见日志!`
4870 } else {
49- console . log ( `签到失败: ${ title } , 编码: ${ result . code } , 原因: ${ result . msg } ` )
50- $notification . post ( '签到失败' , title , `原因 : ${ result . msg } ` )
71+ subTitle = ``
72+ detail = `PC: ${ signinfo . pc . success ? '成功' : '失败' } , APP : ${ signinfo . app . success ? '成功' : '失败' } , 详见日志!`
5173 }
74+ $notification . post ( title , subTitle , detail )
5275}
5376
5477sign ( )
0 commit comments