-2

I've written a bookmarklet that creates a Canvas with an event listener tracking mouse clicks that covers the whole page. The problem is that some sites have event listeners on the body of the page that have useCapture set to true. This blocks my Canvas from registering clicks.

I've researched and tried everything I could think of to remove the event listeners on the body element, but it seems that it is impossible to mess with the event listeners of the body. Does anyone have any ideas?

Side note: please don't mark this as a duplicate. None of the other posts on removing event listeners that I have seen are asking the same thing. I am not trying to remove an event listener that I created myself -- I am trying to remove an event listener that was created through code that I cannot modify.

inavda
  • 333
  • 5
  • 15
  • 1
    Please add your code, otherwise we can't help you – Jack Bashford Nov 07 '18 at 00:30
  • 1
    The reason why you are seeing other posts that relate to removing event listeners that are anonymous is because, for all intents and purposes, that's what you are dealing with - - You need to remove a listener but you don't know its name. This can't be done, so your question is likely to be closed or marked as a dupe. – Scott Marcus Nov 07 '18 at 00:35
  • @Scott I see your point - but all the answers in those posts say to simply not use anonymous functions.. which obviously won't work in my case. – inavda Nov 07 '18 at 05:27
  • @Jack the details of the code aren't really relevant. The issue I'm trying to solve is this: how do I remove event listeners from a body element (or get confirmation that it is, as I suspect, not possible)? I'm not trying to fix a bug in my code - I'm trying to figure out if it's possible to modify the body element of a webpage in the way I described. – inavda Nov 07 '18 at 05:30
  • 1
    @inavda *"but all the answers in those posts say to simply not use anonymous functions.. which obviously won't work in my case"*. Right, and so you are out of luck. This can't be done. – Scott Marcus Nov 07 '18 at 13:10

1 Answers1

0

Turns out this isn't possible. Unless somebody suggests another solution, there is no known way to access event listeners attached to the body of a webpage without pointers to those event listeners.

inavda
  • 333
  • 5
  • 15