use ./, to scroll to the next/previous image within an imgur gallery
当前为
// ==UserScript==
// @name imgur scroll to gallery images keyboard shortcuts
// @namespace http://porath.org/
// @version 0.1
// @description use ./, to scroll to the next/previous image within an imgur gallery
// @author porath
// @match http://imgur.com/*
// @grant none
// ==/UserScript==
// thanks to moiph and CBenni
var current = 0;
var elems = $('div.image');
var numElems = elems.length;
$(document).on('keypress', function (key) {
if (key.which == 46) {
if (current + 1 == numElems) {
if ($('div#album-truncated')) {
$('div#album-truncated > a').click();
elems = $('div.image');
numElems = elems.length;
}
return;
}
elems[current + 1].scrollIntoView();
$('body').scrollTop($('body').scrollTop() - 10);
current = current + 1;
}
if (key.which == 44) {
if (current == 0) {
return;
}
elems[current - 1].scrollIntoView();
$('body').scrollTop($('body').scrollTop() - 10);
current = current - 1;
}
});