class RAMMonitor extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = `
RAM MONITOR
0.0GB / 0.0GB 0%
`; this.updateRAM(); setInterval(() => this.updateRAM(), 3000); } updateRAM() { if (!window.performance || !window.performance.memory) return; const usedMB = window.performance.memory.usedJSHeapSize / (1024 * 1024); const totalMB = window.performance.memory.jsHeapSizeLimit / (1024 * 1024); const percent = Math.round((usedMB / totalMB) * 100); const ramText = this.shadowRoot.getElementById('ram-text'); const ramPercent = this.shadowRoot.getElementById('ram-percent'); const ramBar = this.shadowRoot.getElementById('ram-bar'); ramText.textContent = `${usedMB.toFixed(1)}GB / ${totalMB.toFixed(1)}GB`; ramPercent.textContent = `${percent}%`; ramBar.style.width = `${percent}%`; // Color coding based on usage if (percent > 75) { ramBar.style.backgroundColor = '#FF6666'; // LCARS red ramPercent.style.color = '#FF6666'; } else if (percent > 50) { ramBar.style.backgroundColor = '#FF9966'; // LCARS orange ramPercent.style.color = '#FF9966'; } else { ramBar.style.backgroundColor = '#99CC99'; // LCARS green ramPercent.style.color = '#99CC99'; } } } customElements.define('ram-monitor', RAMMonitor);