I like your use of the subroutine construct!
This came up in another thread where I shared how I auto scroll to the bottom. It doesn’t report any extra information like your approach does so YMMV. I’m no JavaScript expert so I’m not sure where I got this from but here it is:
Here’s the link to that other thread Apparently I can't get Safari to auto-scroll... ideas? FYI
I should add that I found using the scroll action was a bit hit and miss depending on how responsive the web site was which is why I ended up using this JS snippet.