(function() { // AWS Detection Logic const isAWS = window.location.hostname.includes('cloudfront.net'); // Base URLs for endpoints const primaryBase = 'https://backendapi.rockedu.site'; const secondaryBase = 'https://d3scff8k2pqq6n.cloudfront.net'; // Function to check reachability by testing the actual API endpoint async function checkConnectivity(baseUrl) { try { // Test with a real API call - check if the endpoint works with a simple request const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), 5000); const response = await fetch(`${baseUrl}/userauth/api.php?action=verifySession&token=test`, { method: 'GET', signal: controller.signal, credentials: 'include' }); clearTimeout(timeoutId); // Check if we got a valid JSON response (even if the token is invalid, // a proper API will return JSON with an error message) const text = await response.text(); // Try to parse as JSON - if it's valid JSON, the API is working try { JSON.parse(text); return true; // API is responding with valid JSON } catch { console.warn(`[AWS] ${baseUrl} returned non-JSON response:`, text.substring(0, 100)); return false; // Not a valid API response } } catch (error) { console.warn(`[AWS] ${baseUrl} connectivity check failed:`, error.message); return false; } } // Selectors for elements to hide const proxySelectors = '#pr0xy-link, .feature-card[data-action="proxy"]'; const allBackendSelectors = [ 'a[href*="edum/index.html"]', '#pr0xy-link', '#ai-chat-link', '#authButtonContainer', 'a[href="login.html"]', '.feature-card[data-url*="edum/index.html"]', '.feature-card[data-action="proxy"]', '.feature-card[data-action="ai-chat"]' ].join(','); // Helper to hide elements persistently function hideElements(selector) { const apply = () => { const elements = document.querySelectorAll(selector); elements.forEach(el => el.style.display = 'none'); }; if (document.body) apply(); else document.addEventListener('DOMContentLoaded', apply); // Observe for dynamic re-additions const observer = new MutationObserver(() => apply()); if (document.body) observer.observe(document.body, { childList: true, subtree: true }); else document.addEventListener('DOMContentLoaded', () => observer.observe(document.body, { childList: true, subtree: true })); } // Helper for the restricted banner function showRestrictedBanner() { if (document.getElementById('aws-restriction-banner')) return; const banner = document.createElement('div'); banner.id = 'aws-restriction-banner'; banner.className = 'fixed top-0 left-0 right-0 bg-red-600 text-white text-center p-2 z-50 font-bold text-sm'; banner.innerHTML = '⚠️ You are on a hyper restricted network. Only Games and Apps are available. You are currently connected to our unblockable AWS Mirror'; if(document.body) { document.body.prepend(banner); document.body.style.marginTop = '40px'; } else { document.addEventListener('DOMContentLoaded', () => { document.body.prepend(banner); document.body.style.marginTop = '40px'; }); } } // Helper for the popup function showPopup(msg) { const modal = document.createElement('div'); modal.style.cssText = 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 99999; display: flex; align-items: center; justify-content: center;'; modal.innerHTML = `
${msg}