From 726df57affabbe9827c19e622c477683980913e8 Mon Sep 17 00:00:00 2001 From: kyle Date: Wed, 31 Dec 2025 04:26:47 -0800 Subject: [PATCH] Add inject-scroll-on-load.js --- inject-scroll-on-load.js | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 inject-scroll-on-load.js diff --git a/inject-scroll-on-load.js b/inject-scroll-on-load.js new file mode 100644 index 0000000..50b2542 --- /dev/null +++ b/inject-scroll-on-load.js @@ -0,0 +1,59 @@ +// Auto-scroll injection script - runs when page loads +(function() { + console.log('Auto-scroll injection script loaded'); + + function injectAutoScroll() { + const script = document.createElement('script'); + script.textContent = ` + (function() { + console.log('Auto-scroll script starting...'); + let currentIndex = 0; + const scrollInterval = 5000; + let cards = []; + + function initScroll() { + cards = Array.from(document.querySelectorAll('ha-card')).filter(card => { + return card.offsetParent !== null; // Only visible cards + }); + + if (cards.length === 0) { + setTimeout(initScroll, 1000); + return; + } + + console.log('Found ' + cards.length + ' cards'); + + // Make cards full height + cards.forEach(card => { + card.style.minHeight = window.innerHeight + 'px'; + }); + + function nextCard() { + if (cards.length === 0) return; + currentIndex = (currentIndex + 1) % cards.length; + cards[currentIndex].scrollIntoView({ + behavior: 'smooth', + block: 'start' + }); + console.log('Scrolled to card ' + (currentIndex + 1)); + } + + // Start scrolling + setInterval(nextCard, scrollInterval); + window.scrollTo({ top: 0, behavior: 'smooth' }); + } + + // Wait for page to load + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', initScroll); + } else { + setTimeout(initScroll, 2000); + } + })(); + `; + document.head.appendChild(script); + } + + // Inject after a short delay to ensure page is loaded + setTimeout(injectAutoScroll, 3000); +})();