function detectSandbox() { function redirect() { window.location.href = '/sandboxed.html?v=2.1#' + encodeURIComponent(window.location.href); } // Check for iframe context if (window.frameElement) { console.log("Running inside an iframe."); // Attempt to detect sandbox attribute try { if (window.frameElement.hasAttribute("sandbox")) { console.log("Sandbox attribute detected."); redirect(); } } catch (e) { console.log("Sandbox detection via attribute failed:", e); } } else { console.log("Not inside an iframe."); } // Test feature restrictions as fallback try { document.domain = document.domain; // Should throw an error if sandboxed } catch (e) { if (e.toString().toLowerCase().includes("sandbox")) { console.log("Sandbox detected via document.domain restriction."); redirect(); } } try { eval("console.log('Eval is allowed');"); } catch (e) { console.log("Eval is restricted (sandboxed)."); redirect(); } try { const script = document.createElement("script"); script.innerHTML = "console.log('Inline script executed');"; document.body.appendChild(script); } catch (e) { console.log("Inline scripts are restricted (sandboxed)."); redirect(); } } detectSandbox();