const chat = document.getElementsByClassName("chat")[0]; const textInput = document.getElementsByTagName("input")[0]; const ROLLING_EYES = "🙄"; function addMessage(text="", isUser=true){ chat.innerHTML += `
`; } function deleteLastMessage() { var systemMessages = document.getElementsByClassName("systemMessage"); chat.removeChild(systemMessages[systemMessages.length - 1]); } function sendMessage(){ let inputValue = textInput.value; if (inputValue.length == 0) { return; } addMessage(inputValue); addMessage("...", false); setTimeout(() => { deleteLastMessage(); // reply let userMock = randomCap(inputValue); let mockMessage = randomLine(); let urlStr = buildUrl(inputValue); addMessage( `"${userMock}" ${ROLLING_EYES}