2022-06-30 23:16:36 +08:00
/ * *
* @ 临渊
* 功能 : 小米运动刷步数
* 日期 : 6 - 6
* 变量格式 : export xmbs = '小米运动&密码&步数@xxx ' 多个账号用 @ 分割
* 定时一天一次
2022-09-30 21:26:03 +08:00
* 更新成换行登录
2022-06-30 23:16:36 +08:00
* /
const $ = new Env ( '小米步数' ) ;
const notify = $ . isNode ( ) ? require ( './sendNotify' ) : '' ;
const Notify = 1 ; //0为关闭通知, 1为打开通知,默认为1
const debug = 0 ; //0为关闭调试, 1为打开调试,默认为0
//////////////////////
2022-09-05 16:31:52 +08:00
let xmbs = ( $ . isNode ( ) ? process . env . xmbs : $ . getdata ( "xmbs" ) ) || "" ;
2022-06-30 23:16:36 +08:00
let xmbsArr = [ ] ;
let data = '' ;
let msg = '' ;
let back = 0 ;
! ( async ( ) => {
if ( ! ( await Envs ( ) ) )
return ;
else {
console . log ( ` \n \n ========================================= \n 脚本执行 - 北京时间(UTC+8): ${ new Date (
new Date ( ) . getTime ( ) + new Date ( ) . getTimezoneOffset ( ) * 60 * 1000 +
8 * 60 * 60 * 1000 ) . toLocaleString ( ) } \ n === === === === === === === === === === === === === == \ n ` );
console . log ( ` \n =================== 共找到 ${ xmbsArr . length } 个账号 =================== ` )
if ( debug ) {
console . log ( ` 【debug】 这是你的全部账号数组: \n ${ xmbsArr } ` ) ;
}
for ( let index = 0 ; index < xmbsArr . length ; index ++ ) {
let num = index + 1
console . log ( ` \n ========= 开始【第 ${ num } 个账号】========= \n ` )
bs = xmbsArr [ index ] . split ( '&' ) ;
bs [ 2 ] = + bs [ 2 ] ;
bs [ 2 ] += randomInt ( 0 , 1000 ) ;
if ( debug ) {
console . log ( ` \n 【debug】 这是你第 ${ num } 个账号信息: \n ${ bs } \n ` ) ;
}
if ( bs [ 2 ] > 80000 ) {
console . log ( "请输入小于8w的步数, 否则会封号" )
msg += ` 请输入小于8w的步数, 否则会封号 `
break ;
}
msg += ` \n 第 ${ num } 个账号运行结果: `
2022-09-05 16:31:52 +08:00
console . log ( '开始刷步' ) ;
2022-09-08 13:08:59 +08:00
await addStep1 ( ) ;
2022-06-30 23:16:36 +08:00
await $ . wait ( 2 * 1000 ) ;
}
await SendMsg ( msg ) ;
}
} ) ( )
. catch ( ( e ) => console . logErr ( e ) )
. finally ( ( ) => $ . done ( ) )
/ * *
* 步数接口1
* /
function addStep1 ( timeout = 3 * 1000 ) {
return new Promise ( ( resolve ) => {
let url = {
2022-09-08 13:08:59 +08:00
url : ` https://apis.jxcxin.cn/api/mi?user= ${ bs [ 0 ] } &password= ${ bs [ 1 ] } &step= ${ bs [ 2 ] } &ver=cxydzsv3 ` ,
2022-09-05 16:31:52 +08:00
headers : {
2022-09-08 13:08:59 +08:00
"Host" : "apis.jxcxin.cn" ,
"accept" : "application/json, text/javascript, */*; q=0.01" ,
"user-agent" : "Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002;) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.101 Mobile Safari/537.36" ,
"origin" : "http://apk.52dun.cn" ,
"referer" : "http://apk.52dun.cn/" ,
"accept-encoding" : "gzip, deflate" ,
"accept-language" : "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7"
2022-06-30 23:16:36 +08:00
} ,
}
if ( debug ) {
console . log ( ` \n 【debug】=============== 这是 步数接口1 请求 url =============== ` ) ;
console . log ( JSON . stringify ( url ) ) ;
}
2022-09-08 13:08:59 +08:00
$ . get ( url , async ( error , response , data ) => {
2022-06-30 23:16:36 +08:00
try {
if ( debug ) {
console . log ( ` \n \n 【debug】===============这是 步数接口1 返回data============== ` ) ;
console . log ( data )
}
let result = JSON . parse ( data ) ;
if ( result . code == 200 ) {
console . log ( ` 刷步成功,本次刷了 ${ bs [ 2 ] } 步 ` )
msg += ` \n 刷步成功,本次刷了 ${ bs [ 2 ] } 步 `
} else {
2022-09-08 13:08:59 +08:00
console . log ( ` \n 刷步失败 ` )
2022-06-30 23:16:36 +08:00
back = 1 ;
}
} catch ( e ) {
console . log ( e )
} finally {
resolve ( ) ;
}
} , timeout )
} )
}
/ * *
* 步数接口2
* /
function addStep2 ( timeout = 3 * 1000 ) {
return new Promise ( ( resolve ) => {
let url = {
url : ` https://yd.sdbgi.com/step.php?phone= ${ bs [ 0 ] } &password= ${ bs [ 1 ] } &steps= ${ bs [ 2 ] } ` ,
headers : {
"Host" : "yd.sdbgi.com" ,
"Connection" : "keep-alive" ,
"User-Agent" : "Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/3225 MMWEBSDK/20211001 Mobile Safari/537.36 MMWEBID/6242 MicroMessenger/8.0.16.2040(0x28001037) Process/appbrand0 WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android" ,
"content-type" : "application/json" ,
"Accept-Encoding" : "gzip,compress,br,deflate" ,
"Referer" : "https://servicewechat.com/wxbf7d07eb77d51b09/44/page-frame.html"
} ,
}
if ( debug ) {
console . log ( ` \n 【debug】=============== 这是 步数接口2 请求 url =============== ` ) ;
console . log ( JSON . stringify ( url ) ) ;
}
$ . get ( url , async ( error , response , data ) => {
try {
if ( debug ) {
console . log ( ` \n \n 【debug】===============这是 步数接口2 返回data============== ` ) ;
console . log ( data )
}
let result = JSON . parse ( data ) ;
if ( result . code == 200 ) {
console . log ( ` 刷步成功,本次刷了 ${ bs [ 2 ] } 步 ` )
msg += ` \n 刷步成功,本次刷了 ${ bs [ 2 ] } 步 `
} else {
console . log ( ` \n 刷步失败 ` )
back = 1 ;
}
} catch ( e ) {
console . log ( e )
} finally {
resolve ( ) ;
}
} , timeout )
} )
}
// ============================================变量检查============================================ \\
async function Envs ( ) {
if ( xmbs ) {
2022-09-30 21:26:03 +08:00
if ( xmbs . indexOf ( "\n" ) != - 1 ) {
xmbs . split ( "\n" ) . forEach ( ( item ) => {
2022-06-30 23:16:36 +08:00
xmbsArr . push ( item ) ;
} ) ;
} else {
xmbsArr . push ( xmbs ) ;
}
} else {
console . log ( ` \n 【 ${ $ . name } 】:未填写变量 xmbs ` )
return ;
}
return true ;
}
// ============================================发送消息============================================ \\
async function SendMsg ( message ) {
if ( ! message )
return ;
if ( Notify > 0 ) {
if ( $ . isNode ( ) ) {
var notify = require ( './sendNotify' ) ;
await notify . sendNotify ( $ . name , message ) ;
} else {
$ . msg ( message ) ;
}
} else {
console . log ( message ) ;
}
}
/ * *
* 随机数生成
* /
function randomString ( e ) {
e = e || 32 ;
var t = "QWERTYUIOPASDFGHJKLZXCVBNM1234567890" ,
a = t . length ,
n = "" ;
for ( i = 0 ; i < e ; i ++ )
n += t . charAt ( Math . floor ( Math . random ( ) * a ) ) ;
return n
}
/ * *
* 随机整数生成
* /
function randomInt ( min , max ) {
return Math . round ( Math . random ( ) * ( max - min ) + min )
}
/ * *
* 获取毫秒时间戳
* /
function timestampMs ( ) {
return new Date ( ) . getTime ( ) ;
}
/ * *
* 获取秒时间戳
* /
function timestampS ( ) {
return Date . parse ( new Date ( ) ) / 1000 ;
}
2022-09-05 16:31:52 +08:00
function Env ( t , e ) { "undefined" != typeof process && JSON . stringify ( process . env ) . indexOf ( "GITHUB" ) > - 1 && process . exit ( 0 ) ; 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 .