Last active
November 28, 2024 15:53
-
-
Save cmckni3/ef8b27b405669388f5a260d03eb6897c to your computer and use it in GitHub Desktop.
Get all event listeners on page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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