前面说了怎么导出微博黑名单(
🔗网页链接)。那么怎么对导出的黑名单批量拉黑呢?以下是关于批量拉黑的详细操作步骤。
1、用电脑的浏览器访问微博。
2、按 F12 键。
3、在右侧滑出的界面里找到“控制台”标签,并点击。
4、把批量拉黑代码粘贴到控制台,然后按回车,这时会弹出文件选择框,选中之前导出的黑名单文件 blacklist.txt 即可。
5、如果黑名单比较长,耐心等待拉黑操作执行结束。
6、同样再次提醒注意:为了防止用户在控制台里执行恶意代码,浏览器可能会要求用户先在控制台输入“允许粘贴”才能往控制台粘贴代码。
//以下是批量拉黑的代码
(async()=>{
const x=c=>((document.cookie.match(new RegExp('(^| )'+c+'=([^;]+)'))||
![[]](https://face.t.sinajs.cn/t4/appstyle/expression/ext/normal/66/xiaohuangren_jiandaoshou_mobile.png)
)
![[2]](https://face.t.sinajs.cn/t4/appstyle/expression/ext/normal/61/two_org.gif)
||null),t=x('XSRF-TOKEN');if(!t){console.log('未获取_xsrf');return;}
const i=document.createElement('input');i.type='file';i.accept='.txt,.json';i.click();
i.onchange=async e=>{
const b=JSON.parse(await e.target.files[0].text()),u=Object.keys(b),n=u.length;
for(let j=0;j<n;j++){
const id=+u
![[j]](https://face.t.sinajs.cn/t4/appstyle/expression/ext/normal/af/newj_org.gif)
,name=b[id];console.log(`(${j+1}/${n}) 屏蔽 ${name} (${id})`);
try{
const r=await fetch('/ajax/statuses/filterUser',{
method:'POST',
headers:{'Content-Type':'application/json','x-requested-with':'XMLHttpRequest','x-xsrf-token':t},
body:JSON.stringify({uid:id,status:1,interact:1,follow:1}),
credentials:'include'
});
console.log(await r.json().catch(()=>({error:'非JSON'})));
}catch(err){console.log(`${name} (${id}) 失败:`,err);}
await new Promise(r=>setTimeout(r,1000));
}
console.log('全部完成');
};
})();