QQ空间自动点赞脚本,在手机和电脑上的实现

1. 依托于Autojs

// @version      0.0.1
// @name        手机QQ空间自动点赞
/*
    代码运行依托于Autojs4.1+,andirons7.0+
    适用于QQV8.3.0.4480(非简洁模式)
    运行此脚本前请完全退出QQ或将QQ停留在消息页面
    如有漏赞可适当调整function slidScreen(){...sswip()...}

    重点:本脚本需要截图权限,否则无法运行
*/


auto.waitFor() //检查无障碍服务是否启动
device.wakeUp() //唤醒屏幕
console.log("打开QQ=" + openQQ());
sleep(2000);
console.log("打开动态=" + openDongTai());
sleep(2000);
console.log("进入动态" + enterDongTai());
sleep(2000);
console.log("请求截屏权限" + requestScreenCapture());
sleep(2000);
like();


function openQQ() {
    while (!text("动态").findOne(2000))
    {
        toast('正在打开QQ');
        launchApp("QQ"); //打开学习强国 
        sleep(5000);
    }
    toast('已经打开QQ');
    return true;
}
function openDongTai() {
    //打开全部频道

    while (!text("好友动态").findOne(3000))
    {
        toast("正在打开动态页面");
        text("动态").drawingOrder(2).findOne(3000).parent().click();
        sleep(5000);
    }
    toast("已经打开动态页面,正在准备下一步");
    sleep(3000);
    return true;
}
function enterDongTai() {

    while (!desc("好友动态标题").findOne(3000))
    {
        var ct = text("好友动态").depth(14).findOne(3000).bounds();
        click(ct.centerX(), ct.centerY());//点击动态中心
        sleep(5000);
    }
    toast("已经进入动态页面,正在准备下一步");
    sleep(3000);
    return true;
}

function slidScreen(mode) {
    var dW = device.width; //设备宽度
    var dH = device.height; //设备高度
    var TimeLag = 2000;
    //左上角建立坐标系
    switch (mode)
    {
        case "ups": {
            swipe(dW / 2, dH - dH / 4, dW / 2, dH / 4, TimeLag); //直上滑动
            break;
        }
    }
}

function like() {
    while (true) {
        if (id("c7p").findOne(3000))
        {
            var xy = id("c7p").findOne(3000).bounds();
            // console.log("边界=====>" + xy);
            var comparex = xy.left;
            var comparey = xy.top;
            //采集点
            var img = captureScreen();
            if(comparex + xy.width() / 6>=0&&comparey + xy.height() / 2>=0)
            {
                if (images.pixel(img, comparex + xy.width() / 6, comparey + xy.height() / 2) + 0 == "-13354676")
                {
                    // console.log(xy.width(), xy.height());
                    console.log("点赞=" + click(xy.centerX(), xy.centerY()));
                    toast("点赞+1" );
                }   
            }
    
        }
        slidScreen("ups");
        sleep(3000);
    }
}

2. 依托于浏览器(或Tampermonkey)

var QQlist = new Array();
//点赞好友,若不填点赞所有
// QQlist[0] = "666666";
// QQlist[1] = "88888888";

var dList=new Array()
//不要点赞的QQ好友
// dList[0]="1000000005";
// dList[1]="2000000005";


function likeYou() {
    // console.log("likeYou()函数启用");
    var shuoshuolist = document.getElementsByClassName("f-single");
    for (var i = 0; i < shuoshuolist.length; i++)
    {
        var dantiaoshuoshuo = shuoshuolist[i];
        if (dantiaoshuoshuo.children.length == 3)
        {
            var shuoshuohead = dantiaoshuoshuo.children[0].children[3]; //获取到QQ号码和发表时间
            var shuoshuotime=shuoshuohead.children[1].children[0].innerHTML;//获取到发表时间
            var friendname = shuoshuohead.children[0].children[0]; //获取到好友名字(备注)
            var friendQQ = (friendname.href).match(/\d+/g)[0]; //获取到QQ号,会与数组中的匹配
            if ((QQlist.length == 0 || QQlist.indexOf(friendQQ) > -1)&&dList.indexOf(friendQQ)==-1)
            {
                var dianzanBtn = dantiaoshuoshuo.children[2].children[0].children[0].children[4]; //这里获取到点赞按钮
                if (dianzanBtn.className != "item qz_like_btn_v3 item-on")
                {
                    dianzanBtn.click();
                    console.log("点赞:" + shuoshuotime+":" + friendname.innerHTML + " QQ:" + friendQQ);
                }

            }
        }
    }
    window.scrollBy(0, 200); //往下滚,也就是往下翻说说可以适当更改滚动参数200±
}
(function () {
    'use strict';
    console.log("function ()函数启用");
    window.onload = window.setInterval(likeYou, 2000);
})();

猜你喜欢

转载自www.cnblogs.com/boran/p/12682072.html