// ==UserScript== // @name QQ空间自动删除说说 // @description 一键删除QQ空间所有说说。不可恢复,慎用! // @namespace https://greasyfork.org/users/197529 // @homepage https://greasyfork.org/scripts/370936 // @supportURL https://greasyfork.org/scripts/370936/feedback // @version 0.7.11 // @author kkocdko // @license Unlicense // @match *://user.qzone.qq.com/* // @noframes // @downloadURL none // ==/UserScript== 'use strict' const addFloatButton = initFloatButton() addFloatButton('删除所有说说', async function () { this.loop = !this.loop const appIframe = document.querySelector('.app_canvas_frame') if (!appIframe) { const switchToTag = window.confirm('未切换到“说说”标签,是否立即切换?') if (switchToTag) { document.querySelector('.head-nav-menu>.menu_item_311>a').click() } else { return } } const iframeDocument = appIframe.contentWindow.document while (this.loop) { clickAllEl('.del_btn', iframeDocument) await sleepAsync(2000) clickAllEl('.qz_dialog_layer_sub') await sleepAsync(1500) nextPage() await sleepAsync(3000) } function nextPage () { iframeDocument.querySelectorAll('.mod_pagenav_main>a').forEach(el => { if (el.innerText === '下一页') { el.click() } }) } }) function clickAllEl (selector, parentNode = document) { parentNode.querySelectorAll(selector).forEach(el => el.click()) } async function sleepAsync (time) { return new Promise(resolve => setTimeout(resolve, time)) } function initFloatButton () { return (document.addFloatButton = document.addFloatButton || (() => { const buttonBarShadow = document.createElement('div').attachShadow({ mode: 'open' }) buttonBarShadow.innerHTML = '' document.body.appendChild(buttonBarShadow.host) return (text, onclick) => { const button = document.createElement('button') button.textContent = text button.addEventListener('click', onclick) return buttonBarShadow.appendChild(button) } })()) }