Skip to content

Instantly share code, notes, and snippets.

@cmckni3
Last active July 5, 2019 08:56
Show Gist options
  • Save cmckni3/ef8b27b405669388f5a260d03eb6897c to your computer and use it in GitHub Desktop.
Save cmckni3/ef8b27b405669388f5a260d03eb6897c to your computer and use it in GitHub Desktop.
Get all event listeners on page
window.getAllEventListeners = () => {
return Array.from(document.querySelectorAll('*')).map(element => {
const listeners = getEventListeners(element);
return {
element: element,
listeners: Object.keys(listeners).map(key => {
return {
event: key,
listeners: listeners[key]
};
})
};
}).filter(item => item.listeners.length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment