2020-07-02 11:50:39 +08:00
const chavy = init ( )
const cookieName = '人人视频'
const KEY _signcookie = 'chavy_cookie_rrtv'
const signinfo = { }
let VAL _signcookie = chavy . getdata ( KEY _signcookie )
; ( exec = async ( ) => {
2020-07-02 11:52:57 +08:00
chavy . log ( ` 🔔 ${ cookieName } 开始签到 ` )
await signdaily ( )
await signwelfare ( )
2020-07-02 11:50:39 +08:00
await getquestion ( )
2020-07-02 11:52:57 +08:00
if ( ! signinfo . hasAnswered ) {
await answerquestion ( )
await getquestion ( )
}
await openbox ( 'copperbox' , '铜宝箱' , 'simpleBody=nUuymDQ/BcC2Q6QH21Tjww23J7qtVaDlUN17k1/KY%2BXGDsRVwDRJ8YfjAMraptIL%0D%0A4t2g56kUpDGFsn9z6%2BofyiL5QwfBYZBZOTw9stNt9mc%3D' )
await openbox ( 'silverbox' , '银宝箱' , 'simpleBody=nUuymDQ/BcC2Q6QH21Tjww23J7qtVaDlUN17k1/KY%2BXGDsRVwDRJ8YfjAMraptIL%0D%0ADPPhFllL7eBnJs52RODWxxe9rquyWdYcDcbyirN6KiE%3D' )
await openbox ( 'goldenbox' , '金宝箱' , 'simpleBody=3abxJMn7LwEdH8u1Xpe2qN6AtFpDhBrmviLyoU%2BunKwnS1IGS7DIfS0HiKtt03G0%0D%0A/zVCARFyXUFFrOxLRrgAS4m/u4BiQYWJzTUeUqLAFZk%3D' )
await getinfo ( )
showmsg ( )
chavy . done ( )
2020-07-02 11:50:39 +08:00
} ) ( ) . catch ( ( e ) => chavy . log ( ` ❌ ${ cookieName } 签到失败: ${ e } ` ) , chavy . done ( ) )
function signdaily ( ) {
2020-07-02 11:52:57 +08:00
return new Promise ( ( resolve , reject ) => {
let url = { url : ` https://api.rr.tv/rrtv-activity/sign/sign ` , headers : { token : VAL _signcookie } }
url . headers [ 'clientType' ] = ` ios_rrsp_jzsp `
url . headers [ 'Accept-Encoding' ] = ` gzip, deflate, br `
url . headers [ 'Connection' ] = ` keep-alive `
url . headers [ 'clientVersion' ] = ` 4.3.5 `
url . headers [ 'Content-Type' ] = ` application/x-www-form-urlencoded; charset=UTF-8 `
url . headers [ 'Origin' ] = ` https://mobile.rr.tv `
url . headers [ 'Referer' ] = ` https://mobile.rr.tv/ `
url . headers [ 'Accept' ] = ` application/json, text/plain, */* `
url . headers [ 'Host' ] = ` api.rr.tv `
url . headers [ 'Accept-Language' ] = ` zh-cn `
url . headers [ 'Content-Length' ] = ` 12 `
url . headers [ 'User-Agent' ] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 App/RRSPApp platform/iPhone AppVersion/4.3.5'
chavy . post ( url , ( error , response , data ) => {
try {
signinfo . signdaily = JSON . parse ( data )
resolve ( )
} catch ( e ) {
chavy . msg ( cookieName , ` 日常签到: 失败 ` , ` 说明: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } signdaily - 日常签到失败: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } signdaily - response: ${ JSON . stringify ( response ) } ` )
resolve ( )
}
} )
2020-07-02 11:50:39 +08:00
} )
}
function signwelfare ( ) {
2020-07-02 11:52:57 +08:00
return new Promise ( ( resolve , reject ) => {
let url = { url : ` https://api.rr.tv/dailyWelfare/getWelfare ` , headers : { token : VAL _signcookie } }
url . headers [ 'clientType' ] = ` web `
url . headers [ 'Accept-Encoding' ] = ` gzip, deflate, br `
url . headers [ 'Connection' ] = ` keep-alive `
url . headers [ 'clientVersion' ] = ` 0.0.1 `
url . headers [ 'Content-Type' ] = ` application/x-www-form-urlencoded; charset=UTF-8 `
url . headers [ 'Origin' ] = ` https://mobile.rr.tv `
url . headers [ 'Referer' ] = ` https://mobile.rr.tv/mission/ `
url . headers [ 'Accept' ] = ` application/json, text/plain, */* `
url . headers [ 'Host' ] = ` api.rr.tv `
url . headers [ 'Accept-Language' ] = ` zh-cn `
url . headers [ 'Content-Length' ] = ` 45 `
url . headers [ 'User-Agent' ] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 App/RRSPApp platform/iPhone AppVersion/4.3.5'
chavy . post ( url , ( error , response , data ) => {
try {
signinfo . signwelfare = JSON . parse ( data )
resolve ( )
} catch ( e ) {
chavy . msg ( cookieName , ` 日常签到: 失败 ` , ` 说明: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } signwelfare - 日常签到失败: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } signwelfare - response: ${ JSON . stringify ( response ) } ` )
resolve ( )
}
} )
2020-07-02 11:50:39 +08:00
} )
}
function getinfo ( ) {
2020-07-02 11:52:57 +08:00
return new Promise ( ( resolve , reject ) => {
let url = { url : ` https://api.rr.tv/user/profile ` , headers : { token : VAL _signcookie } }
url . headers [ 'clientType' ] = ` ios_rrsp_jzsp `
url . headers [ 'Accept-Encoding' ] = ` gzip, deflate, br `
url . headers [ 'Connection' ] = ` keep-alive `
url . headers [ 'clientVersion' ] = ` 4.3.5 `
url . headers [ 'Content-Type' ] = ` application/x-www-form-urlencoded; charset=UTF-8 `
url . headers [ 'Origin' ] = ` https://mobile.rr.tv `
url . headers [ 'Referer' ] = ` https://mobile.rr.tv/ `
url . headers [ 'Accept' ] = ` application/json, text/plain, */* `
url . headers [ 'Host' ] = ` api.rr.tv `
url . headers [ 'Accept-Language' ] = ` zh-cn `
url . headers [ 'Content-Length' ] = ` 0 `
url . headers [ 'User-Agent' ] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 App/RRSPApp platform/iPhone AppVersion/4.3.5'
chavy . post ( url , ( error , response , data ) => {
try {
signinfo . userinfo = JSON . parse ( data )
resolve ( )
} catch ( e ) {
chavy . msg ( cookieName , ` 获取会员信息: 失败 ` , ` 说明: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } getinfo - 获取会员信息失败: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } getinfo - response: ${ JSON . stringify ( response ) } ` )
resolve ( )
}
} )
2020-07-02 11:50:39 +08:00
} )
}
function getquestion ( ) {
2020-07-02 11:52:57 +08:00
return new Promise ( ( resolve , reject ) => {
let url = { url : ` https://api.rr.tv/v3plus/question/getQuestion ` , headers : { token : VAL _signcookie } }
url . headers [ 'clientType' ] = ` ios_rrsp_jzsp `
url . headers [ 'Accept-Encoding' ] = ` gzip, deflate, br `
url . headers [ 'Connection' ] = ` keep-alive `
url . headers [ 'clientVersion' ] = ` 4.3.5 `
url . headers [ 'Content-Type' ] = ` application/x-www-form-urlencoded; charset=UTF-8 `
url . headers [ 'Origin' ] = ` https://mobile.rr.tv `
url . headers [ 'Referer' ] = ` https://mobile.rr.tv/ `
url . headers [ 'Accept' ] = ` application/json, text/plain, */* `
url . headers [ 'Host' ] = ` api.rr.tv `
url . headers [ 'Accept-Language' ] = ` zh-cn `
url . headers [ 'Content-Length' ] = ` 0 `
url . headers [ 'User-Agent' ] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 App/RRSPApp platform/iPhone AppVersion/4.3.5'
chavy . post ( url , ( error , response , data ) => {
try {
signinfo . question = JSON . parse ( data )
signinfo . questionopts = { }
for ( opt of signinfo . question . data . question . optionViewList ) {
signinfo . questionopts [ opt . id ] = opt
if ( ! signinfo . answeropt ) signinfo . answeropt = opt
else signinfo . answeropt = opt . answererCount > signinfo . answeropt . answererCount ? opt : signinfo . answeropt
}
signinfo . hasAnswered = signinfo . question . data . question . hasAnswered
if ( signinfo . hasAnswered ) {
signinfo . selectId = signinfo . question . data . question . selectId
signinfo . isRight = signinfo . questionopts [ signinfo . selectId ] . isRight
}
resolve ( )
} catch ( e ) {
chavy . msg ( cookieName , ` 获取问题: 失败 ` , ` 说明: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } getquestion - 获取问题失败: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } getquestion - response: ${ JSON . stringify ( response ) } ` )
resolve ( )
}
} )
2020-07-02 11:50:39 +08:00
} )
}
function answerquestion ( ) {
2020-07-02 11:52:57 +08:00
return new Promise ( ( resolve , reject ) => {
let url = { url : ` https://api.rr.tv/v3plus/question/answerQuestion ` , headers : { token : VAL _signcookie } }
url . body = ` optionId= ${ signinfo . answeropt . id } `
url . headers [ 'clientType' ] = ` ios_rrsp_jzsp `
url . headers [ 'Accept-Encoding' ] = ` gzip, deflate, br `
url . headers [ 'Connection' ] = ` keep-alive `
url . headers [ 'clientVersion' ] = ` 4.3.5 `
url . headers [ 'Content-Type' ] = ` application/x-www-form-urlencoded; charset=UTF-8 `
url . headers [ 'Origin' ] = ` https://mobile.rr.tv `
url . headers [ 'Referer' ] = ` https://mobile.rr.tv/ `
url . headers [ 'Accept' ] = ` application/json, text/plain, */* `
url . headers [ 'Host' ] = ` api.rr.tv `
url . headers [ 'Accept-Language' ] = ` zh-cn `
url . headers [ 'Content-Length' ] = ` 0 `
url . headers [ 'User-Agent' ] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 App/RRSPApp platform/iPhone AppVersion/4.3.5'
chavy . post ( url , ( error , response , data ) => {
try {
signinfo . answerquestion = JSON . parse ( data )
resolve ( )
} catch ( e ) {
chavy . msg ( cookieName , ` 获取问题: 失败 ` , ` 说明: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } getquestion - 获取问题失败: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } getquestion - response: ${ JSON . stringify ( response ) } ` )
resolve ( )
}
} )
2020-07-02 11:50:39 +08:00
} )
}
function openbox ( boxcode , boxname , body ) {
2020-07-02 11:52:57 +08:00
return new Promise ( ( resolve , reject ) => {
let url = { url : ` https://api.rr.tv/v3plus/taskCenter/openBox ` , headers : { token : VAL _signcookie } }
url . body = body
url . headers [ 'Accept' ] = ` */* `
url . headers [ 'Accept-Encoding' ] = ` gzip, deflate, br `
url . headers [ 'Accept-Language' ] = ` zh-Hans-CN;q=1, en-US;q=0.9 `
url . headers [ 'Connection' ] = ` keep-alive `
url . headers [ 'Content-Type' ] = ` application/x-www-form-urlencoded `
url . headers [ 'Host' ] = ` api.rr.tv `
url . headers [ 'User-Agent' ] = ` PUClient/4.3.6 (iPhone; iOS 13.3.1; Scale/2.00) `
url . headers [ 'clientType' ] = ` ios_rrsp_jzsp `
url . headers [ 'clientVersion' ] = ` 4.3.6 `
url . headers [ 'deviceMode' ] = ` iPhone 8 `
url . headers [ 'p' ] = ` iOS `
chavy . post ( url , ( error , response , data ) => {
try {
signinfo [ boxcode ] = JSON . parse ( data )
resolve ( )
} catch ( e ) {
chavy . msg ( cookieName , ` 打开 ${ boxname } : 失败 ` , ` 说明: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } getquestion - 打开 ${ boxname } 失败: ${ e } ` )
chavy . log ( ` ❌ ${ cookieName } getquestion - response: ${ JSON . stringify ( response ) } ` )
resolve ( )
}
} )
2020-07-02 11:50:39 +08:00
} )
}
function showmsg ( ) {
2020-07-02 11:52:57 +08:00
let subTitle = ''
let detail = ''
if ( signinfo . signdaily ) {
subTitle = ` 签到: `
if ( signinfo . signdaily . code == '0000' || signinfo . signdaily . code == '8750' ) {
subTitle += signinfo . signdaily . code == '0000' ? '成功; ' : ''
subTitle += signinfo . signdaily . code == '8750' ? '重复; ' : ''
} else {
subTitle += '失败; '
}
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
if ( signinfo . signwelfare ) {
subTitle += ` 福利: `
if ( signinfo . signwelfare . code == '0000' || signinfo . signwelfare . code == '8623' ) {
subTitle += signinfo . signwelfare . code == '0000' ? '成功; ' : ''
subTitle += signinfo . signwelfare . code == '8623' ? '重复; ' : ''
} else {
subTitle += '失败;'
}
}
if ( signinfo . question && signinfo . questionopts ) {
subTitle += ` 答题: ${ signinfo . isRight ? '✅' : '❌' } `
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
if ( signinfo . userinfo . code == '0000' ) {
const levelStr = signinfo . userinfo . data . user . levelStr ? ` ( ${ signinfo . userinfo . data . user . levelStr } ) ` : ` `
detail = ` 等级: ${ signinfo . userinfo . data . user . level } ${ levelStr } , 银币: ${ signinfo . userinfo . data . user . silverCount } `
2020-07-02 11:50:39 +08:00
} else {
2020-07-02 11:52:57 +08:00
detail = ` 编码: ${ signinfo . userinfo . code } , 说明: ${ signinfo . userinfo . msg } `
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
if ( signinfo . question . data . question ) {
detail += ` \n 查看答题详情 `
detail += ` \n \n 问题: ${ signinfo . question . data . question . questionStr } `
for ( key in signinfo . questionopts ) detail += ` \n 选项: ${ signinfo . questionopts [ key ] . optionStr } , 回答人数: ${ signinfo . questionopts [ key ] . answererCount } ( ${ signinfo . questionopts [ key ] . percent } ) `
if ( signinfo . selectId ) {
detail += ` \n 最佳回答: ${ signinfo . answeropt . optionStr } `
detail += ` \n 我的回答: ${ signinfo . questionopts [ signinfo . selectId ] . optionStr } `
detail += ` ${ signinfo . isRight ? '✅' : '❌' } \n `
} else {
detail += ` \n 最佳回答: ${ signinfo . answeropt . optionStr } \n `
}
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
if ( signinfo . copperbox ) {
if ( signinfo . copperbox . code == '0000' ) {
for ( box of signinfo . copperbox . data . boxs ) detail += ` \n 铜宝箱: ${ box . rewardName } (+ ${ box . rewardNum } ) `
} else {
detail += ` \n 铜宝箱: ${ signinfo . copperbox . msg } `
}
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
if ( signinfo . silverbox ) {
if ( signinfo . silverbox . code == '0000' ) {
for ( box of signinfo . silverbox . data . boxs ) detail += ` \n 银宝箱: ${ box . rewardName } (+ ${ box . rewardNum } ) `
} else {
detail += ` \n 银宝箱: ${ signinfo . silverbox . msg } `
}
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
if ( signinfo . goldenbox ) {
if ( signinfo . goldenbox . code == '0000' ) {
for ( box of signinfo . goldenbox . data . boxs ) detail += ` \n 金宝箱: ${ box . rewardName } (+ ${ box . rewardNum } ) `
} else {
detail += ` \n 金宝箱: ${ signinfo . goldenbox . msg } `
}
}
chavy . msg ( cookieName , subTitle , detail )
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 )
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
setdata = ( key , val ) => {
if ( isSurge ( ) ) return $persistentStore . write ( key , val )
if ( isQuanX ( ) ) return $prefs . setValueForKey ( key , val )
2020-07-02 11:50:39 +08:00
}
2020-07-02 11:52:57 +08:00
msg = ( title , subtitle , body ) => {
if ( isSurge ( ) ) $notification . post ( title , subtitle , body )
if ( isQuanX ( ) ) $notify ( title , subtitle , body )
}
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 , resp . body ) )
}
}
post = ( url , cb ) => {
if ( isSurge ( ) ) {
$httpClient . post ( url , cb )
}
if ( isQuanX ( ) ) {
url . method = 'POST'
$task . fetch ( url ) . then ( ( resp ) => cb ( null , resp , 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
}