Testpage
Jump to navigation
Jump to search
... <script> (function() {
window.playerCountCallback = function(data) { try { var count = 0; if (typeof data === 'number') { count = data; } else if (data && typeof data === 'object') { count = data.players || data.online || data.count || (Array.isArray(data) ? data.length : 0); } document.getElementById('playercount').textContent = count; } catch (e) { console.error('Player count callback error:', e); } // Cleanup setTimeout(function() { var script = document.getElementById('playercount-script'); if (script && script.parentNode) { script.parentNode.removeChild(script); } }, 1000); }; // Error handler var handleError = function() { document.getElementById('playercount').textContent = '0'; }; // Create script tag var script = document.createElement('script'); script.id = 'playercount-script'; script.src = 'https://betamc.org:8080/api/players?callback=playerCountCallback'; script.onerror = handleError; script.onload = function() { // If callback wasn't called within 5 seconds, assume error setTimeout(function() { if (document.getElementById('playercount').textContent === '...') { handleError(); } }, 5000); }; document.head.appendChild(script);
})(); </script>