How to get all the Javascript code associated with a DOM element? [closed]

I am working on a web page that has some complex Javascript code that affects the DOM elements. I need a way to programmatically get all the Javascript code that is relevant to a particular element that I choose in the browser. For instance, if I choose a button, I want to get all the event listeners, functions, variables, etc. that determine how the button behaves.

To give another example, suppose I have a button that changes its color on hover using javascript instead of css. I want to find out all the javascript code, that is involved in this feature, such as any event listener, function, or class manipulation that may have happened when the button was mounted onto the website for the first time or something else.

How can I achieve this using code? From code I mean running it in my chrome extension that can take a DOM element and give all the javascript code that affects the element’s functionality.