当前位置: 首页 > news >正文

自动化的抖音

文件命名 main.js
 

var uiModule = require("ui_module.js");
if (!auto.service) {toast("请开启无障碍服务");auto.waitFor();}
var isRunning = true;
var swipeCount = 0;
var targetSwipeCount = random(1, 10);
var window = uiModule.createUI();
uiModule.setTargetSwipeCount(window, targetSwipeCount);
window.stop.click(() => (isRunning = false));
function updateTimer(seconds) {uiModule.updateTimer(window, seconds);
}
function checkForText() {return textContains("点击进入直播间").findOne(1000) != null;
}
threads.start(function () {var width = device.width;var height = device.height;toast("3秒后启动应用");sleep(3000);launchApp("测试");sleep(2000);while (isRunning) {swipeCount = 0;targetSwipeCount = random(1, 10);uiModule.setTargetSwipeCount(window, targetSwipeCount);for (var i = 0; i < targetSwipeCount && isRunning; i++) {if (!isRunning) break;swipe(width / 2, height * 0.8, width / 2, height * 0.2, 500);swipeCount++;uiModule.setSwipeCount(window, swipeCount);var randomWait = random(1, 10);toast("等待: " + randomWait + "秒后继续滑动");uiModule.setRandomWait(window, randomWait);for (var j = randomWait; j > 0 && isRunning; j--) {updateTimer(j);sleep(1000);}if (!isRunning) break;}if (!isRunning) break;if (checkForText()) {toast("发现'点击进入直播间',执行滑动");swipe(width / 2, height * 0.8, width / 2, height * 0.2, 500);} else {var randomWait = random(1, 10);toast("未发现特定文字,等待: " + randomWait + "秒后执行双击");uiModule.setRandomWait(window, randomWait);for (var j = randomWait; j > 0 && isRunning; j--) {updateTimer(j);sleep(1000);}click(width / 2, height / 2);sleep(100);click(width / 2, height / 2);}updateTimer(0);sleep(2000);}window.close();toast("脚本已停止");
});

第二个文件ui_module.js   也是试图 文件 

// 创建UI
function createUI() {var window = floaty.window(<frame><vertical><button id="stop" text="停止" w="120" h="40" bg="#ff0000" /><text id="timer" text="等待: 0s" textSize="14sp" textColor="#ffffff" /><text id="targetSwipeCountText" text="目标滑动次数: 0" textSize="14sp" textColor="#ffffff"/><text id="swipeCountText" text="当前滑动次数: 0" textSize="14sp" textColor="#ffffff"/><text id="randomWaitText" text="随机等待时间: 0s" textSize="14sp" textColor="#ffffff"/></vertical></frame>);window.setPosition(100, 100);  // 设置浮动窗口位置return window;
}// 更新目标滑动次数
function setTargetSwipeCount(window, targetSwipeCount) {ui.run(() => {window.targetSwipeCountText.setText("滑动: " + targetSwipeCount+ '次开始点赞');});
}// 更新当前滑动次数
function setSwipeCount(window, swipeCount) {ui.run(() => {window.swipeCountText.setText("当前滑动次数: " + swipeCount + '次');});
}// 更新随机等待时间
function setRandomWait(window, randomWait) {ui.run(() => {window.randomWaitText.setText("随机等待时间: " + randomWait + "秒");});
}// 更新倒计时
function updateTimer(window, seconds) {ui.run(() => {window.timer.setText("等待: " + seconds + "s");});
}// 导出模块函数
module.exports = {createUI: createUI,setTargetSwipeCount: setTargetSwipeCount,setSwipeCount: setSwipeCount,setRandomWait: setRandomWait,updateTimer: updateTimer
};

http://www.lryc.cn/news/457820.html

相关文章:

  • 无人机之巡航控制篇
  • 面试必问的7大测试分类!一文说清楚!
  • 深信服上网行为管理AC无法注销在线用户
  • 使用GitLab CI构建持续集成案例
  • WSL2环境下Ubuntu的Docker安装与配置
  • 使用vscode调试wails项目(golang桌面GUI)
  • Java中注解与反射的详细介绍
  • Redis 过期时间删除策略详解
  • C语言_内存函数
  • 基于s32ds平台指定变量储存位置
  • 什么是快充协议、支持多协议的USB Type-C受电端取电芯片
  • 在Vue CLI项目中使用ECharts:详细指南
  • 第二阶段:mysql(学完就隐藏版)
  • Spring Cloud微服务
  • 后端复习资料
  • C++和OpenGL实现3D游戏编程【连载14】——VBO、VAO和EBO应用
  • AI + 智能互助平台(一点杂想)
  • 其他浏览器可以联网,但edge不能联网
  • Redis 缓存淘汰策略:LRU 和 LFU 的缺点及解决方案详解
  • 软件工程pipeline梳理
  • npm运行时出现npm ERR! builtins is not a function报错!
  • 2024年软件设计师中级(软考中级)详细笔记【5】软件工程基础知识上(分值10+)
  • C++:vector(题目篇)
  • JS 怎么监听复制事件 并获取复制内容 并修改复制文本内容
  • 安卓使用.9图实现阴影效果box-shadow: 0 2px 6px 1px rgba(0,0,0,0.08);
  • CSS3-Day1
  • 网站集群批量管理-Ansible(ad-hoc)
  • github学生认证(Github Copilot)
  • 【SQL调优指南--附带实例】
  • Java基础(下)