Autojs源码 宜优购浏览视频获得金币软件
环境要求:安卓7.0及以上版本,并且需要root权限,因为这个评论输入的时候没有控件来点击,所以采用了模拟按键,需要root权限。软件功能:模拟人工浏览带有奖励的作品获取金币
软件会自动识别需要执行的任务数量和获取的金币量,从而去执行任务。
分享目的:一方面希望给小白学习aj作为一些参考,另一方面抛砖引玉,希望大神能多多分享
管理大大,如果帖子编辑或者有什么问题,请联系我修改,被删帖删怕了,感觉每次都看了版规的。。。。。
宜优购官方客户端下载地址:https://idou.lanzoui.com/itkjSh2lexc
源码js文件及成品软件下载地址:https://idou.lanzoui.com/itkjSh2lexc
懒人直接看源码"ui";
var 配置 = storages.create("peizhi0");
ui.layout(
<ScrollView>
<vertical>
<appbar>
<toolbar id="bt" title="宜优购" />
</appbar>
<Switch id="autoService" text="无障碍服务" checked="{{auto.service != null}}" padding="8 8 8 8" textSize="15sp" />
<horizontal>
<text text="任务次数:" gravity="left" />
<input id="renwu" hint="任务次数" textSize="15sp" inputType="number" gravity="center" />
</horizontal>
<horizontal>
<text text="评论文本路径:" gravity="left" />
<input id="zhpath" hint="文本路径" textSize="15sp" gravity="center" />
</horizontal>
<horizontal>
<text text="日志文本路径:" gravity="left" />
<input id="logpath" hint="文本路径" textSize="15sp" gravity="center" />
</horizontal>
{/* <text text="数据会自动上传数据库 本地同时保留一份" gravity="left" /> */}
<horizontal>
<text id="安卓版本" textSize="15sp" />
</horizontal>
<button id="start" text="开始运行" style="Widget.AppCompat.Button.Colored" />
</vertical>
</ScrollView>
);
ui.autoService.on("check", function (checked) {
if (checked && auto.service == null) {
app.startActivity({
action: "android.settings.ACCESSIBILITY_SETTINGS"
});
}
if (!checked && auto.service != null) {
auto.service.disableSelf();
}
});
ui.emitter.on("resume", function () {
ui.autoService.checked = auto.service != null;
});
var 悬块 = function (window, view) {
if (!window || !view) {
throw "缺参数";
};
this.x = 0, this.y = 0;
this.windowX, this.windowY;
this.downTime = 500;
this.Timeout = 0;
this.Click = function () { };
this.LongClick = function () { };
this.setClick = function (fun) {
//判断参数类型是否为函数?
if (typeof fun == "function") {
this.Click = fun;
};
};
this.setLongClick = function (fun, ji) {
//判断参数类型是否为函数?
if (typeof fun == "function") {
this.LongClick = fun;
//判断参数是否可为设置数字?
if (parseInt(ji) <= 1000) {
this.downTime = parseInt(ji);
};
};
};
view.setOnTouchListener(new android.view.View.OnTouchListener((view, event) => {
switch (event.getAction()) {
//按下事件。
case event.ACTION_DOWN:
//按下记录各种坐标数据。
this.x = event.getRawX();
this.y = event.getRawY();
this.windowX = window.getX();
this.windowY = window.getY();
//创建一个定时器用来定时执行长按操作。
this.Timeout = setTimeout(() => {
this.LongClick();
this.Timeout = 0;
}, this.downTime);
return true;
//移动事件。
case event.ACTION_MOVE:
return true;
//抬起事件。
case event.ACTION_UP:
if (this.Timeout) {
clearTimeout(this.Timeout);
this.Timeout = 0;
this.Click();
};
return true;
};
return true;
}));
};
ui.renwu.text(配置.get("renwu", "500"));
ui.zhpath.text(配置.get("zhpath", "/sdcard/Pictures/评论.txt"));
ui.logpath.text(配置.get("logpath", "/sdcard/log.txt"));
ui.start.on("click", function () {
//程序开始运行之前判断无障碍服务
if (auto.service == null) {
toast("请先开启无障碍服务!");
return;
}
配置.put("renwu", ui.renwu.text());
配置.put("zhpath", ui.zhpath.text());
配置.put("logpath", ui.logpath.text());
xf();
glb();
});
var money = 0;
var time = 0;
var Newmoney = 0;
var Oldmoney = 0;
var plnr = "";
var 数量 = 0;
function glb() {
主线程 = threads.start(function 抖音ll() {
// console.setSize(device.width / 2, device.height / 2);
console.setTitle("YYG");
console.show();
ts("执行操作:脚本开始运行");
app.launch("com.lyl.yyg");
sleep(4000);
if (!requestScreenCapture(false)) {
toastLog("请求截图失败,脚本结束");
exit();
} else {
toastLog("请求截图成功");
// 权限 = false;
}
plnr = files.read(ui.zhpath.text());
while (true) {
main();
if (数量 >= parseInt(ui.renwu.text())) {
log("任务完成");
exit();
}
}
})
}
function main() {
if (packageName("com.lyl.yyg").exists()) {
swipe(device.width * 0.7, device.height / 4, device.width * 0.7, device.height * 0.9, 500);
sleep(2000);
var a = id("com.lyl.yyg:id/iv_gift").findOne(1500);
if (a) {
a.parent().click();
var b = Get_renwu();
if (b) {
click(b.bounds().centerX(), b.bounds().centerY());
sleep(1000);
a = id("com.lyl.yyg:id/tv_like").visibleToUser().findOne(3000);
if (a) {
var res = findColorEquals(captureScreen(), "#ffff3d89", a.bounds().centerX(), a.bounds().centerY(), 10, 10);
if (res) {
a.click();
sleep(random(800,1200));
}
}
a = id("com.lyl.yyg:id/tv_collect").visibleToUser().findOne(3000);
if (a) {
var res = findColorEquals(captureScreen(), "#ffff3d89", a.bounds().centerX(), a.bounds().centerY(), 10, 10);
if (res) {
a.click();
sleep(random(800,1200));
}
}
djs(time);
}
a = id("com.lyl.yyg:id/tv_like").visibleToUser().findOne(3000);
if (a) {
a.click();
sleep(random(800,1200));
}
a = id("com.lyl.yyg:id/tv_collect").visibleToUser().findOne(1000);
if (a) {
a.click();
sleep(random(800,1200));
}
a = id("com.lyl.yyg:id/tv_comment").visibleToUser().findOne(1000);
if (a) {
a.click();
}
a = textStartsWith("留下精彩的评论").visibleToUser().findOne(3000);
if (a) {
a.click();
sleep(random(800,1200));
setText(sj(plnr));
sleep(random(800,1200));
KeyCode(66);
sleep(random(800,1200));
back();
djs1(6);
back();
sleep(500);
}
if (currentActivity() == "com.lyl.yyg.ui.activity.home.view.GoodsIntroductionActivity") {
back();
sleep(2000);
}
// uc = className("android.widget.FrameLayout").boundsInside(0, device.height * 3 / 4, device.width, device.height).visibleToUser().find();
// // log("uc.length=" + uc.length);
// // for (i = 0; i < uc.length; i++) {
// if (uc.length = 3) {
// click(uc.bounds().centerX(), uc.bounds().centerY());
// sleep(1500);
// }
// click(device.width * 5 / 6, device.height - 50);
// sleep(2000);
// Newmoney = Get_money();
// if (Newmoney) {
// // if (Newmoney > Oldmoney) {
// Oldmoney = Newmoney;
// console.error(CurentTime() + " 金币:" + Newmoney);
// 数量 = 数量 + 1;
// log("当前数量:" + 数量 + "/" + ui.renwu.text());
// files.append(ui.logpath.text(), CurentTime() + " 金币:" + Newmoney + "本次奖励:" + money + "时间:" + time + "\r\n");
// // }
// } else {
// log("读取金币余额失败");
// }
// click(device.width / 6, device.height - 50);
// swipe(device.width * 0.7, device.height / 4, device.width * 0.7, device.height * 0.9, 500);
// sleep(1000);
} else {
// swipe(device.width * 0.7, device.height / 4, device.width * 0.7, device.height * 0.9, 500);
// sleep(1000);
}
if (currentActivity() == "com.lyl.yyg.ui.activity.home.view.GoodsIntroductionActivity") {
back();
sleep(2000);
}
} else {
ts("检测:检测客户端不在前台");
app.launch("com.lyl.yyg");
sleep(5000);
}
// }
}
function CurentTime() {
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //时
var mm = now.getMinutes(); //分
var clock = year + "-";
if (month < 10)
clock += "0";
clock += month + "-";
if (day < 10)
clock += "0";
clock += day + " ";
if (hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm;
return (clock);
}
function Get_renwu() {
var a = textMatches("满足以下条件.+金币").visibleToUser().findOne(1000);
if (a) {
money = a.text().replace(/[^0-9]/ig, "");
log("任务奖励:" + money)
}
var a = textMatches("点赞、收藏.+秒").visibleToUser().findOne(1000);
if (a) {
time = a.text().replace(/[^0-9]/ig, "");
log("任务时间:" + time)
// click(a.bounds().centerX(),a.bounds().centerY());
}
return a;
}
function Get_money() {
var a = textMatches("金币总数.+").visibleToUser().findOne(1000);
if (a) {
let money1 = a.text().replace(/[^0-9]/ig, "");
return money1;
}
// uc = className("android.widget.FrameLayout").boundsInside(0, device.height * 1 / 2, device.width, device.height).visibleToUser().find();
// // log("uc.length=" + uc.length);
// // for (i = 0; i < uc.length; i++) {
// if (uc.length = 3) {
// click(uc.bounds().centerX(), uc.bounds().centerY());
// sleep(1000);
// }
}
function djs(TM) //倒计时
{
for (var i = TM; i > 9; i--) {
log("剩余:" + i + "s");
sleep(1000);
}
}
function djs1(TM) //倒计时
{
for (var i = TM; i > 0; i--) {
log("剩余:" + i + "s");
sleep(1000);
}
}
function sj(str) //返回一个随机值,分隔符|
{
if (str) {
str = str.split("\n");
var sjz = random(0, parseInt(str.length) - 1);
return str;
}
}
function xf() {
var thread = threads.start(function op() {
var window = floaty.window(
// <img id="but" src="file://stop.png" />
<button id="but" text="stop" />
);
window.setPosition(10, device.height / 3)
setInterval(() => { }, 500);
var ad = new 悬块(window, window.but);
ad.setLongClick(function () {
log("停止运行");
exit();
});
ad.setClick(function () {
log("停止运行");
exit();
})
})
//创建一个新的悬浮控制模块 ad 并带入参数(所要控制的悬浮窗和用来控制悬浮窗移动的控件)。
}
function ts(text) {
log(text)
}
谢谢分享 谢谢大牛 谢谢大佬 好的,非常感谢 6666666666 6666 感谢楼主分享
页:
[1]