您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
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.12
- // @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 and Brybry
- var current = 0;
- var elems = $('div.image');
- var numElems = elems.length;
- $(document).on('keydown', function (key) {
- if (key.which == 40) {
- key.preventDefault();
- 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() - 28);
- current = current + 1;
- }
- if (key.which == 38) {
- key.preventDefault();
- if (current == 0) {
- return;
- }
- elems[current - 1].scrollIntoView();
- $('body').scrollTop($('body').scrollTop() - 28);
- current = current - 1;
- }
- if (key.which == 36) { // "home" puts you at the top of the gallery
- current = 0;
- }
- if (key.which == 35) { // "end" puts you at the bottom of the gallery
- current = numElems;
- }
- if (key.which == 37 || key.which == 39) { // when a user presses left or right to go to the prev/next page
- current = 0;
- elems = $('div.image');
- numElems = elems.length;
- }
- });