amolinaedotcom/js/script.js
2025-08-11 23:35:56 -06:00

14 lines
392 B
JavaScript

// This sucks but works.
function getRandomLine(file) {
return fetch(file)
.then(res => res.text())
.then(text => {
const lines = text.trim().split('\n');
const randomIndex = Math.floor(Math.random() * lines.length);
return lines[randomIndex];
});
}
getRandomLine("/assets/messages.txt").then(line => {
document.getElementById("qotd").innerHTML = line;
});