feat: init
This commit is contained in:
156
flow_user.js
Normal file
156
flow_user.js
Normal file
@@ -0,0 +1,156 @@
|
||||
let lib = require("./lib.js")
|
||||
let consts = require("./consts.js")
|
||||
let request = require("./core.request.js")
|
||||
|
||||
let GuanZhu = function () {
|
||||
let times = 0;
|
||||
while (lib.page.user.getBtnGuanZhu() && times++ < 10) {
|
||||
lib.page.user.clickBtnGuanZhu()
|
||||
sleep(1000)
|
||||
}
|
||||
if (times > 10) {
|
||||
toastLog("关注失败")
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
let SiXin = function () {
|
||||
return lib.page.user.clickBtnSiXin()
|
||||
}
|
||||
|
||||
let GoToPengYouLieBiao = function () {
|
||||
return lib.page.user.gotoFriend()
|
||||
}
|
||||
|
||||
let GoToYongHuZhuYe = function () {
|
||||
// 如果当前不是抖音应用,则先打开抖音
|
||||
let times = 0;
|
||||
log("package:", currentPackage())
|
||||
if (currentPackage() == "com.tencent.wetype") {
|
||||
back()
|
||||
sleep(1000)
|
||||
}
|
||||
|
||||
while (times++ < 10 && currentPackage() != consts.Package.DouYin) {
|
||||
log("package:", currentPackage())
|
||||
app.launchPackage(consts.Package.DouYin)
|
||||
sleep(1000)
|
||||
let appId = id(consts.AppID()).findOne(1000)
|
||||
if (appId) {
|
||||
appId.click()
|
||||
}
|
||||
sleep(1000)
|
||||
}
|
||||
if (times > 10) {
|
||||
toastLog("打开 抖音 失败")
|
||||
return false
|
||||
}
|
||||
|
||||
log("activity:", currentActivity())
|
||||
times = 0
|
||||
while (times++ < 20) {
|
||||
log("--------------------------")
|
||||
log("package:", currentPackage())
|
||||
log("activity:", currentActivity())
|
||||
|
||||
let activity = currentActivity()
|
||||
|
||||
|
||||
if (activity == "android.widget.FrameLayout") {
|
||||
times--
|
||||
sleep(2000)
|
||||
continue
|
||||
}
|
||||
|
||||
if (activity == "com.bytedance.dux.toast.ToastDialog") {
|
||||
lib.page.user.open()
|
||||
sleep(1000)
|
||||
continue
|
||||
}
|
||||
|
||||
if (activity == "com.ss.android.ugc.aweme.main.MainActivity") {
|
||||
lib.page.user.clickTabMe()
|
||||
break
|
||||
}
|
||||
|
||||
let package = currentPackage()
|
||||
if (package == consts.Package.DouYin && activity != "com.bytedance.dux.toast.ToastDialo") {
|
||||
|
||||
back()
|
||||
}
|
||||
|
||||
sleep(1000)
|
||||
}
|
||||
|
||||
needLoginActivity = "android.inputmethodservice.SoftInputWindow"
|
||||
needLoginActivity1 = "com.ss.android.ugc.aweme.account.business.login.DYLoginActivity"
|
||||
activity = currentActivity()
|
||||
if (activity == needLoginActivity || activity == needLoginActivity1) {
|
||||
log("当前抖音未登录")
|
||||
return false
|
||||
}
|
||||
|
||||
times = 0
|
||||
while (times++ < 10) {
|
||||
if (lib.page.user.getBtnBianJiZiLiao()) {
|
||||
break
|
||||
}
|
||||
lib.page.user.clickTabMe()
|
||||
sleep(500)
|
||||
}
|
||||
|
||||
if (times > 10) {
|
||||
toastLog("进入 个人中心 失败")
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
let HuoQuXinYongHu = function () {
|
||||
//指定确定按钮点击时要执行的动作
|
||||
let body = null;
|
||||
while (true) {
|
||||
body = request.getOneUser()
|
||||
if (!body) {
|
||||
return false
|
||||
}
|
||||
|
||||
lib.store.lastID(body.ID)
|
||||
toastLog("获取到新用户 " + body.Nickname)
|
||||
if (arguments.length > 0) {
|
||||
let isValid = [];
|
||||
|
||||
for (let i = 0; i < arguments.length; i++) {
|
||||
let f = arguments[i]
|
||||
if (f == undefined) {
|
||||
isValid.push(true)
|
||||
continue
|
||||
}
|
||||
|
||||
if (f(body)) {
|
||||
isValid.push(true)
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid.length != arguments.length) {
|
||||
log("用户不符合要求")
|
||||
continue
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
return lib.page.user.openUser(body.UID)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
GuanZhu,
|
||||
SiXin,
|
||||
HuoQuXinYongHu,
|
||||
GoToYongHuZhuYe,
|
||||
GoToPengYouLieBiao,
|
||||
}
|
||||
Reference in New Issue
Block a user