2020-07-02 11:50:39 +08:00
const cookieName = '懂球帝'
const cookieKey = 'chavy_cookie_dongqiudi'
const chavy = init ( )
const cookieVal = JSON . parse ( chavy . getdata ( cookieKey ) )
sign ( )
function sign ( ) {
2020-07-02 11:52:57 +08:00
let url = { url : ` https://api.dongqiudi.com/v3/useract/sign/tasknew/index ` , headers : { } }
url . headers [ 'UUID' ] = ` ${ cookieVal . UUID } `
url . headers [ 'Authorization' ] = ` ${ cookieVal . Authorization } `
url . headers [ 'Accept-Encoding' ] = ` gzip, deflate, br `
url . headers [ 'Origin' ] = ` https://n.dongqiudi.com `
url . headers [ 'Connection' ] = ` keep-alive `
url . headers [ 'Accept' ] = ` application/json, text/plain, */* `
url . headers [ 'Referer' ] = ` https://n.dongqiudi.com/webapp/signIn.html `
url . headers [ 'Host' ] = ` api.dongqiudi.com `
url . headers [ 'User-Agent' ] = ` Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 NewsApp/7.3.3 NetType/NA Technology/Wifi (iPhone; iOS 13.3; Scale/2.00) dongqiudiClientApp (modelIdentifier/iPhone10,1 ) `
url . headers [ 'Accept-Language' ] = ` zh-cn `
2020-07-02 11:50:39 +08:00
2020-07-02 11:52:57 +08:00
chavy . get ( url , ( error , response , data ) => {
chavy . log ( ` ${ cookieName } , data: ${ data } ` )
let result = JSON . parse ( data )
const title = ` ${ cookieName } `
let subTitle = ` `
let detail = ` `
if ( result . code == 0 ) {
if ( result . data . sign _gold != 0 ) subTitle = '签到结果: 成功'
else subTitle = '签到结果: 成功 (重复签到)'
detail = ` 连签: ${ result . data . continue _sign _days } 天, 金币: ${ result . data . gold _num } (+ ${ result . data . sign _gold } ), 价值: ${ result . data . convertible _money } 元 `
} else {
subTitle = '签到结果: 失败'
detail = ` 编码: ${ result . code } , 说明: ${ result . message } `
}
chavy . msg ( title , subTitle , detail )
} )
chavy . done ( )
2020-07-02 11:50:39 +08:00
}
function init ( ) {
2020-07-02 11:52:57 +08:00
isSurge = ( ) => {
return undefined === this . $httpClient ? false : true
}
isQuanX = ( ) => {
return undefined === this . $task ? false : true
}
getdata = ( key ) => {
if ( isSurge ( ) ) return $persistentStore . read ( key )
if ( isQuanX ( ) ) return $prefs . valueForKey ( key )
}
setdata = ( key , val ) => {
if ( isSurge ( ) ) return $persistentStore . write ( key , val )
if ( isQuanX ( ) ) return $prefs . setValueForKey ( key , val )
}
msg = ( title , subtitle , body ) => {
if ( isSurge ( ) ) $notification . post ( title , subtitle , body )
if ( isQuanX ( ) ) $notify ( title , subtitle , body )
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
log = ( message ) => console . log ( message )
get = ( url , cb ) => {
if ( isSurge ( ) ) {
$httpClient . get ( url , cb )
}
if ( isQuanX ( ) ) {
url . method = 'GET'
$task . fetch ( url ) . then ( ( resp ) => cb ( null , { } , resp . body ) )
}
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
post = ( url , cb ) => {
if ( isSurge ( ) ) {
$httpClient . post ( url , cb )
}
if ( isQuanX ( ) ) {
url . method = 'POST'
$task . fetch ( url ) . then ( ( resp ) => cb ( null , { } , resp . body ) )
}
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
done = ( value = { } ) => {
$done ( value )
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
return { isSurge , isQuanX , msg , log , getdata , setdata , get , post , done }
2020-07-02 11:50:39 +08:00
}