Is there a way to get list of events from element in content script?

1,766 views
Skip to first unread message

Alex Flores

unread,
Oct 8, 2021, 7:47:46 PM10/8/21
to Chromium Extensions
Hello,

As the title says, I'm trying to get a list of events on a particular element in the content script. `getEventListeners(element)` is not a function in the content script. 

Any help would be appreciated.

Thanks

wOxxOm

unread,
Oct 9, 2021, 10:56:44 AM10/9/21
to Chromium Extensions, alex.f...@gmail.com
This function is provided only in devtools console. It's not available anywhere else.

Extensions can do two things:
  1. use chrome.debugger API to send DOMDebugger.getEventListeners
  2. run code in the page context (aka "main world") to read all onXXX properties of the element and override Event.target.addEventListener at document_start to accumulate the listeners in an internal array.
Reply all
Reply to author
Forward
0 new messages