Greasy Fork is available in English.

Prevent Accidental Tab Closure with "ctrl + w" [recommended for sploop.io and moomoo.io]

Prevents accidental tab closure when you press ctrl+w

// ==UserScript==
// @name         Prevent Accidental Tab Closure with "ctrl + w" [recommended for sploop.io and moomoo.io]
// @namespace    http://tampermonkey.net/
// @version      2
// @description  Prevents accidental tab closure when you press ctrl+w
// @author       Lore
// @match        *://*/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('beforeunload', function(e) {
        e.preventDefault();
        e.returnValue = '';
    });

    window.addEventListener('keydown', function(e) {
        if (e.ctrlKey && e.key === 'w') {
            e.preventDefault();
            var confirmed = confirm('Are you sure you would like to close this tab or was this a accident?');
            if (confirmed) {
                window.removeEventListener('beforeunload');
                window.close();
            }
        }
    });
})();