znzf.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. const douyin = require("./common/douyin");
  2. const conf = require("./common/conf");
  3. const engine = require("./common/engine");
  4. const utility = require("./common/utility");
  5. var param = {
  6. yxgs: 500,
  7. czjg1: 3,
  8. czjg2: 6,
  9. gksj1: 5,
  10. gksj2: 10,
  11. tglv: true,
  12. dz: 45,
  13. gz: 5,
  14. pl: 35,
  15. txdz: 60,
  16. pldz: 80,
  17. plhs: conf.commonts,
  18. gjcs: ["77396094576", "60866194851"],
  19. pltp: true
  20. };
  21. var znzf = {
  22. banben: parseFloat(context.getPackageManager().getPackageInfo("com.ss.android.ugc.aweme", 0).versionName) < 27.4,
  23. init() {
  24. return !!douyin.init() && !(typeof ENV_CONF != "undefined" && Object.assign(param, ENV_CONF), param.pl > 0 && param.plhs.length < 1 ? (alert("请设置评论话术"), 1) : douyin.isRecommend() ? (utility.toast("开始任务:智能涨粉"), engine.sleep(1), device.keepScreenDim(), douyin.popupAndClose(), 0) : (alert("请在抖音首页运行"), 1));
  25. },
  26. isUserList() {
  27. var tab = className("androidx.appcompat.app.ActionBar$Tab").visibleToUser().selected().findOnce();
  28. return tab !== null && (tab.findOne(textContains("粉丝")) !== null || tab.findOne(textContains("关注")) !== null);
  29. },
  30. toUserList() {
  31. while (true) {
  32. sleep(2000);
  33. if (this.isUserList()) {
  34. return;
  35. }
  36. back();
  37. sleep(1000);
  38. }
  39. },
  40. execUser() {
  41. engine.sleep(param.czjg1, param.czjg2);
  42. if (!douyin.isHome()) {
  43. utility.toast("进入主页失败");
  44. return false;
  45. }
  46. if (text("私密账号").visibleToUser().findOnce() !== null || text("帐号已被封禁").visibleToUser().findOnce() !== null) {
  47. utility.toast("私密或已封禁账号,跳过");
  48. return false;
  49. }
  50. if (param.tglv && className("android.widget.TextView").visibleToUser().id(douyin.getNode("user.lanv").id).findOnce() !== null) {
  51. utility.toast("蓝v用户,跳过!");
  52. return false;
  53. }
  54. let fansNum = 0;
  55. var fansNode = id(douyin.getNode("user.fansnum").id).visibleToUser().findOnce();
  56. if (fansNode && (fansText = fansNode.text(), fansNum = parseFloat(fansText), fansText.indexOf("w") >= 0 || fansText.indexOf("万") >= 0)) {
  57. fansNum *= 10000;
  58. }
  59. let gzNum = 0;
  60. fansNode = id(douyin.getNode("user.gznum").id).visibleToUser().findOnce();
  61. if (fansNode && (gzText = fansNode.text(), gzNum = parseFloat(gzText), gzText.indexOf("w") >= 0 || gzText.indexOf("万") >= 0)) {
  62. gzNum *= 10000;
  63. }
  64. if (gzNum - fansNum < 1000) {
  65. return false;
  66. }
  67. fansNode = textContains("作品").visibleToUser().findOnce();
  68. let videoNum = 0;
  69. if ((videoNum = fansNode ? parseInt(fansNode.text().replace(/[^0-9]/gi, "")) : videoNum) < 1 || isNaN(videoNum)) {
  70. utility.toast("该用户没有作品或非正常用户,跳过");
  71. return false;
  72. }
  73. if (this.banben && utility.checkProbability(param.txdz, "头像点赞")) {
  74. douyin.execTxdz();
  75. engine.sleepMs(1000, 2000);
  76. }
  77. if (utility.checkProbability(param.gz, "关注")) {
  78. if (followBtn = id(douyin.getNode("user.followBtn").id).visibleToUser().findOnce()) {
  79. utility.toast("执行关注!");
  80. followBtn.click();
  81. engine.sleepMs(500, 1000);
  82. gzCount++;
  83. if (followBtn = desc("更多,已展开").visibleToUser().findOne(5000)) {
  84. followBtn.click();
  85. engine.sleepMs(500, 1000);
  86. }
  87. } else {
  88. utility.toast("不关注!");
  89. }
  90. }
  91. var followBtn = utility.checkProbability(param.dz, "点赞");
  92. var isPl = utility.checkProbability(param.pl, "评论");
  93. if (followBtn || isPl) {
  94. if (!fansNode.selected()) {
  95. engine.boundsClick(fansNode.bounds());
  96. engine.sleepMs(1000, 2000);
  97. }
  98. engine.shortSlide();
  99. var fansNode = id("com.ss.android.ugc.aweme:id/container").visibleToUser().find();
  100. if (!fansNode.empty()) {
  101. let video = fansNode[random(0, fansNode.length - 1)];
  102. video = video.findOne(className("android.view.View"));
  103. sleep(1000);
  104. if (video && video.clickable() && video.click() && douyin.IsVideoDelay(5000)) {
  105. fansNode = random(param.gksj1, param.gksj2);
  106. utility.toast("观看视频:" + fansNode + " 秒");
  107. engine.sleep(fansNode);
  108. if (followBtn) {
  109. douyin.execLike();
  110. dzCount++;
  111. } else {
  112. utility.toast("不点赞");
  113. }
  114. if (isPl && douyin.canComment()) {
  115. fansNode = utility.checkProbability(param.pldz, "评论点赞");
  116. douyin.sendComment(param.plhs, isPl, fansNode, param.pltp);
  117. plCount++;
  118. } else {
  119. utility.toast("不评论");
  120. }
  121. } else {
  122. utility.toast("打开视频失败!");
  123. back();
  124. sleep(1000);
  125. }
  126. }
  127. }
  128. return true;
  129. },
  130. dbzhgjc(gjc) {
  131. engine.sleepMs(1000, 2000);
  132. id("com.ss.android.ugc.aweme:id/et_search_kw").visibleToUser().findOne().setText(gjc);
  133. engine.sleepMs(1000, 2000);
  134. var b1 = text("搜索").visibleToUser().findOne().bounds();
  135. engine.boundsClick(b1);
  136. engine.sleepMs(3000, 4000);
  137. var b1 = text("用户").visibleToUser().findOne().bounds();
  138. engine.boundsClick(b1);
  139. engine.sleepMs(3000, 4000);
  140. var b1 = descContains(gjc).visibleToUser().findOne(5000);
  141. if (b1 === null) {
  142. alert("没有找到对标账号", "请检查对标账号 " + gjc + " 是否输入正确!");
  143. return false;
  144. } else {
  145. engine.boundsClick(b1.bounds());
  146. engine.sleepMs(3000, 4000);
  147. text("粉丝").visibleToUser().findOne().parent().click();
  148. engine.sleepMs(3000, 4000);
  149. return !!id("com.ss.android.ugc.aweme:id/root_layout").exists() || (alert("打开粉丝列表失败", "对标账号 " + gjc + " 粉丝列表可能设置隐私了!"), false);
  150. }
  151. },
  152. run() {
  153. if (this.init()) {
  154. let runCount = dzCount = gzCount = plCount = 0;
  155. var userContents = [];
  156. let gjcsCount = 0;
  157. let dyc = true;
  158. while (true) {
  159. if (dyc && (id("com.ss.android.ugc.aweme:id/hbz").visibleToUser().findOne().parent().click(), dyc = false, !this.dbzhgjc(param.gjcs[gjcsCount]))) {
  160. break;
  161. }
  162. if (runCount >= param.yxgs) {
  163. device.cancelKeepingAwake();
  164. alert("恭喜任务完成!", "本次任务共完成\n点赞" + dzCount + "次\n关注" + gzCount + "次\n评论" + plCount + "次");
  165. return;
  166. }
  167. let listBox = className("androidx.recyclerview.widget.RecyclerView").visibleToUser().findOne();
  168. if (!listBox) {
  169. utility.toast("没有找到用户列表!");
  170. return;
  171. }
  172. var listBoxTop = listBox.bounds().top;
  173. var childCount = listBox.childCount();
  174. for (let i = 0; i < childCount - 1; i++) {
  175. if (runCount >= param.yxgs) {
  176. device.cancelKeepingAwake();
  177. alert("恭喜任务完成!", "本次任务共完成\n点赞" + dzCount + "次\n关注" + gzCount + "次\n评论" + plCount + "次");
  178. return;
  179. }
  180. utility.toast("已执行用户 " + runCount + " 条,任务数" + param.yxgs);
  181. var child = listBox.child(i);
  182. if (child != null && listBoxTop < child.bounds().top && !child.findOne(desc("已关注"))) {
  183. var userNode = child.findOne(className("android.widget.TextView"));
  184. if (userNode) {
  185. userNode = userNode.text();
  186. if (!utility.isEmpty(userNode) && !userContents.includes(userNode)) {
  187. console.log(userNode);
  188. if (userContents.length >= 20) {
  189. userContents.shift();
  190. }
  191. userContents.push(userNode);
  192. try {
  193. child.click();
  194. if (this.execUser()) {
  195. runCount++;
  196. }
  197. } catch (error) {
  198. console.log("用户操作失败:", error);
  199. }
  200. utility.toast("返回用户列表");
  201. this.toUserList();
  202. engine.sleepMs(2000, 3000);
  203. if (!(listBox = className("androidx.recyclerview.widget.RecyclerView").visibleToUser().findOne())) {
  204. utility.toast("没有找到用户列表!");
  205. return;
  206. }
  207. }
  208. } else {
  209. console.log("没有获取到用户信息");
  210. }
  211. }
  212. }
  213. if (!listBox.scrollForward()) {
  214. if (++gjcsCount >= param.gjcs.length) {
  215. alert("对标账号已全部运行完!", "本次任务共完成\n点赞" + dzCount + "次\n关注" + gzCount + "次\n评论" + plCount + "次");
  216. break;
  217. }
  218. engine.sleepMs(3000, 4000);
  219. back();
  220. engine.sleepMs(3000, 4000);
  221. back();
  222. engine.sleepMs(3000, 4000);
  223. if (!this.dbzhgjc(param.gjcs[gjcsCount])) {
  224. break;
  225. }
  226. }
  227. engine.sleepMs(2500, 3500);
  228. }
  229. }
  230. }
  231. };
  232. try {
  233. znzf.run();
  234. } catch (error) {
  235. utility.error(conf.packageName, error);
  236. } finally {
  237. engine.exit();
  238. }