批量删除微博
本文由 小茗同学 发表于 2019-06-15 浏览(3401)
最后修改 2019-06-15 标签:

批量删除微博

打开微博主页,F12打开控制台,粘贴如下代码并回车执行,将自动每隔1秒钟删除本页全部微博:

var items = [...document.getElementsByClassName('WB_feed WB_feed_v3 WB_feed_v4')[0].children];
var interval = setInterval(function() {
	var item = items.shift();
	if (!item) {
		clearInterval(interval);
		console.log('删除完毕!');
		return;
	}
	var mid = item.getAttribute('mid');
	if (!mid) return;
		fetch('https://weibo.com/aj/mblog/del?ajwvr=6', {
	method: 'POST',
	headers: {
		'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
	},
	body: `mid=${mid}`,
}).then(resp => resp.json()).then(resp => {
	if (resp.code === '100000') {
	console.log('删除成功:' + mid)	;
	item.remove();
}
});
}, 1000);

如果只需要删除某种类型的微博,比如原创,可以在这里筛选,然后再粘贴代码执行。

批量设置仅自己可见

var items = [...document.getElementsByClassName('WB_feed WB_feed_v3 WB_feed_v4')[0].children].map(item => ({item, mid: item.getAttribute('mid')}));
console.log('将要处理:' + items.length + ' 条微博');
var interval = setInterval(function() {
	var item = items.shift();
	if (!item) {
		clearInterval(interval);
		console.log('处理完毕!');
		return;
	}
	var mid = item.mid;
	if (!mid) return;
		fetch(`https://weibo.com/p/aj/v6/mblog/modifyvisible?ajwvr=6&domain=100505&__rnd=${Date.now()}`, {
	method: 'POST',
	headers: {
		'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
	},
	body: `visible=1&mid=${mid}&_t=0`,
}).then(resp => resp.json()).then(resp => {
	if (resp.code === '100000') {
	console.log(`设置自己可见成功:${mid}`)	;
//	 item.remove();
} else {
	console.log(`设置自己可见失败:${mid},${resp.msg}`)
}
});
}, 200);