A javascript function to map document.styleSheets.
The return values is an (Promise)[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise]
that resolves to an object with the following properties:
await cssMapper(document);
/* logs something like this:
animations: [CSSKeyframesRule, CSSKeyframesRule]
conditionalGroups: [
{conditionText: '@supports (display:grid)', inheritedConditionText: '', rule: CSSSupportsRule}
{conditionText: '@media screen and (max-width: 900px)', inheritedConditionText: '@supports (display:grid)', rule: CSSMediaRule}
{conditionText: '@media screen and (max-width: 600px)', inheritedConditionText: '@media screen and (max-width: 900px), @supports (display:grid)', rule: CSSMediaRule}
{conditionText: '@media screen and (min-width: 900px)', inheritedConditionText: '', rule: CSSMediaRule}
]
fontDeclarations: [
"\"Titillium Web\", sans-serif"
"Roboto, sans-serif"
]
fonts: [
{mapped: {…}, fontFaceRule: CSSFontFaceRule, cssText: '@font-face { font-family: Roboto; font-style: norm… U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }'}
{mapped: {…}, fontFaceRule: CSSFontFaceRule, cssText: '@font-face { font-family: Roboto; font-style: norm…range: U+400-45F, U+490-491, U+4B0-4B1, U+2116; }'}
{mapped: {…}, fontFaceRule: CSSFontFaceRule, cssText: '@font-face { font-family: Roboto; font-style: norm…") format("woff2"); unicode-range: U+1F00-1FFF; }'}
{mapped: {…}, fontFaceRule: CSSFontFaceRule, cssText: '@font-face { font-family: Roboto; font-style: norm…f2") format("woff2"); unicode-range: U+370-3FF; }'}
{mapped: {…}, fontFaceRule: CSSFontFaceRule, cssText: '@font-face { font-family: Roboto; font-style: norm…169, U+1A0-1A1, U+1AF-1B0, U+1EA0-1EF9, U+20AB; }'}
{mapped: {…}, fontFaceRule: CSSFontFaceRule, cssText: '@font-face { font-family: Roboto; font-style: norm… U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }'}
{mapped: {…}, fontFaceRule: CSSFontFaceRule, cssText: '@font-face { font-family: Roboto; font-style: norm…U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }'}
{mapped: {…}, fontFaceRule: CSSFontFaceRule, cssText: '@font-face { font-family: "Titillium Web"; font-st… U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }'}
{mapped: {…}, fontFaceRule: CSSFontFaceRule, cssText: '@font-face { font-family: "Titillium Web"; font-st…U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }'}
]
mediaQueries: [
{rule: CSSMediaRule, children: Array(1)}
{rule: CSSImportRule, children: Array(0)}
{rule: CSSMediaRule, children: Array(0)}
{rule: CSSStyleSheet, children: Array(0)}
{rule: CSSStyleSheet, children: Array(0)}
]
styleSheets: [
{href: 'https://fonts.googleapis.com/css?family=Roboto:400…cyrillic-ext,greek,greek-ext,latin-ext,vietnamese', sheet: CSSStyleSheet, type: 'external'}
{href: 'https://fonts.googleapis.com/css?family=Titillium+Web:400,400i,700,700i&display=swap', sheet: CSSStyleSheet, type: 'external'}
{href: 'http://localhost:63342/webtile-node-test/www/css-mapper/css.css', sheet: CSSStyleSheet, type: 'text/css'}
{href: 'http://localhost:63342/webtile-node-test/www/css-mapper/widescreen.css', sheet: CSSStyleSheet, type: 'text/css'}
{href: 'http://localhost:63342/webtile-node-test/www/css-mapper/smallscreen.css', sheet: CSSStyleSheet, type: 'text/css'}
{href: null, sheet: CSSStyleSheet, type: 'text/css'}
]
Tests are in test/test.html