Disable page close confirmation (onBeforeUnload)
当前为
// ==UserScript==
// @name Disable page close confirmation
// @description Disable page close confirmation (onBeforeUnload)
// @namespace http://nags.must.die
// @version 1.2
// @grant none
// @run-at document-start
// @match *://*/*
// ==/UserScript==
(function () {
function clearUnload() {
window.onbeforeunload = null;
window.onunload = null;
}
addEventListener('load', function _() {
removeEventListener('load', _);
clearUnload();
});
addEventListener('beforeunload', function(e) {
e.stopImmediatePropagation();
clearUnload();
}, true);
})();