v1版本地址:https://blog.csdn.net/a305822437/article/details/103368949
v2.0 没有考虑到任务按钮竟然还会改名字,并且突然有了个新构思,特此发布v2版本(其实是v3了)
v2.1 修复了历史遗留的问题,并优化了循环
v2.2(max) 应部分朋友v3无法使用的情况,特此重写v2
拥有除v3主菜单功能外的所有特性
/**
* @name 2019支付宝双十二活动
* @author 予我辰心丶
* @version 2.2(max)
*/
//
auto.waitFor();
toastLog("重要说明\n\n1、音量上键可关闭运行脚本");
/***********************
* 关键信息
***********************/
var btn_name = "我要变大红包"//活动任务按钮名称,如有变化,请更改
//更新时间2019/12/5 19:34
var black_list = ["邀请好友助力 (0/20)","邀请好友助力 (1/20)","邀请好友助力 (2/20)","邀请好友助力 (3/20)","邀请好友助力 (4/20)","邀请好友助力 (5/20)","邀请好友助力 (6/20)","邀请好友助力 (7/20)","邀请好友助力 (8/20)","邀请好友助力 (9/20)","邀请好友助力 (10/20)","邀请好友助力 (11/20)","邀请好友助力 (12/20)","邀请好友助力 (13/20)","邀请好友助力 (14/20)","完成一次地铁乘车","体验1笔定期理财","购买1个口碑商品","开启50万保障","1分钱享50万保障","提取1笔黄金奖励","开通余额自动转入","实体店付款1笔","领红包开百万保障","0元开通相互宝","1分钱享全家保障","体验转入功能","1毛起抢地铁周卡","开启400万医疗保障","体验高德打车","设置余额自动转入","到店用花呗付1笔","完成一笔加油支付","参加收益挑战","吃喝玩乐付一笔","邀请家人一起","逛逛还款权益中心","逛一逛体验好服务","公立医院体检预约","完成一笔生活缴费","用支付宝叫滴滴","骑哈啰单车/助力车","下一笔饿了么订单","选1份爆款保险","0元开启健康保障","领888元健康保障","添保障赚现金红包"];
/***********************
* 初始化
***********************/
//标记
var sign_1 = className("android.view.View").text("活动攻略"); //页面加载完毕标记
var sign_2 = className("android.view.View").text("支付记录");//是否参加过活动标记
var err = 1;//错误检测
//音量键功能
threads.start(function(){
events.observeKey();
events.on("key_down", function(keyCode, events){
(keyCode == keys.volume_up) && exit();
});
});
events.on("exit", function(){
(err == 1) && toastLog("脚本已关闭!\n\n如出现异常关闭,请联系作者!");
});
//支付宝双12任务通用规则
var _rule = function () {
threads.start(function() {//返回按钮
while (true) {
desc("返回").depth(9).waitFor();
(!sign_1.exists()) && (desc("返回").depth(9).click());
}
});
threads.start(function() {//取消按钮
while (true) {
desc("取消").waitFor();
(!sign_1.exists()) && (desc("取消").click());
}
});
threads.start(function() {//关闭按钮
while (true) {
className("android.widget.FrameLayout").desc("关闭").waitFor();
(!sign_1.exists()) && className("android.widget.FrameLayout").desc("关闭").click();
}
});
threads.start(function() {//应急处理
var time = 0;
while (true) {
(time > 3) && back();
(time > 3) && toast();
sign_1.exists()?(time = 0):(time += 1);
(sign_1.exists() && text("再玩玩").exists()) && text("再玩玩").findOne().click();
sleep(1000);
}
});
}
//方法
var task = {
Btn:function (e) {
return e.parent();
},
Name:function name(e) {
return e.parent().parent().child(1).text();
},
Enter:function (button) {
let str = button.child(2).text();
let time = 0;
his: while (true) {
if (sign_1.exists()) {
(!str.equals("已完成")) && button.click();
time += 1;
if (time == 3) {
break his;
}
} else {
break his;
}
sleep(500);
}
}
};
/***********************
* 函数
***********************/
var _stop = function () {
var list = engines.all();
//双循环比较
for (var i = 0; i < list.length; i++) {
for (var j = i + 1; j < list.length; j++) {
if (list[i].getSource().toString() == list[j].getSource().toString()) {
list[j].forceStop();
err = 2;toast("请勿重复打开脚本!")
};
};
};
};
var isWhere = function () {
app.launch("com.eg.android.AlipayGphone");
waitForPackage("com.eg.android.AlipayGphone");
if (sign_1.exists()) {
//判断是否第一次参加活动
sign_1.waitFor(); (!sign_2.exists()) && text("我要参与").findOne().click();
className("android.view.View").text(btn_name).findOne().parent().click();
//支付宝双12任务通用规则
_rule();
} else {
app.startActivity({data:"alipays://platformapi/startapp?saId=10000007&clientVersion=3.7.0.0718&qrcode=https%3A%2F%2Fqr.alipay.com%2F04b14414tyqlwmg2wzfdj72%3F_s%3Dweb-other"});
waitForActivity("com.alipay.mobile.nebulacore.ui.H5Activity");sign_1.waitFor();
isWhere();
}
};
/***********************
* 主程序
***********************/
_stop();
isWhere();
me:while (true) {
if (className("android.view.View").text("翻倍豆").exists()) {
let sign = className("android.view.View").text("翻倍豆").find();
let subLog = sign.filter( e => {
return black_list.indexOf(task.Name(e)) == -1;
});
if (subLog.length == 0) {
toastLog("脚本任务已完成,自动退出");
err = 0;
break me;
}
black_list.push(task.Name(subLog[0]));
task.Enter(task.Btn(subLog[0]));
}
}
lock:while(!sign_1.exists()){};
exit();