/ *
获取token 一天能刷1 - 2 块
# new Env ( "养牛牛" )
# cron 10 , 30 , 45 , 59 * * * * yn . js
* /
const jobname = '养牛牛'
const $ = Env ( jobname )
// let token = "1a540798ff6fb16b7980b761de1858e0"
let token = ( $ . isNode ( ) ? process . env . ynCk : $ . getdata ( 'ynCk' ) ) || '' ;
let tokenArr = [ ]
let txsuccess = 0
let currency = 0 , foodstuff = 0 , money = 0
let curHours = new Date ( ) . getHours ( ) ;
let curMinutes = new Date ( ) . getMinutes ( )
! ( async ( ) => {
if ( ! await CheckEnv ( ) ) return
$ . log ( ` 总共 ${ tokenArr . length } 个账号 ` )
$ . log ( ` \n 2022-06-07-8:07 \n 更新自动领取,自动喂牛 ` )
$ . log ( ` \n 2022-06-08-09:49 \n 更新自动领每日牛奶,自动看视频广告 ` )
$ . log ( ` \n 2022-06-09-13:51 \n 美化打印 更新自动兑换,自动强制提现,优化流程判断 ` )
await $ . wait ( 1200 )
for ( userIdx = 0 ; userIdx < tokenArr . length ; userIdx ++ ) {
let ant = tokenArr [ userIdx ] . split ( '#' ) ;
$ . log ( ` \n 🔸------第 ${ userIdx + 1 } 个账号------ ` )
token = tokenArr [ userIdx ]
await $ . wait ( 200 )
await login ( token )
$ . log ( ` \n ---界面刷新 ` )
await index ( token )
await $ . wait ( 420 )
$ . log ( ` \n ---检测养牛 ` )
if ( curHours == 8 && curMinutes < 20 ) {
console . log ( ` 开始签到 ` )
await sign ( token )
await $ . wait ( 420 )
await daily ( token )
await $ . wait ( 420 )
await signdouble ( token )
}
if ( foodstuff >= 1 ) {
$ . log ( ` \n 牛奶充足,开始喂牛 ` )
await video ( token )
await feed ( token )
} else console . log ( ` 牛奶不足,跳过养牛 ` )
$ . log ( ` \n ---开始收牛币 ` )
await upcurrency ( token )
await $ . wait ( 420 )
$ . log ( ` \n ---检测牛币 ` )
await $ . wait ( 500 )
if ( currency >= 10000 ) {
$ . log ( ` \n 牛币充足,开始兑换现金 ` )
await exchange ( token )
} else console . log ( ` 牛币不足,跳过兑换 ` )
$ . log ( ` \n ---检测余额 ` )
await $ . wait ( 500 )
let id = 10
if ( money >= 1 ) {
$ . log ( ` \n 余额足够,开始兑换,从低到高,先尝试1元 ` )
id = 10
txsuccess = 0
await withdraw ( token , id )
console . log ( ` 提现状态: ${ txsuccess } ,money: ${ money } ` )
if ( ! txsuccess ) {
console . log ( ` 提现1元失败,尝试提现下一级 ` )
if ( money >= 2 ) id = 11 , await withdraw ( token , id )
if ( txsuccess == 0 ) {
if ( money >= 5 ) id = 12 , await withdraw ( token , id )
}
}
} else console . log ( ` 余额不足,跳过兑换 ` )
await login ( token )
}
if ( ( curHours == 8 && curMinutes < 20 ) ) {
$ . log ( ` \n ---领取500牛币 ` )
for ( token of tokenArr ) {
await taskad1 ( token )
await $ . wait ( 420 )
await taskad2 ( token )
await $ . wait ( 500 )
}
}
} ) ( )
. catch ( ( e ) => {
// $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')
} )
. finally ( ( ) => {
$ . done ( ) ;
} )
async function CheckEnv ( ) {
if ( token ) {
if ( token . indexOf ( '@' ) > - 1 ) {
let tokens = token . split ( '@' )
for ( let i = 0 ; i < tokens . length ; i ++ ) {
tokenP = tokens [ i ]
if ( tokenP . indexOf ( 'account=' ) > - 1 ) {
tokenP = tokenP . match ( /account=(\S{11})/ ) [ 1 ]
}
tokenArr . push ( tokenP )
}
} else if ( token . indexOf ( '\n' ) > - 1 ) {
let tokens = token . split ( '\n' )
console . log ( '你使用的是\\n分割' )
for ( let i = 0 ; i < tokens . length ; i ++ ) {
tokenP = tokens [ i ]
if ( tokenP . indexOf ( 'account=' ) > - 1 ) {
tokenP = tokenP . match ( /account=(\S{11})/ ) [ 1 ]
}
tokenArr . push ( tokenP )
}
} else {
tokenP = token
if ( tokenP . indexOf ( 'account=' ) > - 1 ) {
tokenP = tokenP . match ( /account=(\S{11})/ ) [ 1 ]
}
tokenArr . push ( tokenP )
}
}
else {
console . log ( '没有找到token' )
return false
}
return true
}
async function daily ( token ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=distribute&m=bh_cat&sign=5301f80ea36b2ddf2f9c24dfc7d01b58&action=daily&contr=food&token= ${ token } &version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
//console.log(`${JSON.stringify(result)}`)
if ( result . status == 1 ) {
console . log ( ` 启动: ${ result . info . loading } ` )
}
}
async function index ( token ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=distribute&m=bh_cat&sign=909e28838c62f8db4d6636e83e3c962c&action=index&contr=task&token= ${ token } &version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
//console.log(`${JSON.stringify(result)}`)
if ( result . status == 1 ) {
loading = result . info . loading
console . log ( ` 启动: ${ loading } ` )
}
}
async function video ( token ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=distribute&m=bh_cat&sign=5fe114760603468fc572d2221f509d7a&action=video&contr=food&token= ${ token } &version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
console . log ( ` ${ JSON . stringify ( result ) } ` )
if ( result . status == 1 ) {
console . log ( ` 看视频成功 增加牛奶 ` )
}
}
async function exchange ( token ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=exchange&m=bh_cat&sign=b10f908bff291c4d55d411067da858d6&token= ${ token } &id=3&version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
console . log ( ` ${ JSON . stringify ( result ) } ` )
if ( result . status == 1 ) {
//console.log(result.info);
}
}
async function withdraw ( token , id ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=distribute&m=bh_cat&sign=2d5fe5548354388f2ef6dc2a52fe6298&action=withdrawals&contr=my&token= ${ token } &money_id= ${ id } &payment_code=&pwd=&version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
console . log ( ` ${ JSON . stringify ( result ) } ` )
if ( result . status == 1 ) {
console . log ( result . info ) ;
txsuccess = 1
}
}
//领取500牛币
async function taskad1 ( token ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=distribute&m=bh_cat&sign=1019cab43a3c7c75f666e764fb1b8ac8&action=complete&contr=task&task_id=15&token= ${ token } &version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
if ( httpResult . body == '' )
return ;
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
console . log ( ` ${ JSON . stringify ( result ) } ` )
if ( result . code == 0 ) {
//console.log(`收取成功`);
}
}
async function taskad2 ( token ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=distribute&m=bh_cat&sign=600c93969e0a66411cf48e9c886cd018&action=index&contr=task&token= ${ token } &version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
if ( httpResult . body == '' )
return ;
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
console . log ( ` ${ JSON . stringify ( result ) } ` )
if ( result . code == 0 ) {
//console.log(`收取成功`);
}
}
async function login ( token ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=distribute&m=bh_cat&sign=058cd6df1bad9ce512f811c142dafd46&action=index&contr=my&token= ${ token } &version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
//console.log(`${JSON.stringify(result)}`)
if ( result . status == 1 ) {
money = result . info . member . money
nickname = result . info . member . nickname
currency = result . info . member . currency
foodstuff = result . info . member . foodstuff
console . log ( ` \n 昵称: ${ nickname } 牛币: ${ currency } 牛奶: ${ foodstuff } 余额 ${ money } ` ) ;
}
}
async function feed ( token ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=distribute&m=bh_cat&sign=edfe0973f186a0a0479903907446dcbb&action=feed&contr=my&token= ${ token } &is_remind=2&version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
//console.log(`${JSON.stringify(result)}`)
if ( result . status == 1 ) {
console . log ( ` 喂牛成功 剩余牛奶: ${ result . info . member . foodstuff } ` ) ;
}
}
async function upcurrency ( token ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=distribute&m=bh_cat&sign=7be19e13c4be78ab4650fc632d7a87b7&action=upcurrency&contr=my&token= ${ token } &collect=1&version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
//console.log(`${JSON.stringify(result)}`)
if ( result . status == 1 ) {
console . log ( ` 收币成功 ${ result . info . collect_currency } 剩余牛币: ${ result . info . member . currency } ` ) ;
}
}
async function sign ( token ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=distribute&m=bh_cat&sign=2ac6d4677711f4d158ec5bc46adb8304&action=sign&contr=my&token= ${ token } &version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
//console.log(`${JSON.stringify(result)}`)
if ( result . status == 1 ) {
console . log ( ` 签到成功 ` )
}
}
async function signdouble ( token ) {
let url = ` https://xyx.zlzw188.com/app/index.php?i=16&t=0&v=1.1.7&from=wxapp&c=entry&a=wxapp&do=distribute&m=bh_cat&sign=4d77c536940c080815b351b0fc31a633&action=signDouble&contr=my&token= ${ token } &version=1.0.43 ` ;
let body = ` `
let urlObject = populateUrlObject ( url , body )
await httpRequest ( 'get' , urlObject )
if ( ! httpResult || httpResult . statusCode != 200 ) { return ; }
let result = JSON . parse ( httpResult . body ) ;
if ( ! result ) return
//console.log(`${JSON.stringify(result)}`)
if ( result . status == 1 ) {
console . log ( ` 签到翻倍成功 ` )
}
}
function populateUrlObject ( url , body = '' ) {
let host = url . replace ( '//' , '/' ) . split ( '/' ) [ 1 ]
let urlObject = {
url : url ,
headers : {
'Referer' : ` https://servicewechat.com/wx9ec970c78cf0153b/6/page-frame.html ` ,
'Connection' : ` keep-alive ` ,
'Host' : host ,
'content-type' : ` application/x-www-form-urlencoded ` ,
'Accept-Encoding' : ` gzip,compress,br,deflate ` ,
'User-Agent' : ` Mozilla/5.0 (iPhone; CPU iPhone OS 14_8 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.20(0x18001442) NetType/WIFI Language/zh_CN `
} ,
}
if ( body ) urlObject . body = body
return urlObject ;
}
async function httpRequest ( method , url ) {
httpResult = null
return new Promise ( ( resolve ) => {
$ [ method ] ( url , async ( err , resp , data ) => {
try {
if ( err ) {
console . log ( ` ${ method } 请求失败 ` ) ;
console . log ( JSON . stringify ( err ) ) ;
$ . logErr ( err ) ;
} else {
httpResult = resp ;
}
} catch ( e ) {
$ . logErr ( e , resp ) ;
} finally {
resolve ( ) ;
}
} ) ;
} ) ;
}
function Env ( t , e ) { class s { constructor ( t ) { this . env = t } send ( t , e = "GET" ) { t = "string" == typeof t ? { url : t } : t ; let s = this . get ; return "POST" === e && ( s = this . post ) , new Promise ( ( e , i ) => { s . call ( this , t , ( t , s , r ) => { t ? i ( t ) : e ( s ) } ) } ) } get ( t ) { return this . send . call ( this . env , t ) } post ( t ) { return this . send . call ( this . env , t , "POST" ) } } return new class { constructor ( t , e ) { this . name = t , this . http = new s ( this ) , this . data = null , this . dataFile = "box.dat" , this . logs = [ ] , this . isMute = ! 1 , this . isNeedRewrite = ! 1 , this . logSeparator = "\n" , this . startTime = ( new Date ) . getTime ( ) , Object . assign ( this , e ) , this . log ( "" , ` 🔔 ${ this . name } , 开始! ` ) } isNode ( ) { return "undefined" != typeof module && ! ! module . exports } isQuanX ( ) { return "undefined" != typeof $task } isSurge ( ) { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon ( ) { return "undefined" != typeof $loon } toObj ( t , e = null ) { try { return JSON . parse ( t ) } catch { return e } } toStr ( t , e = null ) { try { return JSON . stringify ( t ) } catch { return e } } getjson ( t , e ) { let s = e ; const i = this . getdata ( t ) ; if ( i ) try { s = JSON . parse ( this . getdata ( t ) ) } catch { } return s } setjson ( t , e ) { try { return this . setdata ( JSON . stringify ( t ) , e ) } catch { return ! 1 } } getScript ( t ) { return new Promise ( e => { this . get ( { url : t } , ( t , s , i ) => e ( i ) ) } ) } runScript ( t , e ) { return new Promise ( s => { let i = this . getdata ( "@chavy_boxjs_userCfgs.httpapi" ) ; i = i ? i . replace ( /\n/g , "" ) . trim ( ) : i ; let r = this . getdata ( "@chavy_boxjs_userCfgs.httpapi_timeout" ) ; r = r ? 1 * r : 20 , r = e && e . timeout ? e . timeout : r ; const [ o , h ] = i . split ( "@" ) , n = { url : ` http:// ${ h } /v1/scripting/evaluate ` , body : { script_text : t , mock_type : "cron" , timeout : r } , headers : { "X-Key" : o , Accept : "*/*" } } ; this . post ( n , ( t , e , i ) => s ( i ) ) } ) . catch ( t => this . logErr ( t ) ) } loaddata ( ) { if ( ! this . isNode ( ) ) return { } ; { this . fs = this . fs ? this . fs : require ( "fs" ) , this . path = this . path ? this . path : require ( "path" ) ; const t = this . path . resolve ( this . dataFile ) , e = this . path . resolve ( process . cwd ( ) , this . dataFile ) , s = this . fs . existsSync ( t ) , i = ! s && this . fs . existsSync ( e ) ; if ( ! s && ! i ) return { } ; { const i = s ? t : e ; try { return JSON . parse ( this . fs . readFileSync ( i ) ) } catch ( t ) { return { } } } } } writedata ( ) { if ( this . isNode ( ) ) { this . fs = this . fs ? this . fs : require ( "fs" ) , this . path = this . path ? this . path : require ( "path" ) ; const t = this . path . resolve ( this . dataFile ) , e = this . path . resolve ( process . cwd ( ) , this . dataFile ) , s = this . fs . existsSync ( t ) , i = ! s && this . fs . existsSync ( e ) , r = JSON . stringify ( this . data ) ; s ? this . fs . writeFileSync ( t , r ) : i ? this . fs . writeFileSync ( e , r ) : this . fs . writeFileSync ( t , r ) } } lodash_get ( t , e , s ) { const i = e . replace ( /\[(\d+)\]/g , ".$1" ) . split ( "." ) ; let r = t ; for ( const t of i ) if ( r = Object ( r ) [ t ] , void 0 === r ) return s ; return r } lodash_set ( t , e , s ) { return Object ( t ) !== t ? t : ( Array . isArray ( e ) || ( e = e . toString ( ) . match ( /[^.[\]]+/g ) || [ ] ) , e . slice ( 0 , - 1 ) . reduce ( ( t , s , i ) => Object ( t [ s ] ) === t [ s ] ? t [ s ] : t [ s ] = Math . abs ( e [ i + 1 ] ) >> 0 == + e [ i + 1 ] ? [ ] : { } , t ) [ e [ e . length - 1 ] ] = s , t ) } getdata ( t ) { let e = this . getval ( t ) ; if ( /^@/ . test ( t ) ) { const [ , s , i ] = /^@(.*?)\.(.*?)$/ . exec ( t ) , r = s ? this . getval ( s ) : "" ; if ( r ) try { const t = JSON . parse ( r ) ; e = t ? this . lodash_get ( t , i , "" ) : e } catch ( t ) { e = "" } } return e } setdata ( t , e ) { let s = ! 1 ; if ( /^@/ . test ( e ) ) { const [ , i , r ] = /^@(.*?)\.(.*?)$/ . exec ( e ) , o = this . getval ( i ) , h = i ? "null" === o ? null : o || "{}" : "{}" ; try { const e = JSON . parse ( h ) ; this . lodash_set ( e , r , t ) , s = this . setval ( JSON . stringify ( e ) , i ) } catch ( e ) { const o = { } ; this . lodash_set ( o , r , t ) , s = this . setval ( JSON . stringify ( o ) , i ) } } else s = this . setval ( t , e ) ; return s } getval ( t ) { return this . isSurge ( ) || this . isLoon ( ) ? $persistentStore . read ( t ) : this . isQuanX ( ) ? $prefs . valueForKey ( t ) : this . isNode ( ) ? ( this . data = this . loaddata ( ) , this . data [ t ] ) : this . data && this . data [ t ] || null } setval ( t , e ) { return this . isSurge ( ) || this . isLoon ( ) ? $persistentStore . write ( t , e ) : this . isQuanX ( ) ? $prefs . setValueForKey ( t , e ) : this . isNode ( ) ? ( this . data = this . loaddata ( ) , this . data [ e ] = t , this . writedata ( ) , ! 0 ) : this . data && this . data [ e ] || null } initGotEnv ( t ) { this . got = this . got ? this . got : require ( "got" ) , this . cktough = this . cktough ? this . cktough : require ( "tough-cookie" ) , this . ckjar = this . ckjar ? this . ckjar : new this . cktough . CookieJar , t && ( t . headers = t . headers ? t . headers : { } , void 0 === t . headers . Cookie && void 0 === t . cookieJar && ( t . cookieJar = this . ckjar ) ) } get ( t , e = ( ( ) => { } ) ) { t . headers && ( delete t . headers [ "Content-Type" ] , delete t . headers [ "Content-Length" ] ) , this . isSurge ( ) || this . isLoon ( ) ? ( this . isSurge ( ) && this . isNeedRewrite && ( t . headers = t . headers || { } , Ob