网站是否可阻止JavaScript函数运行?Holonis滚动脚本失效求助
Hey there, let's break down why your current script isn't working and how to fix it. The core issue is that Holonis's follower list doesn't use the main window/body for scrolling—it's wrapped in a nested scrollable container (like a div or ul) that handles the list's scroll behavior independently. Your original script targets the entire window, which doesn't affect this inner container at all.
Step 1: Identify the Correct Scrollable Container
First, we need to find that inner container:
- Open your browser's DevTools (press F12 or right-click the follower list and select "Inspect").
- Look for the parent element of the follower items that has a vertical scrollbar. You can spot it by checking for CSS properties like
overflow-y: autooroverflow: scrollin the Styles panel. - Note down its selector (e.g., a class name like
.follower-list-wrapperor an ID).
Step 2: Modify the Script to Target the Container
Replace your original script with this adjusted version, swapping out the selector for the one you found:
function autoScrolling() { // Replace with the selector of your identified scroll container const scrollContainer = document.querySelector('.follower-list-wrapper'); if (scrollContainer) { // Scroll to the bottom of the container scrollContainer.scrollTop = scrollContainer.scrollHeight; } } setInterval(autoScrolling, 500);
Step 3: Fallback for Hard-to-Find Containers
If you can't easily pinpoint the container's selector, use this script to automatically detect any scrollable element on the page:
function findScrollableContainer() { const allElements = document.querySelectorAll('div, ul, ol'); for (const element of allElements) { // Check if the element has a scrollable content area const isScrollable = element.scrollHeight > element.clientHeight && getComputedStyle(element).overflowY !== 'visible'; if (isScrollable) { return element; } } return null; } function autoScrolling() { const scrollContainer = findScrollableContainer(); if (scrollContainer) { scrollContainer.scrollTop = scrollContainer.scrollHeight; } } setInterval(autoScrolling, 500);
Why This Works
Most modern social platforms use nested scroll containers to keep headers/footers fixed while lists scroll. By targeting this specific container instead of the main window, you're interacting with the actual element that controls the follower list's scroll position.
内容的提问来源于stack exchange,提问作者inder

