How could I include the replit username of the website visitor into the script below? Also using this template. (There is already a login screen before this)
This is the script for the onload:
<body onload="sendMessage('{username}');">
This is the script for the webhook message:
function sendMessage(username) {
const webhookUrl = 'https://discord.com/api/webhooks/example';
const time = new Date();
const jsonData = {
"content": `${username} Visited the hh!`,
"embeds": [
{
"title": "Hiddenhub Visit",
"description": `User: ${username}\nTime: ${time}`,
"color": 1488863
}
],
"username": "Visitbot9000",
"avatar_url": "https://www.vippng.com/png/detail/1-10485_free-icons-png-visit-our-website-logo.png",
"attachments": []
};
const xhr = new XMLHttpRequest();
xhr.open('POST', webhookUrl);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(jsonData));
}