源码下载链接:https://pan.baidu.com/s/1mFGtOcVxMXXrNlKtnkz3Dg 密码:rzk3
之前的被封杀了 ,大家自行下载文件看readme文件。绝对值得你下载一次。
我在贴上公布一些代码大家看一下。
auto.waitFor();//判断和等待开启无障碍
app.launchApp('快手极速版');//只有一个快手极速版所以直接Launch就可以,不用包名
sleep(10000);//等待splash时间
console.show(); //开启日志(悬浮窗权限)
if (className("android.widget.FrameLayout").id("redFloat").exists()) {
console.log("点击redFloat红包");
let b = className("android.widget.FrameLayout").id("redFloat").findOne().bounds();
click(b.centerX(), b.centerY());
sleep(5000);
}
sleep(2000);
swipe(device.width / 2, device.height - 200, device.width / 2, 500, 700);
sleep(2000);
for (let i = 1; i <= 10; i++) {
toastLog("快手极速版专属福利第" + i + "次...");
sleep(1000);
if (className("android.widget.Button").text("福利").exists()) {
console.log("快手极速版福利" + i);
let b = className("android.widget.Button").text("福利").findOne().bounds();
let clickResult = click(b.centerX(), b.centerY());
sleep(13000); //10秒的广告
if (clickResult) {
if (className("android.widget.TextView").text("关闭广告").exists()) {
let b = text("关闭广告").findOne().bounds();
click(b.centerX(), b.centerY());
}
}
}
}
个人版本公共方法代码:
/**
*点击一下屏幕
*/
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);
}
/**
* 屏幕向下滑动并延迟8至12秒
*/
function slideScreenDown(startX, startY, endX, endY, pressTime) {
swipe(startX, startY, endX, endY, pressTime);
let delayTime = random(8000, 12000);
sleep(delayTime);//模仿人类随机时间
}
/**
* 薅羊毛App悬浮框
*/
function woolFloaty() {
var window = floaty.rawWindow(
);
window.setPosition(device.width, 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
}
)
}
/**
* 屏幕向下滑动并延迟8至12秒
*/
function slideScreenDown(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);
}
/**
* 输出Tosat和Info日志
* @param {日志消息} messagge
*/
function toastInfo(message) {
toast(message);
console.info(getTime() + "" + message);
}
/**
* 输出Tosat和Error日志
* @param {日志消息} messagge
*/
function toastError(message) {
toast(message);
console.error(getTime() + "" + message);
}
function toastLog(message) {
toast(message);
console.log(getTime() + "" + message);
}
function toastWarn(message) {
toast(message);
console.warn(getTime() + "" + message);
}
/**
* 链接的数组并返回新数组
* @param {原始数组}} compositeArray
* @param {被链接的数组} concatArray
*/
function concatArray(compositeArray, concatArray) {
for (var element in concatArray) {
if (typeof (concatArray[element]) == "function") {
continue;
}
compositeArray.push(concatArray[element]);
}
return compositeArray;
}
/**
* 获取当前时间格式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;
}
/**
* 获取当前时间格式yyyyMMddHHMMSS
*/
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 sec = date.getSeconds();//得到秒
return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + sec;
}
/**
* 强制停止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();
}
sleep(3000);
if (className("android.widget.Button").text("确定").exists()) {
className("android.widget.Button").text("确定").findOnce().click();
toastLog(appName + "已经停止!");
}
else {
let closeButton = className("android.widget.Button").text("强行停止").find();
closeButton[0].click();
toastLog(appName + "已经停止!");
}
} catch (e) {
toastLog(e);
}
}
/**
* 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])
}
}
}
function bSort(arr) {
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;
}
}
}
return arr;
}
/**
* 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;//返回数组
}
保存配置按钮事件
/**
* 保存配置
*/
ui.btnSaveWoolConfig.click(function () {
woolStorage.put("foreachTimes", "" + ui.txtForeachTimes.getText() + "");
woolStorage.put("screenSileTimes", "" + ui.txtScreenSileTimes.getText() + "");
woolStorage.put("isShowConsole", "" + ui.switchIsShowConsole.isChecked() + "");
woolStorage.put("closeDateTime", "" + ui.txtCloseDateTime.getText() + "");
woolStorage.put("timesInterval", "" + ui.txtScreenSileTimesInterval.getText() + "");
woolStorage.put("isEnableClose", "" + ui.switchIsEnableClose.isChecked() + "");
woolStorage.put("isEnableSign", "" + ui.switchIsEnableSign.isChecked() + "");
woolStorage.put("autoSignTime", "" + ui.txtAutoSignTime.getText() + "");
woolStorage.put("isCloseApp", "" + ui.switchIsCloseApp.isChecked() + "");
toast("配置保存成功!");
});
源码下载链接:https://pan.baidu.com/s/1mFGtOcVxMXXrNlKtnkz3Dg 密码:rzk3