Created
June 15, 2020 20:13
-
-
Save dana-ross/940247345e754f62518d27fd7847bd15 to your computer and use it in GitHub Desktop.
This file contains 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
function getFontSize(n) { | |
return parseInt(window.getComputedStyle(n, null).getPropertyValue('font-size')) | |
} | |
function renderNode(n) { | |
let output = [n.tagName] | |
n.id && output.push(`id="${n.id}"`) | |
n.className && output.push(`class="${n.className}"`) | |
return output.join(' ') | |
} | |
function nodePath(n) { | |
let parents = [n] | |
let parent = n.parentElement | |
while(parent) { | |
parents.push(parent) | |
parent = parent.parentElement | |
break | |
} | |
return parents.reverse().map(renderNode).join(' > ') | |
} | |
function checkNode(n) { | |
if(n.nodeType === Node.TEXT_NODE) { | |
return | |
} | |
if(getFontSize(n) < 12) { | |
console.log(nodePath(n)) | |
} | |
n.childNodes.forEach(checkNode) | |
} | |
checkNode(document.querySelector('body')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment