Search code examples
javascriptuniswap

Javascript Inject window.addEventListener not working


I want to Inject https://app.uniswap.org/#/swap. And I Input "document.body.addEventListener('click',function(event){console.log(event)})" in chrome console. I can get the event normally by clicking other places. But after clicking to select ETH, in the pop-up module dialog box, I can’t get the event by clicking

I want to know what caused the failure to get the click event


Solution

  • I think you mean theres no event on the open modal.. because otherwise it works for me also. it seems there are another click event from the reach-portal element which will be do as CBroe sais above a stopPropation or something else. If you remove the second event listener from the reach-portal you are able to do it.

    Or, change the click event to "mousedown" or something else will work in this case.

    update: Or even easier, add useCapture to the addEventListener. document.body.addEventListener('click',function(event){console.log(event)},true)