Skip to content

Instantly share code, notes, and snippets.

@mechiland
Created February 22, 2018 02:20
Show Gist options
  • Save mechiland/b6dd4245730746fea5ad1bc986b85e2b to your computer and use it in GitHub Desktop.
Save mechiland/b6dd4245730746fea5ad1bc986b85e2b to your computer and use it in GitHub Desktop.
Delete Weibo
// ==UserScript==
// @name Delete Weibo
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://weibo.cn/<Your WeiboID>/profile
// @grant none
// ==/UserScript==
(function() {
'use strict';
var queue = [];
function delete_weibo() {
var wb = queue.shift();
if (wb) {
console.log("delete weibo: " + wb);
var wbUrl = "https://weibo.cn/mblog/del?type=del&id=" + wb + "&act=delc&rl=1&st=c72401";
setTimeout(function(){
delete_weibo_internal(wbUrl);
}, 10);
} else {
console.log("All weibo deleted. should refresh.");
window.location.reload();
}
}
function delete_weibo_internal(wbUrl) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if (xhr.readyState === XMLHttpRequest.DONE) {
delete_weibo();
}
};
xhr.open("POST", wbUrl, true);
xhr.send();
}
var allDivs = document.getElementsByClassName("c");
for (var i = 0; i < allDivs.length; i++ ) {
var wb = allDivs[i].id.substring(2, 100);
if (wb.length > 0) {
queue.push(wb);
}
}
delete_weibo();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment