From acd33ee096b6c0a872850a8fd3daac68242bed12 Mon Sep 17 00:00:00 2001 From: jb Date: Thu, 28 Nov 2024 21:10:40 +0100 Subject: [PATCH] Update fontScript/index.js --- fontScript/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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