function guess(username, password) { /* Ensure a display element exists */ let displayElement = document.getElementById("myParagraph"); if (!displayElement) { displayElement = document.createElement("div"); displayElement.id = "myParagraph"; displayElement.style = "position:fixed;top:10px;right:10px;z-index:9999;background:white;color:black;border:2px solid red;padding:10px;max-height:200px;overflow:auto;font-family:monospace;width:300px;"; document.body.appendChild(displayElement); displayElement.textContent = "Fetching..."; } /* Your exact fetch logic */ fetch( "https://parents.westfieldnjk12.org/genesis/sis/j_security_check?parents=Y", { headers: { accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", "accept-language": "en-US,en;q=0.9", "cache-control": "max-age=0", "content-type": "application/x-www-form-urlencoded", "sec-ch-ua": '"Not:A-Brand";v="99", "Google Chrome";v="145", "Chromium";v="145"', "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": '"Windows"', "sec-fetch-dest": "document", "sec-fetch-mode": "navigate", "sec-fetch-site": "same-origin", "sec-fetch-user": "?1", "upgrade-insecure-requests": "1", }, referrer: "https://parents.westfieldnjk12.org/genesis/sis/view?gohome=true", body: `idTokenString=&j_username=${username}%40westfieldnjk12.org&j_password=${password}`, method: "POST", mode: "cors", credentials: "include", }, ) .then(function (response) { if (!response.ok) { throw new Error("Network response was not ok: " + response.status); } return response.text(); }) .then(function (text) { document.getElementById("myParagraph").textContent = text; }) .catch(function (error) { console.error("There was a problem with the fetch operation:", error); document.getElementById("myParagraph").textContent = "Error: " + error.message; }); }