Skip to content

Instantly share code, notes, and snippets.

function allStyleSheets(doc) {
var stylesheets = [];
for(var i = 0; i < doc.styleSheets.length; i++)
stylesheets = stylesheets.concat(getStyleSheets(doc.styleSheets[i]));
return stylesheets;
}
function getStyleSheets(stylesheet) {
if(!stylesheet)
return []; // Firefox protects against @import statement loops
function getFont(element) {
// create canvas in owner doc to get @font-face fonts
var doc = element.ownerDocument;
var canvas = doc.createElement("canvas");
var context = canvas.getContext("2d");
if(!context.measureText)
return "Text";
var style = doc.defaultView.getComputedStyle(element, null);