Created
February 7, 2022 22:56
-
-
Save rosswintle/92f534f0e0ab37d52b4df3b4bf8ebb45 to your computer and use it in GitHub Desktop.
Feedbin: Keep selected centered
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Feedbin: Keep selected centered | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Keeps the selected item vertically centered in Feedbin | |
// @author Ross Wintle | |
// @match https://feedbin.com/ | |
// @icon https://www.google.com/s2/favicons?domain=feedbin.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
document.addEventListener('keyup', function (ev) { | |
if (ev.key === 'ArrowDown' || ev.key === 'ArrowUp') { | |
let entry = document.querySelector( 'li.entry-summary.selected' ); | |
let entryPos = entry.offsetTop; | |
let scrollTo = entryPos - (document.body.offsetHeight / 2) + (entry.offsetHeight / 2); | |
document.querySelector('.entries').scrollTo({ | |
top: scrollTo, | |
left: 0, | |
behavior: 'smooth' | |
}); | |
} | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment