1function listAllEventListeners() {
2 const allElements = Array.prototype.slice.call(document.querySelectorAll('*'));
3 allElements.push(document);
4 allElements.push(window);
5
6 const types = [];
7
8 for (let ev in window) {
9 if (/^on/.test(ev)) types[types.length] = ev;
10 }
11
12 let elements = [];
13 for (let i = 0; i < allElements.length; i++) {
14 const currentElement = allElements[i];
15 for (let j = 0; j < types.length; j++) {
16 if (typeof currentElement[types[j]] === 'function') {
17 elements.push({
18 "node": currentElement,
19 "type": types[j],
20 "func": currentElement[types[j]].toString(),
21 });
22 }
23 }
24 }
25
26 return elements.sort(function(a,b) {
27 return a.type.localeCompare(b.type);
28 });
29}