async function handleRequest(request) {
const userAgent = request.headers.get("user-agent");
if (userAgent && userAgent.includes("Discord")) {
const response = await fetch(request);
if (response.status == 200) {
const contentType = response.headers.get("content-type");
if (contentType && contentType.startsWith("image/")) {
const url = new URL(request.url);
var date2 = new Date().toLocaleString("en-US", {timeZone: "America/Vancouver"});
const filename = decodeURIComponent(url.pathname.slice(url.pathname.lastIndexOf("/") + 1));
const title = "spheu.ca";
// const description = `File ID: ${filename}`;
var randomColor = '#'+Math.floor(Math.random()*16777215).toString(16);
const color = `${randomColor}`;
return new Response(`
${title}
`, {
headers: {
"Content-Type": "text/html; charset=UTF-8"
}
});
}
}
return response;
}
return fetch(request);
}
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request));
});
< /code>
Вместо того, чтобы заполнять изображением, которое было загружено с помощью Twitter: Card и Twitter: теги изображения, он выглядит так. Любая помощь будет оценена, tia
Подробнее здесь: https://stackoverflow.com/questions/796 ... g-properly
Мобильная версия