let i = 0;
async function deleteMessage() {
const arrowButtons = document.getElementsByClassName('woo-font woo-font--angleDown morepop_action_bk3Fq');
if (i >= arrowButtons.length) {
console.log("No more elements found for index =", i);
return;
}
const iDom = arrowButtons[i];
if (iDom) {
iDom.click();
await wait(300);
try {
const deleteButtons = Array.from(document.querySelectorAll('div.woo-box-flex.woo-box-alignCenter[role="button"]'));
const deleteButton = deleteButtons.find(el =>
el.querySelector('div > div > div') && el.querySelector('div > div > div').textContent.includes('删除')
);
if (deleteButton) {
deleteButton.click();
await wait(300);
const confirmDom = document.getElementsByClassName('woo-dialog-btn')[1];
if (confirmDom) {
confirmDom.click();
await deleteMessage();
} else {
console.log("Confirmation button not found, retrying...");
await deleteMessage();
}
} else {
console.log("Delete button not found, retrying...");
await deleteMessage();
}
} catch (error) {
console.error("Error during delete operation:", error);
await deleteMessage();
}
} else {
console.log("No element found at index =", i);
}
}
function wait(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// 执行
deleteMessage();
找了几个脚本感觉都不是很好用,以上是自己修改基本上改掉了80%的版本。
使用方法:
打开微博个人主页→按F12打开开发者工具→console控制台-复制粘贴(粘贴不了手动打下allow pasting)该段代码→回车即可