The Pug Automatic

ScrollToY

Written January 16, 2007. Tagged Greasemonkey, JavaScript, Bookmarklets.

I hate it when image galleries have lots of content (often big headers) above the images, so that you end up scrolling down, going to the next image, scrolling down…

This gallery is one example.

On my 1280 x 800 pixel resolution screen, with Firefox maximized (in Windows terms), I have to scroll down 300 pixels or so every time I access a new image.

Or rather, had to. Lacking a larger screen, I wrote a small Greasemonkey script that interacts with a tiny bookmarklet to ameliorate this problem.

Once installed, every time you load a page, the script will check for a saved vertical scroll-to position for that host, and scroll there if there was one. It also creates a method to store the current position. The method is exposed so that it can be triggered by a bookmarklet.

I suggest you bookmark this with a keyword like "y": Set ScrollToY.

Using the script/bookmarklet combo is very easy. Scroll down below the header, and then trigger the bookmarklet. For all subsequent page visits on that host, you'll be automatically scrolled to that position.

The script considers a host to be the domain name along with any subdomains. http://www.example.com/foo and http://www.example.com/bar are on the same host. http://www.example.com/ and http://two.example.com are not, because the subdomains differ. Hosts are normalized for www. though, so http://www.example.com/ and http://example.com are considered the same.

To reset the scroll, just scroll to the very top and store that.