123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- const douyin = require("./common/douyin");
- const conf = require("./common/conf");
- const engine = require("./common/engine");
- const utility = require("./common/utility");
- var param = {
- yxgs: 500,
- czjg1: 3,
- czjg2: 6,
- gksj1: 5,
- gksj2: 10,
- tglv: true,
- dz: 45,
- gz: 5,
- pl: 35,
- txdz: 60,
- pldz: 80,
- plhs: conf.commonts,
- gjcs: ["77396094576", "60866194851"],
- pltp: true
- };
- var znzf = {
- banben: parseFloat(context.getPackageManager().getPackageInfo("com.ss.android.ugc.aweme", 0).versionName) < 27.4,
- init() {
- 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));
- },
- isUserList() {
- var tab = className("androidx.appcompat.app.ActionBar$Tab").visibleToUser().selected().findOnce();
- return tab !== null && (tab.findOne(textContains("粉丝")) !== null || tab.findOne(textContains("关注")) !== null);
- },
- toUserList() {
- while (true) {
- sleep(2000);
- if (this.isUserList()) {
- return;
- }
- back();
- sleep(1000);
- }
- },
- execUser() {
- engine.sleep(param.czjg1, param.czjg2);
- if (!douyin.isHome()) {
- utility.toast("进入主页失败");
- return false;
- }
- if (text("私密账号").visibleToUser().findOnce() !== null || text("帐号已被封禁").visibleToUser().findOnce() !== null) {
- utility.toast("私密或已封禁账号,跳过");
- return false;
- }
- if (param.tglv && className("android.widget.TextView").visibleToUser().id(douyin.getNode("user.lanv").id).findOnce() !== null) {
- utility.toast("蓝v用户,跳过!");
- return false;
- }
- let fansNum = 0;
- var fansNode = id(douyin.getNode("user.fansnum").id).visibleToUser().findOnce();
- if (fansNode && (fansText = fansNode.text(), fansNum = parseFloat(fansText), fansText.indexOf("w") >= 0 || fansText.indexOf("万") >= 0)) {
- fansNum *= 10000;
- }
- let gzNum = 0;
- fansNode = id(douyin.getNode("user.gznum").id).visibleToUser().findOnce();
- if (fansNode && (gzText = fansNode.text(), gzNum = parseFloat(gzText), gzText.indexOf("w") >= 0 || gzText.indexOf("万") >= 0)) {
- gzNum *= 10000;
- }
- if (gzNum - fansNum < 1000) {
- return false;
- }
- fansNode = textContains("作品").visibleToUser().findOnce();
- let videoNum = 0;
- if ((videoNum = fansNode ? parseInt(fansNode.text().replace(/[^0-9]/gi, "")) : videoNum) < 1 || isNaN(videoNum)) {
- utility.toast("该用户没有作品或非正常用户,跳过");
- return false;
- }
- if (this.banben && utility.checkProbability(param.txdz, "头像点赞")) {
- douyin.execTxdz();
- engine.sleepMs(1000, 2000);
- }
- if (utility.checkProbability(param.gz, "关注")) {
- if (followBtn = id(douyin.getNode("user.followBtn").id).visibleToUser().findOnce()) {
- utility.toast("执行关注!");
- followBtn.click();
- engine.sleepMs(500, 1000);
- gzCount++;
- if (followBtn = desc("更多,已展开").visibleToUser().findOne(5000)) {
- followBtn.click();
- engine.sleepMs(500, 1000);
- }
- } else {
- utility.toast("不关注!");
- }
- }
- var followBtn = utility.checkProbability(param.dz, "点赞");
- var isPl = utility.checkProbability(param.pl, "评论");
- if (followBtn || isPl) {
- if (!fansNode.selected()) {
- engine.boundsClick(fansNode.bounds());
- engine.sleepMs(1000, 2000);
- }
- engine.shortSlide();
- var fansNode = id("com.ss.android.ugc.aweme:id/container").visibleToUser().find();
- if (!fansNode.empty()) {
- let video = fansNode[random(0, fansNode.length - 1)];
- video = video.findOne(className("android.view.View"));
- sleep(1000);
- if (video && video.clickable() && video.click() && douyin.IsVideoDelay(5000)) {
- fansNode = random(param.gksj1, param.gksj2);
- utility.toast("观看视频:" + fansNode + " 秒");
- engine.sleep(fansNode);
- if (followBtn) {
- douyin.execLike();
- dzCount++;
- } else {
- utility.toast("不点赞");
- }
- if (isPl && douyin.canComment()) {
- fansNode = utility.checkProbability(param.pldz, "评论点赞");
- douyin.sendComment(param.plhs, isPl, fansNode, param.pltp);
- plCount++;
- } else {
- utility.toast("不评论");
- }
- } else {
- utility.toast("打开视频失败!");
- back();
- sleep(1000);
- }
- }
- }
- return true;
- },
- dbzhgjc(gjc) {
- engine.sleepMs(1000, 2000);
- id("com.ss.android.ugc.aweme:id/et_search_kw").visibleToUser().findOne().setText(gjc);
- engine.sleepMs(1000, 2000);
- var b1 = text("搜索").visibleToUser().findOne().bounds();
- engine.boundsClick(b1);
- engine.sleepMs(3000, 4000);
- var b1 = text("用户").visibleToUser().findOne().bounds();
- engine.boundsClick(b1);
- engine.sleepMs(3000, 4000);
- var b1 = descContains(gjc).visibleToUser().findOne(5000);
- if (b1 === null) {
- alert("没有找到对标账号", "请检查对标账号 " + gjc + " 是否输入正确!");
- return false;
- } else {
- engine.boundsClick(b1.bounds());
- engine.sleepMs(3000, 4000);
- text("粉丝").visibleToUser().findOne().parent().click();
- engine.sleepMs(3000, 4000);
- return !!id("com.ss.android.ugc.aweme:id/root_layout").exists() || (alert("打开粉丝列表失败", "对标账号 " + gjc + " 粉丝列表可能设置隐私了!"), false);
- }
- },
- run() {
- if (this.init()) {
- let runCount = dzCount = gzCount = plCount = 0;
- var userContents = [];
- let gjcsCount = 0;
- let dyc = true;
- while (true) {
- if (dyc && (id("com.ss.android.ugc.aweme:id/hbz").visibleToUser().findOne().parent().click(), dyc = false, !this.dbzhgjc(param.gjcs[gjcsCount]))) {
- break;
- }
- if (runCount >= param.yxgs) {
- device.cancelKeepingAwake();
- alert("恭喜任务完成!", "本次任务共完成\n点赞" + dzCount + "次\n关注" + gzCount + "次\n评论" + plCount + "次");
- return;
- }
- let listBox = className("androidx.recyclerview.widget.RecyclerView").visibleToUser().findOne();
- if (!listBox) {
- utility.toast("没有找到用户列表!");
- return;
- }
- var listBoxTop = listBox.bounds().top;
- var childCount = listBox.childCount();
- for (let i = 0; i < childCount - 1; i++) {
- if (runCount >= param.yxgs) {
- device.cancelKeepingAwake();
- alert("恭喜任务完成!", "本次任务共完成\n点赞" + dzCount + "次\n关注" + gzCount + "次\n评论" + plCount + "次");
- return;
- }
- utility.toast("已执行用户 " + runCount + " 条,任务数" + param.yxgs);
- var child = listBox.child(i);
- if (child != null && listBoxTop < child.bounds().top && !child.findOne(desc("已关注"))) {
- var userNode = child.findOne(className("android.widget.TextView"));
- if (userNode) {
- userNode = userNode.text();
- if (!utility.isEmpty(userNode) && !userContents.includes(userNode)) {
- console.log(userNode);
- if (userContents.length >= 20) {
- userContents.shift();
- }
- userContents.push(userNode);
- try {
- child.click();
- if (this.execUser()) {
- runCount++;
- }
- } catch (error) {
- console.log("用户操作失败:", error);
- }
- utility.toast("返回用户列表");
- this.toUserList();
- engine.sleepMs(2000, 3000);
- if (!(listBox = className("androidx.recyclerview.widget.RecyclerView").visibleToUser().findOne())) {
- utility.toast("没有找到用户列表!");
- return;
- }
- }
- } else {
- console.log("没有获取到用户信息");
- }
- }
- }
- if (!listBox.scrollForward()) {
- if (++gjcsCount >= param.gjcs.length) {
- alert("对标账号已全部运行完!", "本次任务共完成\n点赞" + dzCount + "次\n关注" + gzCount + "次\n评论" + plCount + "次");
- break;
- }
- engine.sleepMs(3000, 4000);
- back();
- engine.sleepMs(3000, 4000);
- back();
- engine.sleepMs(3000, 4000);
- if (!this.dbzhgjc(param.gjcs[gjcsCount])) {
- break;
- }
- }
- engine.sleepMs(2500, 3500);
- }
- }
- }
- };
- try {
- znzf.run();
- } catch (error) {
- utility.error(conf.packageName, error);
- } finally {
- engine.exit();
- }
|