auto.waitFor(); log( "-启动-垂直浏览功能" ); var startTime = new Date().getTime(); var plList; / / 评论内容列表 var gzzbNum = 0 ; / / 记录关注主播数量 var dzslNum = 0 ; / / 点赞主播数量 var llzpNum = 0 ; / / 浏览作品数量 var zpgjcList; / / 关键词 var tlsjTime = 5000 ; / / 停留观看时间 默认 5s beforRun(); doNext(); endRun(); storage.put( "RUN_JS_RUNING" ,false); / / 运行结束 log( "-停止-垂直浏览功能" ); / / 继续下一步 function doNext(){ var ifInLiveRoom = checkInLive(); / / 是否在直播间 if (ifInLiveRoom){ / / 直播间里 zbjRun(); } else { / / 短视频 dspRun(); } } / / 短视频运行 function dspRun(){ console.warn( "浏览短视频" ); console.warn( "自定义评论内容:" + DY_czll_plnr); while (true){ llzpNum + + ; var ifContinue = checkGjz(); / / 检测关键字 if (ifContinue){ / / 检测有关键字 clickGuanzhu(); / / 短视频点赞关注 clickZan(); / / 短视频点赞关注 clickPinglun(); / / 短视频评论 sleep(tlsjTime); / / 停留浏览时间 3s } / / 判断是否停止运行脚本 var isRun = storage.get( "RUN_JS_RUNING" ,false); if (!isRun){ return ; / / 结束 } / / 检测运行时间 var endTime = new Date().getTime(); var runAllTime = (endTime - startTime) / 1000 ; / / 已经运行秒 if (runAllTime>DY_czll_lltjsc * 60 ){ / / 到达设置时间 return ; } console.warn( "屏幕宽高:" + device.width + "," + device.height); / / swipe(device.width - 200 , device.height - 400 , device.width - 200 , 100 , 500 ); / / 下一条视频 swipe(device.width / 2 , device.height / 5 * 4 , device.width / 2 , device.height / 5 , 200 ); / / 下一条视频 sleep( 1000 ); } } / / 直播间运行 function zbjRun(){ console.warn( "观看直播" ); while (true){ llzpNum + + ; clickHbFd(); / / 点击领取红包福袋 var ifContinue = checkZbjGjz(); / / 检测关键字 if (ifContinue){ / / 检测有关键字 clickZbjPinglun(); / / 直播间评论 sleep(tlsjTime); / / 停留浏览时间 3s } / / 判断是否停止运行脚本 var isRun = storage.get( "RUN_JS_RUNING" ,false); if (!isRun){ return ; / / 结束 } / / 检测运行时间 var endTime = new Date().getTime(); var runAllTime = (endTime - startTime) / 1000 ; / / 已经运行秒 if (runAllTime>DY_czll_lltjsc * 60 ){ / / 到达设置时间 return ; } swipe(device.width - 200 , device.height - 400 , device.width - 200 , 100 , 500 ); / / 下一条视频 sleep( 1000 ); } } / / 运行开始 function beforRun(){ log( "系统提醒:浏览时长" + DY_czll_lltjsc + "分钟" ); if (DY_czll_gbgjcsb){ log( "关闭关键词识别" ); } else { if (DY_czll_zpgjc! = null&&DY_czll_zpgjc! = ""){ zpgjcList = DY_czll_zpgjc.split( "," ); log( "关键词数量:" + zpgjcList.length); for (var i = 0 ;i<zpgjcList.length;i + + ){ var gjc = zpgjcList[i]; log( "关键词" + (i + 1 ) + ":" + gjc); } } } } / / 运行结束 function endRun(){ var ifInLiveRoom = checkInLive(); / / 是否在直播间 var endTime = new Date().getTime(); log( "时间提示:运行" + (endTime - startTime) / 1000 + "秒" ); if (ifInLiveRoom){ log( "观看直播间:" + llzpNum); } else { log( "浏览作品:" + llzpNum); log( "点赞作品:" + dzslNum); log( "关注作品:" + gzzbNum); } } / / 校验是否在直播间页面 function checkInLive(){ var livecommentLab = text( "说点什么..." ).findOne( 1000 ); if (livecommentLab = = null){ return false; } else { return true; } } / / 直播间领取红包和福袋 function clickHbFd(){ var hbmqdLable = text( "知道了" ).findOne( 100 ); if (hbmqdLable! = null){ hbmqdLable.click(); } if (!DY_czll_lqhbfd){ return ; } sleep( 5000 ); var hbfdLayout = className( "android.widget.HorizontalScrollView" ).findOne( 2000 ); if (hbfdLayout = = null){ log( "系统提示:没有红包或福袋,自动跳过" ); return ; } if (hbfdLayout.childCount() = = 0 ){ log( "系统提示:没有红包或福袋,自动跳过" ); return ; } var hbfdFrameLayout = hbfdLayout.child( 0 ); if (hbfdFrameLayout.childCount() = = 0 ){ log( "系统提示:没有红包或福袋,自动跳过" ); return ; } log( "系统提示:检测到红包或福袋" ); for (var i = 0 ;i<hbfdFrameLayout.childCount();i + + ){ var hbfdFrameItem = hbfdFrameLayout.child(i); if (hbfdFrameItem = = null){ continue ; } hbfdFrameItem.click(); sleep( 2000 ); var ifFd = clickFd(hbfdFrameItem); if (ifFd){ / / 是福袋 continue ; } clickHb(); sleep( 2000 ); } suijiSleep(); } / / 点击的是福袋 function clickFd(hbfdFrameItem){ var fdView = text( "福袋" ).findOne( 1000 ); if (fdView = = null){ return false; } if ( "2" = = DY_czll_fdhbsz){ / / 只领取红包 log( "系统提示:只领取红包,自动关闭福袋" ); click(device.width / 2 + 200 , device.height / 2 - 300 ); return false; } if ( "android.view.View" ! = fdView.className()){ click(device.width / 2 + 200 , device.height / 2 - 300 ); return false; } var jrfstView = textContains( "加入粉丝团" ).findOne( 1000 ); if (jrfstView! = null){ / / 需要加入粉丝团 if ( "2" = = DY_czll_fdlqtj){ / / 免费领取的 跳过 log( "系统提示:领取福袋需要加入粉丝团,自动跳过" ); click(device.width / 2 + 200 , device.height / 2 - 300 ); return true; } var jrfstydbLabel = text( "加入粉丝团(1抖币)" ).findOne( 1000 ); if (jrfstydbLabel = = null){ log( "系统提示:加入粉丝团大于1抖币,自动跳过" ); click(device.width / 2 + 200 , device.height / 2 - 300 ); return true; } jrfstydbLabel.click(); sleep( 2000 ); var czLabel = textContains( "立即充值" ).findOne( 1000 ); if (czLabel! = null){ log( "系统提示:抖币余额不足,自动跳过" ); click(device.width / 2 + 200 , device.height / 2 - 300 ); sleep( 1000 ); click(device.width / 2 + 200 , device.height / 2 - 300 ); return true; } else { log( "系统提示:支付1抖币加入粉丝团" ); } } var qfbplView = text( "去发表评论" ).findOne( 1000 ); if (qfbplView = = null){ log( "系统提示:未找到参与福袋评论按钮,自动跳过" ); click(device.width / 2 + 200 , device.height / 2 - 300 ); return true; } console.warn( "时间限制:" + DY_czll_fdsjxz); if ( "3" ! = DY_czll_fdsjxz){ / / 少于 1 分钟或少于两分钟 var ifLessTime = false; var djsTitleLabel = text( "倒计时" ).findOne( 1000 ); if (djsTitleLabel! = null){ var djsParentLayout = djsTitleLabel.parent(); var djsLabel = djsParentLayout.child( 1 ); if (djsLabel! = null){ var djsTimeStr = djsLabel.text(); log( "系统提示:福袋开奖时间" + djsTimeStr); if ( "1" = = DY_czll_fdsjxz){ / / 少于 1 分钟 if (djsTimeStr.indexOf( "00:" ) = = 0 ){ ifLessTime = false; } else { ifLessTime = true; } } else if ( "2" = = DY_czll_fdsjxz){ / / 少于 2 分钟 if (djsTimeStr.indexOf( "00:" ) = = 0 ||djsTimeStr.indexOf( "01:" ) = = 0 ){ ifLessTime = false; } else { ifLessTime = true; } } } } if (ifLessTime){ log( "系统提示:开奖时间太长,自动跳过" ); click(device.width / 2 + 200 , device.height / 2 - 300 ); return true; } } console.warn( "福袋概率设置:" + DY_czll_fdzjgl); if ( "5" ! = DY_czll_fdzjgl){ / / 中奖概率设置 var gfdNumLabel = textContains( "个福袋" ).findOne( 1000 ); var yzyNumLabel = textContains( "人已参与" ).findOne( 1000 ); if (gfdNumLabel! = null&&yzyNumLabel! = null){ var gfdNumStr = gfdNumLabel.text(); var yzyNumStr = yzyNumLabel.text(); log( "系统提示:" + gfdNumStr + "," + yzyNumStr); gfdNumStr = gfdNumStr. slice ( 0 ,gfdNumStr.indexOf( "个福袋" )); yzyNumStr = yzyNumStr. slice ( 0 ,yzyNumStr.indexOf( "人已参与" )); var gailv = parseInt(parseInt(gfdNumStr) / (parseInt(yzyNumStr) * 1.00 ) * 100 ); log( "系统提示:中奖概率" + gailv + "%" ); if ( "1" = = DY_czll_fdzjgl){ / / 中奖概率大于 20 if (gailv< 20 ){ log( "系统提示:中奖概率低于20%,自动跳过" ); click(device.width / 2 + 200 , device.height / 2 - 300 ); return true; } } else if ( "2" = = DY_czll_fdzjgl){ / / 中奖概率大于 50 if (gailv< 50 ){ log( "系统提示:中奖概率低于50%,自动跳过" ); click(device.width / 2 + 200 , device.height / 2 - 300 ); return true; } } else if ( "3" = = DY_czll_fdzjgl){ / / 中奖概率大于 80 if (gailv< 80 ){ log( "系统提示:中奖概率低于80%,自动跳过" ); click(device.width / 2 + 200 , device.height / 2 - 300 ); return true; } } else if ( "4" = = DY_czll_fdzjgl){ / / 中奖概率大于 100 if (gailv< 100 ){ log( "系统提示:中奖概率低于100%,自动跳过" ); click(device.width / 2 + 200 , device.height / 2 - 300 ); return true; } } } } qfbplView.click(); var huifuEditView = className( "android.widget.EditText" ).findOne( 1000 ); / / 找到输入框 if (huifuEditView! = null){ var msgStr = huifuEditView.text(); var sendBtn = desc( "发送" ).findOne(); sendBtn.click(); log( "评论内容:" + msgStr); log( "系统提示:已参与福袋抽奖" ); sleep( 2000 ); hbfdFrameItem.click(); var hbmqdLable = text( "知道了" ).findOne(); if (hbmqdLable! = null){ suijiSleep(); hbmqdLable.click(); } } return true; } / / 点击的是红包 function clickHb(){ var closeBtnArr = desc( "关闭" ).find(); console.warn( "关闭按钮的数量:" + closeBtnArr.length); var closeBtn = closeBtnArr[closeBtnArr.length - 1 ]; if (closeBtn = = null){ return ; } var closeViewGroup = closeBtn.parent(); if ( "android.view.ViewGroup" ! = closeViewGroup.className()){ console.warn( "不是 android.view.ViewGroup" ); console.warn( "关闭按钮的位置:" + closeBtn.bounds().centerY()); if (closeBtn.bounds().centerY()<device.height / 2 - 500 ){ / / 不是弹框的关闭 return ; } closeBtn.click(); return ; } if ( "1" = = DY_czll_fdhbsz){ / / 只领取福袋 log( "系统提示:只领取福袋,不点击红包" ); closeBtn.click(); return ; } console.warn( "时间限制:" + DY_czll_fdsjxz); if ( "3" ! = DY_czll_fdsjxz){ / / 少于 1 分钟或少于两分钟 var ifLessTime = false; var djsLabel = textContains( "可抢" ).findOne( 1000 ); if (djsLabel! = null){ var djsTimeStr = djsLabel.text(); log( "系统提示:福袋开奖时间" + djsTimeStr); if ( "1" = = DY_czll_fdsjxz){ ifLessTime = true; } else if ( "2" = = DY_czll_fdsjxz){ / / 少于 2 分钟 if (djsTimeStr.indexOf( "1分" ) = = 0 ){ ifLessTime = false; } else { ifLessTime = true; } } } if (ifLessTime){ log( "系统提示:开奖时间太长,自动跳过" ); closeBtn.click(); return ; } } var hbyqwLabel = text( "红包已抢完" ).findOne( 50 ); var hbmqdLable = text( "知道了" ).findOne( 50 ); var smlLable = text( "手慢了" ).findOne( 50 ); var ckdjsqLabel = text( "查看大家手气" ).findOne( 50 ); var hbygqLabel = text( "红包已过期" ).findOne( 50 ); while (hbyqwLabel = = null&&hbmqdLable = = null&&smlLable = = null&&ckdjsqLabel = = null&&hbygqLabel = = null){ log( "系统提示:点击抢红包" ); console.warn( "点击位置:" + device.width / 2 + "," + device.height / 2 ); click(device.width / 2 ,device.height / 2 ); hbyqwLabel = text( "红包已抢完" ).findOne( 50 ); hbmqdLable = text( "知道了" ).findOne( 50 ); smlLable = text( "手慢了" ).findOne( 50 ); ckdjsqLabel = text( "查看大家手气" ).findOne( 50 ); hbygqLabel = text( "红包已过期" ).findOne( 50 ); } suijiSleep(); closeBtn.click(); } / / 短视频关键字校验 function checkGjz(){ var startCheckTime = new Date().getTime(); var headImgView = findBtnType( 3 ); var textRootLayout = findBtnType( 4 ); if (headImgView! = null){ var nickNameStr = headImgView.desc(); log( "视频发布者:" + nickNameStr); } var ifCheckHave = checkGjzDetail(textRootLayout); var endCheckTime = new Date().getTime(); var logStr = "检测耗时" + (endCheckTime - startCheckTime) / 1000 + "秒" ; if (ifCheckHave){ if (!DY_czll_gbgjcsb){ / / 开启检测关键词 logStr = "检测到关键字," + logStr; log(logStr); } / / 随机停留观看时间 tlsjTime = parseInt(Math.random() * (DY_czll_llzpsj_big - DY_czll_llzpsj_small)) + DY_czll_llzpsj_small; tlsjTime = tlsjTime * 1000 ; log( "停留观看" + tlsjTime / 1000 + "秒" ); } else { logStr = "跳过该视频,未检测到关键字," + logStr; log(logStr); sleep( 2000 ); } return ifCheckHave; } / / 短视频点赞 function clickZan(){ if (DY_czll_pldz){ var checkItem = findBtnType( 2 ); if (checkItem! = null){ checkItem.click(); dzslNum + + ; log( "点赞数量:" + dzslNum); sleep( 500 ); } else { console.warn( "未找到点赞按钮" ); } } } / / 直播间关键字 function checkZbjGjz(){ var startCheckTime = new Date().getTime(); var nickNameView = findZbjBtnType( 1 ); var textRootLayout = findZbjBtnType( 2 ); if (nickNameView! = null){ var nickNameStr = nickNameView.text(); log( "直播者:" + nickNameStr); } var ifCheckHave = checkGjzDetail(textRootLayout); var endCheckTime = new Date().getTime(); var logStr = "检测耗时" + (endCheckTime - startCheckTime) / 1000 + "秒" ; if (ifCheckHave){ if (!DY_czll_gbgjcsb){ / / 开启检测关键词 logStr = "检测到关键字," + logStr; log(logStr); } / / 随机停留观看时间 tlsjTime = parseInt(Math.random() * (DY_czll_llzpsj_big - DY_czll_llzpsj_small)) + DY_czll_llzpsj_small; tlsjTime = tlsjTime * 1000 ; log( "停留观看" + tlsjTime / 1000 + "秒" ); } else { logStr = "跳过该视频,未检测到关键字," + logStr; log(logStr); sleep( 2000 ); } return ifCheckHave; } / / 直播间评论 function clickZbjPinglun(){ if (DY_czll_kqnc){ suijiSleep(); if ( 1 = = DY_czll_ncfs){ / / 自定义评论 if (DY_czll_plnr = = null||DY_czll_plnr = = ""){ return ; } } var checkItem = text( "说点什么..." ).findOne( 1000 ); / / 获取评论按钮 if (checkItem! = null){ var msgStr = DY_czll_plnr; if ( 1 ! = DY_czll_ncfs){ } checkItem.parent().click(); sleep( 1000 ); var huifuEditView = className( "android.widget.EditText" ).findOne( 1000 ); / / 找到输入框 if (huifuEditView! = null){ huifuEditView.setText(msgStr); var sendBtn = desc( "发送" ).findOne(); sendBtn.click(); log( "评论内容:" + msgStr); sleep( 500 ); } } else { console.warn( "未找到评论按钮" ); } } } |