-
-
Save thepeoplesbourgeois/66c2eeecc5b264efd41471ca5e354b1a to your computer and use it in GitHub Desktop.
Revisions
-
thepeoplesbourgeois revised this gist
Nov 5, 2019 . 2 changed files with 15 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ function allEventListeners(){ const eventNames = Object.keys(window).filter(key => /^on/.test(key)) return [...document.querySelectorAll('*'), document].flatMap((node) => eventNames .filter(event => node[event]) .map(event => { return { node, event, listener: (typeof node[event] === 'function') ? node[event].toString() : node[event] } }) ) } console.table(allEventListeners()) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,26 +0,0 @@ -
tkafka revised this gist
Mar 6, 2019 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,12 @@ console.table((function listAllEventListeners() { const allElements = Array.prototype.slice.call(document.querySelectorAll('*')); allElements.push(document); // we also want document events const types = []; for (let ev in window) { if (/^on/.test(ev)) types[types.length] = ev; } let elements = []; for (let i = 0; i < allElements.length; i++) { const currentElement = allElements[i]; for (let j = 0; j < types.length; j++) { @@ -22,4 +23,4 @@ console.table((function listAllEventListeners() { return elements.sort(function(a,b) { return a.type.localeCompare(b.type); }); })()); -
tkafka revised this gist
Mar 6, 2019 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ console.table((function listAllEventListeners() { let elements = []; const allElements = document.querySelectorAll('*'); const types = []; @@ -22,6 +22,4 @@ const listeners = (function listAllEventListeners() { return elements.sort(function(a,b) { return a.type.localeCompare(b.type); }); })()); -
tkafka revised this gist
Mar 6, 2019 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,16 +12,16 @@ const listeners = (function listAllEventListeners() { if (typeof currentElement[types[j]] === 'function') { elements.push({ "node": currentElement, "type": types[j], "func": currentElement[types[j]].toString(), }); } } } return elements.sort(function(a,b) { return a.type.localeCompare(b.type); }); })(); console.table(listeners); -
dmnsgn created this gist
Apr 5, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ const listeners = (function listAllEventListeners() { let elements = []; const allElements = document.querySelectorAll('*'); const types = []; for (let ev in window) { if (/^on/.test(ev)) types[types.length] = ev; } for (let i = 0; i < allElements.length; i++) { const currentElement = allElements[i]; for (let j = 0; j < types.length; j++) { if (typeof currentElement[types[j]] === 'function') { elements.push({ "node": currentElement, "listeners": [ { "type": types[j], "func": currentElement[types[j]].toString(), }] }); } } } return elements.filter(element => element.listeners.length) })(); console.table(listeners);