37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
// Auto-scroll script for Home Assistant Dashboard
|
|
// Inject this into the browser console (F12) on the dashboard page
|
|
|
|
(function() {
|
|
let currentIndex = 0;
|
|
const scrollInterval = 5000; // 5 seconds
|
|
const cards = document.querySelectorAll('ha-card');
|
|
|
|
// Make each card full viewport height
|
|
cards.forEach(card => {
|
|
card.style.minHeight = window.innerHeight + 'px';
|
|
});
|
|
|
|
function scrollToNext() {
|
|
if (cards.length === 0) return;
|
|
|
|
currentIndex = (currentIndex + 1) % cards.length;
|
|
const targetCard = cards[currentIndex];
|
|
|
|
targetCard.scrollIntoView({
|
|
behavior: 'smooth',
|
|
block: 'start'
|
|
});
|
|
|
|
console.log(`Scrolled to card ${currentIndex + 1} of ${cards.length}`);
|
|
}
|
|
|
|
// Start auto-scrolling
|
|
console.log('Auto-scroll started: changing card every 5 seconds');
|
|
setInterval(scrollToNext, scrollInterval);
|
|
|
|
// Scroll to first card immediately
|
|
if (cards.length > 0) {
|
|
cards[0].scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
}
|
|
})();
|