Scriptbar Snippets 🚀
Handy and easy to understand snippets to keep in your browser
list-all-event-listeners.js

#Basic

List all event listener on page

Script will list all eventlistener on page by selector, event, and function detail

List all event listeners demo

console.table((function listAllEventListeners() { const allElements = Array.prototype.slice.call(document.querySelectorAll('*')); allElements.push(document); // we also want document events const types = []; for (let ev in window) { if (/^on/.test(ev)) types[types.length] = ev; } let elements = []; for (let i = 0; i < allElements.length; i++) { const currentElement = allElements[i]; for (let j = 0; j < types.length; j++) { if (typeof currentElement[types[j]] === 'function') { elements.push({ "node": currentElement, "type": types[j], "func": currentElement[types[j]].toString(), }); } } } return elements.sort(function(a,b) { return a.type.localeCompare(b.type); }); })());
Built with ❤️ by @domnguyen and everyone on the internet 🚀