kimi清空历史记录

在历史记录页面右上角“清空历史记录”,点击后清空所有历史记录

  1. // ==UserScript==
  2. // @name kimi清空历史记录
  3. // @version 0.2
  4. // @description 在历史记录页面右上角“清空历史记录”,点击后清空所有历史记录
  5. // @author Yu1978
  6. // @match https://kimi.moonshot.cn/*
  7. // @grant none
  8. // @namespace https://gf.qytechs.cn/users/1440235
  9. // ==/UserScript==
  10. (function() {
  11. 'use strict';
  12.  
  13. const startButton = document.createElement('button');
  14. startButton.textContent = '清空历史记录';
  15. // 设置按钮样式
  16. startButton.style.position = 'fixed';
  17. startButton.style.top = '15px'; // 距离顶部15px
  18. startButton.style.right = '15px'; // 距离右侧15px
  19.  
  20. // 按钮外观样式
  21. startButton.style.backgroundColor = 'black'; // 黑色背景
  22. startButton.style.color = 'white'; // 白色文字
  23. startButton.style.fontSize = '16px'; // 文字大小
  24. startButton.style.fontWeight = 'bold'; // 文字加粗
  25. startButton.style.padding = '10px 20px'; // 内边距,左右更宽
  26. startButton.style.border = 'none'; // 去掉默认边框
  27. startButton.style.borderRadius = '30px'; // 两端圆形
  28. startButton.style.cursor = 'pointer'; // 鼠标悬浮时显示指针
  29. startButton.style.transition = 'background-color 0.3s ease'; // 添加平滑的颜色变化效果
  30.  
  31. // 鼠标悬浮时的效果
  32. startButton.onmouseover = function() {
  33. startButton.style.backgroundColor = '#333'; // 鼠标悬浮时变暗
  34. };
  35.  
  36. startButton.onmouseout = function() {
  37. startButton.style.backgroundColor = 'black'; // 鼠标移出时恢复原色
  38. };
  39.  
  40. let intervalId = setInterval(() => {
  41. var targetDiv = document.querySelector('.history-modal.hole');
  42. if (targetDiv) {
  43. // 如果找到目标div,将按钮插入
  44. targetDiv.appendChild(startButton);
  45. clearInterval(intervalId); // 停止定时器
  46. }
  47. }, 1000); // 每隔1秒检查一次
  48.  
  49. // 开始按钮点击事件处理函数
  50. startButton.addEventListener('click', async function() {
  51. // 获取所有 class 为 "delete" 的 span 元素
  52. const deleteSpans = document.querySelectorAll('span.delete');
  53.  
  54. // 遍历所有 deleteSpan 元素
  55. for (const deleteSpan of deleteSpans) {
  56. if (deleteSpan) {
  57. // 点击当前的 delete span
  58. deleteSpan.click();
  59.  
  60. // 等待10毫秒后再去查找并点击确认按钮
  61. await new Promise(resolve => setTimeout(resolve, 10));
  62.  
  63. // 找到 class 为 "kimi-button btn-confirm" 的按钮并点击
  64. const confirmButton = document.querySelector('button.kimi-button.btn-confirm');
  65. if (confirmButton) {
  66. confirmButton.click();
  67. }
  68.  
  69. // 本次循环操作结束后,等待500毫秒开始下一次循环
  70. await new Promise(resolve => setTimeout(resolve, 500));
  71. }
  72. }
  73. });
  74. })();

QingJ © 2025

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