Greasy Fork

Greasy Fork is available in English.

秘塔搜清空历史记录

添加一个清空按钮,点击后执行清空操作

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         秘塔搜清空历史记录
// @namespace    https://www.52pojie.cn/home.php?mod=space&uid=1034393
// @version      1.0
// @description  添加一个清空按钮,点击后执行清空操作
// @author       aura_service
// @match       https://metaso.cn/*
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 创建清空按钮
    const clearButton = document.createElement('button');
    clearButton.textContent = '清空';
    clearButton.style.position = 'fixed';
    clearButton.style.bottom = '20px';
    clearButton.style.right = '20px';
    clearButton.style.zIndex = '1000';
    clearButton.style.padding = '10px 20px';
    clearButton.style.backgroundColor = '#f00';
    clearButton.style.color = '#fff';
    clearButton.style.border = 'none';
    clearButton.style.borderRadius = '5px';
    clearButton.style.cursor = 'pointer';

    // 将按钮添加到页面
    document.body.appendChild(clearButton);

    // 按钮点击事件
    clearButton.addEventListener('click', () => {
        // 获取所有按钮元素
        const buttons = document.querySelectorAll('button');

        // 遍历所有按钮
        buttons.forEach(button => {
            // 检查按钮的类名是否匹配
            if (button.classList.contains('MuiButtonBase-root') &&
                button.classList.contains('MuiIconButton-root') &&
                button.classList.contains('MuiIconButton-sizeMedium') &&
                button.classList.contains('Search_delete-btn__XlhFS') &&
                button.classList.contains('css-txgqa2')) {

                // 点击匹配的按钮
                button.click();

                // 等待0.1秒后查找文本为“确定”的按钮
                setTimeout(() => {
                    const new_buttons = document.querySelectorAll('button');
                    // 查找文本为“确定”的按钮
                    const confirmButton = Array.from(new_buttons).find(btn => btn.textContent.trim() === '确定');

                    // 如果找到“确定”按钮,则点击
                    if (confirmButton) {
                        confirmButton.click();
                    }
                }, 100); // 100毫秒
            }
        });
    });
})();