MacOS – How to add a confirmation prompt window to warn before closing a window for any application

dialogfirefoxmacosscriptwindow-manager

This is about adding a Warn-Before-Closing Confirmation Dialog Window to all application windows in macOS before closing a window.

How do I add a Confirmation Dialog Window when I click the Red X close circle button in the top left corner of a application window to warn me before closing a window? This is basically what Firefox has or at least it had it when I used it a couple years ago, but I would want this applied to every single application window that has an X button for closing that window. When you would click the X button for a window in Firefox with multiple tabs open and try to close that window it would state and ask the following: "You are about to close 83 tabs. Are you sure you want to continue?"

This is a picture of the FireFox warn-before-closing confirmation dialog window I was talking about.

enter image description here

I want to add a confirmation dialog window like that for any and all application/program windows because I sometimes accidentally press the red x close circle button to close a window. When I click or press that red x close circle button to close a window for any reason intentionally or unintentionally, especially by accident, I want a confirmation dialog window to appear confirming whether or not I really want to close it.

Again, I would want this Warn-Before-Closing Confirmation Dialog Window to appear when the Red X Circle Close button is clicked before Closing ANY macOS application window.

Again, how it works is after I would click on a Red X circle close button to close a window, a prompt would appear asking if I am sure I want to close that specific window for that specific app. I would have to click on the "Close" button in the prompt window, highlighted in blue, to confirm to successfully close that specified window.

Here are a few examples featuring a few apps of how I would want it to look and work upon clicking the Red X circle close button to warn me before closing a window for every macOS application window:

enter image description here
enter image description here
enter image description here

I would want this close confirmation prompt window to warn me before closing a window for EVERY macOS application, not just the ones I showed in the examples.

To clarify, I am pretty sure this would be applied system-wide, not to any one specific app or program, but rather to ALL applications/programs for every application/program window that is attempted to be closed.

Let me know if I would need to update to the latest version of macOS to do this. Or if I can use the older version of macOS High Sierra that I have installed on my computer.

Does anyone know if this is possible? Thank you.

Best Answer

You clearly know what you want, and that is great, but you might have a hard time convincing other people to make it for you to your exact specifications.

Safari on macOS does not have any scripting hooks you can use to prevent closing any Safari window with the red button, so it won't be trivial to make Safari do what you want.

One possible avenue to consider is writing a webpage that intercepts the window close event to install a custom behaviour. This might be satisfactory, depending on exactly what problem you're trying to solve.

If you're not totally set on using Safari, you could try developing an extension for Firefox that implements the behaviour you want. I don't actually know for sure if that is possible.

You could try visiting the Mozilla Forums and submitting a feature request to have your feature added to Firefox core, but it is extremely unlikely that anybody will listen and add your feature.

If you want this badly enough that you're willing to pay money for it, you could try putting out an offer on a marketplace for freelance programmers (like Fiverr) and maybe somebody can help you create this feature that is very important to you.