40
loading...
This website collects cookies to deliver better user experience
<head>
tag of websites that you host and do not have access to the source or do not want to monkey patch source. /join
route. <link>
element into the <head>
element of a websites served HTML. For the example, we will be inject a style sheet into the <head>
to change the appearance of FoundryVTT. class ElementHandler {
element(element) {
element.append(`<link
rel="stylesheet"
type="text/css"
data-id="foundry-login"
href="https://cdn.jsdelivr.net/gh/TheEpicSnowWolf/Foundry-VTT-Prettier-Login-Screen@main/foundry_login.css"
>`, {html: true});
console.log("injected");
}
}
<head>
element on the HTML dom and append a link to the foundry_login.css
script found in the Foundry VTT Prettier Login Screen repository by TheEpicSnowWolf.async function handleRequest(req) {
const res = await fetch(req)
if (res.url.includes('example.com/join')) {
return new HTMLRewriter().on("head", new ElementHandler()).transform(res)
}
return res;
}
/join
route. In the script above, replace the example.com
with your domain or sub-domain.domian.tld
(ex dnd.example.com
)addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
example.com
or sub-domain.domian.tld
with a trailing /join
if you are doing this for foundry.