Grok Delete File Uploads

Deletes all uploaded files on Grok files page by pressing a button

当前为 2025-06-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Grok Delete File Uploads
  3. // @namespace nisc
  4. // @version 0.6
  5. // @description Deletes all uploaded files on Grok files page by pressing a button
  6. // @author nisc
  7. // @match https://grok.com/files
  8. // @icon https://grok.com/images/favicon-light.png
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function(){
  13. 'use strict';
  14. const sleep = ms => new Promise(res => setTimeout(res, ms));
  15.  
  16. async function deleteAll() {
  17. const deleteButtons = Array.from(document.querySelectorAll('button[aria-label="Delete"]'));
  18. if (deleteButtons.length === 0) {
  19. console.warn('GRK-USR: No delete buttons found');
  20. return;
  21. }
  22.  
  23. for (const btn of deleteButtons) {
  24. btn.click();
  25. await sleep(200); // Allow modal to open
  26. }
  27.  
  28. await sleep(500); // Wait for all confirm modals to render
  29.  
  30. const confirmButtons = Array.from(document.querySelectorAll('button[aria-label="Confirm"]'));
  31. if (confirmButtons.length === 0) {
  32. console.warn('GRK-USR: No confirm buttons found');
  33. return;
  34. }
  35.  
  36. for (const conf of confirmButtons) {
  37. conf.click();
  38. await sleep(200); // Allow each deletion to process
  39. }
  40.  
  41. console.log('GRK-USR: Deletion sequence complete');
  42. }
  43.  
  44. function addButton() {
  45. const container = document.querySelector('.max-w-\\[50rem\\]');
  46. if (container && !document.getElementById('delete-all-btn')) {
  47. const btn = document.createElement('button');
  48. btn.id = 'delete-all-btn';
  49. btn.textContent = 'Delete all files';
  50. Object.assign(btn.style, {
  51. backgroundColor: 'red', color: 'white', padding: '8px 12px',
  52. border: 'none', borderRadius: '8px', cursor: 'pointer', marginBottom: '10px'
  53. });
  54. btn.addEventListener('click', deleteAll);
  55. container.insertBefore(btn, container.firstChild);
  56. console.log('GRK-USR: Delete all files button added');
  57. }
  58. }
  59.  
  60. new MutationObserver(addButton).observe(document.body, { childList: true, subtree: true });
  61. addButton();
  62. })();

QingJ © 2025

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