11const $ = new Env ( '百度签到' )
22$ . VAL_cookies = $ . getdata ( 'chavy_cookie_tieba' ) || $ . getdata ( 'CookieTB' )
33
4- $ . CFG_isOrderBars = 1 // 1: 经验排序, 2: 连签排序
5- $ . CFG_maxShowBars = 15 //每次通知数量
4+ $ . CFG_isOrderBars = $ . getdata ( 'CFG_tieba_isOrderBars' ) || 'false' // 1: 经验排序, 2: 连签排序
5+ $ . CFG_maxShowBars = $ . getdata ( 'CFG_tieba_maxShowBars' ) * 1 || 15 //每次通知数量
66
7- $ . CFG_maxSignBars = 5 // 每次并发执行多少个任务
8- $ . CFG_signWaitTime = 2000 // 每次并发间隔时间 (毫秒)
7+ $ . CFG_maxSignBars = $ . getdata ( 'CFG_tieba_maxSignBars' ) * 1 || 5 // 每次并发执行多少个任务
8+ $ . CFG_signWaitTime = $ . getdata ( 'CFG_tieba_signWaitTime' ) * 1 || 2000 // 每次并发间隔时间 (毫秒)
99
1010! ( async ( ) => {
1111 $ . log ( '' , `🔔 ${ $ . name } , 开始!` , '' )
@@ -53,7 +53,6 @@ async function signbars(bars) {
5353 // 处理`已签`数据
5454 bars . filter ( ( bar ) => bar . isSign ) . forEach ( ( bar ) => ( bar . iscurSign = false ) )
5555 // 处理`未签`数据
56- const waitact = ( resove ) => setTimeout ( ( ) => resove ( ) , $ . CFG_signWaitTime )
5756 let _curbarIdx = 1
5857 let _signbarCnt = 0
5958 bars . filter ( ( bar ) => ! bar . isSign ) . forEach ( ( bar ) => _signbarCnt ++ )
@@ -78,7 +77,7 @@ async function signbars(bars) {
7877 bar . signMsg = error !== null ? error : e
7978 $ . log ( '' , `❗️ 贴吧: ${ bar . name } , 签到失败! 原因: ` , e , '错误: ' , error , '响应: ' , JSON . stringify ( response ) , '数据: ' , data )
8079 } finally {
81- $ . log ( `❕ 贴吧:【${ bar . name } 】签到完成!` , data , '' )
80+ $ . log ( `❕ 贴吧:【${ bar . name } 】签到完成!` )
8281 resove ( )
8382 }
8483 } )
@@ -87,7 +86,7 @@ async function signbars(bars) {
8786 if ( signbarActs . length === $ . CFG_maxSignBars || _signbarCnt === _curbarIdx ) {
8887 $ . log ( '' , `⏳ 正在发起 ${ signbarActs . length } 个签到任务!` )
8988 await Promise . all ( signbarActs )
90- await new Promise ( waitact )
89+ await new Promise ( $ . wait ( $ . CFG_signWaitTime ) )
9190 signbarActs = [ ]
9291 }
9392 _curbarIdx ++
@@ -192,7 +191,7 @@ function showmsg() {
192191 $ . bars . filter ( ( bar ) => bar . isSign ) . forEach ( ( bar ) => ( allsignCnt += 1 ) )
193192 $ . bars . filter ( ( bar ) => bar . iscurSign && bar . issignSuc ) . forEach ( ( bar ) => ( cursignCnt += 1 ) )
194193 $ . bars . filter ( ( bar ) => bar . iscurSign && ! bar . issignSuc ) . forEach ( ( bar ) => ( curfailCnt += 1 ) )
195- $ . bars = $ . CFG_isOrderBars === 2 ? $ . bars . sort ( ( a , b ) => b . exp - a . exp ) : $ . bars
194+ $ . bars = [ true , 'true' ] . includes ( $ . CFG_isOrderBars ) ? $ . bars . sort ( ( a , b ) => b . contsignCnt - a . contsignCnt ) : $ . bars
196195 allsignCnt += cursignCnt
197196 // 通知: 副标题
198197 let tiebasubt = '贴吧: '
@@ -218,9 +217,6 @@ function showmsg() {
218217 $ . desc . push ( `${ signbar } ` )
219218 $ . desc . push ( `${ signlevel } , ${ signexp } , ${ signcnt } ` )
220219 $ . desc . push ( `${ signmsg } ` )
221- $ . log ( `${ signbar } ` )
222- $ . log ( `${ signlevel } , ${ signexp } , ${ signcnt } ` )
223- $ . log ( `${ signmsg } ` )
224220 if ( barno % $ . CFG_maxShowBars === 0 || barno === allbarCnt ) {
225221 const _descinfo = [ ]
226222 _descinfo . push ( `共签: ${ allsignCnt } /${ allbarCnt } , 本次成功: ${ cursignCnt } , 本次失败: ${ curfailCnt } ` )
@@ -234,4 +230,4 @@ function showmsg() {
234230}
235231
236232// prettier-ignore
237- 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 ) ) }
233+ 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 ) ) }
0 commit comments