Script to find all fonts used on a page

后端 未结 6 1244
無奈伤痛
無奈伤痛 2020-12-10 04:42

Is there easy way to parse a HTML page to find all the fonts used (or all the font stacks used)?

Or similarly, is there a script that parses a page and returns which

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-10 05:33

    developer tools are handy for this sort of thing, but you can spin your own by looping through every element and looking at its computed style properties.

    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

提交回复
热议问题