菜鸡源码,专注精品下载!
当前位置:首页 > 建站教程 > 建站知识

分享京东618活动AutoJS脚本

发布时间:2024-01-05  栏目:建站知识   浏览:   分类:js教程 autojs

京东618活动autojs脚本分享是一种自动化抢购脚本,可以帮助用户在京东618活动中自动完成商品抢购。这种脚本通常基于Auto.js或Tasker等自动化工具编写,可以实现自动打开商品页面、自动点击抢购按钮、自动填写收货地址等功能。然而,需要注意的是,使用这种脚本可能违反京东的用户协议,甚至可能导致账号被封禁。因此,在使用前请确保了解相关风险,并谨慎操作。此外,由于京东618活动的抢购机制可能会不断更新,脚本的有效性也可能受到影响。

京东618活动autoJS脚本,参考czj2369大佬的改了一下,我用的autojs4.1.0版本的基本上都能做完。

//判断停留时间varJUDGE_TIME=0;varappName="com.jingdong.app.mall";init();/***初始化*/functioninit(){//子线程监听脚本threads.start(function(){events.setKeyInterceptionEnabled("volume_up",true);//启用按键监听events.observeKey();//监听音量上键按下events.onKeyDown("volume_up",function(event){console.log("脚本退出!")exit();});});console.show();while(true){enterActivity();recoverApp();getNeedSelector();}}/***进入做任务界面*/functionenterActivity(){if(!launch(appName)){console.log('可能未安装京东App')}//console.info("准备进入任务界面");if(!textContains("累计任务奖励").exists()){sleep(1000);if(textContains("累计任务奖励").exists()){console.info("已经在任务界面");sleep(1000);headerXY=id("a96").findOne().bounds();}else{if(desc("浮层活动").exists()){console.info("点击浮层活动");varhuodong=desc("浮层活动").findOne().bounds();randomClick(huodong.centerX(),huodong.centerY());sleep(1000);}//获取进入做任务界面的控件varbutton=className('android.view.View').depth(15).indexInParent(5).drawingOrder(0).clickable();if(button.exists()){console.info("点击进入做任务界面")varrect=button.findOne().click();sleep(1000);}else{console.info("无法进入做任务界面,请手动点入")}}}}/***加入购物车*/functionaddMarketCar(){if(textContains('当前页点击浏览4个').exists()||textContains('当前页浏览加购').exists()){console.info("在加购页面");constproductList=textContains('¥').find()//desc("¥").find();console.info(productList.length);//}//constproductList=className('android.widget.Button').depth(19).clickable().find()varcount=0;for(index=0;index<productList.length;index++){if(count==4){if(back()){sleep(3000)count=0;break;}}if(productList[index].parent().parent().children()[4].click()){//重置计时JUDGE_TIME=0;log("加购浏览任务:正在添加第"+(index+1)+"个商品");sleep(2000);while(true){if(back()){count=count+1;sleep(2000);if(textContains("当前页").exists()){break;}}}}}}}/***获取需要进行的控件*@returns*/functiongetNeedSelector(){sleep(2000)varallSelector,parent=nullallSelector=className('android.view.View').depth(19).indexInParent(3).drawingOrder(0).clickable().find();varflag=falsefor(letindex=0;index<allSelector.length;index++){varparent=allSelector[index].parent()if(parent!=null&&parent.parent()!=null&&parent.parent().childCount()>=3){varr=parent.child(1).text().match(/(\d)\/(\d*)/)if(r[2]-r[1]>0){if(parent.child(2).text().match(/每邀1个好友/))continueif(parent.child(2).text().match(/入会/))continueif(parent.child(2).text().match(/下单/))continueflag=goTask(parent.child(2).text(),parent,r[2]-r[1]);}}}if(!flag){console.error("没有可以做的任务了")//exit()}}functiongoTask(text,parent,count){console.log('需要进行'+count+'次“'+text+'”类任务')//获取去完成按钮varbutton=parent.child(3);for(index=0;index<count;index++){button.click();console.info('正在进行第%s次任务',index+1)if(text.indexOf("8s")>-1){//需要浏览8s的任务timeTask()}elseif(text.indexOf("累计浏览")>-1){while(true){if(textContains("当前页点击浏览").exists()&&textStartsWith("¥").find().length>0){varproduct=textStartsWith("¥").find()[0].parent().parent().parent().childCount();if(product>=4){log("进入浏览任务")for(vari=0;i<=3;i++){if(textStartsWith("¥").find()[i].parent().parent().children()[4].click()){sleep(1000);log("加购并返回");while(!textContains("当前页点击浏览").exists()&&back()){sleep(1000*2);}}}if(back()){sleep(1000);break;}}}elseif(textContains("当前页浏览加购").exists()&&textStartsWith("¥").find().length>0){addMarketCar();break;}}viewAndFollow();}elseif(parent.child(1).text().indexOf("种草")>-1){if(textContains("品牌种草城").exists()){for(varj=0;j<4;j++){if(textContains("喜欢").exists()&&textContains("喜欢").click()){while(!textContains("喜欢").click()&&back()){sleep(1000);}}}}}else{console.log('看下就完成')sleep(1000);viewAndFollow();}}console.info("进行下一个任务")returntrue;}//浏览n秒的任务functiontimeTask(){console.log('等待浏览任务完成...')JUDGE_TIME=0while(true){letfinish_reg=/获得.*?金币|已达上限/if((textMatches(finish_reg).exists()||descMatches(finish_reg).exists())){//等待已完成出现,有可能失败viewAndFollow();break}sleep(1000)JUDGE_TIME++;recoverApp()}}/***返回*/functionviewAndFollow(){console.info("回到任务首页")trytime=0;while(!textContains("累计任务奖励").exists()&&trytime<10){back();sleep(1000);trytime++;}}/***自动判断程序是否卡顿,恢复方法*判断依据:1.不在活动界面2.停留某个界面长达30s*@returns*/functionrecoverApp(){if(!text("累计任务奖励").exists()&&JUDGE_TIME>30){if(back()){//计时器重置JUDGE_TIME=0;console.warn("停留某个页面超过30s,自动返回,重置定时器。");}}}/***点击*@param{横坐标}x*@param{纵坐标}y*/functionrandomClick(x,y){varrx=random(0,5);varry=random(0,5);click(x+rx,y+ry);sleep(2000);returntrue;}



相关文章

    无相关信息
评论
建站知识
建站知识
使用技巧
调试安装
运营推广