Greasemonkey script "scroll to bottom" issue

Scorpion Ghost

Elite Member
Executive VIP
Jr. VIP
Joined
Mar 22, 2013
Messages
9,143
Reaction score
10,489
I need a Gresemonkey script that scroll to bottom of a page when the page loads.

I got this:

Code:
// ==UserScript==
// @name           Scroll to Bottom
// @namespace      https://somesite.com/
// @description    Simply scrolls to the bottom of a page
// @grant          none
// ==/UserScript==

function scrollToBottom() {

window.setTimeout("window.scrollTo(0, document.body.offsetHeight);", 10);
};

window.addEventListener('mouseover',function() {
scrollToBottom()
},true);

This script is from 2009, so no surprise I have some issues with it.

1) It scrolls to bottom only when I center that tab, and not instantly. I'd like it to be more efficient on that.
2) It keeps me scrolled at the bottom of the page. If I try to scroll up it scrolls me right down again. I'd like it to just run once on page load and then stop.

Any help?
 
You just need this part
Code:
window.scrollTo(0, document.body.offsetHeight);

You can also add the metadata key @run-at with the value document-idle as described in the doc
Code:
// @run-at      document-idle
 
You just need this part
Code:
window.scrollTo(0, document.body.offsetHeight);

You can also add the metadata key @run-at with the value document-idle as described in the doc
Code:
// @run-at      document-idle

Perfect, works. I knew it was simple. But I guess not simple enough for me to do it myself :p

Many thanks :)
 
check out this

Code:
https://stackoverflow.com/questions/11715646/scroll-automatically-to-the-bottom-of-the-page
 
check out this

Code:
https://stackoverflow.com/questions/11715646/scroll-automatically-to-the-bottom-of-the-page

Hm, I totally avoided the threads on Stackoverflow that had "javascript" in the title. Not sure why.

Oh well, I got a lot on my head at the moment, I'll just forgive myself this one haha :D
 
Back
Top