If anyone has this similar problem the solution for me was to correctly format set timeout, before I was doing setTimeout(function() {//program here}, 5000) but that did not work, naming the function and then calling it properly from settimeout did not cause any issues. Also, make sure the bottom of your file doesn't have some random brackets--mine did and causes problems.
I am currently trying to improve a mod menu / cheat for an online virtual school program. It works fine and builds its UI elements by appending to a few different areas on the virtual school page, however, whenever it runs it fails multiple times before succeeding because it is trying to append to objects that are not loaded yet.
The .js file is injected by this tool although I don't really know what it is doing. I can't see any options like "delay before running" etc.
How can I wait for either a certain amount of time or check if the site is loaded without interrupting it's loading process? All the solutions I have tried so far (settimeout, event listener for loaded, while loop for site not being loaded) don't work because they stop the site from loading while they check.
This is the start of the JS file (it will not run here)
(function() {
'use strict';
//==BEGIN UI BUILDING==
window.configElements = []; //Config infomation
function init() {
//Builder Functionsfunction appender(b, p){ //appends things, if p is null defaults to tweaksmenu
if (p == undefined) {
document.getElementById("tweaksmenu").appendChild(b)
} else document.getElementById(p).appendChild(b)
}
function RenderPane(name, id, width, height, margintop, marginleft) { //renders panes
window.pane = document.createElement("div")
window.pane.style.width = width
window.pane.style.height = height
window.pane.style.position = "absolute"
window.pane.style.marginTop = margintop
window.pane.style.marginLeft = marginleft
window.pane.style.border = "1px solid rgb(95, 95, 95)"
window.pane.style.borderRadius = "3px"
window.pane.style.backgroundColor = "rgb(39, 39, 39)"
window.pane.style.overflow = "hidden"
window.pane.style.color = "rgb(249, 166, 25)"
window.pane.style.textAlign = "center"
window.pane.style.overflowY = "scroll"
window.pane.id = id
window.panetitle = document.createElement("h1")
window.panetitle.innerText = " " + name //shitty centering fix
window.pane.appendChild(window.panetitle)
window.pane.appendChild(document.createElement("hr"))
document.getElementById("overlay").appendChild(window.pane)
}
function BuildMenuEntry (name, info, id, configpane, override) { //Creates tickbox element with info and optional (new) config pane (see guesspractice). Override autoappends to tweaksmenu and does not return
window.entry = document.createElement("div")
window.tickbox = document.createElement("input")
window.tickbox.type = "checkbox"
window.tickbox.id = id
window.configElements.push(id)
window.entry.appendChild(window.tickbox)
window.window.label = document.createElement("label")
window.label.innerText = " " + name //spacing fix
window.entry.appendChild(window.label)
if (configpane != undefined) { //If any configpane was passed through try and create a button to attach it.
window.configbutton = document.createElement("button")
window.configbutton.innerText = "Configure"
window.configbutton.style.marginLeft = "7px"
window.configbutton.style.border = "1px solid #5f5f5f"
window.configbutton.style.boxShadow = "inset 0 0 5px rgba(0, 0, 0, 0.6)"
window.configbutton.style.backgroundColor = "rgb(39, 39, 39)"
window.configbutton.style.color = "#f9a619"
window.configbutton.style.borderRadius = "3px"
window.configbutton.onclick = function () {
if (document.getElementById(configpane).style.visibility == "unset") { //visiblitly handler for configpane button
document.getElementById(configpane).style.visibility = "hidden"
} else {
document.getElementById(configpane).style.visibility = "unset"
}
}
window.entry.appendChild(window.configbutton)
}
window.desc = document.createElement("p")
window.desc.innerHTML = info;
window.entry.appendChild(window.desc)
if (override == 1) { //override
window.document.getElementById("tweaksmenu").appendChild(window.entry);
}
else return window.entry;
}