diff --git a/fontScript/index.js b/fontScript/index.js index 2b01f7f..28fbca4 100644 --- a/fontScript/index.js +++ b/fontScript/index.js @@ -1,7 +1,7 @@ (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; + 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 @@ -9,7 +9,7 @@ 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))['"]?\)/); + 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