Giter Club home page Giter Club logo

robveg's People

Contributors

aohanhongzhi avatar qulingyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

robveg's Issues

处理了很多else, 非常不好看,能跑就行,

处理了很多else, 非常不好看,能跑就行(不懂语法)
需要在购物车页面开启,可能会出现无法识别的情况( 最好配合上下滑动的功能可解决),

const musicNotify = () => {
	const m = '/storage/emulated/0/Download/SnapTube Audio/Like A Dino_(MP3_320K).mp3'
	media.playMusic(m);
	sleep(media.getMusicDuration());
}
const to_mall_cart = () => {
	shopping_cart_btn=id('img_shopping_cart').findOne()
	if(shopping_cart_btn){
		shopping_cart_btn.parent().click() //btn上一级控件可点击
		console.log('已进入购物车')
	}else{
		console.log('未找到购物车按钮,退出')
		exit;
	}
}

const pay = () =>{
	if(textStartsWith('确认并支付').exists()){
		console.log("确认并支付")
		text("确认并支付").findOne().parent().click()
		console.log("确认并支付结束")
		musicNotify()
		back();
	}
	if(textStartsWith('立即支付').exists()){
		console.log("确认并支付")
		textStartsWith('立即支付').findOne().parent().click()
		iKnowExist = textStartsWith('我知道了').exists()
		if(iKnowExist){
			textStartsWith('我知道了').findOne().parent().click()
			pay()
		}
		sorryexist = textStartsWith('抱歉').exists()
		if(sorryexist){
			console.log('抱歉')
			textStartsWith('抱歉').findOne().parent().click()
			if(textStartsWith('我知道了').exists()){
				textStartsWith('我知道了').findOne().parent().click()
			}
		}
		selectall = text('全选').exists()
		if(selectall){
			sleep(50)
			console.log("pay select all")
			submit_order(0)
		}else{
			console.log("pay notify")
			musicNotify()
		}
	}
}

const selectTime = (countT,status) =>{
	console.log("进入选择时间")
	//选择送达时间
	textStartsWith('送达时间').findOne().parent().click()
	var selectedTime=null;
	hourClock_unfilterd=textContains(':00').find()
	hourClock=hourClock_unfilterd.filter(item => item.clickable&&item.checkable&&enabled)
	if(hourClock.length>0){
		selectedTime=hourClock[hourClock.length-1]
	}else{
		quarClock_unfilterd=textContains(':15').find()
		quarClock=quarClock_unfilterd.filter(item => item.clickable&&item.checkable&&enabled)
		if(quarClock.length>0){
			selectedTime=quarClock[hourClock.length-1]
		}else{
			halfClock_unfilterd=textContains(':30').find()
			halfClock=halfClock_unfilterd.filter(item => item.clickable&&item.checkable&&enabled)
			if(halfClock.length>0){
				selectedTime=halfClock[hourClock.length-1]
			}else{
				clock_last_unfilterd=textContains(':45').find()
				clock_last=clock_last_unfilterd.filter(item => item.clickable&&item.checkable&&enabled)
				if(clock_last.length>0){
					selectedTime=clock_last[hourClock.length-1]
				}
			}
		}
	}
	if(selectedTime!=null){
		selectedTime.parent().click()
		sleep(50) 
		status=true
		pay()
	}else{
		countT=countT+1;
		if(countT>18000){
			console.log('抢菜选择时间失败')
			exit;
		}
		sleep(50)
		selectTime(countT,false)

	}
}




const submit_order = (count) => {
	console.show();
	console.log('抢菜第'+count+'次尝试')
	if(textStartsWith('立即支付').exists()){
		console.log("SUBMIT 确认并支付")
		textStartsWith('立即支付').findOne().parent().click()
	}
	//美团买菜 结算按钮无id
	submit_findone=textStartsWith('结算(').exists()

	console.log("开始:" +submit_findone)
	if((!submit_findone) && !text('放弃机会').exists()){
		if(textStartsWith('我知道了').exists()){
			console.log('配送运力已约满')
			sleep(100)
			t1 = textStartsWith('我知道了').exists();
			if(textStartsWith('我知道了')){
				console.log("t1")
				textStartsWith('我知道了').findOne().parent().click()
			}else{
				console.log("t1不存在")
			}
	
		}else if (textStartsWith('放弃机会').exists()){
			console.log('跳过加购')
			textStartsWith('放弃机会').findOne().parent().click()
			selectTime(0,false)
		}else{
			console.log('未找到结算按钮,退出')
		}
		
	}else{
		existFindOne = textStartsWith('结算(').findOne().parent()
		if(submit_findone && textStartsWith('结算(').exists()){
			console.log("结算存在")
			existFindOne.click() //结算按钮点击
		}else{
			console.log("结算按钮不存在, 进行继续")
		}
	}
	sleep(600)

	if(text('返回购物车').exists()){
		text('返回购物车').findOne().parent().click()
	}

	console.log('我知道开始' + count)
	iKnowExist = textStartsWith('我知道了').exists()
	console.log(iKnowExist)
	if(iKnowExist){
		console.log('配送运力已约满')
		textStartsWith('我知道了').findOne().parent().click()
	}else{
		if(textStartsWith('放弃机会').exists()){
			console.log('跳过加购')
			textStartsWith('放弃机会').findOne().parent().click()
		}
		if(textStartsWith('送达时间').exists()){
			console.log('送达时间')
			selectTime(0,false)
		}


	}
	console.log('我知道结束' + count)
	sleep(100)
	count=count+1;
	if(count>18000){
		console.log('抢菜失败')
		exit;
	}
	submit_order(count)
}



const start = () =>{
	console.show();
	console.log('开始抢菜')
    kill_app('美团买菜')
    console.log("关闭 美团买菜")
	const appName = "美团买菜";
	launchApp(appName);
	sleep(600);  
	auto.waitFor()
	//跳过开屏广告
	btn_skip=id('btn_skip').findOne()
	if(btn_skip){
		btn_skip.click()
		console.log('已跳过开屏广告')
	}
	console.log('开始抢菜')
	sleep(600);  
	//跳过后加载首页会有一段时间再加载出购物车


	to_mall_cart()
	sleep(3000) //等待购物车加载完成
	submit_order(0)
}



function kill_app(packageName) {
    var name = getPackageName(packageName);
	console.log(name);
    if (!name) {
        if (getAppName(packageName)) {
            name = packageName;
        } else {
            return false;
        }
    }
    app.openAppSetting(name);
    text(app.getAppName(name)).waitFor();
    let is_sure = textMatches(/(结束运行|.*orce.*)/).findOne();
    if (is_sure.enabled()) {
		if(textMatches(/(结束运行|.*orce.*)/).exists()){
			console.log(textMatches(/(结束运行|.*orce.*)/).find().length);
			console.log(textMatches(/(结束运行|.*orce.*)/).findOne());
		}else{
			console.log("不存在")
		}
		
		textMatches(/(结束运行|.*orce.*)/).findOne().click();
        buttons=textMatches(/(.*强.*|.*停.*|.*结.*|.*行.*|确定|是|OK)/).find()
        if(buttons.length>0){
            buttons[buttons.length-1].parent().click()
			console.log("buttons length  结束")
        }else{
			console.log("结束按钮不存在")
			if(id("button3")){
				id("button3").findOne().click();
				sleep(100)
				console.log("button3  结束")
			}
		}
        if(id("button1")){
			id("button1").findOne().click();
			console.log("button1  结束")
		}
		
        console.log(app.getAppName(name) + "应用已被关闭");
        sleep(700);
        back();
    } else {
        console.log(app.getAppName(name) + "可能不在后台运行");
        back();
    }
}

//start();
 submit_order();

试了三个小时,发现还是放弃了!

首先,早上起来的时候,如果无障碍服务不是开着的话,就行不通了!
其次,我试着试着,发现购物车的ID("img_shopping_cart")忽然不见了,在autojs的控件信息里面找不到,导致无法进入购物车!所以也行不通了

谨慎发布该类脚本

推上不小心刷到
敏感时期,尽量不要使用私人账户/实名社交平台发布,注意保护隐私
祝好

一些修改的建议

1.建议加入时间限制
function robVeg() {
var myDate = new Date();
const hour = myDate.getHours();
if (hour == 6) {
/** you code **/
}
}
2.递归的时候submitOrder(count)中如果使用count = count ++会进入死递归
建议submitOrder(count++)

关于异地抢菜的问题

抢菜地址和当前地址不符时,app会弹出确认地址的弹窗,这个怎么解决?(菜鸟,见谅)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.