|
function() { |
|
document.body.classList.add('dark'); |
|
|
|
|
|
const checkSandboxTimeout = function() { |
|
const timeElement = document.getElementById('sandbox-creation-time'); |
|
|
|
if (timeElement) { |
|
const creationTime = parseFloat(timeElement.getAttribute('data-time')); |
|
const timeoutValue = parseFloat(timeElement.getAttribute('data-timeout')); |
|
const currentTime = Math.floor(Date.now() / 1000); |
|
|
|
const elapsedTime = currentTime - creationTime; |
|
console.log("Sandbox running for: " + elapsedTime + " seconds of " + timeoutValue + " seconds"); |
|
|
|
|
|
if (elapsedTime >= timeoutValue) { |
|
console.log("Sandbox timeout! Showing BSOD"); |
|
showBSOD('Error'); |
|
|
|
return; |
|
} |
|
} |
|
|
|
|
|
setTimeout(checkSandboxTimeout, 5000); |
|
}; |
|
|
|
const showBSOD = function(statusText = 'Error') { |
|
console.log("Showing BSOD with status: " + statusText); |
|
const iframe = document.getElementById('sandbox-iframe'); |
|
const bsod = document.getElementById('bsod-image'); |
|
|
|
if (iframe && bsod) { |
|
iframe.style.display = 'none'; |
|
bsod.style.display = 'block'; |
|
|
|
|
|
const statusIndicator = document.querySelector('.status-indicator'); |
|
const statusTextElem = document.querySelector('.status-text'); |
|
|
|
if (statusIndicator) { |
|
statusIndicator.className = 'status-indicator status-error'; |
|
} |
|
|
|
if (statusTextElem) { |
|
statusTextElem.innerText = statusText; |
|
} |
|
} |
|
}; |
|
|
|
const resetBSOD = function() { |
|
console.log("Resetting BSOD display"); |
|
const iframe = document.getElementById('sandbox-iframe'); |
|
const bsod = document.getElementById('bsod-image'); |
|
|
|
if (iframe && bsod) { |
|
if (bsod.style.display === 'block') { |
|
|
|
iframe.style.display = 'block'; |
|
bsod.style.display = 'none'; |
|
console.log("BSOD reset complete"); |
|
return true; |
|
} |
|
} |
|
return false; |
|
}; |
|
|
|
|
|
const monitorForErrors = function() { |
|
console.log("Error monitor started"); |
|
const resultsInterval = setInterval(function() { |
|
const resultsElements = document.querySelectorAll('textarea, .output-text'); |
|
for (let elem of resultsElements) { |
|
const content = elem.value || elem.innerText || ''; |
|
if (content.includes('Error running agent')) { |
|
console.log("Error detected!"); |
|
showBSOD('Error'); |
|
clearInterval(resultsInterval); |
|
break; |
|
} |
|
} |
|
}, 1000); |
|
}; |
|
|
|
|
|
|
|
checkSandboxTimeout(); |
|
|
|
|
|
setTimeout(monitorForErrors, 3000); |
|
|
|
|
|
document.addEventListener('click', function(e) { |
|
if (e.target.tagName === 'BUTTON') { |
|
if (e.target.innerText === "Let's go!") { |
|
resetBSOD(); |
|
} |
|
setTimeout(monitorForErrors, 3000); |
|
} |
|
}); |
|
|
|
|
|
setInterval(function() { |
|
const btn = document.getElementById('refresh-log-btn'); |
|
if (btn) btn.click(); |
|
}, 5000); |
|
|
|
|
|
const params = new URLSearchParams(window.location.search); |
|
if (!params.has('__theme')) { |
|
params.set('__theme', 'dark'); |
|
window.location.search = params.toString(); |
|
} |
|
} |