各位老铁支持我这么久小弟首先感谢了~
微博小助手UI
刷微博的项目是个老项目,多少年了,我也参于一下,其实没啥东西很简单就是会遇到个三无的ad控件。我实在是没办法了就强制停止在打开了,AD就没了。另外就是做任务有个0-2的任务做起来也不难,我测试了3个手机问题不大。最主要的是微博专业版我做了2个群刷模式,一个是切号模式一个是分身模式,分身我就不多说了大家都知道而且我在之前的快手、凹音和秘乐都说过,今天就简单说说切号模式。其实就是一个给客户端多个帐号来回登录和登出。
分身模式也做了很多修改可以保存动态的名和刷新UI,无须重启就可以刷新UI和执行任务。
其实这个微博项目就是我亚丁号(原薅羊毛专业版)的代码修改的。公共方法和UI构建都都有,绝对值得大家入门一看,高手工作室专业选手请绕行。我意在未大家抛砖引玉。全部代码如下:
"ui"; //#region UI和系统变量 var rootUrl = "http://49.234.93.82";//各位大神小弟自己的服务器别黑谢谢 var rootPath = "/sdcard/亚丁号/微博/"; var storageSign = "AutoWeiBoPro@Sina.com"; var softVersion = "0.6" var softName = "微博小助手" var woolStorage = storages.create(storageSign);//创建本地存储 var videoArray = new Array("微博", "微博1", "微博2", "微博4", "微博5"); var havedVideoChecked = new Map();//已经被选择的小视频集合 var havedVideoTimes = new Map(); // var videoBrushThread = null; var videoSignThread = null; var videoItems = [];//小视频集合 var probabilityValue = 10; //系统默认概率 var loginInfoArray = []; ui.layout( <drawer id="drawer"> <relative id="mainWindows"> <viewpager id="viewpager"> <relative id="welecome"> <vertical w="*" h="*" id="firstPage" gravity="center"> <img w="64" h="64" src="https://ucc.alicdn.com/images/user-upload-01/2022010622400513246.png" /> <text text="欢迎使用{{softName}}" textSize="32sp" textColor="#FFFFFF" gravity="center" /> <text text="滑动屏幕来了解更多信息" marginTop="10" textSize="25sp" textColor="#A0FFFFFF" gravity="center" id="txtTimeTip" /> </vertical> <text id="skip" text="单击此处以跳过" marginBottom="100" textSize="13sp" textColor="#30FFFFFF" gravity="center" layout_alignParentBottom="true" layout_centerHorizontal="true" /> </relative> <vertical id="secondPage" gravity="center"> <text text="{{softName}}" textSize="45sp" textColor="#FFFFFF" gravity="center" /> <text text="让生活更简单" marginTop="10" textSize="15sp" textColor="#A0FFFFFF" gravity="center" /> <webview id="adWebview1" h="*" margin="0 16" /> </vertical> <vertical id="threePage" gravity="center"> <text text="{{softName}}" textSize="45sp" textColor="#FFFFFF" gravity="center" /> <text text="让生活更简单" marginTop="10" textSize="15sp" textColor="#A0FFFFFF" gravity="center" /> <webview id="adWebview2" h="*" margin="0 16" /> </vertical> <vertical id="startpage" > <vertical> <appbar> <toolbar bg="#FF5c50e6" id="toolbar" title="{{softName}}" paddingTop="2dp" h="auto" > </toolbar> <tabs id="drawerTabs" /> </appbar> <viewpager id="woolView" > <frame id="frameFirstTab"> <scroll> <vertical> {/* 开启无障碍服务 */} <vertical> <horizontal > <img w="45" h="45" padding="16" src="https://ucc.alicdn.com/images/user-upload-01/2022010622400510894.png"></img> <Switch id="autoService" paddingTop="12" text="开启无障碍服务" checked="{{auto.service != null}}" textColor="red" textSize="15sp" /> </horizontal> </vertical> {/* 开启悬浮窗权限 */} <vertical> <horizontal > <img w="50" h="50" padding="16" src="https://ucc.alicdn.com/images/user-upload-01/2022010622400615532.png"></img> <Switch id="switchEnbleFloating" paddingTop="16" text="开启悬浮窗权限" checked="{{auto.service != null}}" textSize="15sp" textColor="red" /> </horizontal> </vertical> {/* 分身模式Or切号模式 */} <vertical> <horizontal > <img w="50" h="50" padding="16" src="https://ucc.alicdn.com/images/user-upload-01/2022010622400661585.png"></img> <Switch id='switchSeparationOrSingleApp' text="分身模式OR切号模式(开启是分身模式)" paddingTop="16" textColor="black" /> </horizontal> </vertical> {/* 是否开启控制台 */} <vertical> <horizontal > <img w="50" h="50" padding="16" src="https://ucc.alicdn.com/images/user-upload-01/2022010622400638091.png"></img> <Switch id='switchIsShowConsole' text="是否开启控制台" paddingTop="16" textColor="black" /> </horizontal> </vertical> {/* 是否显示Toast */} <vertical> <horizontal > <img w="50" h="50" padding="16" src="https://ucc.alicdn.com/images/user-upload-01/2022010622400653285.png"></img> <Switch id='switchIsShowToast' text="是否开启Toast提示" paddingTop="16" textColor="black" /> </horizontal> </vertical> {/* 是否强制停止 */} <vertical> <horizontal > <img w="50" h="50" padding="16" src="https://ucc.alicdn.com/images/user-upload-01/2022010622400635047.png"></img> <Switch id='switchIsCloseApp' text="是否强制停止(不是所有手机都支持)" paddingTop="16" textColor="black" /> </horizontal> </vertical> {/* 是否保活无障碍服务 */} <vertical> <horizontal > <img w="50" h="50" padding="16" src="https://ucc.alicdn.com/images/user-upload-01/2022010622400638091.png"></img> <Switch id='switchIsKeepOnline' text="是否保活无障碍服务" paddingTop="16" textColor="black" /> </horizontal> </vertical> {/* Splash时间 */} <vertical> <horizontal > <text text="App启动等待时间(秒):" textColor="red" padding="8 8 8 8" /> <input id="txtWateForTime" text="10" hint="App启动等待时间(秒)" inputType="number" padding="8 8 8 8" /> </horizontal> </vertical> </vertical> </scroll> <horizontal gravity="right|bottom"> <button style="Widget.AppCompat.Button.Colored" id="btnExecuteTasker" text="执行任务" padding="12dp" w="auto" /> <button style="Widget.AppCompat.Button.Colored" id="btnSaveWoolConfig" text="保存配置" padding="12dp" w="auto" /> </horizontal> </frame> <frame id="frameSecondTab"> <scroll> <vertical gravity="center"> <list id="videoList"> <card w="*" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground"> <horizontal gravity="center_vertical"> <horizontal h="auto" w="0" layout_weight="1"> <input id="appIndex" text="{{this.AppIndex}}" inputType="number" padding="8 8 8 8" w="40" gravity="center" /> <text id="appName" text="{{this.AppName}}" textColor="#222222" textSize="16sp" maxLines="1" /> <text id="isSign" text="{{this.IsSign}}" textColor="{{SignColor}}" textSize="16sp" maxLines="1" /> </horizontal> <checkbox id="done" marginLeft="4" marginRight="6" checked="{{this.done}}" /> </horizontal> </card> </list> {/* 占位符 */} <card h="40" w="*" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground"> </card> <vertical> <text text="App名称集合:" textColor="red" padding="8 8 8 8" /> <input line="3" id="txtAppNameArray" text="" inputType="textLongMessage" padding="8 8 8 8" singleLine="false" /> </vertical> </vertical> </scroll> <horizontal gravity="right|bottom"> <button style="Widget.AppCompat.Button.Colored" id="allCheck" text="全选" padding="12dp" w="auto" /> <button style="Widget.AppCompat.Button.Colored" id="unAllCheck" text="反选" padding="12dp" w="auto" /> <button style="Widget.AppCompat.Button.Colored" id="btnSaveAppList" text="保存App配置" padding="12dp" w="auto" /> </horizontal> </frame> <frame id="frameThreeTab"> <scroll> <vertical gravity="center"> <text w="auto" color="#111111" size="26" text="帐号和密码" textColor="black" padding="8 8 8 8" /> <vertical> <text text="登录帐号和密码集合:" textColor="red" padding="8 8 8 8" /> <input line="3" id="txtLoginInfoArray" text="" inputType="textLongMessage" padding="8 8 8 8" singleLine="false" /> </vertical> <text w="auto" color="#111111" size="26" text="示例" textColor="black" padding="8 8 8 8" /> <vertical padding="8 8 8 8"> <text w="auto" color="#228B22" size="16" text="13478970891@iop-163.com" /> <text w="auto" color="#228B22" size="16" text="137988@123456687" /> <text w="auto" color="#228B22" size="16" text="使用@符号分割用户名和密码,换行是新的帐号和密码" padding="8" /> <text text="友情提醒:密码里面不能有@符号" textColor="red" padding="8" /> </vertical> </vertical> </scroll> <horizontal gravity="right|bottom"> <button style="Widget.AppCompat.Button.Colored" id="btnSaveLoginList" text="保存配置" padding="12dp" w="auto" /> </horizontal> </frame> </viewpager> </vertical> </vertical> </viewpager> </relative> {/* drawer */} <vertical id="drawWindows" layout_gravity="left" bg="#ffffff" w="280"> <img w="280" h="200" scaleType="fitXY" src="{{rootUrl}}/upload/profile/WX赞赏码.jpg" /> <scroll> <list id="menu"> <horizontal bg="?selectableItemBackground" w="*"> <img w="50" h="50" padding="16" src="{{icon}}" /> <text textColor="black" textSize="15sp" text="{{title}}" layout_gravity="center" /> </horizontal> </list> </scroll> </vertical> </drawer> ); //#endregion //#region 初始化方法 initializeUI(); initializeData(); initializeEvent(); /** * 初始化UI */ function initializeUI() { ui.woolView.setTitles(["自动刷", "分身设置", "切号配置"]);//设置滑动页面的标题 ui.drawerTabs.setupWithViewPager(ui.woolView);//让滑动页面和标签栏联动 activity.setSupportActionBar(ui.toolbar); activity.window.addFlags(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏 ui.viewpager.overScrollMode = android.view.View.OVER_SCROLL_NEVER;//删除滑动到底时的边缘阴影 //为页面设置渐变色背景 ui.firstPage.backgroundDrawable = GradientDrawable("TL_BR", ["#81C784", "#2E7D32", "#2E7D32"]); ui.secondPage.backgroundDrawable = GradientDrawable("TL_BR", ["#4FC3F7", "#0277BD", "#0277BD"]);//蓝色 ui.threePage.backgroundDrawable = GradientDrawable("TL_BR", ["#FFF176", "#F9A825", "#F9A825"]);//黄色 //ui.fourPage.backgroundDrawable = GradientDrawable("TL_BR", ["#80DEEA", "#0097A7", "#0097A7"]);//浅蓝色 ui.skip.click(() => ui.viewpager.currentItem = ui.viewpager.childCount - 2);//点击跳过则跳转到最后一页 permissionpage = ui.viewpager.childCount - 3;//授权页下标(启动页前一页)(启动页固定最后一页) ui.txtTimeTip.setText("今天是:" + getDate()); ui.adWebview1.loadUrl(rootUrl + "/upload/profile/副业赚钱课.jpg"); ui.adWebview2.loadUrl(rootUrl + "/upload/profile/副业赚钱.jpg"); initializeSDCardConfig(); initializeSecondFrame(); initializeThreeFrame(); initializeRightMenu(); initializeHeaderMenu(); threads.start(function () { woolFloaty(); }); } /** * 初始化第2个frame页 */ function initializeSecondFrame() { //ui.woolVideo.visibility=8 for (let i = 0; i < videoArray.length; i++) { let appName = videoArray[i]; let signMessage = "未签"; let signValue = getSignTime(appName); let signColor = "#FF0000"; if (getDate() == signValue) { signMessage = "已签"; signColor = "#228B22"; } let execTimesMessage = ""; let key = appName + storageSign + getDate(); let havedRunTimes = woolStorage.get("" + key + ""); if (havedRunTimes == null) { execTimesMessage = ("已刷:0分"); } else { if (parseInt(havedRunTimes) < 1000 * 60) { execTimesMessage = ("已刷时间小于1分钟"); } let havedMinute = (havedRunTimes / 1000) / 60;//读取到的时间是毫秒需要转换成秒,转换成秒后在转换成分钟 execTimesMessage = ("已刷:" + havedMinute.toFixed(2) + "分"); } let row = { SignColor: signColor, AppName: videoArray[i], AppIndex: (i + 1), IsSign: signMessage, done: false }; videoItems.push(row); } ui.videoList.setDataSource(videoItems); ui.videoList.on("item_bind", function (itemView, itemHolder) { itemView.done.on("check", function (checked) { let item = itemHolder.item; item.done = checked; let appName = item.AppName; let appIndex = itemView.appIndex.getText(); item.AppIndex = appIndex; if (checked) { havedVideoChecked.put(appName, appIndex); } else { havedVideoChecked.remove(appName); } }); }); ui.videoList.on("item_click", function (item, i, itemView, listView) { itemView.done.checked = !itemView.done.checked; }); } /** * 初始化第三张选项卡 * 同时将帐号信息读取 */ function initializeThreeFrame() { let appArrayFile = rootPath + "配置/" + "Login集合.txt"; if (files.exists(appArrayFile)) { let loginInfos = files.read(appArrayFile).split("\n"); loginInfoArray = loginInfos; ui.txtLoginInfoArray.setText(files.read(appArrayFile)); } else { toastError("文件不存在,文件不存在"); ui.txtLoginInfoArray.setText("文件不存在"); } } /** * 初始化权限菜单 */ function initializeRightMenu() { ui.menu.setDataSource([ { title: "注册", icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAADDElEQVRYR6XXa+iecxgH8M8cyqk1Zs4vLKfmNENJihcOyyHEUJOyVsyU8oIXDiNGyiGyLBRLbEmOG6klRAu1pCTKISJqWNJiTaNv/f7r7tl9+D2Pq543z/29vr/vdf+u0z1NnV2Am3A2dsO/+Bhr8Qx+qaPZGTVtwHFXPInFPbjfcQdWTiJiSMCzuLaS+Do8XYndAesTsBAvjEH4N47Cj2P46BPwFY4ehwzLcO84Pl0CjsDX4xAV7Cc4bRy/LgFX4sVxiAp2O/bBX7W+XQLuwt21JCO4k/FprW+XgCdwQy3JCO48rK/17RLwEhbUkozgLsXrtb5tAg4qpZQmNIl9hpNq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iszSfA3UDNKrk5zbkLgNPAFuBTq+Q9XQMUtXlGwEvABbfC/ef2yZN9AUyZ63G8FyA8PFtX8lBanDUKjFR/2RaJ5c+BAvhHrRp7qx15lgLBb+R1c1PkCfG880Pbz1U2fN8abw1ArM0rwAFg2io53imBugEI/iVtnvPwInDYKvlkW4Dhw6fjofy6UwixPoqiW+f3bvxmEAAhRlyt/QzklxeXbjh/YKttjntJgWLVKCGoAu9aJR/JOj7dKtAA0OYNYLf3VOoVqVMBYl07BmKPJ7qvrjZ+OEiAkUmzI8pxAs+btiJ3pSugzYlw7kVu6LqFxzfMZgFkFaJm//LRuTEXuTPAV1bJO9ptwe9CMBrlR4bnd41eGCjAodmCK+TOA/NWydE2W2CCQYFlrrL7ZfjdccTaLCZ3QSHrLoiPmGGG+CPUFqvkcDuAINEYEVvsXvlTFkAv8/FqUfoxrbL+fQqSHADGrZLTvSyQZVuq1h7wQsx4OFlX8q5UBUraVDwc7aYIZS3YOl+smkkhmBBwcEHJUJQujSYFZm8U5H5ozDhusxPy614XSrNP9v8zYFtagWstxe8DDw5ShVjXXgbxNDBjlXyoFXINQFGfuVMQhcsDvHjKVjaFu6HvEU/VduLE8UY43Pa62vxFR4AwGToZgdjXOGJtmpFuiS4Wq3AZ1ZU8mOaX3hFpYwRsShx6PhWxNg9DoxcI4x/VLzUJW+libb4Ebk/+n8bxalZilvXZmx1uT7hTVmXnbF1J2Umxjl1xUZsXBDzfFOAjL3hHCL5jidU+bx3X4BqtV3jr8KymEH6y76a0mThJzCeS09HN9s943GtpCdd1DqQZlqfmbvHO3etgp4D1wNWAEILfvG88H+Q8x+cn5LfdUF606fvDpJdF+s6BQS3yP0AnBf4C4vh6MKas2UAAAAAASUVORK5CYII=" } ]); ui.menu.on("item_click", item => { switch (item.title) { case "注册": var AdenDeanLoginInfoSign = woolStorage.get("AdenDeanLoginInfoSign"); if (AdenDeanLoginInfoSign == null) { threads.start(function () { registerWindow(); //注册弹窗 }); return; } else { alert("您已经登录无序重复登录!"); } break; case "登录": var AdenDeanLoginInfoSign = woolStorage.get("AdenDeanLoginInfoSign"); if (AdenDeanLoginInfoSign == null) { threads.start(function () { loginWindows(); }); return; } else { alert("您已经登录无序重复登录!"); } break; case "退出登录": woolStorage.remove("AdenDeanLoginInfoSign"); toastWarn("退出成功!"); break; case "日志": app.openUrl(rootUrl + "/app/WoolUpgradeLog.html"); break; case "检查更新": threads.start(function () { let titileAndVersion = ui.toolbar.getTitle(); let appNameAndVersionArray = titileAndVersion.split("v"); let appName = appNameAndVersionArray[0]; let appVersion = appNameAndVersionArray[1]; var url = rootUrl + "/app/WebService.asmx/CheckAppVersion"; var version = appVersion; var res = http.post(url, { "appName": appName, "version": version }); var returnString = res.body.string(); let json = JSON.parse(returnString); if (json.success == "true") { if (json.data.upgrade == "true") { app.openUrl(rootUrl + "/app/WebService.asmx/DownLoadWoolUIApk"); } else { toast("已经是最新版"); } } else { toast("请求远端服务器出现异常!请稍后重试!"); } }); break; case "教程": app.openUrl("https://blog.csdn.net/zy0412326/article/details/104767602"); break; case "关于": dialogs.build({ title: "关于", positive: "确定", items: ["薅羊毛专业版纯属个人爱好,如果涉及到侵权请通知作者,作者会尽快解决相应问题。作者邮箱:zy0412326@sina.com"] }).on("show", (dialog) => { }).show(); break; case "退出平台": ui.finish(); break; } }); //让工具栏左上角可以打开侧拉菜单 ui.toolbar.setupWithDrawer(ui.drawer); } /** * 创建选项菜单(右上角)右上角菜单事件 */ function initializeHeaderMenu() { ui.emitter.on("create_options_menu", menu => { menu.add("日志"); menu.add("打赏"); menu.add("教程"); menu.add("关于"); menu.add("退出"); }); ui.emitter.on("options_item_selected", (e, item) => { switch (item.getTitle()) { case "日志": app.openUrl(rootUrl + "/app/WoolUpgradeLog.html"); break; case "打赏": app.openUrl(rootUrl + "/app/index.aspx"); break; case "教程": app.openUrl("https://blog.csdn.net/zy0412326/article/details/104767602"); break; case "关于": dialogs.build({ title: "关于", positive: "确定", items: ["薅羊毛UI版纯属个人爱好,如果涉及到侵权请通知作者,作者会尽快解决相应问题。作者邮箱:zy0412326@sina.com"] }).on("show", (dialog) => { }).show(); break; case "退出": ui.finish(); break; } e.consumed = true; }); } /** * 初始化系统配置 */ function initializeSDCardConfig() { let appArrayFile = rootPath + "配置/" + "App集合.txt"; if (files.exists(appArrayFile)) { let appNames = files.read(appArrayFile).split("\n"); videoArray = appNames; ui.txtAppNameArray.setText(files.read(appArrayFile)); } else { toastError("文件不存在,使用系统默认配置"); ui.txtAppNameArray.setText("文件不存在,使用系统默认配置"); } //txtLoginInfoArray ui.txtLoginInfoArray.setText("文件不存在"); } /** * 初始化配置数据 */ function initializeData() { var IsShowToast = woolStorage.get("IsShowToast"); if (IsShowToast != null && IsShowToast == "true") { ui.switchIsShowToast.setChecked(true); } else { ui.switchIsShowToast.setChecked(false); } var WateForTime = woolStorage.get("WateForTime"); if (WateForTime != null) { ui.txtWateForTime.setText(WateForTime); } var screenSileTimes = woolStorage.get("screenSileTimes"); var isShowConsole = woolStorage.get("isShowConsole"); if (screenSileTimes != null) { ui.txtScreenSileTimes.setText(screenSileTimes); } var IsCloseApp = woolStorage.get("IsCloseApp"); if (IsCloseApp != null && IsCloseApp == "true") { ui.switchIsCloseApp.setChecked(true); } else { ui.switchIsCloseApp.setChecked(false); } if (isShowConsole != null && isShowConsole == "true") { ui.switchIsShowConsole.setChecked(true); } else { ui.switchIsShowConsole.setChecked(false); } var IsKeepOnline = woolStorage.get("IsKeepOnline"); if (IsKeepOnline != null && IsKeepOnline == "true") { ui.switchIsKeepOnline.setChecked(true); } else { ui.switchIsKeepOnline.setChecked(false); } var SeparationOrSingleApp = woolStorage.get("SeparationOrSingleApp"); if (SeparationOrSingleApp != null && SeparationOrSingleApp == "true") { ui.switchSeparationOrSingleApp.setChecked(true); } else { ui.switchSeparationOrSingleApp.setChecked(false); } } //#endregion //#region 初始化事件 function initializeEvent() { ui.btnExecuteTasker.click(function () { var SeparationOrSingleApp = ui.switchSeparationOrSingleApp.isChecked(); if (SeparationOrSingleApp) { var appArray = mapSort(havedVideoChecked);//排好序列得app if (appArray.length == 0) { alert("分身模式下必须选中相应的app~请前往配置界面勾选要执行的分身~"); return; } } else { let appArrayFile = rootPath + "配置/" + "Login集合.txt"; if (!files.exists(appArrayFile)) { alert("切号模式下必须填写登录帐号和密码~"); return; } } var isShowConsole = ui.switchIsShowConsole.isChecked(); var IsShowToast = ui.switchIsShowToast.isChecked(); var WateForTime = parseInt(ui.txtWateForTime.getText()) * 1000; var IsCloseApp = ui.switchIsCloseApp.isChecked(); var IsKeepOnline = ui.switchIsKeepOnline.isChecked(); var consoleMessage = "不开启控制台"; if (isShowConsole) { consoleMessage = "开启控制台"; } var tipMessage = "确认执行吗?如果配置不正确请点击取消,修正参数达到想要的效果!"; confirm(tipMessage).then(value => { //当点击确定后会执行这里, value为true或false, 表示点击"确定"或"取消" if (value) { threads.start(function () { //在新线程执行的代码 auto.waitFor(); autoBrush(appArray, isShowConsole, IsShowToast, WateForTime, IsCloseApp, IsKeepOnline, SeparationOrSingleApp); }); } else { toastWarn("操作被取消了"); } }); }); ui.btnSaveWoolConfig.click(function () { woolStorage.put("isShowConsole", "" + ui.switchIsShowConsole.isChecked() + ""); woolStorage.put("IsShowToast", "" + ui.switchIsShowToast.isChecked() + ""); woolStorage.put("WateForTime", "" + ui.txtWateForTime.getText() + ""); woolStorage.put("IsCloseApp", "" + ui.switchIsCloseApp.isChecked() + ""); woolStorage.put("IsKeepOnline", "" + ui.switchIsKeepOnline.isChecked() + ""); woolStorage.put("SeparationOrSingleApp", "" + ui.switchSeparationOrSingleApp.isChecked() + ""); toastLog("系统配置保存成功!"); }); ui.btnSaveAppList.click(function () { var appArrayFileName = "App集合.txt"; var configPath = rootPath + "/配置/"; let txtAppNameArray = ui.txtAppNameArray.getText(); if (!files.isDir(rootPath)) { if (files.create(rootPath)) { files.create(configPath) } } else { files.create(configPath) } let configFullPath = configPath + "/" + appArrayFileName; files.remove(configFullPath); files.write(configFullPath, txtAppNameArray);//app集合 toastInfo("App集合文件保存成功!"); let appArrayFile = rootPath + "配置/" + "App集合.txt"; if (files.exists(appArrayFile)) { let appNames = files.read(appArrayFile).split("\n"); videoArray = appNames; ui.txtAppNameArray.setText(files.read(appArrayFile)); } let newVideoItems = []; havedVideoChecked = new Map(); for (let i = 0; i < videoArray.length; i++) { let appName=videoArray[i] let appIndex=parseInt(i)+1 let signMessage = "未签"; let signValue = getSignTime(appName); let signColor = "#FF0000"; if (getDate() == signValue) { signMessage = "已签"; signColor = "#228B22"; } let row = { SignColor:signColor, AppName: appName, AppIndex: appIndex, IsSign:signMessage, done: false}; newVideoItems.push(row); } videoItems = newVideoItems; ui.videoList.setDataSource(videoItems); }); ui.allCheck.click(function () { let newVideoItems = []; havedVideoChecked = new Map(); for (let i = 0; i < videoItems.length; i++) { havedVideoChecked.put(videoItems[i].AppName, videoItems[i].AppIndex); havedVideoTimes.put(videoItems[i].AppName, videoItems[i].ExecTimes) let row = { SignColor: videoItems[i].SignColor, AppName: videoItems[i].AppName, AppIndex: videoItems[i].AppIndex,IsSign: videoItems[i].IsSign, done: true }; newVideoItems.push(row); } videoItems = newVideoItems; ui.videoList.setDataSource(videoItems); }); ui.unAllCheck.click(function(){ let newVideoItems = []; havedVideoChecked = new Map(); for (let i = 0; i < videoItems.length; i++) { havedVideoChecked.remove(videoItems[i].AppName, videoItems[i].AppIndex); havedVideoTimes.remove(videoItems[i].AppName, videoItems[i].ExecTimes) let row = { SignColor: videoItems[i].SignColor, AppName: videoItems[i].AppName, AppIndex: videoItems[i].AppIndex, ExecTimes: videoItems[i].ExecTimes, IsSign: videoItems[i].IsSign, done: false, ExecTimesMessage: videoItems[i].ExecTimesMessage }; newVideoItems.push(row); } videoItems = newVideoItems; ui.videoList.setDataSource(videoItems); }); ui.btnSaveLoginList.click(function () { var appArrayFileName = "Login集合.txt"; var configPath = rootPath + "/配置/"; let txtLoginInfoArray = ui.txtLoginInfoArray.getText(); if (!files.isDir(rootPath)) { if (files.create(rootPath)) { files.create(configPath) } } else { files.create(configPath) } let configFullPath = configPath + "/" + appArrayFileName; files.remove(configFullPath); files.write(configFullPath, txtLoginInfoArray);//app集合 toastInfo("App登录帐号集合文件保存成功!"); }); //btnSaveLoginList } //#endregion //#region 业务方法 /** * 自动刷方法 */ function autoBrush(appArray, isShowConsole, IsShowToast, WateForTime, IsCloseApp, IsKeepOnline, SeparationOrSingleApp) { device.keepScreenDim();//保持屏幕常亮 /** * 是否开启控制台,不建议开启偶尔会遮挡click事件 */ threads.start(function () { if (isShowConsole) { console.show(); console.setPosition(0, device.height / 3); console.setSize(device.width, device.height / 4); } }); let x1 = random(device.width * 0.2, device.width * 0.3); let y1 = device.height * 0.72 let x2 = random(device.width * 0.2, device.width * 0.3); let y2 = device.height * 0.12 let pressTime = 600; let timesInterval = random(3000, 6000) if (!SeparationOrSingleApp) { toastInfo("切号模式") let appName = "微博" if (IsCloseApp) stopApp(appName); app.launchApp(appName);//只有一个快手极速版所以直接Launch就可以,不用包名 sleep(WateForTime);//等待splash时间手机不好长点 clickControl(text("不了谢谢")) for (let i = 0, logins = loginInfoArray.length; i < logins; i++) { let uNameAndPword = loginInfoArray[i].toString().split("@") let userName = uNameAndPword[0] let passWord = uNameAndPword[1] login(userName, passWord) clickControl(text("立即签到")) text("关注").waitFor() if (clickControl(id("redpacketSave"))) { text("用户任务中心").waitFor() swipe(x1, y1, x2, y2, pressTime) sleep(timesInterval) for (let i = 0; i < 6; i++) { brushMicroBlog() } autoClickHeart() autoClickHeart() clickControl(text("领0.1元")) clickControl(text("领0.01元")) clickControl(text("领0.01元")) if (text("用户任务中心").exists() && id("titleLeft").exists()) { clickControl(id("titleLeft")) } } else { toastError("click error") } logout(3) } } else { toastInfo(SeparationOrSingleApp) for (let i = 0, apps = appArray.length; i < apps; i++) { let appName = appArray[i]; if (IsShowToast) toastInfo("当前薅羊毛程序" + appName);//系统日志提示 app.launchApp(appName);//启动App sleep(WateForTime);//启动App时候等待时间 adolescentWindows();//关闭青少年窗口 closeUpgradetWindows();//关闭升级提示框 clickControl(text("立即签到")) if (clickControl(id("redpacketSave"))) { text("用户任务中心").waitFor() let signValue = getSignTime(appName); if (getDate() != signValue) { recordSignTime(appName) stopApp(appName) startApp(appName, WateForTime) clickControl(id("redpacketSave")) text("用户任务中心").waitFor() } swipe(x1, y1, x2, y2, pressTime) sleep(timesInterval) for (let i = 0; i < 6; i++) { brushMicroBlog() } autoClickHeart() autoClickHeart() clickControl(text("领0.1元")) clickControl(text("领0.01元")) clickControl(text("领0.01元")) } else { stopApp(appName) startApp(appName, WateForTime) clickControl(text("立即签到")) if (clickControl(id("redpacketSave"))) { text("用户任务中心").waitFor() let signValue = getSignTime(appName); if (getDate() != signValue) { recordSignTime(appName) stopApp(appName) startApp(appName, WateForTime) clickControl(id("redpacketSave")) text("用户任务中心").waitFor() } swipe(x1, y1, x2, y2, pressTime) sleep(timesInterval) autoReadMicroblog() autoClickHeart() autoClickHeart() clickControl(text("领0.1元")) clickControl(text("领0.01元")) clickControl(text("领0.01元")) } } } } if (IsKeepOnline) { while (true) { keepOnline(); // if (IsKeepOnline) { // launchApp("凹音短视频"); // sleep(10000); // if (IsCloseApp) // stopApp("凹音短视频"); // home(); // } } } } function startApp(appName, WateForTime) { sleepRandom3() app.launchApp(appName);//启动App sleep(WateForTime);//启动App时候等待时间 adolescentWindows();//关闭青少年窗口 closeUpgradetWindows();//关闭升级提示框 } function autoReadMicroblog() { if (clickControl(text("刷微博"))) { sleepRandom3() let x1 = random(device.width * 0.2, device.width * 0.3); let y1 = device.height * 0.72 let x2 = random(device.width * 0.2, device.width * 0.3); let y2 = device.height * 0.12 let pressTime = 600; swipe(x1, y1, x2, y2, pressTime) sleepRandom5() back() } } function autoClickHeart() { if (clickControl(text("点赞"))) { sleep(3000) let likes = desc("喜欢").find(); // toastInfo(likes.length) // for (let i = 0, controlNum = likes.length; i < controlNum; i++) { // toastInfo(likes[i].bounds()); // } if (likes.length > 3) { let b = likes[2].bounds(); clickResult = click(b.centerX(), b.centerY()); sleep(random(1000, 1200)); } sleepRandom5(); back(); } } function login(userName, passWord) { if (clickControl(text("用帐号密码登录"))) { setText(0, userName); setText(1, passWord); return clickControl(text("登录")); } else { sleepRandom5(); if (clickControl(text("用帐号密码登录"))) { setText(0, userName); setText(1, passWord); return clickControl(text("登录")); } return false; } } function logout(times) { for (let i = times; i < 0; i--) { if (times == 0) { return } logout_detail(); stopApp(appName); } } function logout_detail() { if (clickControl(text("我"))) { if (clickControl(desc("设置"))) { if (clickControl(desc("帐号管理"))) { if (clickControl(desc("退出当前帐号"))) { if (clickControl(desc("确定"))) { sleepRandom3() toastLog("退出成功"); return } } } } } } /** * 获取服务器任务 */ function keepOnline() { if (!device.isScreenOn()) { device.wakeUp(); } } function brushMicroBlog() { let x1 = random(device.width * 0.2, device.width * 0.3); let y1 = device.height * 0.72 let x2 = random(device.width * 0.2, device.width * 0.3); let y2 = device.height * 0.12 let pressTime = 600; let timesInterval = random(3000, 6000) if (text("刷微博").exists()) { if (clickControl(text("刷微博"))) { swipe(x1, y1, x2, y2, pressTime) sleep(timesInterval) if (clickControl(id("redpacketSave"))) { swipe(x1, y1, x2, y2, pressTime) sleepRandom3() } } } else { if (text("刷微博").exists()) { if (clickControl(text("刷微博"))) { swipe(x1, y1, x2, y2, pressTime) sleep(timesInterval) if (clickControl(id("redpacketSave"))) { swipe(x1, y1, x2, y2, pressTime) sleepRandom3() } } } else { clickControl(text("领取0.2元")) clickControl(text("领取100积分")) } } } //#endregion //#region 窗体方法 function loginWindows() { var window = floaty.rawWindow( <vertical id="fourPage" gravity="center" background='#80DEEA' > <text text="{{softName}}" textSize="45sp" textColor="#FFFFFF" gravity="center" /> <text text="系统登录" marginTop="10" textSize="25sp" textColor="#A0FFFFFF" gravity="center" /> <vertical > <input id="txtUserName" w="*" marginRight="30" marginLeft="30" singleLine="true" hint="账号" textColorHint="#dd000000" /> <input id="txtPassWord" inputType="textPassword" w="*" marginRight="30" marginLeft="30" singleLine="true" hint="密码" textColorHint="#dd000000" password="true" /> <button style="Widget.AppCompat.Button.Colored" id="btnLogin" text="登录" /> <horizontal gravity="center" > <text id="Register" padding="16">注册账号</text> <text id="closeApp" padding="16">退出系统</text> </horizontal> <horizontal gravity="center" > <text id="txtErrInfo" color="red" /> </horizontal> </vertical> </vertical> ); w = Math.floor(device.width) h = Math.floor(device.height) window.setSize(w, h) window.setPosition(0, 0) window.txtUserName.on("key", function (keyCode, event) { log('keyCode=', keyCode) if (event.getAction() == event.ACTION_DOWN && keyCode == keys.back) { window.disableFocus(); event.consumed = true; } }); window.txtUserName.on("touch_down", () => { window.requestFocus(); window.txtUserName.requestFocus(); }); window.txtPassWord.on("key", function (keyCode, event) { log('keyCode=', keyCode) if (event.getAction() == event.ACTION_DOWN && keyCode == keys.back) { window.disableFocus(); event.consumed = true; } }); window.txtPassWord.on("touch_down", () => { window.requestFocus(); window.txtPassWord.requestFocus(); }); setInterval(() => { }, 1000); window.Register.click(function () { window.close(); threads.start(function () { registerWindow(); return; }); }); window.closeApp.click(function () { window.close(); ui.finish(); }); window.btnLogin.click(function () { var message = threads.disposable(); threads.start(function () { var DeviceId = device.getAndroidId() var UserName = window.txtUserName.getText(); var Password = window.txtPassWord.getText(); let url_address = rootUrl + "/App/Login"; var response = http.post(url_address, { "deviceId": DeviceId, "userName": UserName, "passWord": Password, "loginType": 'code' }); //let url_address = rootUrl + "/App/Login?deviceId=" + DeviceId + "&userName=" + UserName + "&passWord=" + Password + "&loginType=code" //var response = http.get(url_address); var json = response.body.json(); if (json.success == "true") { ui.woolVideo.visibility = 0; //显示挂机按钮?deviceId=" + DeviceId + "&userName=" + UserName + "&passWord=" + Password + "&loginType=code woolStorage.put("AdenDeanUserName", UserName); woolStorage.put("AdenDeanPassWord", Password); woolStorage.put("AdenDeanDeviceId", DeviceId); woolStorage.put("AdenDeanLoginInfoSign", "true"); window.close(); toastInfo("登录成功!"); message.setAndNotify("登录成功!"); } else { //通知主线程接收结果 message.setAndNotify(json.message); } }); window.txtErrInfo.setText(message.blockedGet());//主线程等待通知 }); } function registerWindow() { regWindow = floaty.rawWindow( <vertical gravity="center" background='#80DEEA' > <text text="{{softName}}" textSize="45sp" textColor="#FFFFFF" gravity="center" /> <text text="系统注册" textSize="25sp" textColor="#A0FFFFFF" gravity="center" /> <vertical > <input id="txtInviteCode" w="*" marginRight="30" marginLeft="30" singleLine="true" hint="邀请码" textColorHint="#dd000000" /> <input id="txtMobileCode" inputType="phone" w="*" marginRight="30" marginLeft="30" singleLine="true" hint="手机号" textColorHint="#dd000000" /> <horizontal marginRight="30" marginLeft="30"> <horizontal layout_weight="1"> <input id="txtVerificationCode" w="*" singleLine="true" hint="验证码" textColorHint="#dd000000" /> </horizontal> <text id="getVerificationCode" color="red" text="获取验证码" paddingTop="12" /> </horizontal> <input id="txtPassWord" inputType="textPassword" w="*" marginRight="30" marginLeft="30" singleLine="true" hint="密码" textColorHint="#dd000000" /> <button style="Widget.AppCompat.Button.Colored" id="btnRegist" text="注册" /> <horizontal gravity="center" > <text id="returnLogin" padding="16">返回登录</text> <text id="closeApp" padding="16">退出系统</text> </horizontal> <horizontal gravity="center" > <text id="txtErrInfo" color="red" /> </horizontal> </vertical> </vertical> ); //textPassword w = Math.floor(device.width) h = Math.floor(device.height) regWindow.setSize(w, h); regWindow.setPosition(0, 0); setInterval(() => { }, 1000); regWindow.txtInviteCode.on("key", function (keyCode, event) { if (event.getAction() == event.ACTION_DOWN && keyCode == keys.back) { regWindow.disableFocus(); event.consumed = true; } }); regWindow.txtInviteCode.on("touch_down", () => { regWindow.requestFocus(); regWindow.txtInviteCode.requestFocus(); }); regWindow.returnLogin.click(function () { regWindow.close(); threads.start(function () { loginWindows(); }); return; }); regWindow.closeApp.click(function () { let android_id = device.getAndroidId(); regWindow.close(); ui.finish(); }); regWindow.getVerificationCode.click(function () { let inviteCode = regWindow.txtInviteCode.getText(); if (inviteCode == "") { regWindow.txtErrInfo.setText("邀请码不能为空!"); return; } let mobileCode = regWindow.txtMobileCode.getText(); if (mobileCode == "") { regWindow.txtErrInfo.setText("手机号码不能为空!"); return; } regWindow.txtErrInfo.setText("");//清空错误提示 countDown(60); try { var url = "https://login.taobao.com/member/login.jhtml"; var res = http.post(url, { "TPL_username": username, "TPL_password": password, "MobileCode": mobileCode }); } catch (error) { regWindow.txtErrInfo.setText("获取验证码失败:" + error); } function countDown(seconds) { if (seconds == 0) { regWindow.getVerificationCode.setText("获取验证码"); return; } regWindow.getVerificationCode.setText(seconds + "S"); setTimeout(function () { seconds--; countDown(seconds); }, 1000); } }); regWindow.btnRegist.click(function () { var message = threads.disposable(); threads.start(function () { let DeviceId = device.getAndroidId(); let inviteCode = regWindow.txtInviteCode.getText(); let UserName = regWindow.txtMobileCode.getText(); let verificationCode = regWindow.txtVerificationCode.getText(); let Password = regWindow.txtPassWord.getText(); let url_address = rootUrl + "/App/Register"; var response = http.post(url_address, { "deviceId": DeviceId, "userName": UserName, "passWord": Password, "inviteCode": inviteCode, "inviteType": 'android', "verifCode": verificationCode, }); var json = response.body.json(); if (json.success == "true") { } else { //通知主线程接收结果 message.setAndNotify(json.message); } }); regWindow.txtErrInfo.setText(message.blockedGet());//主线程等待通知 //regWindow.close(); }); } /** * app首页配置信息 * @param {app的名}} appName */ function getAppInfo(appName, deaufltIndex) { let AppKey = appName + "AdenDean"; let AppInfo = woolStorage.get("" + AppKey + ""); if (AppInfo == "" || AppInfo == null) { if (appName == "微视") { let AppInfoArray = [deaufltIndex, "48", false]; return AppInfoArray; } else if (appName == "秘乐短视频") { let AppInfoArray = [deaufltIndex, "7", false]; return AppInfoArray; } else if (appName == "凹音短视频") { let AppInfoArray = [deaufltIndex, "6", false]; return AppInfoArray; } else if (appName == "闪电盒子极速版") { let AppInfoArray = [deaufltIndex, "45", false]; return AppInfoArray; } let AppInfoArray = [deaufltIndex, "60", false]; return AppInfoArray; } else { let appIndex = AppInfo.split("@")[0]; if (appIndex == "") { appIndex = deaufltIndex; } let appExecTimes = AppInfo.split("@")[1]; if (appExecTimes == "") { appExecTimes = 60; } let isCheck = AppInfo.split("@")[2]; if (isCheck == "") { isCheck = false; } let AppInfoArray = [appIndex, appExecTimes, isCheck]; return AppInfoArray; } } /** * 拖动滑块 * */ function dragSlider() { for (var i = 0; i < 0; i++) { sleep(1000); log(i); } while (true) { img = images.captureScreen(); if (img) { log("截图成功。进行识别滑块!"); break; } else { log('截图失败,重新截图'); } } var x = discernSlidingblock(img, device.width) + 65 console.info("识别结果滑块X坐标:" + x); if (x > -1) { randomSwipe(拖动滑块x, 拖动滑块y, x, 拖动滑块y) return true; } else { console.log("识别有误,请确认是否在滑块界面"); return false; } } /** * 计算滑块位置 * @param {图片} img * @param {分辨率} ratio */ function discernSlidingblock(img, ratio) { //创建识别变量 var temp, temp2, x, y, num, color, p, temp3, arr1; //分析设备分辨率 if (ratio == 720) { var tb = [348, 253, 691, 638, 81] log("您的设备分辨率为:720p"); } else if (ratio == 1080) { var tb = [463, 387, 912, 831, 125] log("您的设备分辨率为:1080p"); } else { log("当前设备分辨率不符合规范") return -2 } num = Math.ceil(tb[4] / 3.3 - 4); //计算滑块位置 for (var k = 29; k <= 40; k++) { temp2 = ""; color = "#" + k + "" + k + "" + k + ""; for (var i = 1; i <= num; i++) { temp2 = temp2 + "0|" + i + "|" + color + ","; temp2 = temp2 + i + "|0|" + color + ","; temp2 = temp2 + "1|" + i + "|" + color + ","; temp2 = temp2 + i + "|1|" + color + ","; temp2 = temp2 + "2|" + i + "|" + color + ","; temp2 = temp2 + i + "|2|" + color + ","; } x = 0; while (x > -2) { y = 0; while (y > -2) { temp = ""; for (var i = 1; i <= num; i += 2) { temp = temp + "0|" + (tb[4] + y - i - 1) + "|" + color + ","; temp = temp + (tb[4] + x) + "|" + i + "|" + color + ","; temp = temp + (tb[4] + x) + "|" + (tb[4] + y - i - 1) + "|" + color + ","; temp = temp + (tb[4] + x - i - 1) + "|0|" + color + ","; temp = temp + i + "|" + (tb[4] + y) + "|" + color + ","; temp = temp + (tb[4] + x - i - 1) + "|" + (tb[4] + y) + "|" + color + ","; temp = temp + "1|" + (tb[4] + y - i - 1) + "|" + color + ","; temp = temp + (tb[4] + x - 1) + "|" + i + "|" + color + ","; temp = temp + (tb[4] + x - 1) + "|" + (tb[4] + y - i - 1) + "|" + color + ","; temp = temp + (tb[4] + x - i - 1) + "|1|" + color + ","; temp = temp + i + "|" + (tb[4] + y - 1) + "|" + color + ","; temp = temp + (tb[4] + x - i - 1) + "|" + (tb[4] + y - 1) + "|" + color + ","; } temp = temp + temp2 + "0|0|" + color; arr1 = temp.split(","); var arr2 = new Array(); for (var i = 0; i < arr1.length - 1; i++) { arr2[i] = new Array(); temp3 = arr1[i].split("|"); arr2[i] = [Number(temp3[0]), Number(temp3[1]), temp3[2]]; } try { p = images.findMultiColors(img, color, arr2, { region: [tb[0], tb[1], tb[2] - tb[0], tb[3] - tb[1]], threshold: (Math.floor(k / 10) * 16 + k % 10) }); if (p) { img.recycle(); return p.x } } catch (error) { //出错 console.log("识别失败,错误原因:" + error); return -1; } y = --y; } x = --x; } } try { img.recycle(); } catch (error) { console.log("识别失败,错误原因:" + error); } return -1; } /** * 真人模拟滑动函数 (滑块滑动) * @param {起点x} sx * @param {起点y} sy * @param {终点x} ex * @param {终点y} ey */ function randomSwipe(sx, sy, ex, ey) { //设置随机滑动时长范围 var timeMin = 1000 var timeMax = 3000 //设置控制点极限距离 var leaveHeightLength = 500 //根据偏差距离,应用不同的随机方式 if (Math.abs(ex - sx) > Math.abs(ey - sy)) { var my = (sy + ey) / 2 var y2 = my + random(0, leaveHeightLength) var y3 = my - random(0, leaveHeightLength) var lx = (sx - ex) / 3 if (lx < 0) { lx = -lx } var x2 = sx + lx / 2 + random(0, lx) var x3 = sx + lx + lx / 2 + random(0, lx) } else { var mx = (sx + ex) / 2 var y2 = mx + random(0, leaveHeightLength) var y3 = mx - random(0, leaveHeightLength) var ly = (sy - ey) / 3 if (ly < 0) { ly = -ly } var y2 = sy + ly / 2 + random(0, ly) var y3 = sy + ly + ly / 2 + random(0, ly) } //获取运行轨迹,及参数 var time = [0, random(timeMin, timeMax)] var track = bezierCreate(sx, sy, x2, y2, x3, y3, ex, ey) log("随机控制点A坐标:" + x2 + "," + y2) log("随机控制点B坐标:" + x3 + "," + y3) log("随机滑动时长:" + time[1]) //滑动 gestures(time.concat(track)) } /** * 计算滑动轨迹 */ function bezierCreate(x1, y1, x2, y2, x3, y3, x4, y4) { //构建参数 var h = 100; var cp = [{ x: x1, y: y1 + h }, { x: x2, y: y2 + h }, { x: x3, y: y3 + h }, { x: x4, y: y4 + h }]; var numberOfPoints = 100; var curve = []; var dt = 1.0 / (numberOfPoints - 1); //计算轨迹 for (var i = 0; i < numberOfPoints; i++) { var ax, bx, cx; var ay, by, cy; var tSquared, tCubed; var result_x, result_y; cx = 3.0 * (cp[1].x - cp[0].x); bx = 3.0 * (cp[2].x - cp[1].x) - cx; ax = cp[3].x - cp[0].x - cx - bx; cy = 3.0 * (cp[1].y - cp[0].y); by = 3.0 * (cp[2].y - cp[1].y) - cy; ay = cp[3].y - cp[0].y - cy - by; var t = dt * i tSquared = t * t; tCubed = tSquared * t; result_x = (ax * tCubed) + (bx * tSquared) + (cx * t) + cp[0].x; result_y = (ay * tCubed) + (by * tSquared) + (cy * t) + cp[0].y; curve[i] = { x: result_x, y: result_y }; } //轨迹转路数组 var array = []; for (var i = 0; i < curve.length; i++) { try { var j = (i < 100) ? i : (199 - i); xx = parseInt(curve[j].x) yy = parseInt(Math.abs(100 - curve[j].y)) } catch (e) { break } array.push([xx, yy]) } return array } /** * 判断是否是凌晨 false可以继续执行 * @param {开始执行脚本的日期} execAutoBrushDate * @param {函数调用层级} level */ function checkTimesIsZeroTime(execAutoBrushDate, level) { //execAutoBrushDate="2020-6-4"; //let key = "HavedComputerDateIsExec" +execAutoBrushDate; //getDate(); let key = "HavedComputerDateIsExec" + getDate(); let HavedComputerDateIsExec = woolStorage.get("" + key + ""); //不存储记录每天的1点将无法执行 //toastInfo(key + "key的值" + HavedComputerDateIsExec); //woolStorage.remove(key); if (HavedComputerDateIsExec == null) { //Null本地方存储未存值且不是第一天执行 if (execAutoBrushDate == getDate()) { return false;//当天还不用执行 } else { //说明当前日期大于执行日期 var date = new Date(); var hour = date.getHours(); if (hour == 0) { print("第几次梦境" + level + "层"); if (level == 1) { toastError("回到第一层梦境进入半夜时间并记录已经执行过") woolStorage.put("" + key + "", "true");//记录一下 今天就再也进不来了 } return true; } else { //toastError("日期不等且返回的应该是false") return false; } } } else { if (HavedComputerDateIsExec) { //toastInfo("今天已经计算过" + HavedComputerDateIsExec); //今天已经计算过 return false; } else { return true; //理论值是进不来的 } } } /** * 判断app今日时间否到达 * @param {app名称} appName * @param {app执行时常 单位分钟} execTimes */ function computerExctueTime(appName, execTimes) { let key = appName + storageSign + getDate(); let havedRunTimes = woolStorage.get("" + key + ""); //系统存储已经执行的时间 if (havedRunTimes == null) { return false; } else { let havedMinute = (havedRunTimes / 1000) / 60;//读取到的时间是毫秒需要转换成秒,转换成秒后在转换成分钟 toastLog(appName + "已经执行" + havedMinute.toFixed(2) + '分' + "总计:" + execTimes + "分"); if (havedMinute < execTimes) { return false; } else { return true; } } } //#endregion //#region 公共方法 /** * 休眠随机1秒至3秒 */ function sleepRandom1() { sleep(random(1000, 3000)); } /** * 休眠随机3秒至5秒 */ function sleepRandom3() { sleep(random(3000, 5000)); } /** * 休眠随机5秒至7秒 */ function sleepRandom5() { sleep(random(5000, 7000)); } /** * 休眠随机7秒至9秒 */ function sleepRandom7() { sleep(random(7000, 9000)); } /** * 点击UI上的控件 * @param {UI上的元素} element */ function clickControl(element) { let clickResult = false; try { if (element.exists()) { toastLog("准备click:" + element.findOnce().getText()); let clickable = element.findOnce().clickable();//是否可以点击 if (clickable) { clickResult = element.findOnce().click(); sleep(random(2000, 3200)); } else { let b = element.findOnce().bounds(); clickResult = click(b.centerX(), b.centerY()); sleep(random(2000, 3200)); } } return clickResult; } catch (error) { toastError("clickControl方法出现错误:" + error) return false; } } /** * 元素对象 * @param {ID或name} obj */ function uiSelector(obj) { let element = null; try { if (text(obj).exists()) { element = text(obj); return element; } if (desc(obj).exists()) { element = desc(obj); return element; } if (id(obj).exists()) { element = id(obj); return element; } } catch (error) { return null; } } /** * 强制停止app * @param {应用名称} appName */ function stopApp(appName) { try { openAppSetting(getPackageName(appName)); sleep(3000); if (className("android.widget.Button").text("强行停止").exists()) { className("android.widget.Button").text("强行停止").findOnce().click(); } else { if (text("强行停止").exists()) { text("强行停止").findOnce().click(); } } sleep(3000); if (className("android.widget.Button").text("确定").exists()) { className("android.widget.Button").text("确定").findOnce().click(); toastLog(appName + "已经停止!"); } else { if (text("强行停止").exists()) { text("强行停止").findOnce().click(); toastLog(appName + "已经停止!"); } else { if (text("结束运行").exists()) { text("结束运行").findOnce().click(); sleep(500); if (text("确定").exists()) { text("确定").findOnce().click(); toastLog("MIUI9 Android7" + appName + "已经停止!"); } } } } } catch (e) { toastLog(e); } } /** * 薅羊毛App悬浮框 */ function woolFloaty() { var window = floaty.rawWindow( <relative id='main' layout_width="match_parent" layout_height="wrap_content" alpha="0.6" > <img w="44" h="44" src="#ffffff" circle="true" alpha="0.8" /> <img id="img_logo" w="32" h="32" src="https://ucc.alicdn.com/images/user-upload-01/2022010622400789999.png" gravity="center" layout_gravity="center" /> <img id="logo_click" w="*" h="*" src="#ffffff" alpha="0" /> </relative> ); window.setPosition(0, device.height / 2) setInterval(() => { }, 1000); //记录按键被按下时的触摸坐标 let x = 0; let y = 0; //记录按键被按下时的悬浮窗位置 let windowX; let windowY; //移动窗口 //按下时长超过此值则执行长按等动作 let downTime = 500; //记录定时执行器的返回id let Timeout = 0; window.setSize(100, 100); window.main.setOnTouchListener( function (view, event) { switch (event.getAction()) { case event.ACTION_DOWN: x = event.getRawX(); y = event.getRawY(); windowX = window.getX(); windowY = window.getY(); //创建一个定时器用来定时执行长按操作。 Timeout = setTimeout(() => { toast("薅羊毛线程已经被关闭!"); threads.shutDownAll(); Timeout = 0; }, downTime); return true case event.ACTION_MOVE: //移动距离过大则判断为移动状态 if (Math.abs(event.getRawY() - y) > 5 && Math.abs(event.getRawX() - x) > 5) { //移动状态清除定时器 if (Timeout) { //定时器存在则清除定时器。 clearTimeout(Timeout); Timeout = 0; }; //移动手指时调整悬浮窗位置 window.setPosition(windowX + (event.getRawX() - x), windowY + (event.getRawY() - y)); }; return true; case event.ACTION_UP: if (Timeout) { //清除定时器。 clearTimeout(Timeout); Timeout = 0; //执行点击事件。 toast("点击"); }; return true; } return true } ) } /** * 贝塞尔曲线 * @param {坐标点} ScreenPoint * @param {偏移量} Offset */ function bezier_curves(ScreenPoint, Offset) { cx = 3.0 * (ScreenPoint[1].x - ScreenPoint[0].x); bx = 3.0 * (ScreenPoint[2].x - ScreenPoint[1].x) - cx; ax = ScreenPoint[3].x - ScreenPoint[0].x - cx - bx; cy = 3.0 * (ScreenPoint[1].y - ScreenPoint[0].y); by = 3.0 * (ScreenPoint[2].y - ScreenPoint[1].y) - cy; ay = ScreenPoint[3].y - ScreenPoint[0].y - cy - by; tSquared = Offset * Offset; tCubed = tSquared * Offset; result = { "x": 0, "y": 0 }; result.x = (ax * tCubed) + (bx * tSquared) + (cx * Offset) + ScreenPoint[0].x; result.y = (ay * tCubed) + (by * tSquared) + (cy * Offset) + ScreenPoint[0].y; return result; } /** * 滑动(默认概率是百分之三十) * @param {*} qx * @param {*} qy * @param {*} zx * @param {*} zy * @param {*} time * @param {*} timesInterval */ function slideScreenDown(qx, qy, zx, zy, time, timesInterval, CurveBrushScreen) { if (CurveBrushScreen) { curveDown(qx, qy, zx, zy, time, timesInterval); //曲线概率 } else { lineDown(qx, qy, zx, zy, time, timesInterval); //直线概率 } } /** * 概率0-9 大于3的时候采用曲线概率 小于3的时候直线概率 */ function randomFunction() { return Math.floor(Math.random() * 10); } function curveDown(qx, qy, zx, zy, time, timesInterval) { var xxy = [time]; var point = []; var dx0 = { "x": qx, "y": qy }; var dx1 = { "x": random(qx - 100, qx + 100), "y": random(qy, qy + 50) }; var dx2 = { "x": random(zx - 100, zx + 100), "y": random(zy, zy + 50), }; var dx3 = { "x": zx, "y": zy }; for (var i = 0; i < 4; i++) { eval("point.push(dx" + i + ")"); }; for (let i = 0; i < 1; i += 0.08) { let newPoint = bezier_curves(point, i); xxyy = [parseInt(newPoint.x), parseInt(newPoint.y)] xxy.push(xxyy); } gesture.apply(null, xxy); let randomMin = timesInterval * 1000; let randomMax = (parseInt(timesInterval) + 2) * 1000; let delayTime = random(randomMin, randomMax); sleep(delayTime); } /** * 屏幕向下滑动并延迟8至12秒 */ function lineDown(startX, startY, endX, endY, pressTime, timesInterval) { swipe(startX, startY, endX, endY, pressTime); let randomMin = timesInterval * 1000; let randomMax = (parseInt(timesInterval) + 2) * 1000; let delayTime = random(randomMin, randomMax); sleep(delayTime); } /** * 按照指定概率随机上滑 * @param {*} startX * @param {*} startY * @param {*} endX * @param {*} endY * @param {*} pressTime * @param {*} probability */ function randomUpSildeScreen(startX, startY, endX, endY, pressTime, probability) { let randomIndex = random(1, parseInt(probability)); if (randomIndex == 1) { swipe(startX, startY, endX, endY, pressTime); delayTime = random(12000, 15000); sleep(delayTime); } } /** * 连续下滑对上一个无兴趣 * 其实得和上滑做个排他,既然无兴趣不要在上滑 */ function randomDownSildeScreen(startX, startY, endX, endY, pressTime, timesInterval, probability) { let randomIndex = random(1, parseInt(probability)); if (randomIndex == 1) { swipe(startX, startY, endX, endY, pressTime); sleep(2000); swipe(startX, startY, endX, endY, pressTime); sleep(timesInterval); } } /** * 随机点赞 * @param {点赞ID}} view_id */ function randomHeart(view_id, probability) { index = random(1, parseInt(probability)); if (index == 1) { var target = id(view_id).findOnce(); if (target == null) { return; } else { target.click(); sleep(1000); } } } /** * 随机关注 * @param {控件ID} follow_view_id * @param {概率} probability */ function randomFollow(follow_view_id, probability) { index = random(1, parseInt(probability)); if (index == 1) { var target = id(follow_view_id).findOnce(); if (target == null) { return; } else { target.click(); sleep(1000); } } } /** * 输出Tosat和Info日志 * @param {日志消息} messagge */ function toastInfo(message) { writeLog(message, "info"); } /** * 输出Tosat和Error日志 * @param {日志消息} messagge */ function toastError(message) { writeLog(message, "error"); } /** * * @param {*} message */ function toastLog(message) { writeLog(message, "log"); } function toastWarn(message) { writeLog(message, "warn"); } /** * 写日志,toast、consle和文件日志 * @param {日志内容} loginfo * @param {日志等级} level */ function writeLog(loginfo, level) { try { var logName = getDate() + "_" + "Log.txt"; var logPath = rootPath + "/日志/"; let message = getTime() + "(" + softVersion + "):" + loginfo; if (!files.isDir(rootPath)) { if (files.create(rootPath)) { files.create(logPath) } } else { files.create(logPath) } let logFilePath = logPath + "/" + logName; if (!files.exists(logFilePath)) { files.create(logFilePath); files.write(logFilePath, message + "\r");//写日志 } else { files.append(logFilePath, message + "\r");//追加日志 } toast(message); if (level == "log") { console.log(message); } else if (level == "info") { console.info(message); } else if (level == "warn") { console.warn(message); } else if (level == "error") { console.error(message); } } catch (error) { console.error("系统再写日志的时候出现错误若不影响使用请略过" + error); } } /** * 记录App签到时间 * @param {App名称} appName */ function getSignTime(appName) { let key = appName + storageSign; let value = woolStorage.get(key); return value; } function Color(color) { return android.graphics.Color.parseColor(color); } function GradientDrawable(orientation, color) { var colors = []; color.forEach(color => colors.push(Color(color))); return new android.graphics.drawable.GradientDrawable(android.graphics.drawable.GradientDrawable.Orientation[orientation], colors); } /** * 青少年窗口 */ function adolescentWindows() { if (text("我知道了").exists()) { text("我知道了").findOnce().click(); } if (text("知道了").exists()) { text("知道了").findOnce().click(); } } /** * 升级窗口 */ function closeUpgradetWindows() { if (text("直接无视").exists()) { text("直接无视").findOnce().click(); } if (text("忽略本次").exists()) { text("忽略本次").findOnce().click(); } if (text("稍候再说").exists()) { text("稍候再说").findOnce().click(); } if (text("以后").exists()) { text("以后").findOnce().click(); } if (text("以后更新").exists()) { text("以后更新").findOnce().click(); } } /** * 记录App签到时间 * @param {App名称} appName */ function recordSignTime(appName) { let key = appName + storageSign; let value = getDate(); woolStorage.put(key, value); } /** * 记录App一次运行的时间 * @param {appName} appName * @param {本次运行时间} recordTimes */ function appRunTimeRecord(appName, recordTimes) { let key = appName + storageSign + getDate(); var havedRunTimes = woolStorage.get("" + key + ""); let value = ""; if (havedRunTimes == null) { woolStorage.put(key, parseInt(recordTimes)); } else { value = parseInt(havedRunTimes) + parseInt(recordTimes); woolStorage.put(key, value); } } function clearRunTime(appName) { let key = appName + storageSign + getDate(); toastInfo(key); woolStorage.remove(key) } /** * 秒转换成小时 * @param {*} appCount * @param {*} foreachCount * @param {*} slideTimes * @param {*} timesInterval * @param {*} isExistsLongTimes */ function computerTime(appCount, foreachCount, slideTimes, timesInterval, isExistsLongTimes) { let maxSecond = appCount * foreachCount * slideTimes * timesInterval; let maxHour = maxSecond / 3600; return Math.round(maxHour); } /** * 获取当前时间格式yyyyMMdd */ function getDate() { var date = new Date(); var year = date.getFullYear(); var month = date.getMonth() + 1; if (month < 10) { month = "0" + month; }; var day = date.getDate(); if (day < 10) { day = "0" + day; }; return year + "-" + month + "-" + day; } /** * */ function getTime() { var date = new Date(); var year = date.getFullYear(); var month = date.getMonth() + 1; if (month < 10) { month = "0" + month; }; var day = date.getDate(); if (day < 10) { day = "0" + day; }; var hour = date.getHours(); if (hour < 10) { hour = "0" + hour; }; var minute = date.getMinutes(); if (minute < 10) { minute = "0" + minute; }; var seconds = date.getSeconds(); //获取当前秒数(0-59) var millisecond = date.getMilliseconds(); //获取当前毫秒数(0-999) return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + seconds; }; /** * JS构建Map */ function Map() { var obj = {}; this.put = function (key, value) { obj[key] = value;//把键值绑定到obj对象上 } //size方法,获取Map容器的个数 this.size = function () { var count = 0; for (var attr in obj) { count++; } return count; } //get方法,根据key获取value的值 this.get = function (key) { if (obj[key] || obj[key] === 0 || obj[key] === false) { return obj[key] } else { return null; } } //remove方法,删除方法 this.remove = function (key) { if (obj[key] || obj[key] === 0 || obj[key] === false) { delete obj[key] } } //each方法,遍历方法 this.eachMap = function (callBack) { for (var attr in obj) { callBack(attr, obj[attr]) } } } /** * map排序(核心是冒泡有点笨) */ function mapSort(mapTask) { var arr = []; var result = []; mapTask.eachMap(function (key, value) { arr.push(parseInt(value)); result.push(key); }); var len = arr.length; for (var i = 0; i < len - 1; i++) { for (var j = 0; j < len - 1 - i; j++) { // 相邻元素两两对比,元素交换,大的元素交换到后面 if (arr[j] > arr[j + 1]) { var temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; //value交换key也得换 var keyTemp = result[j + 1]; result[j + 1] = result[j]; result[j] = keyTemp; } } } return result;//返回数组 } /** *点击一下屏幕 */ 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); } //#endregion