Skip to content

Instantly share code, notes, and snippets.

@unarist
Created May 26, 2020 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unarist/654da43b13108d30d6dbb602e42cd6d8 to your computer and use it in GitHub Desktop.
Save unarist/654da43b13108d30d6dbb602e42cd6d8 to your computer and use it in GitHub Desktop.
Mastodon - Jump to the bottom on min_id pages
// ==UserScript==
// @name Mastodon - Jump to the bottom on min_id pages
// @namespace https://github.com/unarist/
// @version 0.1
// @author unarist
// @match https://*/@*
// @downloadURL https://gist.github.com/unarist/654da43b13108d30d6dbb602e42cd6d8/raw/mastodon-min_id-autoscroll.user.js
// @grant none
// @noframes
// @run-at document-idle
// ==/UserScript==
(function() {
'use strict';
const target = document.querySelector('.activity-stream > .entry:last-child');
if (target && new URL(location).searchParams.has('min_id') && !window.scrollY) {
// scrollIntoViewでも下端にあわせることはできるが、ちょっと余白がほしい気がしたので自分でなんとかする
// 色々読み込みがおわってないとスクロールが足りなかったりするので雑にウェイトを入れてみる
setTimeout(() => window.scrollBy({ top: target.getBoundingClientRect().bottom - window.innerHeight * 0.8 }), 200);;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment