auto.waitFor();
let see_count = 1000;
app.launchApp(
'刷宝短视频'
);
sleep(4000);
console.show();
authorityCancleTip();
for
(
var
i = 1; i < see_count; i++) {
toast(
"刷宝短视频滑动"
+ i +
'次'
);
console.log(
"刷宝短视频滑动"
+ i +
'次'
+
"总计:"
+ see_count +
"次"
);
shuabaoCloseAD();
randomDownSildeScreen();
randomHeart();
randomFollow();
slideScreenDown(device.width / 2, device.height * 0.8, device.width / 2, device.height * 0.1, 400);
}
home();
function
shuabaoCloseAD() {
let liveVideo=className (
"android.widget.RelativeLayout"
).find();
if
(liveVideo.length>9){
clickScreen();
}
if
(id(
"hotspot_imgdismiss"
).exists()) {
id(
"hotspot_imgdismiss"
).findOnce().click();
}
}
function
slideScreenDown(startX, startY, endX, endY, pressTime) {
swipe(startX, startY, endX, endY, pressTime);
delayTime = random(8000, 10000);
sleep(delayTime);
}
function
clickScreen() {
var
x = device.width - device.width * 0.2;
var
y = device.height - device.height * 0.2;
toastLog(
"点击屏幕"
+ x +
":"
+ y);
let clickResult = click(x, y);
toastLog(clickResult);
}
function
authorityCancleTip() {
if
(text(
"取消"
).exists()){
text(
"取消"
).findOnce().click();
}
if
(id(
"cancel"
).exists()) {
id(
"cancel"
).findOnce().click();
}
}
function
randomUpSildeScreen() {
let randomIndex = random(1, 40);
if
(randomIndex == 1) {
console.log(
"随机上滑被执行了"
);
pressTime = random(200, 500);
swipe(device.width / 2, 500, device.width / 2, device.height - 200, 700);
delayTime = random(8000, 10000);
sleep(delayTime);
}
}
function
randomDownSildeScreen() {
let randomIndex = random(1, 20);
if
(randomIndex == 1) {
console.log(
"连续下滑被执行了"
);
swipe(device.width / 2, device.height * 0.8, device.width / 2, device.height * 0.1, 400);
sleep(2000);
swipe(device.width / 2, device.height * 0.8, device.width / 2, device.height * 0.1, 400);
delayTime = random(8000, 10000);
sleep(delayTime);
}
}
function
randomHeart() {
index = random(1, 10);
if
(index == 6) {
if
(id(
"praise"
).exists()){
id(
"praise"
).findOnce().click();
}
}
}
function
randomFollow() {
index = random(1, 10);
if
(index == 6) {
if
(id(
'tv_ad_attention'
).exists()){
id(
"tv_ad_attention"
).findOnce().click();
}
else
{
if
(text(
"关注"
).exists()){
text(
"关注"
).findOnce().click();
}
}
}
}