Event Listeners list

Adds a method to elements to get their event listeners

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name     Event Listeners list
// @description Adds a method to elements to get their event listeners
// @version  1.0.1
// @grant    none
// @match    *://*/*
// @license  MIT
// @run-at   document-start
// @namespace https://greasyfork.org/users/223733
// ==/UserScript==

function main() {
  var _addEventListener = Element.prototype.addEventListener;
  var _removeEventListener = Element.prototype.removeEventListener;

  Element.prototype.listEventListeners = function(name) {
    if (!name) return this._eventsList || {};
    if (!this._eventsList) return []
    return this._eventsList[name] || [];
  };

  Element.prototype.addEventListener = function(name, callback) {
    _addEventListener.bind(this)(name, callback);
    if (!this._eventsList) this._eventsList = {};
    if (!this._eventsList[name]) this._eventsList[name] = [];
    this._eventsList[name].push(callback);
  };

  Element.prototype.removeEventListener = function(name, callback) {
    _removeEventListener.bind(this)(name, callback);

    if (!this._eventsList) return;
    if (!this._eventsList[name]) return;
    this._eventsList[name].splice(this._eventsList[name].indexOf(callback), 1);
  };
}

var script = document.createElement('script');
script.appendChild(document.createTextNode('('+ main +')();'));
(document.body || document.head || document.documentElement).appendChild(script);