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 characters
// Get all the binding click events number in page | |
// Return number | |
Array.from(document.querySelectorAll('*')) | |
.reduce(function(pre, dom){ | |
var clks = getEventListeners(dom).click; | |
pre += clks ? clks.length || 0 : 0; | |
return pre | |
}, 0) | |
// If you want see what events have been bound in all your elements in your page and |
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 characters
const replaceOnDocument = (pattern, string, { target = document.body } = {}) => { | |
[target, ...target.querySelectorAll("*:not(script):not(noscript):not(style)")] | |
.forEach(({ childNodes: [...nodes] }) => nodes | |
.filter(({ nodeType }) => nodeType === document.TEXT_NODE).forEach((textNode) => (textNode.textContent = textNode.textContent.replace(patter, string))) | |
); | |
replaceOnDocument("search","replace"); | |
// retrives all childNodes of body |