ChatGPT Edit Cancel Confirmation

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

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         ChatGPT Edit Cancel Confirmation
// @namespace    https://github.com/GooglyBlox
// @version      1.0
// @description  Adds a confirmation dialog when clicking the Cancel button when editing messages
// @author       GooglyBlox
// @match        https://chatgpt.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function handleCancelClick(event) {
        const target = event.target.closest('button');
        if (target &&
            target.classList.contains('btn-secondary') &&
            target.textContent.trim() === 'Cancel') {

            event.stopPropagation();
            event.preventDefault();

            if (confirm('Are you sure you want to cancel?')) {
                document.removeEventListener('click', handleCancelClick, true);

                target.click();

                setTimeout(() => {
                    document.addEventListener('click', handleCancelClick, true);
                }, 0);
            }
        }
    }

    document.addEventListener('click', handleCancelClick, true);
})();