javascriptgoogle-chrome-extensionscroll

Scroll to bottom not working in an inactive tab


I'm trying to create a chrome extension content script that runs in inactive tab.

I have an infinite scroll element that I'd like to scroll to bottom.

If the tab is active and in foreground the following code works:

div.scrollTop = div.scrollHeight;

If I'm in another tab, the scrolling doesn't work...

Is there a flag at chrome://flag that can fix it? Or do you have another suggestion?


Solution

  • Ok, After a long research, I finally have a conclusion.

    When a tab is not visible (tab can be active but not visible), chrome doesn't do the UI calculations. Because of that, scrolling calculations are not done, only visible measurement can be done.

    A workaround solution is to open the tab in new window, which make the tab visible (although this window is not focused) and set "Throttle expensive background timers" in chrome://flags to disable