找回密码
  注册[Register]
查看: 1067|回复: 7

Autojs源码 宜优购浏览视频获得金币软件

[复制链接]
发表于 2020-10-1 13:16 | 显示全部楼层 |阅读模式
禁止求评分、诱导评分、互刷评分、互刷悬赏值,违规者封号处理。
禁止发布推广、邀请码、邀请链接、二维码或者有利益相关的任何推广行为。
所有非原创软件请发布在【精品软件区】,发帖必须按照本版块版规格式发帖。

环境要求:安卓7.0及以上版本,并且需要root权限,因为这个评论输入的时候没有控件来点击,所以采用了模拟按键,需要root权限。
软件功能:模拟人工浏览带有奖励的作品获取金币
软件会自动识别需要执行的任务数量和获取的金币量,从而去执行任务。

分享目的:一方面希望给小白学习aj作为一些参考,另一方面抛砖引玉,希望大神能多多分享

管理大大,如果帖子编辑或者有什么问题,请联系我修改,被删帖删怕了,感觉每次都看了版规的。。。。。

宜优购官方客户端下载地址:https://idou.lanzoui.com/itkjSh2lexc


源码js文件及成品软件下载地址:https://idou.lanzoui.com/itkjSh2lexc


懒人直接看源码
  1. "ui";
  2. var 配置 = storages.create("peizhi0");
  3. ui.layout(
  4.     <ScrollView>
  5.         <vertical>
  6.             <appbar>
  7.                 <toolbar id="bt" title="宜优购" />
  8.             </appbar>
  9.             <Switch id="autoService" text="无障碍服务" checked="{{auto.service != null}}" padding="8 8 8 8" textSize="15sp" />
  10.             <horizontal>
  11.                 <text text="  任务次数:" gravity="left" />
  12.                 <input id="renwu" hint="任务次数" textSize="15sp" inputType="number" gravity="center" />
  13.             </horizontal>
  14.             <horizontal>
  15.                 <text text="  评论文本路径:" gravity="left" />
  16.                 <input id="zhpath" hint="文本路径" textSize="15sp" gravity="center" />
  17.             </horizontal>
  18.             <horizontal>
  19.                 <text text="  日志文本路径:" gravity="left" />
  20.                 <input id="logpath" hint="文本路径" textSize="15sp" gravity="center" />
  21.             </horizontal>
  22.             {/* <text text="  数据会自动上传数据库 本地同时保留一份" gravity="left" /> */}
  23.             <horizontal>
  24.                 <text id="安卓版本" textSize="15sp" />
  25.             </horizontal>

  26.             <button id="start" text="开始运行" style="Widget.AppCompat.Button.Colored" />
  27.         </vertical>
  28.     </ScrollView>
  29. );

  30. ui.autoService.on("check", function (checked) {
  31.     if (checked && auto.service == null) {
  32.         app.startActivity({
  33.             action: "android.settings.ACCESSIBILITY_SETTINGS"
  34.         });
  35.     }
  36.     if (!checked && auto.service != null) {
  37.         auto.service.disableSelf();
  38.     }
  39. });
  40. ui.emitter.on("resume", function () {
  41.     ui.autoService.checked = auto.service != null;
  42. });

  43. var 悬块 = function (window, view) {
  44.     if (!window || !view) {
  45.         throw "缺参数";
  46.     };
  47.     this.x = 0, this.y = 0;
  48.     this.windowX, this.windowY;
  49.     this.downTime = 500;
  50.     this.Timeout = 0;
  51.     this.Click = function () { };
  52.     this.LongClick = function () { };
  53.     this.setClick = function (fun) {
  54.         //判断参数类型是否为函数?
  55.         if (typeof fun == "function") {
  56.             this.Click = fun;
  57.         };
  58.     };
  59.     this.setLongClick = function (fun, ji) {
  60.         //判断参数类型是否为函数?
  61.         if (typeof fun == "function") {
  62.             this.LongClick = fun;
  63.             //判断参数是否可为设置数字?
  64.             if (parseInt(ji) <= 1000) {
  65.                 this.downTime = parseInt(ji);
  66.             };
  67.         };
  68.     };

  69.     view.setOnTouchListener(new android.view.View.OnTouchListener((view, event) => {
  70.         switch (event.getAction()) {
  71.             //按下事件。
  72.             case event.ACTION_DOWN:
  73.                 //按下记录各种坐标数据。
  74.                 this.x = event.getRawX();
  75.                 this.y = event.getRawY();
  76.                 this.windowX = window.getX();
  77.                 this.windowY = window.getY();
  78.                 //创建一个定时器用来定时执行长按操作。
  79.                 this.Timeout = setTimeout(() => {
  80.                     this.LongClick();
  81.                     this.Timeout = 0;
  82.                 }, this.downTime);
  83.                 return true;
  84.             //移动事件。
  85.             case event.ACTION_MOVE:

  86.                 return true;
  87.             //抬起事件。
  88.             case event.ACTION_UP:
  89.                 if (this.Timeout) {
  90.                     clearTimeout(this.Timeout);
  91.                     this.Timeout = 0;
  92.                     this.Click();
  93.                 };
  94.                 return true;
  95.         };
  96.         return true;
  97.     }));
  98. };



  99. ui.renwu.text(配置.get("renwu", "500"));
  100. ui.zhpath.text(配置.get("zhpath", "/sdcard/Pictures/评论.txt"));
  101. ui.logpath.text(配置.get("logpath", "/sdcard/log.txt"));


  102. ui.start.on("click", function () {
  103.     //程序开始运行之前判断无障碍服务
  104.     if (auto.service == null) {
  105.         toast("请先开启无障碍服务!");
  106.         return;
  107.     }
  108.     配置.put("renwu", ui.renwu.text());
  109.     配置.put("zhpath", ui.zhpath.text());
  110.     配置.put("logpath", ui.logpath.text());
  111.     xf();
  112.     glb();
  113. });



  114. var money = 0;
  115. var time = 0;
  116. var Newmoney = 0;
  117. var Oldmoney = 0;
  118. var plnr = "";
  119. var 数量 = 0;

  120. function glb() {
  121.     主线程 = threads.start(function 抖音ll() {
  122.         // console.setSize(device.width / 2, device.height / 2);
  123.         console.setTitle("YYG");
  124.         console.show();
  125.         ts("执行操作:脚本开始运行");
  126.         app.launch("com.lyl.yyg");
  127.         sleep(4000);
  128.         if (!requestScreenCapture(false)) {
  129.             toastLog("请求截图失败,脚本结束");
  130.             exit();
  131.         } else {
  132.             toastLog("请求截图成功");
  133.             // 权限 = false;
  134.         }
  135.         plnr = files.read(ui.zhpath.text());
  136.         while (true) {
  137.             main();
  138.             if (数量 >= parseInt(ui.renwu.text())) {
  139.                 log("任务完成");
  140.                 exit();
  141.             }
  142.         }
  143.     })
  144. }




  145. function main() {
  146.     if (packageName("com.lyl.yyg").exists()) {
  147.         swipe(device.width * 0.7, device.height / 4, device.width * 0.7, device.height * 0.9, 500);
  148.         sleep(2000);
  149.         var a = id("com.lyl.yyg:id/iv_gift").findOne(1500);
  150.         if (a) {
  151.             a.parent().click();
  152.             var b = Get_renwu();
  153.             if (b) {
  154.                 click(b.bounds().centerX(), b.bounds().centerY());
  155.                 sleep(1000);
  156.                 a = id("com.lyl.yyg:id/tv_like").visibleToUser().findOne(3000);
  157.                 if (a) {
  158.                     var res = findColorEquals(captureScreen(), "#ffff3d89", a.bounds().centerX(), a.bounds().centerY(), 10, 10);
  159.                     if (res) {
  160.                         a.click();
  161.                         sleep(random(800,1200));
  162.                     }
  163.                 }
  164.                 a = id("com.lyl.yyg:id/tv_collect").visibleToUser().findOne(3000);
  165.                 if (a) {
  166.                     var res = findColorEquals(captureScreen(), "#ffff3d89", a.bounds().centerX(), a.bounds().centerY(), 10, 10);
  167.                     if (res) {
  168.                         a.click();
  169.                         sleep(random(800,1200));
  170.                     }
  171.                 }
  172.                 djs(time);
  173.             }
  174.             a = id("com.lyl.yyg:id/tv_like").visibleToUser().findOne(3000);
  175.             if (a) {
  176.                 a.click();
  177.                 sleep(random(800,1200));
  178.             }
  179.             a = id("com.lyl.yyg:id/tv_collect").visibleToUser().findOne(1000);
  180.             if (a) {
  181.                 a.click();
  182.                 sleep(random(800,1200));
  183.             }
  184.             a = id("com.lyl.yyg:id/tv_comment").visibleToUser().findOne(1000);
  185.             if (a) {
  186.                 a.click();
  187.             }
  188.             a = textStartsWith("留下精彩的评论").visibleToUser().findOne(3000);
  189.             if (a) {
  190.                 a.click();
  191.                 sleep(random(800,1200));
  192.                 setText(sj(plnr));
  193.                 sleep(random(800,1200));
  194.                 KeyCode(66);
  195.                 sleep(random(800,1200));
  196.                 back();
  197.                 djs1(6);
  198.                 back();
  199.                 sleep(500);
  200.             }
  201.             if (currentActivity() == "com.lyl.yyg.ui.activity.home.view.GoodsIntroductionActivity") {
  202.                 back();
  203.                 sleep(2000);
  204.             }
  205.             // uc = className("android.widget.FrameLayout").boundsInside(0, device.height * 3 / 4, device.width, device.height).visibleToUser().find();
  206.             // // log("uc.length=" + uc.length);
  207.             // // for (i = 0; i < uc.length; i++) {
  208.             // if (uc.length = 3) {
  209.             //     click(uc[2].bounds().centerX(), uc[2].bounds().centerY());
  210.             //     sleep(1500);
  211.             // }
  212.             // click(device.width * 5 / 6, device.height - 50);
  213.             // sleep(2000);
  214.             // Newmoney = Get_money();
  215.             // if (Newmoney) {
  216.             //     // if (Newmoney > Oldmoney) {
  217.             //     Oldmoney = Newmoney;
  218.             //     console.error(CurentTime() + "   金币:" + Newmoney);
  219.             //     数量 = 数量 + 1;
  220.             //     log("当前数量:" + 数量 + "/" + ui.renwu.text());
  221.             //     files.append(ui.logpath.text(), CurentTime() + "   金币:" + Newmoney + "  本次奖励:" + money + "  时间:" + time + "\r\n");
  222.             //     // }
  223.             // } else {
  224.             //     log("读取金币余额失败");
  225.             // }
  226.             // click(device.width / 6, device.height - 50);
  227.             // swipe(device.width * 0.7, device.height / 4, device.width * 0.7, device.height * 0.9, 500);
  228.             // sleep(1000);
  229.         } else {
  230.             // swipe(device.width * 0.7, device.height / 4, device.width * 0.7, device.height * 0.9, 500);
  231.             // sleep(1000);
  232.         }
  233.         if (currentActivity() == "com.lyl.yyg.ui.activity.home.view.GoodsIntroductionActivity") {
  234.             back();
  235.             sleep(2000);
  236.         }
  237.     } else {
  238.         ts("检测:检测客户端不在前台");
  239.         app.launch("com.lyl.yyg");
  240.         sleep(5000);
  241.     }

  242.     // }
  243. }
  244. function CurentTime() {
  245.     var now = new Date();

  246.     var year = now.getFullYear();       //年
  247.     var month = now.getMonth() + 1;     //月
  248.     var day = now.getDate();            //日

  249.     var hh = now.getHours();            //时
  250.     var mm = now.getMinutes();          //分

  251.     var clock = year + "-";

  252.     if (month < 10)
  253.         clock += "0";

  254.     clock += month + "-";

  255.     if (day < 10)
  256.         clock += "0";

  257.     clock += day + " ";

  258.     if (hh < 10)
  259.         clock += "0";

  260.     clock += hh + ":";
  261.     if (mm < 10) clock += '0';
  262.     clock += mm;
  263.     return (clock);
  264. }
  265. function Get_renwu() {
  266.     var a = textMatches("满足以下条件.+金币").visibleToUser().findOne(1000);
  267.     if (a) {
  268.         money = a.text().replace(/[^0-9]/ig, "");
  269.         log("任务奖励:" + money)
  270.     }
  271.     var a = textMatches("点赞、收藏.+秒").visibleToUser().findOne(1000);
  272.     if (a) {
  273.         time = a.text().replace(/[^0-9]/ig, "");
  274.         log("任务时间:" + time)
  275.         // click(a.bounds().centerX(),a.bounds().centerY());
  276.     }
  277.     return a;
  278. }
  279. function Get_money() {
  280.     var a = textMatches("金币总数.+").visibleToUser().findOne(1000);
  281.     if (a) {
  282.         let money1 = a.text().replace(/[^0-9]/ig, "");
  283.         return money1;
  284.     }
  285.     // uc = className("android.widget.FrameLayout").boundsInside(0, device.height * 1 / 2, device.width, device.height).visibleToUser().find();
  286.     // // log("uc.length=" + uc.length);
  287.     // // for (i = 0; i < uc.length; i++) {
  288.     // if (uc.length = 3) {
  289.     //     click(uc[0].bounds().centerX(), uc[0].bounds().centerY());
  290.     //     sleep(1000);
  291.     // }

  292. }
  293. function djs(TM) //倒计时
  294. {
  295.     for (var i = TM; i > 9; i--) {
  296.         log("剩余:" + i + "s");
  297.         sleep(1000);
  298.     }
  299. }
  300. function djs1(TM) //倒计时
  301. {
  302.     for (var i = TM; i > 0; i--) {
  303.         log("剩余:" + i + "s");
  304.         sleep(1000);
  305.     }
  306. }
  307. function sj(str) //返回一个随机值,分隔符|
  308. {
  309.     if (str) {
  310.         str = str.split("\n");
  311.         var sjz = random(0, parseInt(str.length) - 1);
  312.         return str[sjz];
  313.     }

  314. }
  315. function xf() {
  316.     var thread = threads.start(function op() {
  317.         var window = floaty.window(
  318.             // <img id="but" src="file://stop.png" />
  319.             <button id="but" text="stop" />
  320.         );
  321.         window.setPosition(10, device.height / 3)
  322.         setInterval(() => { }, 500);
  323.         var ad = new 悬块(window, window.but);
  324.         ad.setLongClick(function () {

  325.             log("停止运行");
  326.             exit();
  327.         });
  328.         ad.setClick(function () {
  329.             log("停止运行");
  330.             exit();
  331.         })
  332.     })
  333.     //创建一个新的悬浮控制模块 ad 并带入参数(所要控制的悬浮窗和用来控制悬浮窗移动的控件)。

  334. }
  335. function ts(text) {
  336.     log(text)
  337. }
复制代码


093608hrrpap639j8rqjpb.png 093610nelyy52y2e2eryzr.png
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心值】和【牛币】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2020-10-1 13:16 | 显示全部楼层
谢谢分享
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心值】和【牛币】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 有用 没用

使用道具 举报

发表于 2020-10-1 13:44 | 显示全部楼层
谢谢大牛
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心值】和【牛币】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 有用 没用

使用道具 举报

发表于 2020-10-1 13:51 | 显示全部楼层
谢谢大佬
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心值】和【牛币】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 有用 没用

使用道具 举报

发表于 2020-10-1 13:55 | 显示全部楼层
好的,非常感谢
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心值】和【牛币】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 有用 没用

使用道具 举报

发表于 2020-10-1 14:49 | 显示全部楼层
6666666666
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心值】和【牛币】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 有用 没用

使用道具 举报

发表于 2020-10-1 19:52 | 显示全部楼层
6666
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心值】和【牛币】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 有用 没用

使用道具 举报

发表于 2020-10-1 20:03 | 显示全部楼层
感谢楼主分享
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【热心值】和【牛币】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 有用 没用

使用道具 举报

您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

RSS订阅|手机版|小黑屋|广告投放|大牛论坛

GMT+8, 2024-5-31 03:29 , Processed in 0.045168 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表