当前位置:   article > 正文

AutoJs UI版

autojs ui

AutoJs UI版 

 

  1. ui.layout(
  2. <drawer id="drawer">
  3. <vertical>
  4. <appbar>
  5. <toolbar bg="#FF5c50e6" id="toolbar" title="超级大蚂蚁UI版v1.0.0" paddingTop="2dp" h="auto" >
  6. </toolbar>
  7. <tabs id="tabs" />
  8. </appbar>
  9. <viewpager id="viewpager">
  10. {/* 第一个Frame */}
  11. <frame>
  12. <scroll>
  13. <vertical gravity="center">
  14. <horizontal gravity="center_vertical" padding="5 5" >
  15. <View bg="#00BFFF" h="*" w="10" ></View>
  16. <vertical padding="10 8" h="auto" w="0" layout_weight="1">
  17. <text w="auto" textColor="#222222" textSize="14sp" text="今日头条极速版" />
  18. <text w="auto" textColor="#999999" textSize="12sp" text="自动阅读、领金币、宝箱" />
  19. </vertical>
  20. <checkbox id="toutiao" marginLeft="4" marginRight="6" checked="true" />
  21. </horizontal>
  22. <horizontal gravity="center_vertical" padding="5 5" >
  23. <View bg="#00FFFF" h="*" w="10" ></View>
  24. <vertical padding="10 8" h="auto" w="0" layout_weight="1">
  25. <text w="auto" textColor="#222222" textSize="14sp" text="抖音短视频" />
  26. <text w="auto" textColor="#999999" textSize="12sp" text="滑动、关注、点赞、评论,自动化一体" />
  27. </vertical>
  28. <checkbox id="douyin" marginLeft="4" marginRight="6" checked="false" />
  29. </horizontal>
  30. <horizontal gravity="right">
  31. <button style="Widget.AppCompat.Button.Colored" id="wool" text="启动" padding="12dp" w="auto" />
  32. <button style="Widget.AppCompat.Button.Colored" id="close" text="关闭线程" />
  33. </horizontal>
  34. </vertical>
  35. </scroll>
  36. </frame>
  37. {/* 第二个Frame */}
  38. <frame>
  39. <scroll>
  40. <vertical>
  41. <horizontal gravity="center_vertical" padding="5 5" >
  42. <View bg="#4876FF" h="*" w="10" ></View>
  43. <text w="auto" padding="8 8 8 8" textColor="#222222" textSize="14sp" text="遍历次数:" />
  44. <input id="txtForeachTimes" text="10" hint="App被打开的次数" textSize="13sp" inputType="number" />
  45. </horizontal>
  46. <horizontal gravity="center_vertical" padding="5 5" >
  47. <View bg="#4876FF" h="*" w="10" ></View>
  48. <text w="auto" padding="8 8 8 8" textColor="#222222" textSize="14sp" text="滑动屏幕次数:" />
  49. <input id="txtScreenSileTimes" text="100" hint="滑动屏幕次数" textSize="13sp" inputType="number" />
  50. </horizontal>
  51. <horizontal gravity="center_vertical" padding="5 5" >
  52. <View bg="#4876FF" h="*" w="10" ></View>
  53. <text w="auto" padding="8 8 8 8" textColor="#222222" textSize="14sp" text="屏幕滑动时间间隔(秒):" />
  54. <input id="txtScreenSileTimesInterval" text="15" hint="滑动时间间隔" textSize="13sp" inputType="number" />
  55. </horizontal>
  56. <horizontal gravity="center_vertical" padding="5 5" >
  57. <View bg="#4F4F4F" h="*" w="10" ></View>
  58. <text w="auto" padding="8 8 8 8" textColor="#222222" textSize="14sp" text="开启无障碍服务" />
  59. <Switch id="autoService" checked="{{auto.service != null}}" padding="8 8 8 8" />
  60. </horizontal>
  61. <horizontal gravity="center_vertical" padding="5 5" >
  62. <View bg="#4F4F4F" h="*" w="10" ></View>
  63. <text w="auto" padding="8 8 8 8" textColor="#222222" textSize="14sp" text="是否开启控制台" />
  64. <Switch id='switchIsShowConsole' padding="8 8 8 8" />
  65. </horizontal>
  66. <horizontal>
  67. <button style="Widget.AppCompat.Button.Colored" id="btnSaveWoolConfig" text="保存配置" padding="12dp" w="*" />
  68. </horizontal>
  69. </vertical>
  70. </scroll>
  71. </frame>
  72. {/* 第三页*/}
  73. <frame>
  74. <scroll>
  75. <vertical>
  76. <horizontal gravity="center_vertical" padding="5 5" >
  77. <View bg="#00BFFF" h="*" w="10" ></View>
  78. <vertical padding="10 8" h="auto" w="0" layout_weight="1">
  79. <text w="auto" color="#111111" size="16" text="1、需要启动无障碍服务。" />
  80. <text w="auto" color="#111111" size="16" text="2、允许app显示在其他应用的上层。" />
  81. </vertical>
  82. </horizontal>
  83. </vertical>
  84. </scroll>
  85.                 </frame>
  86. </viewpager>
  87. </vertical>
  88. {/* drawer */}
  89. <vertical layout_gravity="left" bg="#ffffff" w="280">
  90. <img w="280" h="200" scaleType="fitXY" src="{{rootUrl}}/app/Resources/Images/weixin.jpg" />
  91. <scroll>
  92. <list id="menu">
  93. <horizontal bg="?selectableItemBackground" w="*">
  94. <img w="50" h="50" padding="16" src="{{icon}}" />
  95. <text textColor="black" textSize="15sp" text="{{title}}" layout_gravity="center" />
  96. </horizontal>
  97. </list>
  98. </scroll>
  99. </vertical>
  100. </drawer>
  101. );
  102. //设置滑动页面的标题
  103. ui.viewpager.setTitles(["首页", "配置","说明"]);
  104. //让滑动页面和标签栏联动
  105. ui.tabs.setupWithViewPager(ui.viewpager);
  106. activity.setSupportActionBar(ui.toolbar);
  107. // 用户勾选无障碍服务的选项时,跳转到页面让用户去开启
  108. //android.permission.SYSTEM_ALERT_WINDOW
  109. ui.autoService.on("check", function (checked) {
  110. if (checked && auto.service == null) {
  111. app.startActivity({
  112. action: "android.settings.ACCESSIBILITY_SETTINGS"
  113. });
  114. }
  115. if (!checked && auto.service != null) {
  116. auto.service.disableSelf();
  117. }
  118. });
  119. // 当用户回到本界面时,resume事件会被触发
  120. ui.emitter.on("resume", function () {
  121. // 此时根据无障碍服务的开启情况,同步开关的状态
  122. ui.autoService.checked = auto.service != null;
  123. });
  124. initializeRightMenu();
  125. initializeData();
  126. /**
  127. * 薅羊毛
  128. */
  129. ui.wool.click(function () {
  130. var appArray = getAppList();
  131. var foreachTimes = ui.txtForeachTimes.getText();
  132. var screenSileTimes = ui.txtScreenSileTimes.getText();
  133. var isShowConsole = ui.switchIsShowConsole.isChecked();
  134. var timesInterval = ui.txtScreenSileTimesInterval.getText();
  135. var consoleMessage = "不开启控制台";
  136. if (isShowConsole) {
  137. consoleMessage = "开启控制台";
  138. }
  139. var tipMessage = "本次共" + appArray.length + "个App参与薅羊毛任务,共循环"
  140. + ui.txtForeachTimes.getText() + "次,"
  141. + "屏幕滑动" + screenSileTimes + "次,"
  142. + consoleMessage
  143. + "确认执行吗?如果配置不正确请点击取消,前往配置页面进行参数修正!";
  144. confirm(tipMessage).then(value => {
  145. //当点击确定后会执行这里, value为true或false, 表示点击"确定"或"取消"
  146. if (value) {
  147. threads.start(function () {
  148. //在新线程执行的代码
  149. auto.waitFor();
  150. toastLog("薅羊毛开始请等待进入第一个程序!");
  151. wool(appArray, foreachTimes, screenSileTimes, isShowConsole, timesInterval);
  152. });
  153. } else {
  154. }
  155. });
  156. });
  157. /**
  158. * 关闭薅羊毛程序
  159. */
  160. ui.close.click(function () {
  161. toastLog("薅羊毛线程已经被关闭!");
  162. threads.shutDownAll();
  163. });
  164. ui.btnSaveWoolConfig.click(function () {
  165. var woolStorage = storages.create("abc11ss13");//创建本地存储
  166. woolStorage.put("foreachTimes", "" + ui.txtForeachTimes.getText() + "");
  167. woolStorage.put("screenSileTimes", "" + ui.txtScreenSileTimes.getText() + "");
  168. woolStorage.put("isShowConsole", "" + ui.switchIsShowConsole.isChecked() + "");
  169. woolStorage.put("timesInterval", "" + ui.txtScreenSileTimesInterval.getText() + "");
  170. toastLog("薅羊毛配置保存成功!");
  171. });
  172. function initializeRightMenu() {
  173. ui.menu.setDataSource([
  174. { title: "更新日志",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAC8klEQVRYR82XT2sTQRjGn3cTaG8mG28eqrATEQ8NePIiFRFURCoigohWVOxORNtP0PQTmKKZHEQoRQQtUpQigmjrBxDqRbGzYj140kziLaXpjszalDSm+bOxxDkF8s7z/N5535nZIfR4UI/90RTAFvJpN4Da1zPFW8n5ZhoNAezc5wzIugngdjcAAE4S4UjBZc52Oo0BhPyuONvTpXkwfff9L0ltrY8XeNJtpPcXwMayzyrOZv8FgNGIC7lQ5OxozwBsId8ozo71EGD5teLJ410BxPKf9qLcXwpE+suxkntgpSoYyy2nQLRri8Fq9ENpfF8Qb+flK+WyE10BJIRc1KABQBvRlOJss39sIZcADNYZjCvOsgGAkC8VZ6d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0GMao2vlcVt5pEDwEueY3++iKzp5MqTrwF8BaB5nBgF9VmqtnOWssZmdnRfCjus+/hizpr/oyj0ixC1CcDjANYZgg2nZ1cIq5+QihDfa82xtjl/bGZ4w7UwVubw+W6lVRFQRShsAptYMC86S830ov/yNDpbCd9Vsv9Wlv8E0mP+P0I4oqkAAAAASUVORK5CYII=" },
  177. { title: "关于",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAE3ElEQVRYR61Xa4hUZRh+3jOrK1G7M2fGtIug654xS1IqSIpCKKlMtCL3RyCx5YU940oKJmSQCxoUhOU232Sp+K/UH1mkGRiKGV0oumDFzhnTMipx58xgCO26c574zjmj42Vmzkrn38z3vO/7fO/9E0T8EluOtRuet4DkQoF0EEgBkgzEWRRgkEBePG+nnOWBwbW3/BNFtTQDJbP56RDpJfAUgPZm+PC8JMB7IPuLmfQvjWQaEkjk8huE0gugLVRyBsAXAhwmcYpi/K3/F3oTRTCB4D0QmQtibBVPYX+pJ/1iPRJ1CZjK2QVgkS8o8qlHbi6nhvaja8Zwoxu1bT1pxoaHngS4TIA7wxB95trp+68kd0UCpiocBzg5FFjq2tbWiK6/CJZQhWUCbglJDLp2evylei4jYKr8aUBSfmohNrNkd/x4NcarMglVeETAfcFvOeHanVNq9V1EwFT5w4DcpwGubTVN0NEQM5XDEL/bta2uqux5I2HCrQtuLvNKdufHUQyYbzm3soI59PBzudc6VE8moX69XVD5wdcv3FhNTJ+ALjWKfBlme+SYj88evbYirVruNt8wvT43M219PRKmcpYAeAfAGSFn6xINCChHEejR2e72dD4Y5eYaE+935hgxHLyAp+va6bA5XVmLmSscAPmAALmibdk+AVM5vwOY5AELy7b1YVQC120ZSI2pGKfP40V2uD2d3Y3k48pZYAAfAPjTta2bJJ49PsuQke8AlN1TQxPQ17jOL1VuKmeRAIsJDrh2ek1T8ruOjjUHWzXpNhHvbknmCitJvkHInpLd+XhTBf8DwFTOfgAPgVgtZtbZBsEzAqw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ui.menu.on("item_click", item => {
  181. switch (item.title) {
  182. case "更新日志":
  183. app.openUrl(rootUrl+"/app/WoolUpgradeLog.html");
  184. break;
  185. case "检查更新":
  186. threads.start(function () {
  187. let titileAndVersion = ui.toolbar.getTitle();
  188. let appNameAndVersionArray = titileAndVersion.split("v");
  189. let appName = appNameAndVersionArray[0];
  190. let appVersion = appNameAndVersionArray[1];
  191. var url = rootUrl + "/app/WebService.asmx/CheckAppVersion";
  192. var version = appVersion;
  193. var res = http.post(url, { "appName": appName, "version": version });
  194. var returnString = res.body.string();
  195. let json = JSON.parse(returnString);
  196. if (json.success == "true") {
  197. if (json.data.upgrade == "true") {
  198. app.openUrl(rootUrl + "/app/WebService.asmx/DownLoadWoolUIApk");
  199. } else {
  200. toastLog("已经是最新版");
  201. }
  202. } else {
  203. toastLog("请求远端服务器出现异常!请稍后重试!");
  204. }
  205. });
  206. break;
  207. case "教程":
  208. app.openUrl("https://blog.csdn.net/zy0412326/article/details/104767602");
  209. break;
  210. case "关于":
  211. dialogs.build({
  212. title: "关于",
  213. positive: "确定",
  214. items: ["薅羊毛UI版纯属个人爱好,如果涉及到侵权请通知作者,作者会尽快解决相应问题。作者邮箱:zy0412326@sina.com"]
  215. }).on("show", (dialog) => { }).show();
  216. break;
  217. case "退出":
  218. ui.finish();
  219. break;
  220. }
  221. });
  222. //让工具栏左上角可以打开侧拉菜单
  223. ui.toolbar.setupWithDrawer(ui.drawer);
  224. }
  225. /**
  226. * 初始化UI和数据
  227. */
  228. function initializeData() {
  229. // threads.start(function () {
  230. // console.show();
  231. // });
  232. var woolStorage = storages.create("abc11ss13");//创建本地存储
  233. var foreachTimes = woolStorage.get("foreachTimes");
  234. var screenSileTimes = woolStorage.get("screenSileTimes");
  235. var isShowConsole = woolStorage.get("isShowConsole");
  236. var timesInterval = woolStorage.get("timesInterval");
  237. var appInstallDateTime = woolStorage.get("appInstallDateTime");
  238. if (foreachTimes != null) {
  239. ui.txtForeachTimes.setText(foreachTimes);
  240. }
  241. if (screenSileTimes != null) {
  242. ui.txtScreenSileTimes.setText(screenSileTimes);
  243. }
  244. if (isShowConsole != null && isShowConsole == "true") {
  245. ui.switchIsShowConsole.setChecked(true);
  246. } else {
  247. ui.switchIsShowConsole.setChecked(false);
  248. }
  249. if (timesInterval != null) {
  250. ui.txtScreenSileTimesInterval.setText(timesInterval);
  251. }
  252. if (appInstallDateTime != null) {
  253. var curTime = new Date();
  254. var currentTime = new Date(parseInt(curTime.getFullYear()), parseInt(curTime.getMonth() + 1), parseInt(curTime.getDate()), parseInt(curTime.getHours()), parseInt(curTime.getMinutes()), parseInt(curTime.getSeconds()));
  255. var appInstallDate = appInstallDateTime.toString().split("-");
  256. var getDay = appInstallDate[2].split(" ")[0]; //天
  257. var hourMM = appInstallDate[2].split(" ")[1];//时分秒
  258. var appInstallTime = new Date(parseInt(appInstallDate[0]), parseInt(appInstallDate[1]), parseInt(getDay), hourMM.split(":")[0], hourMM.split(":")[1], parseInt(0));
  259. var seconds=currentTime - appInstallTime;
  260. if (seconds/(1000 * 60 * 60 * 24)>3) {
  261. alert("薅羊毛已经过去3天了,烦请打赏一下作者,您的支持是作者最大的动力!");
  262. woolStorage.put("appInstallDateTime", "" + getTime() + "");
  263. }
  264. } else {
  265. woolStorage.put("appInstallDateTime", "" + getTime() + "");
  266. }
  267. }
  268. /**
  269. * 获取被选择的app
  270. */
  271. function getAppList() {
  272. var appArray = new Array(); //app集合
  273. var toutiao = ui.toutiao.isChecked();
  274. if (toutiao) {
  275. appArray.push(ui.toutiao.getText());
  276. }
  277. return appArray;
  278. }
  279. /**
  280. * 主程序
  281. * @param {应用列表} appArray
  282. * @param {应用打开次数} foreach_count
  283. * @param {屏幕滑动次数} see_count
  284. * @param {是否显示控制台} isShowConsole
  285. * @param {延迟时间} timesInterval
  286. */
  287. function wool(appArray, foreach_count, see_count, isShowConsole, timesInterval) {
  288. threads.start(function () {
  289. if (isShowConsole) {
  290. console.show();
  291. console.setSize(device.width, device.height / 4);
  292. }
  293. });
  294. for (x = 1; x <= foreach_count; x++) {
  295. for (y = 0; y < appArray.length; y++) {
  296. let appName = appArray[y];
  297. toastLog("当前程序:" + appName);
  298. //app.launchApp(appName);
  299. sleep(10000);//目前无法判断网速和splash时间,只能延迟久一点。10秒延迟。
  300. if (appName == '今日头条极速版') {
  301. toutiaorun();
  302. }
  303. //滑动次数
  304. for (z = 1; z <= see_count; z++) {
  305. }
  306. console.clear();//
  307. }
  308. }
  309. toastLog("程序执行完毕3秒后即将关闭...");
  310. console.error("程序执行完毕3秒后即将关闭...");
  311. for (let i = 3; i >= 1; i--) {
  312. console.error(i);
  313. sleep(1000);
  314. if (i == 1) {
  315. home();//返回主页面
  316. return;
  317. }
  318. }
  319. }
  320. /**
  321. * 一键签到
  322. * @param {签到程序得app} appArray
  323. * @param {是否显示控制台} isShowConsole
  324. */
  325. function sign(appArray, isShowConsole) {
  326. }
  327. /**
  328. * 屏幕向下滑动并延迟8至12秒
  329. */
  330. function slideScreenDown(startX, startY, endX, endY, pressTime, timesInterval) {
  331. swipe(startX, startY, endX, endY, pressTime);
  332. let randomMin = timesInterval * 1000;
  333. let randomMax = (parseInt(timesInterval) + 2) * 1000;
  334. let delayTime = random(randomMin, randomMax);
  335. sleep(delayTime);
  336. }
  337. /**
  338. *关闭广告
  339. */
  340. function caiDanCloseAd() {
  341. if (id("btn_back").exists()) {
  342. console.log("关闭广告");
  343. id("btn_back").findOne().click();
  344. }
  345. }
  346. /**
  347. *点击一下屏幕
  348. */
  349. function clickScreen() {
  350. var x = device.width / 2;
  351. var y = device.height / 2;
  352. click(x, y);
  353. }
  354. /**
  355. *向右侧滑动
  356. */
  357. function sildeScreenRight() {
  358. pressTime = random(250, 600);
  359. swipe(750, 1000, 100, 1000, pressTime);//750, 120, 100, 120, 100
  360. delayTime = random(25000, 30000);
  361. sleep(delayTime);
  362. }
  363. /**
  364. * 随机点赞
  365. * @param {点赞ID}} view_id
  366. */
  367. function randomHeart(view_id) {
  368. index = random(1, 100);
  369. if (index == 66) {
  370. var target = id(view_id).findOnce();
  371. if (target == null) {
  372. return;
  373. } else {
  374. target.click();
  375. sleep(1000);
  376. }
  377. }
  378. }
  379. /**
  380. * 随机关注
  381. * @param {*} follow_view_id
  382. */
  383. function randomFollow(follow_view_id) {
  384. index = random(1, 100);
  385. if (index == 66) {
  386. var target = id(follow_view_id).findOnce();
  387. if (target == null) {
  388. return;
  389. } else {
  390. target.click();
  391. sleep(1000);
  392. }
  393. }
  394. }
  395. /**
  396. * 随机上滑(防止被判定是机器)上滑后停留时间至少是10S,造成假象表示是对内容感兴趣
  397. * 点赞和关注先不搞。
  398. */
  399. function randomUpSildeScreen() {
  400. let randomIndex = random(1, 50);
  401. if (randomIndex == 1) {
  402. console.log("随机上滑被执行了!!!");
  403. pressTime = random(200, 500);
  404. swipe(device.width / 2, 500, device.width / 2, device.height - 200, 300);
  405. delayTime = random(10000, 15000);
  406. sleep(delayTime);
  407. }
  408. }
  409. /**
  410. * 连续下滑对上一个无兴趣
  411. * 其实得和上滑做个排他,既然无兴趣不要在上滑
  412. */
  413. function randomDownSildeScreen() {
  414. let randomIndex = random(1, 20);
  415. if (randomIndex == 1) {
  416. console.log("连续下滑被执行了");
  417. swipe(device.width / 2, device.height - 200, device.width / 2, 500, 300);
  418. sleep(2000);
  419. swipe(device.width / 2, device.height - 200, device.width / 2, 500, 300);
  420. delayTime = random(8000, 10000);
  421. sleep(delayTime);
  422. }
  423. }
  424. /**
  425. *
  426. * 获取当前时间
  427. */
  428. function getTime() {
  429. var date = new Date();
  430. var year = date.getFullYear();
  431. var month = date.getMonth() + 1;
  432. if (month < 10) {
  433. month = "0" + month;
  434. };
  435. var day = date.getDate();
  436. if (day < 10) {
  437. day = "0" + day;
  438. };
  439. var hour = date.getHours();
  440. if (hour < 10) {
  441. hour = "0" + hour;
  442. };
  443. var minute = date.getMinutes();
  444. if (minute < 10) {
  445. minute = "0" + minute;
  446. };
  447. return year +"-"+ month +"-"+ day +" "+ hour +":"+ minute+":"+ "0";
  448. };
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/111731
推荐阅读
相关标签