「CSDN」- 相关内容记录

  CREATED BY JENKINSBOT

批量删除博客

What is the JavaScript version of sleep()? – Stack Overflow

在浏览器的浏览器中(我们在 Firefox 中测试通过),执行如下脚本:

function sleep(ms) {
	return new Promise(resolve => setTimeout(resolve, ms));
}
async function delete_posts() {

	for (var delete_button_list; delete_button_list = $x('//span[contains(text(), "删除")]');) {
		console.log("Length: " + delete_button_list.length)
		for (var delete_button of delete_button_list) {
			
			console.log("Delete...")
			delete_button.click();
			await sleep(500)

			console.log("Confirm...")
			$x('//span[contains(text(), "确定")]')[0].click();
			await sleep(500)	
		}
	}
}

delete_posts()