Last active
December 22, 2015 05:28
-
-
Save catdad/6423949 to your computer and use it in GitHub Desktop.
fonts in page
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
function styleInPage(css, verbose){ | |
if(typeof getComputedStyle== "undefined") | |
getComputedStyle= function(elem){ | |
return elem.currentStyle; | |
} | |
var who, hoo, values= [], val, | |
nodes= document.body.getElementsByTagName('*'), | |
L= nodes.length; | |
for(var i= 0; i<L; i++){ | |
who= nodes[i]; | |
if(who.style){ | |
hoo= '#'+(who.id || who.nodeName+'('+i+')'); | |
val= who.style.fontFamily || getComputedStyle(who, '')[css]; | |
if(val){ | |
if(verbose) values.push([hoo, val]); | |
else if(values.indexOf(val)== -1) values.push(val); | |
// before IE9 you need to shim Array.indexOf (shown below) | |
} | |
} | |
} | |
return values; | |
} | |
//call | |
styleInPage('fontFamily'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment