kimi删除历史记录

在页面右上角添加开始按钮,循环5次点击删除和确认操作,每次循环间隔500毫秒,并显示运行次数

// ==UserScript==
// @name         kimi删除历史记录
// @version      0.1
// @description  在页面右上角添加开始按钮,循环5次点击删除和确认操作,每次循环间隔500毫秒,并显示运行次数
// @author       3588
// @match        https://kimi.moonshot.cn/*
// @grant        none
// @namespace https://gf.qytechs.cn/users/1428429
// ==/UserScript==

(function() {
    'use strict';

    // 创建开始按钮
    const startButton = document.createElement('button');
    startButton.textContent = '开始';
    startButton.style.position = 'fixed';
    startButton.style.top = '10px';
    startButton.style.right = '10px';
    document.body.appendChild(startButton);

    // 创建用于显示运行次数的元素
    const runCountElement = document.createElement('div');
    runCountElement.style.position = 'fixed';
    runCountElement.style.top = '40px';
    runCountElement.style.right = '10px';
    runCountElement.textContent = '已运行次数: 0';
    document.body.appendChild(runCountElement);

    // 开始按钮点击事件处理函数
    startButton.addEventListener('click', async function() {
        for (let i = 0; i < 5; i++) {
            // 找到 class 为 "delete" 的 span 元素并点击
            const deleteSpan = document.querySelector('span.delete');
            if (deleteSpan) {
                deleteSpan.click();
            }

            // 等待10毫秒后再去查找并点击确认按钮
            await new Promise(resolve => setTimeout(resolve, 10));

            // 找到 class 为 "kimi-button btn-confirm" 的按钮并点击
            const confirmButton = document.querySelector('button.kimi-button.btn-confirm');
            if (confirmButton) {
                confirmButton.click();
            }

            // 更新已运行次数显示
            runCountElement.textContent = `已运行次数: ${i + 1}`;

            // 本次循环操作结束后,等待500毫秒开始下一次循环
            await new Promise(resolve => setTimeout(resolve, 500));
        }
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址