Event Listeners list

Adds a method to elements to get their event listeners

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==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);