Update fontScript/index.js
This commit is contained in:
parent
809aa6b21b
commit
acd33ee096
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue