1

I'm trying to write a chrome extension that scrolls through a particular page after it's been created as a background tab. The code I have recursively scrolls until the bottom of the page (each iteration checks scrollTop, terminating if N value == N-1 value) and is working if I have that tab focused, but it doesn't if it's in the background/not visible (which is where it's primary use case is intended to be).

I'm guessing this because of a decision in webkit/blink to enforce lazy loading/rendering behaviour to save resources, hoping there is a way around it. I've tried a few techniques listed here to try to force a re-paint in conventional ways to no avail.

Any tips would be greatly appreciated!

Community
  • 1
  • 1
Alex Latchford
  • 655
  • 1
  • 9
  • 17
  • So what happens exactly? – wOxxOm Oct 28 '16 at 19:54
  • @wOxxOm it just seems to render only the part of the screen that would be visible if the tab was open. If you try to scroll I get an updated scrollTop value but it won't scroll beyond the screen height :/ – Alex Latchford Oct 29 '16 at 00:34
  • And what type of content is influenced when the tab becomes visible? I'd suspect iframes. You can probably force them to load via CSS-repositioning: inject a style element in head e.g. `iframe {position:fixed!important; top:0!important}` and then remove it before the tab is activated. – wOxxOm Oct 29 '16 at 01:02
  • No it's just a standard webpage. I'm using chrome.tabs.executeScript to send `document.body.scrollTop = 10000;` calls in a recursive fashion (with a timeout/network detection (via chrome.webRequest.onCompleted/onErrorOccurred) to ensure what I'm loading is a completed). It still seems to stop advancing the scroll at ~3000px which is the size of the screen I'm working with. I've tried using the position, overflow, content, z-index and a couple of other CSS directives to no avail :/ – Alex Latchford Oct 30 '16 at 22:25
  • Huh, looks like a bug. Would you report it on https://crbug.com and link here for reference? – wOxxOm Oct 31 '16 at 06:02
  • Yeah that's what I was assuming. Either that or it's an optimisation to prevent extra resource use by misbehaving/abusive pages. – Alex Latchford Oct 31 '16 at 17:40

0 Answers0