ChatGPT Edit Cancel Confirmation

Adds a confirmation dialog when clicking the Cancel button when editing messages

  1. // ==UserScript==
  2. // @name ChatGPT Edit Cancel Confirmation
  3. // @namespace https://github.com/GooglyBlox
  4. // @version 1.0
  5. // @description Adds a confirmation dialog when clicking the Cancel button when editing messages
  6. // @author GooglyBlox
  7. // @match https://chatgpt.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function handleCancelClick(event) {
  16. const target = event.target.closest('button');
  17. if (target &&
  18. target.classList.contains('btn-secondary') &&
  19. target.textContent.trim() === 'Cancel') {
  20.  
  21. event.stopPropagation();
  22. event.preventDefault();
  23.  
  24. if (confirm('Are you sure you want to cancel?')) {
  25. document.removeEventListener('click', handleCancelClick, true);
  26.  
  27. target.click();
  28.  
  29. setTimeout(() => {
  30. document.addEventListener('click', handleCancelClick, true);
  31. }, 0);
  32. }
  33. }
  34. }
  35.  
  36. document.addEventListener('click', handleCancelClick, true);
  37. })();

QingJ © 2025

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