From aaddd47c4f05a891cd3f0a0a891428766bf0aee2 Mon Sep 17 00:00:00 2001 From: ghostrick Date: Sat, 23 May 2020 01:42:57 +0900 Subject: [PATCH] feat: Make web fonts available --- lib/css.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/css.js b/lib/css.js index bdcbe3e..821a36d 100644 --- a/lib/css.js +++ b/lib/css.js @@ -15,7 +15,19 @@ const callbacks = (elementString, cssText, options = {}) => { } const css = async ($, options) => { - const styleSheetElements = $('link[rel="stylesheet"]') + const styleSheetElements = $('link[rel="stylesheet"]').filter(function () { + const href = $(this).attr('href') + const whitelist = [ + 'cloud.typography.com', + 'fast.fonts.net', + 'fonts.googleapis.com', + 'use.typekit.net', + 'maxcdn.bootstrapcdn.com', + 'use.fontawesome.com', + ] + + !whitelist.find((url) => href.includes(url)) + }) const styleElements = $('style') const urlElms = Array.from(styleSheetElements).map((node, i) => { const $element = cheerio.load(node)