Skip to content

Commit df696b2

Browse files
MaxGhenisclaude
andcommitted
Add aggressive scrollable container detection
Search ALL elements for scrollHeight > clientHeight and log candidates. Try scrolling each candidate to find actual scrollable content. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c4fa6b8 commit df696b2

1 file changed

Lines changed: 33 additions & 15 deletions

File tree

background.js

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,39 @@ async function injectScrollScript(tabId, duration) {
109109
fallbackMaxScroll = document.body.scrollTop;
110110
}
111111

112-
// Look for scrollable containers
113-
if (fallbackMaxScroll === 0) {
114-
const containers = document.querySelectorAll('div, main, section, article');
115-
for (const el of containers) {
116-
const style = getComputedStyle(el);
117-
if (style.overflowY === 'auto' || style.overflowY === 'scroll') {
118-
el.scrollTop = 999999;
119-
if (el.scrollTop > 0) {
120-
console.log('[Scrollywood] Found scrollable container:', el.tagName, el.className);
121-
fallbackMaxScroll = el.scrollTop;
122-
el.scrollTop = 0;
123-
// Store reference for later scrolling
124-
window.__scrollywoodContainer = el;
125-
break;
126-
}
112+
// Look for scrollable containers - check ALL elements with scrollHeight > clientHeight
113+
if (fallbackMaxScroll < minThreshold) {
114+
console.log('[Scrollywood] Searching for scrollable containers...');
115+
const allElements = document.querySelectorAll('*');
116+
const candidates = [];
117+
118+
for (const el of allElements) {
119+
if (el.scrollHeight > el.clientHeight + 50) {
120+
candidates.push({
121+
el,
122+
tag: el.tagName,
123+
className: el.className?.toString().slice(0, 30),
124+
scrollHeight: el.scrollHeight,
125+
clientHeight: el.clientHeight,
126+
diff: el.scrollHeight - el.clientHeight,
127+
});
128+
}
129+
}
130+
131+
console.log('[Scrollywood] Candidates with scrollHeight > clientHeight:', candidates.length);
132+
candidates.slice(0, 5).forEach(c => console.log('[Scrollywood] Candidate:', c));
133+
134+
// Try scrolling each candidate
135+
for (const { el } of candidates) {
136+
const before = el.scrollTop;
137+
el.scrollTop = 999999;
138+
const scrolled = el.scrollTop;
139+
el.scrollTop = before;
140+
141+
if (scrolled > fallbackMaxScroll) {
142+
console.log('[Scrollywood] Found better scrollable:', el.tagName, el.className, 'scrolled to', scrolled);
143+
fallbackMaxScroll = scrolled;
144+
window.__scrollywoodContainer = el;
127145
}
128146
}
129147
}

0 commit comments

Comments
 (0)