Skip to content

Instantly share code, notes, and snippets.

@catdad
Last active December 22, 2015 05:28
Show Gist options
  • Save catdad/6423949 to your computer and use it in GitHub Desktop.
Save catdad/6423949 to your computer and use it in GitHub Desktop.
fonts in page
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