random/hot-posts
document.addEventListener('DOMContentLoaded', (event) => { const toggleButton = document.getElementById('dark-mode-toggle'); const body = document.body; // Check if dark mode was previously enabled if (localStorage.getItem('dark-mode') === 'enabled') { body.classList.add('dark-mode'); } toggleButton.addEventListener('click', () => { if (body.classList.contains('dark-mode')) { body.classList.remove('dark-mode'); localStorage.setItem('dark-mode', 'disabled'); } else { body.classList.add('dark-mode'); localStorage.setItem('dark-mode', 'enabled'); } }); });