本站仅供阅览使用。若需进行编辑等操作,请前往源站点。
待删除(炸站特殊时期用)
// ==UserScript==
// @name 自动删除
// @namespace http://tampermonkey.net/
// @version 1.5
// @description 自动删除Wikidot指定页面中的链接内容
// @author H_W
// @match https://lostmedia.wikidot.com/need-deleted
// @match https://*.wikidot.com/*
// @grant GM_openInTab
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @require https://code.jquery.com/jquery-3.6.0.min.js
// ==/UserScript==
(function() {
'use strict';
const OPERATION_DELAY = 5000; // 操作间隔时间
const RETRY_TIMEOUT = 1000; // 重试检查间隔
const MAX_ATTEMPTS = 5; // 最大重试次数
if (isControlPage()) {
handleControlPage();
} else if (isDeletePage()) {
handleDeletePage();
}
function isControlPage() {
return window.location.href === 'https://lostmedia.wikidot.com/need-deleted';
}
function isDeletePage() {
return new URLSearchParams(window.location.search).has('autodelete');
}
function handleControlPage() {
const targetDiv = document.getElementById('u-need-deleted');
if (!targetDiv) return;
const links = extractLinks(targetDiv);
if (links.length > 0) {
setupDeletionQueue(links);
}
}
function extractLinks(container) {
return [...container.querySelectorAll('a[href]')]
.map(a => a.href)
.filter(link => link.startsWith('https://'));
}
function setupDeletionQueue(links) {
GM_setValue('deleteQueue', links);
GM_setValue('processing', false);
startProcessing();
}
async function startProcessing() {
if (GM_getValue('processing')) return;
GM_setValue('processing', true);
const links = GM_getValue('deleteQueue', []);
for (const [index, link] of links.entries()) {
await processLink(link, index);
}
cleanup();
}
async function processLink(link, index) {
const deleteUrl = `${link}?autodelete=${Date.now()}`;
await openTab(deleteUrl);
console.log(`Deleted ${index + 1} pages`);
}
function openTab(url) {
return new Promise(resolve => {
const tab = GM_openInTab(url, {
active: true, // 在前台打开新页面
loadInBackground: false,
incognito: false
});
setTimeout(() => resolve(tab), OPERATION_DELAY);
});
}
function cleanup() {
GM_deleteValue('deleteQueue');
GM_deleteValue('processing');
//alert('已完成!');
location.reload();
}
function handleDeletePage() {
let attempts = 0;
const deletionProcess = setInterval(() => {
if (attempts++ >= MAX_ATTEMPTS) {
clearInterval(deletionProcess);
return;
}
if (tryExecuteDeletion()) {
clearInterval(deletionProcess);
scheduleWindowClose();
}
}, RETRY_TIMEOUT);
}
function tryExecuteDeletion() {
try {
if (WIKIDOT.page.listeners.deletePage) {
WIKIDOT.page.listeners.deletePage({});
setTimeout(() => {
// 自动点击确认警告框
//clickConfirmButton();
// 调用重命名模块的删除函数
if (WIKIDOT.modules.RenamePageModule?.listeners?.deletePage) {
WIKIDOT.modules.RenamePageModule.listeners.deletePage({});
}
}, 1000); // 延迟1秒以确保确认框弹出
return true;
}
} catch (e) {
console.error('删除操作出错:', e);
}
return false;
}
/*
function clickConfirmButton() {
const confirmButton = document.querySelector('#dialog-yes');
if (confirmButton) {
console.log('检测到确认按钮,正在点击...');
confirmButton.click();
} else {
console.log('未找到确认按钮,等待重试...');
setTimeout(clickConfirmButton, RETRY_TIMEOUT);
}
}
*/
window.addEventListener('load', function() {
window.confirm = function() { return true; }
});
function scheduleWindowClose() {
setTimeout(() => {
window.close();
}, OPERATION_DELAY);
}
})();取消Confirm
// ==UserScript==
// @name No Confirm
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 取消Confirm
// @author H_W
// @match https://lostmedia.wikidot.com/*aaaa*
// @icon https://www.google.com/s2/favicons?sz=64&domain=jd.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 重写 confirm 函数
window.confirm = function(message) {
console.log(message); // 可选:打印传入的提示信息
return true; // 总是返回 true
};
})();Please Try Again
// ==UserScript==
// @name Please Try Again页面处理
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 操你妈Please Try Again
// @author 你的名字
// @match https://lostmedia.wikidot.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 检查是否存在 id 为 content 的 div
const contentDiv = document.getElementById('content');
if (contentDiv) {
// 检查是否存在 h1 标签且内容为 "Please try again"
const h1Element = contentDiv.querySelector('h1');
if (h1Element && h1Element.textContent.trim() === 'Please try again') {
// 如果当前页面是 https://lostmedia.wikidot.com/need-deleted,刷新页面
if (window.location.href === 'https://lostmedia.wikidot.com/need-deleted') {
window.location.reload();
} else {
// 否则关闭页面
window.close();
}
}
}
})();页面版本: 4, 最后编辑于: 07 Feb 2025 05:17


