先说清楚,此法不适合非程序员,根据自身情况酌情继续阅读。

之前在一个假群里假狗2号(没记错的话)提供了一个Chrome插件及教学视频,对某条评论的所有点赞uid进行批量拉黑。我基本上没这个需求,所发微博阅读量极小,也不怎么发引战话题,所以一直未测前述插件。

近日TK提到一个类似插件,不知与我说的是不是同一个,他批量误拉黑了一千多人。为了某种程度地回滚,他提供了一个批量解除拉黑的法子,参看

https://weibo.com/1401527553/M115vv3F7
在微博评论页F12,切至Network标签页。点击某条评论的"回复",有个请求形如

https://weibo.com/aj/comment/privacy?ajwvr=6&ouid=...&cid=4802650673513214&nick=...
从中获取"cid=4802650673513214",该值只是示例,不要出现将示例私钥抄进代码的笑话啊。查看Network标签页时,可在Filter中选中"Fetch/XHR"。

在控制台执行如下脚本获取给该条评论点赞的用户列表

var cid     = 4802650673513214;
var http    = new XMLHttpRequest();
var uidlist = [];
var pagenum = 1;
while ( 1 )
{
    var url = 'https://weibo.com/aj/like/object/big?ajwvr=6&page=' + pagenum + '&object_id=' + cid + '&object_type=comment';
    http.open( 'GET', url, false );
    http.send( null );
    if ( http.status === 200 )
    {
        var resp    = JSON.parse( http.responseText );
        var temp    = resp.data.html.match( /(?:uid=\")(\d+)(?:\")/g );
        if ( temp )
        {
            for ( var i = 0; i < temp.length; i++ )
            {
                uidlist.unshift( temp[i].match( /\d{10}/i )[0] );
            }
        }
        if( resp.data.page.pagenum == resp.data.page.totalpage )
        {
            break;
        }
    }
    pagenum++;
}
console.log( uidlist );

GUI中第一个点赞的在最右侧,最后一个点赞的在最左侧,我将push换成unshift,输出列表中第一个元素就是第一个点赞的uid。这没啥必要,只是个人喜好。

将uidlist复制到如下脚本,在account.weibo.com页面的控制台对uidlist解除拉黑,如下示例假设uidlist只含有一个uid。

var uidlist = ['5878659096'];
var http    = new XMLHttpRequest();
for ( var i = 0; i < uidlist.length; i++ )
{
    var uid = uidlist[i];
    var rnd = Math.floor( Math.random() * 1e4 + 1.5788995e12 );
    var url = 'https://account.weibo.com/set/aj5/filter/delfeeduser';
    http.open( 'POST', url, false )
    http.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' )
    http.send( 'uid=' + uid + '&_t=0&__rnd' + rnd );
    if ( http.status === 200 )
    {
        var resp    = JSON.parse( http.responseText );
        if ( resp.code != 100000 )
        {
            console.error( '失败: ' + uid );
        }
    }
}

我用"超话社区"进行拉黑、解除拉黑测试

https://weibo.com/u/5878659096
上面是TK提供的法子,适用于我。就此需求而言,不太喜欢全自动插件,这是一种非正常人类研究中心后遗症,而前述两个脚本简单易懂,心里有数。

下面来点狗尾续貂。有很多URL可用于解除拉黑,用F12看了另一种解除拉黑的操作。去目标主页,手动解除拉黑,同时看Network标签页中的日志,选中"Preserve log",否则页面刷新时之前的日志会被清空。在此看到一个

curl 'https://weibo.com/aj/f/delblack?ajwvr=6' \
...
-H 'x-requested-with: XMLHttpRequest' \
--data-raw 'uid=5878659096&objectid=&f=1&extra=&...'
我不会WEB前端编程,简单套用TK的示例,切至weibo.com页面,测试解除拉黑脚本

var uidlist = ['5878659096'];
var http    = new XMLHttpRequest();
for ( var i = 0; i < uidlist.length; i++ )
{
    var uid = uidlist[i];
    var rnd = Math.floor( Math.random() * 1e4 + 1.5788995e12 );
    var url = 'https://weibo.com/aj/f/delblack?ajwvr=6';
    http.open( 'POST', url, false )
    http.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' )
    http.send( 'uid=' + uid + '&objectid=&f=1&__rnd' + rnd );
    if ( http.status === 200 )
    {
        var resp    = JSON.parse( http.responseText );
        if ( resp.code != 100000 )
        {
            console.error( '失败: ' + uid );
        }
    }
}

同理,去目标主页,手动拉黑,看到

curl 'https://weibo.com/aj/filter/block?ajwvr=6' \
...
-H 'x-requested-with: XMLHttpRequest' \
--data-raw 'uid=5878659096&filter_type=1&status=1&interact=1&follow=1'
切至weibo.com页面,测试拉黑脚本

var uidlist = ['5878659096'];
var http    = new XMLHttpRequest();
for ( var i = 0; i < uidlist.length; i++ )
{
    var uid = uidlist[i];
    var rnd = Math.floor( Math.random() * 1e4 + 1.5788995e12 );
    var url = 'https://weibo.com/aj/filter/block?ajwvr=6';
    http.open( 'POST', url, false )
    http.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' )
    http.send( 'uid=' + uid + '&filter_type=1&status=1&interact=1&follow=1&__rnd' + rnd );
    if ( http.status === 200 )
    {
        var resp    = JSON.parse( http.responseText );
        if ( resp.code != 100000 )
        {
            console.error( '失败: ' + uid );
        }
    }
}

将uidlist扩展成多个uid,就是批量拉黑操作。

把获取uidlist的脚本与批量拉黑的脚本合一起,每拉黑10个uid休眠1秒

function sleep ( ms )
{
    return new Promise( resolve => setTimeout( resolve, ms ) );
}

async function block ( cid, group, interval )
{
    var http_0  = new XMLHttpRequest();
    var http_1  = new XMLHttpRequest();
    var pagenum = 1;
    var count   = 0;
    while ( 1 )
    {
        var url = 'https://weibo.com/aj/like/object/big?ajwvr=6&page=' + pagenum + '&object_id=' + cid + '&object_type=comment';
        http_0.open( 'GET', url, false );
        http_0.send( null );
        if ( http_0.status === 200 )
        {
            var resp    = JSON.parse( http_0.responseText );
            var temp    = resp.data.html.match( /(?:uid=\")(\d+)(?:\")/g );
            if ( temp )
            {
                for ( var i = 0; i < temp.length; i++ )
                {
                    var uid = temp[i].match( /\d{10}/i )[0]
                    var rnd = Math.floor( Math.random() * 1e4 + 1.5788995e12 );
                    http_1.open( 'POST', 'https://weibo.com/aj/filter/block?ajwvr=6', false )
                    http_1.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' )
                    http_1.send( 'uid=' + uid + '&filter_type=1&status=1&interact=1&follow=1&__rnd' + rnd );
                    count++;
                    if ( count % group === 0 )
                    {
                        console.log( uid );
                        await sleep( interval * 1000 );
                        count   = 0;
                    }
                }
            }
            if( resp.data.page.pagenum == resp.data.page.totalpage )
            {
                break;
            }
        }
        pagenum++;
    }
}

block( 4802692784066365, 10, 1 );

把获取uidlist的脚本与批量解除拉黑的脚本合一起,每解除拉黑10个uid休眠1秒

function sleep ( ms )
{
    return new Promise( resolve => setTimeout( resolve, ms ) );
}

async function unblock ( cid, group, interval )
{
    var http_0  = new XMLHttpRequest();
    var http_1  = new XMLHttpRequest();
    var pagenum = 1;
    var count   = 0;
    while ( 1 )
    {
        var url = 'https://weibo.com/aj/like/object/big?ajwvr=6&page=' + pagenum + '&object_id=' + cid + '&object_type=comment';
        http_0.open( 'GET', url, false );
        http_0.send( null );
        if ( http_0.status === 200 )
        {
            var resp    = JSON.parse( http_0.responseText );
            var temp    = resp.data.html.match( /(?:uid=\")(\d+)(?:\")/g );
            if ( temp )
            {
                for ( var i = 0; i < temp.length; i++ )
                {
                    var uid = temp[i].match( /\d{10}/i )[0]
                    // console.log( uid );
                    var rnd = Math.floor( Math.random() * 1e4 + 1.5788995e12 );
                    http_1.open( 'POST', 'https://weibo.com/aj/f/delblack?ajwvr=6', false )
                    http_1.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' )
                    http_1.send( 'uid=' + uid + '&objectid=&f=1&__rnd' + rnd );
                    count++;
                    if ( count % group === 0 )
                    {
                        console.log( uid );
                        await sleep( interval * 1000 );
                        count   = 0;
                    }
                }
            }
            if( resp.data.page.pagenum == resp.data.page.totalpage )
            {
                break;
            }
        }
        pagenum++;
    }
}

unblock( 4802692784066365, 10, 1 );

是不是得随机延时啥的啊,别被渣浪给那啥了。

用法是去找"目标评论",停在那个页面时F12呼出Console,copy/paste脚本,记得改cid值。block/unblock并不对称,解除拉黑后除非有意识地重新关注,否则找不到来时的路。

本文展示了一名不会WEB前端编程的老年C/ASM程序员如何照猫画虎胡整的过程,很可能存在大量低级错误,贻笑大方。

2022-08-15 19:50 scz

特别感谢如下134个uid,对cid=4802692784066365的评论"静等被拉黑"进行了测试性点赞,用自己实践了"试试就逝世"的伟大信念,非常感谢你们,我爱你们。

640.png

测试已结束,我回原测试主贴,对每一位有效参与测试者的留言进行了逐条点赞,因为也没有别的办法可有效致谢,只能如此了。另有一些朋友,从留言判断TA们是计划参与测试的,但可能不太理解测试上下文,未被脚本取到uid,未被拉黑,在此一并感谢。

对了,我已将测试结束前脚本取到的134个uid列入TXT备忘。万一将来有天本想拉黑谁,但在这张uidlist中发现有TA,会想起TA头铁的岁月而假装没看见新近的内容。我是个很念香火情的老家伙。

摘自:四哥http://scz.617.cn:8/web/202208141754.txt