From 882a29f1cabc0944f4310f0efba26ded077cf94e Mon Sep 17 00:00:00 2001 From: hugogogo Date: Sun, 16 May 2021 21:18:29 +0200 Subject: [PATCH] script pour lister les font-faces --- fr/script.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fr/script.js b/fr/script.js index 7d37843..df835f8 100644 --- a/fr/script.js +++ b/fr/script.js @@ -41,6 +41,19 @@ function change_font() let content = Array.from(document.styleSheets); console.log(content); */ + // get all the styleSheets + const styleSheets = Array.from(document.styleSheets); + + styleSheets.forEach(styleSheet => { + const cssRules = styleSheet.cssRules; + + // all the font-faces rules + const rulesFontFace = cssRules.filter(rule => rule.cssText.startsWith('@font-face')); + + rulesFontFace.forEach(fontFace => { + console.log(fontFace); // CSSFontFaceRule object + }); + }); }