Add fontScript/index.js
This commit is contained in:
parent
e220eb2cc9
commit
809aa6b21b
23
fontScript/index.js
Normal file
23
fontScript/index.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
(async () => {
|
||||||
|
const website = "https://example.tld/"; // Replace with the URL of the website
|
||||||
|
const pathToCss = "path/to/css"; // Replace with the path to the CSS file
|
||||||
|
const cssUrl = website + pathToCss;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Fetch the CSS file
|
||||||
|
const response = await fetch(cssUrl);
|
||||||
|
const cssText = await response.text();
|
||||||
|
|
||||||
|
// Use a regular expression to extract the font file path
|
||||||
|
const fontMatch = cssText.match(/url\(['"]?(.*?web-font\.(otf|ttf|woff|woff2|eot))['"]?\)/);
|
||||||
|
|
||||||
|
if (fontMatch && fontMatch[1]) {
|
||||||
|
const resolvedFontPath = new URL(fontMatch[1], cssUrl).href; // Resolve relative path
|
||||||
|
console.log(`Found font URL: ${resolvedFontPath}`);
|
||||||
|
} else {
|
||||||
|
console.log('Font not found in the CSS file.');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching or parsing the CSS file:', error);
|
||||||
|
}
|
||||||
|
})();
|
Loading…
Reference in a new issue