diff --git a/dashboard-auto-scroll.js b/dashboard-auto-scroll.js new file mode 100644 index 0000000..e186255 --- /dev/null +++ b/dashboard-auto-scroll.js @@ -0,0 +1,64 @@ +// Auto-scroll script for Home Assistant dashboard +// Inject this into the browser console or use as a browser_mod service + +(function() { + 'use strict'; + + console.log('Auto-scroll script starting...'); + + // Get all cards + const cards = Array.from(document.querySelectorAll('ha-card')); + console.log(`Found ${cards.length} cards`); + + if (cards.length === 0) { + console.error('No cards found!'); + return; + } + + // Ensure each card takes full viewport height + cards.forEach((card, index) => { + card.style.minHeight = window.innerHeight + 'px'; + card.style.scrollMarginTop = '0px'; + console.log(`Card ${index + 1}: Set min-height to ${window.innerHeight}px`); + }); + + // Scroll to first card + window.scrollTo({ top: 0, behavior: 'smooth' }); + + let currentIndex = 0; + + // Function to scroll to next card + function scrollToNext() { + currentIndex = (currentIndex + 1) % cards.length; + const targetCard = cards[currentIndex]; + + if (targetCard) { + targetCard.scrollIntoView({ + behavior: 'smooth', + block: 'start', + inline: 'nearest' + }); + console.log(`Scrolled to card ${currentIndex + 1} of ${cards.length}`); + } + } + + // Start auto-scrolling every 5 seconds + const intervalId = setInterval(scrollToNext, 5000); + console.log('Auto-scroll enabled: scrolling every 5 seconds'); + + // Cleanup function (optional) + window.stopAutoScroll = function() { + clearInterval(intervalId); + console.log('Auto-scroll stopped'); + }; + + // Also handle page visibility changes + document.addEventListener('visibilitychange', function() { + if (document.hidden) { + console.log('Page hidden, pausing auto-scroll'); + } else { + console.log('Page visible, resuming auto-scroll'); + } + }); + +})();