Skip to content

Instantly share code, notes, and snippets.

@mariotaku
Last active July 3, 2022 03:55
Show Gist options
  • Star 53 You must be signed in to star a gist
  • Fork 17 You must be signed in to fork a gist
  • Save mariotaku/e00b6b93663f2f420ef9 to your computer and use it in GitHub Desktop.
Save mariotaku/e00b6b93663f2f420ef9 to your computer and use it in GitHub Desktop.
删除当前屏幕所有微博

删除所有微博

在Chrome Dev Tools中粘贴代码到Console,就可以删除当前屏幕所有微博。经过测试一万条微博大约需要10小时的半人工操作。

每批删除大概一分钟,最多50条。

如果遇到微博的Rate limit(提示操作过快),稍等三五分钟再试即可。

/*
* 在weibo.com的个人首页删除当前屏幕所有微博
*/
var http = new XMLHttpRequest();
var anchors = document.getElementsByTagName("div");
for (i = 0; i < anchors.length; i++) {
// 找到有mid属性的div元素
var mid = anchors[i].getAttribute("mid");
if (mid) {
console.log("Deleting " + mid);
// 这是微博的删除接口
var url = "/aj/mblog/del?ajwvr=6";
var params = "mid=" + mid;
http.open("POST", url, false);
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.send(params);
}
}
window.location.reload();
/*
* 在weibo.cn的个人微博列表删除当前屏幕所有微博
* 推荐把屏幕条数设置为50,这样删得多很多
*/
var http = new XMLHttpRequest();
// 找到所有链接
var anchors = document.getElementsByTagName("a");
for (i = 0; i < anchors.length; i++) {
var name = anchors[i].textContent;
// 找出文字为“删除”的链接
if (name == "删除") {
var delLink = anchors[i].getAttribute("href");
console.log("Deleting " + delLink);
// 实际删除操作是删除确认的URL+如下两个参数
var url = delLink + "&type=del&act=delc";
http.open("GET", url, false);
http.send();
}
}
// 重载页面
window.location.reload();
@mariotaku
Copy link
Author

有谁有兴趣做个bookmarklet?这些代码我把它归属到公有领域吧。

@kyykyy54321
Copy link

书签。。 稍微改了一点点 XD

javascript:!function(){var a=document,b=a.createElement("div");b.innerHTML='<div id="_msg" style="background-color:rgba(0,0,0,.8);position:fixed;top:0;left:0;min-width:320px;min-height:64px;margin:15px;padding:5px;color:#fff;z-index:99999"></div>',a.body.appendChild(b),b=b.querySelector("div");var c=function(c){var d=a.createElement("p");d.innerHTML=c,b.appendChild(d)},d=new XMLHttpRequest,e=a.getElementsByTagName("div");for(i=0;i<e.length;i++){var f=e[i].getAttribute("mid");if(f){c("Deleting "+f);var g="/aj/mblog/del?ajwvr=6",h="mid="+f;d.open("POST",g,!1),d.setRequestHeader("Content-type","application/x-www-form-urlencoded"),d.send(h)}}return c("本页删除完成"),void window.location.reload()}();

@mariotaku
Copy link
Author

@mekomlusa
Copy link

巨巨我是特地登录GIT表示感谢的(

@zh4n7wm
Copy link

zh4n7wm commented Jul 24, 2018

发到 Greasy Fork 上,https://greasyfork.org/zh-CN/scripts/370558-delete-sina-weibo-posts
装个浏览器扩展,然后安装该脚本可以自动删除所有微博。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment