var
LONG_TIME = 8000;
var
SHORT_TIME = 3000;
var
TAP_FLAG =
true
;
var
TAP_INTERVAL = 100;
var
TAP_TIMES = 200;
var
MODE = 1;
auto.waitFor();
var
height = device.height;
var
width = device.width;
setScreenMetrics(width, height);
killOthersAlive();
var
w = floaty.window(
<frame gravity=
"left"
>
<text id=
"text"
textColor=
"black"
bg=
'#ffffff'
>★★★Tips:按下[音量-]键或者长按[悬浮窗内文字]可随时结束脚本</text>
</frame>
);
floatW();
keyDetector();
switch
(MODE) {
case
0:
device.keepScreenDim(30 * 60 * 1000);
lingQuZhifubao();
case
1:
device.keepScreenDim(30 * 60 * 1000);
lingQuZhifubao();
case
2:
device.keepScreenDim(30 * 60 * 1000);
lingQuTaobao();
default
:
toast(
"脚本26行MODE非有效值,脚本结束^_^"
)
sleep(SHORT_TIME);
exit();
}
function
keyDetector() {
threads.start(
function
() {
events.observeKey();
events.on(
"key"
,
function
(code, event) {
var
keyCodeStr = event.keyCodeToString(code);
console.log(code);
console.log(keyCodeStr);
if
(keyCodeStr ==
"KEYCODE_VOLUME_DOWN"
) {
toast(
"检测到音量下键,程序已结束。"
);
device.cancelKeepingAwake();
exit();
}
});
});
}
function
lingQuTaobao() {
app.startActivity({
packageName:
"com.taobao.taobao"
,
className:
"com.taobao.tao.TBMainActivity"
});
ui.run(
function
() {
w.text.setText(
"★★★Tips:若长时间无反应请手动打开淘宝首页"
);
});
text(
"今日爆款"
).waitFor();
sleep(1000);
ui.run(
function
() {
w.text.setText(
"★★★Tips:按下[音量-]键或者长按[悬浮窗内文字]可随时结束脚本"
);
});
id(
"rv_main_container"
).findOne().child(4).child(0).child(0).click();
toast(
"进入活动页"
);
className(
"android.widget.Button"
).text(
"我的猫,点击撸猫"
).findOne(LONG_TIME);
if
(text(
"亲爱的主人我去芭芭农场玩耍了快来找我回家吧~"
).exists()) {
ui.run(
function
() {
w.text.setText(
"★★★猫跑去芭芭农场了,请手动完成任务后返回活动主页"
);
});
className(
"android.widget.Button"
).text(
"我的猫,点击撸猫"
).waitFor();
ui.run(
function
() {
w.text.setText(
"★★★Tips:按下[音量-]键或者长按[悬浮窗内文字]可随时结束脚本"
);
});
}
if
(text(
"获得一个待开奖的彩蛋"
).exists()) {
text(
"好的,11月11日见"
).findOne().click();
toast(
"领取彩蛋成功"
);
sleep(SHORT_TIME);
}
if
(className(
"android.widget.Button"
).textContains(
"点击领取"
).exists()) {
className(
"android.widget.Button"
).textContains(
"点击领取"
).findOne().click();
text(
"去喂猫 赚更多喵币"
).waitFor();
text(
"去喂猫 赚更多喵币"
).findOne().click();
sleep(SHORT_TIME);
}
className(
"android.widget.Button"
).text(
"赚喵币"
).findOne().click()
toast(
"赚喵币"
);
sleep(SHORT_TIME * 2);
if
(text(
"签到"
).exists()) {
text(
"签到"
).findOne().click();
sleep(SHORT_TIME);
toast(
"签到成功"
);
sleep(2000);
}
while
(text(
"去浏览"
).exists()) {
toast(
"存在去浏览"
);
text(
"去浏览"
).findOne().click();
sleep(1500);
swipe(width / 2, height - 500, width / 2, 0, 500);
sleep(2500);
swipe(width / 2, height - 500, width / 2, 0, 500);
sleep(10000);
swipe(width / 2, height - 500, width / 2, 0, 500);
sleep(8000);
back();
sleep(SHORT_TIME + 1000);
if
(!text(
"累计任务奖励"
).exists()) {
back();
sleep(SHORT_TIME);
}
}
if
(textContains(
"邀请好友一起撸猫"
).exists()) {
toast(
"有邀请任务"
);
while
(text(
"去完成"
).exists()) {
var
tmp = text(
"去完成"
).findOnce(1);
if
(tmp ==
null
) {
break
;
}
toast(
"存在新任务"
);
tmp.click();
sleep(2500);
swipe(width / 2, height - 600, width / 2, 0, 500);
sleep(3500);
swipe(width / 2, height - 600, width / 2, 0, 500);
sleep(10000);
swipe(width / 2, height - 600, width / 2, 0, 500);
sleep(9000);
back();
sleep(SHORT_TIME + 1000);
}
}
else
{
toast(
"无邀请任务"
);
while
(text(
"去完成"
).exists()) {
toast(
"存在新任务"
);
text(
"去完成"
).findOne().click();
sleep(2500);
swipe(width / 2, height - 600, width / 2, 0, 500);
sleep(3500);
swipe(width / 2, height - 600, width / 2, 0, 500);
sleep(10000);
swipe(width / 2, height - 600, width / 2, 0, 500);
sleep(9000);
back();
sleep(SHORT_TIME + 1000);
}
}
while
(text(
"去搜索"
).exists()) {
toast(
"存在去搜索"
);
text(
"去搜索"
).findOne().click();
sleep(1500);
swipe(width / 2, height - 500, width / 2, 0, 500);
sleep(2500);
swipe(width / 2, height - 500, width / 2, 0, 500);
sleep(10000);
swipe(width / 2, height - 500, width / 2, 0, 500);
sleep(8000);
back();
sleep(SHORT_TIME + 1000);
}
while
(text(
"去逛逛"
).exists()) {
toast(
"存在去逛逛"
);
text(
"去逛逛"
).findOne().click();
sleep(1500);
swipe(width / 2, height - 500, width / 2, 0, 500);
sleep(2500);
swipe(width / 2, height - 500, width / 2, 0, 500);
sleep(10000);
swipe(width / 2, height - 500, width / 2, 0, 500);
sleep(8000);
back();
sleep(SHORT_TIME + 1000);
}
toast(
"领取完成..."
);
if
(TAP_FLAG) {
back();
sleep(SHORT_TIME + 1000);
id(
"rv_main_container"
).findOne().child(4).child(0).child(0).click();
taptap();
}
home();
toast(
"脚本结束^_^"
);
device.cancelKeepingAwake();
sleep(SHORT_TIME);
exit();
}
function
lingQuZhifubao() {
app.startActivity({
packageName:
"com.eg.android.AlipayGphone"
,
className:
"com.eg.android.AlipayGphone.AlipayLogin"
});
ui.run(
function
() {
w.text.setText(
"★★★Tips:若长时间无反应请手动打开支付宝首页"
);
});
text(
"扫一扫"
).waitFor();
sleep(2000);
ui.run(
function
() {
w.text.setText(
"★★★如等待较长请手动进入支付宝活动页"
);
});
var
target=className(
"android.widget.RelativeLayout"
).idContains(
"home_adbannerview"
).findOne(SHORT_TIME);
if
(target==
null
) {
target = className(
"android.widget.FrameLayout"
).descContains(
"双11狂欢节"
).findOne(2000);
if
(target.bounds().right < (width / 2)) {
target = className(
"android.widget.FrameLayout"
).desc(
"双11狂欢节"
).findOnce(1);
}
click(target.bounds().centerX(), target.bounds().centerY());
}
else
{
target = descContains(
"双11来了,瓜分20亿红包"
).findOne(2000);
if
(target !=
null
) {
click(parseInt(width / 2), target.bounds().bottom - 100);
}
else
{
target = idContains(
"home_grid_notice_container"
).findOne();
click(parseInt(width / 2), target.bounds().top - 100);
}
}
textContains(
"我的猫,点击撸猫"
).waitFor();
sleep(1000);
ui.run(
function
() {
w.text.setText(
"★★★Tips:按下[音量-]键或者长按[悬浮窗内文字]可随时结束脚本"
);
});
if
(text(
"获得一个待开奖的彩蛋"
).exists()) {
text(
"好的,11月11日见"
).findOne().click();
toast(
"领取彩蛋成功"
);
sleep(SHORT_TIME);
}
if
(className(
"android.widget.Button"
).textContains(
"点击领取"
).exists()) {
className(
"android.widget.Button"
).textContains(
"点击领取"
).findOne().click();
text(
"去喂猫 赚更多喵币"
).waitFor();
text(
"去喂猫 赚更多喵币"
).findOne().click();
sleep(SHORT_TIME);
}
toast(
"赚喵币"
);
if
(className(
"android.widget.Button"
).text(
"赚喵币"
).exists()) {
className(
"android.widget.Button"
).text(
"赚喵币"
).findOne().click();
sleep(SHORT_TIME * 2);
}
if
(text(
"签到"
).exists()) {
text(
"签到"
).findOne().click();
sleep(SHORT_TIME);
toast(
"签到成功"
);
sleep(2000);
}
while
(text(
"逛一逛"
).exists()) {
toast(
"存在逛一逛"
);
text(
"逛一逛"
).findOne().click();
sleep(18000);
back();
sleep(SHORT_TIME + 1000);
if
(text(
"好的,我知道了"
).exists()) {
text(
"好的,我知道了"
).findOne().click();
sleep(SHORT_TIME);
}
if
(text(
"残忍离开"
).exists()) {
text(
"残忍离开"
).findOne().click();
sleep(SHORT_TIME);
}
}
if
(text(
"去芭芭农场施肥一次"
).exists()) {
text(
"去芭芭农场施肥一次"
).findOne().parent().child(3).click();
ui.run(
function
() {
w.text.setText(
"★★★正在运行[去芭芭农场施肥一次]任务,如等待较长请手动操作完成"
);
});
sleep(SHORT_TIME);
target = className(
"android.widget.Image"
).idContains(
"game"
).findOne().parent().parent().parent().parent().child(3);
target.click();
var
t = text(
"去签到"
).findOne(3000);
if
(t !=
null
) {
t.click();
}
else
{
toast(
"未找到[去签到],如肥料不够请手动获取"
);
}
className(
"android.widget.Image"
).idContains(
"game"
).findOne().parent().parent().parent().parent().parent().child(3).child(0).child(1).click();
sleep(1000);
target = className(
"android.widget.Image"
).idContains(
"game"
).findOne().bounds();
click(target.centerX() + 230, target.centerY() + target.height() * 0.09);
t = text(
"去施肥"
).findOne(1000);
if
(t !=
null
) {
t.click();
}
sleep(1000);
target = className(
"android.widget.Image"
).idContains(
"game"
).findOne().parent().parent().parent().parent().child(3);
click(width / 2, target.bounds().centerY());
back();
text(
"好的,我知道了"
).findOne().click();
ui.run(
function
() {
w.text.setText(
"★★★Tips:按下[音量-]键或者长按[悬浮窗内文字]可随时结束脚本"
);
});
sleep(SHORT_TIME);
}
if
(text(
"去蚂蚁森林给好友浇水"
).exists()) {
ui.run(
function
() {
w.text.setText(
"★★★正在运行[浇水]任务,如浇水上限/等待较长请手动操作完成"
);
});
text(
"去蚂蚁森林给好友浇水"
).findOne().parent().child(3).click();
text(
"种树"
).waitFor();
swipe(width / 2, height - 300, width / 2, 0, 500);
toast(text(
"总排行榜"
).findOne().parent().parent().child(12).child(0).bounds());
text(
"总排行榜"
).findOne().parent().parent().child(12).child(0).click();
textEndsWith(
"的蚂蚁森林"
).waitFor();
sleep(1000);
target = idContains(
"J_tree_dialog_wrap"
).findOne().bounds();
click(target.centerX() - 50, target.bottom - 50);
className(
"android.widget.Button"
).text(
"浇水送祝福"
).findOne().click();
sleep(1000)
back();
sleep(2000);
back();
text(
"好的,我知道了"
).findOne().click();
}
if
(className(
"android.widget.Button"
).textContains(
"关闭任务弹窗"
).exists()){
className(
"android.widget.Button"
).textContains(
"关闭任务弹窗"
).findOne().click();
sleep(500);
}
if
(className(
"android.widget.Button"
).textContains(
"点击领取"
).exists()) {
className(
"android.widget.Button"
).textContains(
"点击领取"
).findOne().click();
text(
"去喂猫 赚更多喵币"
).waitFor();
text(
"去喂猫 赚更多喵币"
).findOne().click();
}
if
(MODE == 1) {
if
(TAP_FLAG){
toast(
"开始扁猫猫"
);
taptap();
}
toast(
"无[逛一逛]任务,脚本结束^_^"
);
device.cancelKeepingAwake();
sleep(SHORT_TIME);
exit();
}
else
{
toast(
"无[逛一逛]任务\n结束支付宝,等待打开淘宝..."
);
lingQuTaobao();
}
}
function
taptap() {
toast(
"开始狂扁猫猫功能"
);
className(
"android.widget.Button"
).text(
"我的猫,点击撸猫"
).waitFor();
for
(
var
i = 0; i < TAP_TIMES; i++) {
click(parseInt(width / 2), parseInt(height / 2));
sleep(TAP_INTERVAL);
}
toast(
"扁猫结束"
);
}
function
floatW() {
setInterval(() => {}, 1000);
w.setPosition(0, height - 800);
w.setSize(400, 300);
w.setAdjustEnabled(
true
);
w.text.longClick(() => {
device.cancelKeepingAwake();
toast(
"检测到长按悬浮窗文字,脚本终止"
);
try
{
exit();
}
catch
(err) {}
return
true
;
});
}
function
killOthersAlive() {
var
allEngines = engines.all();
for
(
var
i = 0; i < allEngines.length; i++) {
if
(allEngines[i] != engines.myEngine()) {
allEngines[i].forceStop();
}
}
}