I tried searching for a way to hook the mouseleave event on any document and could accomplish this snippet:
let hook = $(this).mouseleave(() => {
alert('mouseleave')
});
$(this).mouseleave = (...args) => (alert('mouseleave'));
It successfully registers any mouseleave events, but my goal is to replace the existing mouseleave function of a page to my function of choice. The question is: Is there a way to capture the existing mouseleave events globally to replace them with my own function?