Disable page close confirmation

Disable page close confirmation (onBeforeUnload)

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Disable page close confirmation
// @description Disable page close confirmation (onBeforeUnload)
// @namespace   http://nags.must.die
// @version     2.0
// @grant       none
// @run-at      document-start
// @match       *://*/*
// ==/UserScript==

(function () {
  var spoofer = {
    enumerable: true,
    configurable: false,
    get: () => null,
    set: fn => fn,
  };
  Object.defineProperties(window, {
    onbeforeunload: spoofer,
    onunload: spoofer,
  });

  var originalAdd = EventTarget.prototype.addEventListener;
  EventTarget.prototype.addEventListener = function (type) {
    var tl;
    if (this !== window ||
        typeof type !== 'string' ||
        (tl = type.toLowerCase()) !== 'beforeunload' && tl !== 'unload') {
      originalAdd.apply(this, arguments);
    }
  };
})();