// ==UserScript==
// @name QQ空间自动删除说说
// @description 一键删除QQ空间所有说说
// @namespace https://greasyfork.org/users/197529
// @version 0.7.6
// @author kkocdko
// @include *://user.qzone.qq.com/*
// @noframes
// @downloadURL none
// ==/UserScript==
let FloatButton = document.FloatButton = document.FloatButton || (() => {
let buttonBarShadow = document.createElement('div').attachShadow({ mode: 'open' });;
buttonBarShadow.innerHTML = '';
document.body.append(buttonBarShadow.host);
return function(text, onclick) {
let button = document.createElement('button');
button.innerText = text;
button.addEventListener('click', onclick);
buttonBarShadow.append(button);
return button;
};
})();
async function sleepAsync(time) {
return new Promise(resolve => setTimeout(resolve, time));
}
function clickAll(selector, parentNode = document) {
parentNode.querySelectorAll(selector).forEach(el => el.click());
}
new FloatButton('删除所有说说', async () => {
let appIframe = document.querySelector('.app_canvas_frame');
if (!appIframe){
let switchToTag = confirm('未切换到“说说”标签,是否立即切换?');
if (switchToTag){
document.querySelector('.head-nav-menu>.menu_item_311>a').click();
} else {
return;
}
}
let iframeDocument = appIframe.contentWindow.document;
while (true) {
clickAll('.del_btn', iframeDocument);
await sleepAsync(1000);
clickAll('.qz_dialog_layer_sub', iframeDocument);
await sleepAsync(1000);
nextPage();
await sleepAsync(1000);
}
function nextPage() {
iframeDocument.querySelector('.mod_pagenav_main>a').forEach(el => {
if (el.innerText == '下一页') {
el.click();
return;
}
});
}
});