账号管理脚本,可应对长名刷屏

By 爱狗却养猫 at 2020-07-06

@natasha @electron8964 @Merlin @libgen

由于前段时间的刷屏问题,我一个朋友帮我写了一个账号管理脚本,在这里:https://paste.ee/p/cKLH2

可以用Tor的插件violentmonkey,新建脚本复制黏贴code,然后在2049站上时只要violentmonkey开着会自动运行。我今天试了试,真的很好用。

先申明:Tor本身不推荐插件,指出风险自负。我选择violentmonkey的原因是因为:(1)它是开源插件(https://violentmonkey.github.io/),(2)它与其他类似插件相比,能兼容Tor,(3)我自己评估后愿意接受风险。脚本我自己一行行看过,不含任何危险因素(如跟踪记录什么的)。你们如果想用的话可以找信得过的人帮忙看,不想用就不用。

之所以先多说这几句的原因:由于匿名论坛的性质,我现在最担心的事情之一,是大家因为怀疑而开始分裂捉鬼(而且我以前也被当作过鬼,有点PTSD),所以觉得什么话直接说明白了更好。有怀疑完全可以理解,不过在结果上,我只希望解决问题而不是创造问题。

以下是使用tutorial:

  1. 在Tor里安装Firefox的violentmonkey插件,地址如下:https://addons.mozilla.org/en-US/firefox/addon/violentmonkey/。在Tor里打开该页面,Add to Firefox会装在顶栏。

  1. 点击右上角的猴子图标,再点击齿轮图标,Open Dashboard。在打开的页面里点击加号,选择“New”。

  1. 打开的页面就是脚本编辑器。从 https://paste.ee/p/cKLH2 拷贝所有的code,黏贴到脚本编辑器里。然后点击右上角倒数第二个按钮,Save & Close。

  1. 可以看到在violentmonkey的窗口里出现了新脚本。这时可以关闭violentmonkey的页面。

  1. 以管理员账号登录2049,会看到右上角的猴子有一个“1”的标志,意为有与此站点相匹配的script。(可以随时切换启用/停用。)然后所有ID(包括我自己)的后面都有快捷选项,包括封禁(0),注销(-1),恢复(5),限制(6)。

  1. 此外如果碰到太长的ID(大于16),会出现一键“截断用户名”的选项(用开头16个字),例如这里:

截断了以后的效果:

刷屏, 长名, 账号, 脚本, 应对


非常感谢!我学习学习,然后再来汇报一下试验结果。

natasha at 2020-07-06
1

使用Adblock Plus 插件,可以屏蔽首页、二级页面、文章页的长ID的DOM节点,但是尚不知是否和暴力猴插件互相冲突。有兴趣的话可以尝试tor中下载。然后点击右上ABP图标,点击齿轮图标,进入设置页面,点选”高级”选项卡,“您的自定义过滤”->”我的过滤列表”, 添加以下文本,可以有效解决浏览器卡爆的问题。

2049bbs.xyz##.topic-title-date

2049bbs.xyz##.item-date

阿離 at 2020-07-06
2

如果冲突了,还是以猫狗的脚本为主。 因为如果ABP删除了DOM节点,那么暴力猴插件还是读不到长文本ID的length属性的。

阿離 at 2020-07-06
3
        var toolong = uname.length> 16
        var shorter = n=>n.slice(0,16)

改成

        var toolong = uname.length> 32
        var shorter = n=>md5(n)

因爲前16個字節一樣,你slice就重複了。。。

然後就會rename失敗

霏艺Faye at 2020-07-06
4

突然好感动:小二要是知道猫猫以及大家为维护这个网站花了这么多心思一定会很开心!

natasha at 2020-07-06
5

@阿離 #3 谢谢阿離妹妹啊~

爱狗却养猫 at 2020-07-07
6

@霏艺Faye #4 转换成md5 hash,真是个聪明的好方法!谢谢霏艺~ 我去试验下玩玩。

爱狗却养猫 at 2020-07-07
7

@natasha #5 唉,也不知道他现在怎么样了。

爱狗却养猫 at 2020-07-07
8

@霏艺Faye #4 试了一下,出现了”ReferenceError: md5 is not defined”。我的Tor version 是9.5.1 (based on Mozilla Firefox 68.10.0esr) (64-bit)

爱狗却养猫 at 2020-07-07
9

补充,“限制”的选项是我后来加的。需要在link.style=’color:green’之后,elem.appendChild(link)前,加上一段:

    elem.appendChild(link)

    link = dce('a')
    link.innerText='限制(6)'
    link.title=`按下后“${uname}(${id})”不顶帖,帖子折叠`
    link.onclick = function(){form_flag_post(`/admin/user/edit/${id}`, {act:"flag",flag:6})}
    link.style='color:purple'
爱狗却养猫 at 2020-07-07
10

可以将长名字改为md5的新code(在改了的名字前加md5“标签”):

// ==UserScript==
// @<a href="/member/name">name</a>         2049bbs admin quickban md5
// @<a href="/member/version">version</a>      0.1
// @<a href="/member/description">description</a>  try to take over the world!
// @<a href="/member/author">author</a>       your_old_friend
// @<a href="/member/match">match</a>        https://2049bbs.xyz/*
// @<a href="/member/grant">grant</a>        none
// @<a href="/member/run">run</a> -at       document-idle
// ==/UserScript==

(function() {

    var MD5 = function (string) {

       function RotateLeft(lValue, iShiftBits) {
               return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
       }

       function AddUnsigned(lX,lY) {
               var lX4,lY4,lX8,lY8,lResult;
               lX8 = (lX & 0x80000000);
               lY8 = (lY & 0x80000000);
               lX4 = (lX & 0x40000000);
               lY4 = (lY & 0x40000000);
               lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
               if (lX4 & lY4) {
                       return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
               }
               if (lX4 | lY4) {
                       if (lResult & 0x40000000) {
                               return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
                       } else {
                               return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
                       }
               } else {
                       return (lResult ^ lX8 ^ lY8);
               }
       }

       function F(x,y,z) { return (x & y) | ((~x) & z); }
       function G(x,y,z) { return (x & z) | (y & (~z)); }
       function H(x,y,z) { return (x ^ y ^ z); }
       function I(x,y,z) { return (y ^ (x | (~z))); }

       function FF(a,b,c,d,x,s,ac) {
               a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
               return AddUnsigned(RotateLeft(a, s), b);
       };

       function GG(a,b,c,d,x,s,ac) {
               a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
               return AddUnsigned(RotateLeft(a, s), b);
       };

       function HH(a,b,c,d,x,s,ac) {
               a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
               return AddUnsigned(RotateLeft(a, s), b);
       };

       function II(a,b,c,d,x,s,ac) {
               a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
               return AddUnsigned(RotateLeft(a, s), b);
       };

       function ConvertToWordArray(string) {
               var lWordCount;
               var lMessageLength = string.length;
               var lNumberOfWords_temp1=lMessageLength + 8;
               var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
               var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
               var lWordArray=Array(lNumberOfWords-1);
               var lBytePosition = 0;
               var lByteCount = 0;
               while ( lByteCount < lMessageLength ) {
                       lWordCount = (lByteCount-(lByteCount % 4))/4;
                       lBytePosition = (lByteCount % 4)*8;
                       lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
                       lByteCount++;
               }
               lWordCount = (lByteCount-(lByteCount % 4))/4;
               lBytePosition = (lByteCount % 4)*8;
               lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
               lWordArray[lNumberOfWords-2] = lMessageLength<<3;
               lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
               return lWordArray;
       };

       function WordToHex(lValue) {
               var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
               for (lCount = 0;lCount<=3;lCount++) {
                       lByte = (lValue>>>(lCount*8)) & 255;
                       WordToHexValue_temp = "0" + lByte.toString(16);
                       WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
               }
               return WordToHexValue;
       };

       function Utf8Encode(string) {
               string = string.replace(/\r\n/g,"\n");
               var utftext = "";

               for (var n = 0; n < string.length; n++) {

                       var c = string.charCodeAt(n);

                       if (c < 128) {
                               utftext += String.fromCharCode(c);
                       }
                       else if((c > 127) && (c < 2048)) {
                               utftext += String.fromCharCode((c >> 6) | 192);
                               utftext += String.fromCharCode((c & 63) | 128);
                       }
                       else {
                               utftext += String.fromCharCode((c >> 12) | 224);
                               utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                               utftext += String.fromCharCode((c & 63) | 128);
                       }

               }

               return utftext;
       };

       var x=Array();
       var k,AA,BB,CC,DD,a,b,c,d;
       var S11=7, S12=12, S13=17, S14=22;
       var S21=5, S22=9 , S23=14, S24=20;
       var S31=4, S32=11, S33=16, S34=23;
       var S41=6, S42=10, S43=15, S44=21;

       string = Utf8Encode(string);

       x = ConvertToWordArray(string);

       a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;

       for (k=0;k<x.length;k+=16) {
               AA=a; BB=b; CC=c; DD=d;
               a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
               d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
               c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
               b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
               a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
               d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
               c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
               b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
               a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
               d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
               c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
               b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
               a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
               d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
               c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
               b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
               a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
               d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
               c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
               b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
               a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
               d=GG(d,a,b,c,x[k+10],S22,0x2441453);
               c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
               b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
               a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
               d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
               c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
               b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
               a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
               d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
               c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
               b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
               a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
               d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
               c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
               b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
               a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
               d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
               c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
               b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
               a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
               d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
               c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
               b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
               a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
               d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
               c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
               b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
               a=II(a,b,c,d,x[k+0], S41,0xF4292244);
               d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
               c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
               b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
               a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
               d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
               c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
               b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
               a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
               d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
               c=II(c,d,a,b,x[k+6], S43,0xA3014314);
               b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
               a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
               d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
               c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
               b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
               a=AddUnsigned(a,AA);
               b=AddUnsigned(b,BB);
               c=AddUnsigned(c,CC);
               d=AddUnsigned(d,DD);
          }

        var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);

        return temp.toLowerCase();
    }  

    var gebcn = e=> cn=>e.getElementsByClassName(cn)
    var gebtn = e=> n=>e.getElementsByTagName(n)
    var print = console.log
    var foreach = a=> f=>{var r=[];for(var i=0;i<a.length;i++){r.push(f(a[i]))}return r}

    function dce(t){return document.createElement(t)}

    var cap = i=>Math.min(Math.max(i,0), 1)
    var rgbify = a=>`rgb(${a.join(',')})`

    print('yolo')

    var lis = gebtn(document)('li')


    lis = foreach(lis)(i=>i).filter(e=>e.innerText.startsWith('id'))

    var j = lis.length; j=lis[0]; print(lis) // script fails to run on violentmonkey(firefox) if this line is commented out.
    // seems to be a javascript JIT compiler bug.

    function form_flag_post(url, obj){
        var flag = $('#flag').val();

        $.ajax({
            type: "POST",
            url: url,
            data: JSON.stringify(obj),
            dataType: "json",
            contentType: "application/json",
            success: function(data){
                $.toast(data.retmsg);
                window.location.reload()
            },
            fail: function(errMsg) {
                $.toast(errMsg);
            }
        });
        return false;
    }

    var st = dce('style')
    document.body.appendChild(st)

    st.innerHTML = `
.shorter {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100px;display: inline-block;
}

.flu {
width:250px;
}

.sinfo{
color:gray;
}

.compact{
line-height: 1;margin: 5px;
}
.toolong{
color:red;
}
`
    function append_mgmt(elem, uname, id){
        var link = dce('a')
        link.innerText=' 封禁(0)'
        link.title=`按下后会封禁“${uname}(${id})”,但保留帖子`
        link.onclick = function(){form_flag_post(`/admin/user/edit/${id}`, {act:"flag",flag:0})}
        link.style='color:blue'

        elem.appendChild(link)

        link = dce('a')
        link.innerText='注销(-1)'
        link.title=`按下后会直接注销“${uname}(${id})”,且会从眼前的列表中消失,帖子会被隐藏`
        link.onclick = function(){form_flag_post(`/admin/user/edit/${id}`, {act:"flag",flag:-1})}

        elem.appendChild(link)

        link = dce('a')
        link.innerText='恢复(5)'
        link.title=`按下后会将“${uname}(${id})”恢复正常`
        link.onclick = function(){form_flag_post(`/admin/user/edit/${id}`, {act:"flag",flag:5})}
        link.style='color:green'

        elem.appendChild(link)

        link = dce('a')
        link.innerText='限制(6)'
        link.title=`按下后“${uname}(${id})”不顶帖,帖子折叠`
        link.onclick = function(){form_flag_post(`/admin/user/edit/${id}`, {act:"flag",flag:6})}
        link.style='color:purple'
        elem.appendChild(link)

        var toolong = uname.length> 36
        var premd5 = "MD5_"
        var shorter = n=>premd5.concat(MD5(n))

        if(toolong){
            link = dce('a')
            link.innerText='md5用户名'
            link.title = `将此人用户名修改为[${shorter(uname)}]`
            link.onclick = function(){
                form_flag_post(`/admin/user/edit/${id}`, {"act":"info","name":shorter(uname)})
            }
            elem.appendChild(link)
        }
    }
    foreach(lis)(e=>{
        // parse format
        var match = e.innerHTML.match(/.*?id:(.*?) - (.*?) - flag: (.*?) - info:((.|\n)*?)(<a href=(.|\n)+)/)
        if(!match){
            return -1
        }
        var id = match[1], uname=match[2], flag=match[3], info=match[4], rest=match[6]
        // print(id)

        var toolong = uname.length> 36
        var premd5 = "MD5_"
        var shorter = n=>premd5.concat(MD5(n))

        e.innerHTML = `(${id})[${flag}] <span title="${uname}" class="flu shorter${toolong?" toolong":""}">${toolong?'[过长('+uname.length+')]'+uname:uname}</span> <span class="sinfo shorter" title="${info}">${info}</span> ${rest}`

        e.className+=" compact"

        var div = dce('span')
        e.appendChild(div)

        append_mgmt(div, uname, id)
    })

    var a = gebtn(document)('a')
    a = foreach(a)(e=>{
        var match = e.outerHTML.match(/<a href="\/member\/(\d+?)">(.+?)<\/a>/)
        if (!match){return -1}

        var id = match[1], uname=match[2];
        if(uname=='查看')return -1;
        if(uname.match('<'))return -1;
        print(id, uname)
        var span = dce('span')
        e.after(span)
        append_mgmt(span,uname,id)
    })

})();
爱狗却养猫 at 2020-07-06
11

效果:

截断前:

截断后:

爱狗却养猫 at 2020-07-06
12

/(ㄒoㄒ)/~~再也不用挂一早上/10min 一刷/手动了。程序员们真伟大~

Merlin at 2020-07-15
13

@爱狗却养猫 #8 酷刑伺候中

vowitnow at 2020-07-17
14