(async () => { const website = window.location.origin; // Get the current website's base URL (or switch to "https://website.tld/") const pathToCss = "path/to/css"; // Replace with the relative path to the CSS file const cssUrl = `${website}/${pathToCss}`; // Combine base URL and CSS path 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\(['"]?(.*?\.(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); } })();