Update fontScript/index.js
This commit is contained in:
parent
acd33ee096
commit
39954c0579
|
@ -1,9 +1,20 @@
|
||||||
(async () => {
|
(async () => {
|
||||||
const website = window.location.origin; // Get the current website's base URL (or switch to "https://website.tld/")
|
// Use window.location.origin or fallback to "https://website.tld"
|
||||||
const pathToCss = "path/to/css"; // Replace with the relative path to the CSS file
|
const website = window.location.origin || "https://website.tld";
|
||||||
const cssUrl = `${website}/${pathToCss}`; // Combine base URL and CSS path
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Find the first <link> tag with an href ending in ".css"
|
||||||
|
const linkElement = Array.from(document.querySelectorAll('link'))
|
||||||
|
.find(link => link.href.endsWith('.css')); // Adjust condition if needed
|
||||||
|
|
||||||
|
if (!linkElement) {
|
||||||
|
console.log("No CSS file found on the page.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cssUrl = linkElement.href; // Get the full URL of the CSS file
|
||||||
|
console.log(`Fetching CSS from: ${cssUrl}`);
|
||||||
|
|
||||||
// Fetch the CSS file
|
// Fetch the CSS file
|
||||||
const response = await fetch(cssUrl);
|
const response = await fetch(cssUrl);
|
||||||
const cssText = await response.text();
|
const cssText = await response.text();
|
||||||
|
|
Loading…
Reference in a new issue