Sometimes websites making some important things and they don’t want to leave or refresh the page until the process finish. But some websites are using this feature for unnecessary things and this become annoying. For solving this problem you can disable “beforeunload” event with UserScript (tempermonkey).

In first please install this extension. Then create new user script and put these codes to there:

// ==UserScript==
// @name Disable beforeunload Event
// @namespace Nixarsoft
// @include *
// @grant none
// @run-at document-start
// ==/UserScript==

(function () {
  'use strict'

  EventTarget.prototype.addEventListenerBase = EventTarget.prototype.addEventListener;
  EventTarget.prototype.addEventListener = function (type, listener) {
    if (type == "beforeunload") {
      console.log('>>>>>>>>>> Event blocked: ' + type)
      // ignore attempts to add a beforeunload event

    // treat all other events normally
    this.addEventListenerBase(type, listener);

Happy coding!!

0 yorum

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

This site uses Akismet to reduce spam. Learn how your comment data is processed.