赞
踩
Q群:209689138 "ui"; var appName = "与海挂机脚本"; let OutTimeTip = "与海挂机脚本(点击更新)" let workThread = null; let STORAGE = storages.create("与海挂机脚本") let backTag = false; ui.statusBarColor("#FF4FB3FF") ui.layout( <drawer id="drawer"> <vertical> <appbar> <toolbar id="toolbar" bg="#ff4fb3ff" title="{{appName}}"/> </appbar> <vertical gravity="center" layout_weight="1"> <frame> <viewpager h="84" id="pager"> <vertical> <card w="*" h="68" margin="10 8" cardCornerRadius="6dp" cardElevation="2dp" gravity="center"> <linear> <vertical margin="10" layout_gravity="center_vertical" layout_weight="1"> <text id="name" size="18" color="#444444" text="无帐号"/> <text id="integral" padding="1" size="16" text="..." foreground="?selectableItemBackground"/> </vertical> <button id="login" w="90" text="登录账号" color="#ff5d85ff" style="Widget.AppCompat.Button.Borderless.Colored"/> </linear> </card> </vertical> <vertical> <card w="*" h="68" margin="10 8" cardCornerRadius="6dp" cardElevation="2dp" gravity="center"> <linear> <vertical margin="10" layout_gravity="center_vertical" layout_weight="1"> <text id="imei" textIsSelectable="true" size="18" color="#444444" text="{}"/> <text id="Etime" size="16" text="..."/> </vertical> <button id="recharge" w="70" text="绑卡" color="#ff5d85ff" style="Widget.AppCompat.Button.Borderless.Colored"/> </linear> </card> </vertical> </viewpager> </frame> <tabs w="40" id="tabs" tabIndicatorColor="#777777" bg="#cfcfcf" h="2"/> <vertical padding="10 6 0 6" bg="#ffffff" w="*" h="auto" margin="0 5" elevation="1dp"> <Switch id="autoService" w="*" checked="{{auto.service != null}}" textColor="#666666" text="无障碍服务"/> <View h="5"/> <Switch w="*" textColor="#666666" text="不做评论任务" id="noComment"/> </vertical> <vertical margin="0 5" bg="#ffffff" elevation="1dp" padding="5 5 10 5" w="*" h="auto"> <linear> <checkbox id="DYcheck" text="抖音" layout_weight="1"/> <text text="单次运行任务上限↓"/> </linear> <linear> <seekbar id="DYseekbar" max="10" layout_weight="1"/> <text gravity="center" id="DYlimit"/> </linear> </vertical> <vertical margin="0 5" bg="#ffffff" elevation="1dp" padding="5 5 10 5" w="*" h="auto"> <linear> <text text="点赞百分比" size="16" color="#222222"/> <seekbar id="likePercentSeekBar" max="100" layout_weight="1"/> <text gravity="center" id="likePercent"/> </linear> <linear> <text text="评论百分比" size="16" color="#222222"/> <seekbar id="commentPercentSeekBar" max="100" layout_weight="1"/> <text gravity="center" id="commentPercent"/> </linear> </vertical> <linear> <text layout_weight="1" size="19" color="#222222" text="日志"/> <button id="tolog" h="40" text="全部日志" style="Widget.AppCompat.Button.Borderless.Colored"/> </linear> <text paddingLeft="5" size="16" id="oneLog"/> <list bg="#ffffff" elevation="1dp" h="*" id="logList"> <linear> <text size="13" textColor="#555555" text="{{time}} "/> <text size="13" text="{{message}}"/> </linear> </list> </vertical> <button id="start" text="开始运行" tag="ScriptTag" color="#ffffff" bg="#FF4FB3FF" foreground="?selectableItemBackground"/> </vertical> </drawer> ); // 设置滑动模式 ui.logList.setOverScrollMode(2); // 设置滑动页面的标题 ui.pager.setTitles(["", ""]); // 让滑动页面和标签栏联动 ui.tabs.setupWithViewPager(ui.pager); ui.login.click((view) => { var dialog = new android.app.AlertDialog.Builder(activity).create() dialog.setView(new android.widget.EditText(context)) dialog.show(); dialog.setCancelable(false) var window = dialog.getWindow(); window.setDimAmount(0.6); var vv = ui.inflate( <vertical> <text text="与海登录" size="19" color="#000000" padding="12 12"/> <vertical margin="25 0 25 10"> <linear> <text gravity="center" color="#555555" size="17" text="账号 "/> <input textColor="#000000" inputType="number" id="username" w="*"/> </linear> <linear> <text gravity="center" color="#555555" size="17" text="密码 "/> <input textColor="#000000" id="password" w="*"/> </linear> </vertical> <relative> <button id="cancle" layout_alignParentLeft="true" text="取消" style="Widget.AppCompat.Button.Borderless.Colored" w="auto"/> <button id="login" layout_alignParentRight="true" text="登录" style="Widget.AppCompat.Button.Borderless.Colored" w="auto"/> </relative> </vertical>) window.setContentView(vv); vv.cancle.click(() => { dialog.dismiss(); }); vv.login.click(() => { if (!vv.username.text()) { toast("账号不能为空!"); return; } if (!vv.password.text()) { toast("密码不能为空"); return; } threads.start(function () { var pL = login(vv.username.text(), vv.password.text()); if (!pL.data || !pL.data.token) { toast("登录失败!"); return; } toast("登陆成功!"); STORAGE.put("username", vv.username.text()) STORAGE.put("password", vv.password.text()) STORAGE.put("token", pL.data.token); ui.run(function () { // refreshZZ(); }); dialog.dismiss(); }); }); }); // 无障碍开关监控 ui.autoService.setOnCheckedChangeListener(function (widget, checked) { if (checked && !auto.service) { app.startActivity({ action: "android.settings.ACCESSIBILITY_SETTINGS" }); } if (!checked && auto.service) auto.service.disableSelf() ui.autoService.setChecked(auto.service != null) }); // 存储 ui.DYseekbar.setOnSeekBarChangeListener({ onProgressChanged: function (v, i, fromUser) { ui.run(() => { ui.DYlimit.setText("" + i * 10) }) storages.create(appName).put("DYlimit", i * 10) } }) // 存储器 ui.DYseekbar.setProgress(storages.create(appName).get("DYlimit", 200) / 10) ui.likePercentSeekBar.setOnSeekBarChangeListener({ onProgressChanged: function (v, i, fromUser) { ui.run(() => { ui.likePercent.setText("" + i + "%"); }); storages.create(appName).put("likePercent", i); } }); // 评论百分比调整 ui.commentPercentSeekBar.setOnSeekBarChangeListener({ onProgressChanged: function (v, i, fromUser) { ui.run(() => { ui.commentPercent.setText("" + i + "%"); }); storages.create(appName).put("commentPercent", i); } }); // 加载保存的百分比 ui.likePercentSeekBar.setProgress(storages.create(appName).get("likePercent", 50)); ui.commentPercentSeekBar.setProgress(storages.create(appName).get("commentPercent", 50)); // 回到本界面时,resume事件会被触发 ui.emitter.on("resume", () => { // 此时根据无障碍服务的开启情况,同步开关的状态 ui.autoService.checked = auto.service != null; }); // 禁止返回退出脚本 ui.emitter.on("back_pressed", function (event) { if (workThread && workThread.isAlive()) { backTag = true; toast("为防止脚本自动退出,脚本运行时不可返回退出软件"); event.consumed = true; } }) ui.tolog.click(() => { app.startActivity("console") }) ui.integral.click((v) => { if (v.text() == OutTimeTip) { if (!STORAGE.get("username", null)) { toast("未保存账号"); return; } if (!STORAGE.get("password", null)) { toast("未保存密码"); return; } threads.start(function () { var pL = login(STORAGE.get("username", null), STORAGE.get("password", null)); if (!pL.data || !pL.data.token) { toastLog("自动登录失败!" + pL.msg); return; } toast("自动登陆成功!"); STORAGE.put("token", pL.data.token); ui.run(function () { // refreshZZ(); }); }); } }) ui.start.click(() => { ui.start.setText("停止运行"); workThread = threads.start(function () { try { workMain() } catch (e) { console.log(e); } }); }); function workMain() { home() sleep(2000) device.keepScreenOn() // tiktokMonitoring() sleep(2000) app.launchPackage("com.ss.android.ugc.aweme") sleep(2000) goHome() task() } function tiktokMonitoring() { setInterval(() => { try { console.log("监听执行中..."); if (text("添加到主屏幕").exists()) { clickIfExists("取消"); } else if (text("云空间").exists()) { clickIfExists("取消"); } else if (text("朋友推荐").exists()) { clickIfExists("关闭"); } else if (text("使用以下方式打开").exists()) { clickIfExists("抖音"); clickIfExists("仅此一次"); } else if (text("休息一下吧").exists()) { clickIfExists("取消"); } else if (text("对该评论表态").exists()) { clickIfExists("不感兴趣"); } else { var lists = ["同意授权", "不清楚", "跳过", "我知道了", "以后再说", "直接退出", "拒绝", "不满意", "设置私密", "暂不", "暂不公开", "仅使用期间允许", '始终允许', "允许", "好的", "暂不开启", "暂不使用", "一般", "暂不公开"]; for (var i = 0; i < lists.length; i++) { if (clickIfExists(lists[i])) { break; } } } } catch (error) { console.log("监听异常:" + error); } }, 2000) function clickIfExists(textOrDesc) { let element = null; if (text(textOrDesc).exists()) { element = text(textOrDesc).findOne(100); } else if (desc(textOrDesc).exists()) { element = desc(textOrDesc).findOne(100); } if (element) { click(element.bounds().centerX(), element.bounds().centerY()); return true; } else { return false; } } } function randomSlideVideo() { for (let index = 0; index < random(2, 6); index++) { slideVideo(device.width * 0.5, device.height * 0.8, device.width * 0.55, device.height * 0.3, 200); runSleep() } } // 生成随机的延迟时间 function getRandomDelay(minDelay, maxDelay) { return Math.round(Math.random() * (maxDelay - minDelay + 1)) + minDelay; } //随机延迟 function runSleep() { var sr = getRandomDelay(3000, 30000) if (sr > 30000) { sleep(getRandomDelay(3000, 6000)); } else if (sr < 3000) { sleep(getRandomDelay(3000, 30000)); } else if (sr > 3000) { sleep(getRandomDelay(4000, 12000)); } else { sleep(random(2000, 30000)); } } function runSleepl(a, b) { sleep(random(a, b)); } function goHome() { var tmp = "snssdk1128://feed" app.startActivity({ data: tmp }); } function userHome() { if (enabled(true).descMatches("粉丝.*?按钮").exists()) { let fsanniu = className("android.widget.TextView").descMatches("粉丝.*?按钮").findOne(200) clickElement(fsanniu) } } // 定义滑动起始点和结束点 let startX = device.width * 0.9; // 起始点横坐标为屏幕宽度的80% let startY = device.height * 0.5; // 起始点纵坐标为屏幕高度的50% let endX = device.width * 0.1; // 结束点横坐标为屏幕宽度的20% let endY = device.height * 0.5; // 结束点纵坐标为屏幕高度的50% function task() { onShowUserHomeFsAnNiu(); } // 点击用户首页粉丝 function onShowUserHomeFsAnNiu() { sleep(2000) if (desc("首页,按钮").exists() || text("首页").exists()) { randomSlideVideo() sleep(1500) swipe(startX, startY, endX, endY, 300); } sleep(1500) // 直接查找粉丝列表元素 var userListElement = className("android.widget.TextView").text("粉丝").findOne(200); if (userListElement) { clickElement(userListElement) } sleep(1500); if (userHomeListShow()) { go(); } else { back() sleep(1500); onShowUserHomeFsAnNiu() } } // 查找粉丝列表 function userHomeListShow() { sleep(2000); if (className("android.widget.TextView").descMatches("粉丝 \\d+.*?按钮").exists()) { console.log("正在处理粉丝列表"); var listShow = className("android.widget.TextView").descMatches("粉丝 \\d+.*?按钮").findOne(); return clickElement(listShow); } console.log("查找粉丝列表未找到"); return false; } // 开始递归 function go() { sleep(1500); slideVideo(device.width * 0.5, device.height * 0.8, device.width * 0.55, device.height * 0.3, 200); var userListDataContainer = className("androidx.recyclerview.widget.RecyclerView").scrollable(true).findOne(200); if (userListDataContainer) { var userListData = userListDataContainer.children(); if (userListData.length > 3) { var nu = random(3, userListData.length - 1); var data = userListData.get(nu); if (clickElement(data)) { console.log("粉丝列表中第:" + nu + "用户"); sleep(1500); if (true) { sleep(2000) if (onUserAvatar()) { sleep(2000) if (true) { onUserAvatarLike() } sleep(1200) if (true) { onUserAvatarFollow() } back(); } } sleep(1500); onUserHoneWorks(); task(); } } } else { console.log("未找到用户列表容器"); } } // 点开头像 function onUserAvatar() { sleep(1500) var imageView = className("android.widget.ImageView").desc("用户头像,直播中").findOne(200); if (imageView && imageView.parent()) { return false; } var imageViews = className("android.widget.ImageView").desc("用户头像").findOne(200); if (imageViews) { return imageViews.click() } return false; } // 头像中点赞 function onUserAvatarLike() { sleep(1500) var like = className("android.widget.TextView").text("点赞").findOne(200); if (clickElement(like)) { console.log("头像中点赞成功!"); } else { console.log("头像中点赞失败!"); } sleep(1500) } // 头像中关注 function onUserAvatarFollow() { sleep(1500) var follow = className("android.widget.TextView").text("关注").findOne(200); if (clickElement(follow)) { console.log("头像中关注成功!"); } else { console.log("头像中关注失败!"); } sleep(1500) } // 点击工具 function clickElement(element) { return click(element.bounds().centerX(), element.bounds().centerY()); } // 在用户首页进入作品 function onUserHoneWorks() { sleep(1500) if (!className("androidx.recyclerview.widget.RecyclerView").findOne(200)) { return } var works = className("androidx.recyclerview.widget.RecyclerView").findOne(200).children() if (works.length < 1 || text("你可能感兴趣").exists()) { return } var nu = random(1, works.length - 1) const element = works.get(nu); sleep(1500) if (clickElement(element)) { sleep(3000) if (text("善语结善缘,恶言伤人心").exists()) { console.log("第" + nu + "作品"); if (true) { sleep(1500); onWorksLike(); sleep(1200); } if (true) { WorksCommentSetText(); } back(); // 返回上一级页面 } else { back(); // 如果未进入作品详情页面,也返回上一级页面 } } // 等待返回上一级页面 sleep(1500); // 可根据实际情况调整等待时间 } function WorksCommentSetText() { sleep(1500); var onPl = text("善语结善缘,恶言伤人心").findOne(10); if (onPl) { sleep(1500); if (true) { var onplText = text("善语结善缘,恶言伤人心").findOne(10); console.log("执行作品评论"); clickElement(onplText); sleep(1200); setText("终于发作品了!"); sleep(1500); click("发送"); sleep(1500); } sleep(1500); if (true) { sleep(1200); onCommentLike(); back() } } sleep(1500); } // 作品点赞 function onWorksLike() { sleep(1500) var like = descMatches("未点赞,喜欢\\d+,按钮").untilFind(); if(like){ console.log("执行作品点赞"); return like.click(); } return false; } // 评论区点赞 function onCommentLike() { sleep(1500); if (descMatches("评论\\d+,按钮").exists()) { var onpl = descMatches("评论\\d+,按钮").findOne() sleep(1500); onpl.click() sleep(1500); console.log("查找评论列表数据"); slideVideo(device.width * 0.5, device.height * 0.8, device.width * 0.55, device.height * 0.3, 200); sleep(1500); var likeListContainer = className("androidx.recyclerview.widget.RecyclerView").findOne(200); console.log("执行评论区点赞"); if (likeListContainer) { var likeListData = likeListContainer.children(); if (likeListData.length !== 0) { for (var index = 0; index < likeListData.length; index++) { sleep(1500); var nu = random(1, likeListData.length - 1); var target = likeListData.get(nu).findOne(className("android.widget.LinearLayout")); if (target) { console.log("对第" + nu + "评论点赞"); sleep(1500); clickElement(target); sleep(1500); break; } else { console.log("未找到评论元素"); } } } else { console.log("评论列表为空"); } } else { console.log("未找到评论容器元素"); } } } /** * 曲线滑动 * @param {*} qx * @param {*} qy * @param {*} zx * @param {*} zy * @param {*} time */ function slideVideo(qx, qy, zx, zy, time) { 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.02) { let newPoint = bezier_curves(point, i); xxyy = [parseInt(newPoint.x), parseInt(newPoint.y)]; xxy.push(xxyy); } gesture.apply(null, xxy); } /** * 贝塞尔曲线 * @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; }
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。