Greasy Fork

Greasy Fork is available in English.

Keyboard Page Up/Down

Use key (PgUp: ← D P Ctrl+Shift+Space; PgDn: → F N Ctrl+Space) to click the privious or next button on the page.

当前为 2021-01-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Keyboard Page Up/Down
// @name:zh      键盘翻页
// @description       Use key (PgUp: ← D P Ctrl+Shift+Space; PgDn: → F N Ctrl+Space) to click the privious or next button on the page.
// @description:zh    使用键盘按键(PgUp: ← D P Ctrl+Shift+Space; PgDn: → F N Ctrl+Space) 点击页面上的上一页/下一页
// @namespace    keybordPageUpDown.userscript
// @version      0.1
// @description  使用键盘翻页(PgUp: ← D P Ctrl+Shift+Space; PgDn: → F N Ctrl+Space)
// @author       h
// @match        https://yande.re/*
// @match        https://konachan.com/*
// @match        https://*.iwara.tv/*
// @match        https://*.javlibrary.com/*
// @match        https://adnmb3.com/*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';

  window.addEventListener('keyup', function(e){
    let s;
    switch(e.keyCode){
      case 32: // Space
        if(e.ctrlKey && !e.metaKey) s = e.shiftKey ? 1 : 2;
        break;
      case 37: // ←
      case 68: // D
      case 80: // P
      case 33: // PgUp
        s = 1;
        break;
      case 39: // →
      case 70: // F
      case 78: // N
      case 34: // PgDn
        s = 2;
        break;
    }
    if (s) {
      const m = {
        "https://yande\.re/post/popular.*": {"btn": ['#post-popular > h3 > a:nth-child(1)', '#post-popular > h3 > a:nth-child(2)'], "ignore_id": ["tags"]},
        "https://yande\.re/.*": {"btn":['a.previous_page', 'a.next_page'], "ignore_id": ["tags"]},
        "https://konachan.com/.*": {"btn": ['a.previous_page', 'a.next_page']},
        "https://.*\.iwara\.tv/.*": {"btn": ['.pager-previous > a', '.pager-next > a']},
        "https://(.*\.)?javlibrary\.com/.*": {"btn": ['a.page.prev', 'a.page.next']},
        "https://adnmb[0-9]?\.com/.*": {"btn": ['#h-content > div.uk-container > ul > li:nth-child(1) > a', '#h-content > div.uk-container > ul > li:nth-last-child(2) > a'], "ignore": "textarea, input, select, button"},
      };

      let u = window.location.href;
      let k = Object.keys(m).find(k => u.match(k));
      if (!k) return;
      let t = m[k];

      let ae = document.activeElement;
      if (ae && t.ignore_id && t.ignore_id.find(i => ae === document.getElementById(i))) return;
      if (ae && t.ignore && [...document.querySelectorAll(t.ignore)].find(i => i.contains(ae))) return;

      let a = document.querySelector(t.btn[s-1]);
      if (a){ a.click(); return; }
    }
  });
})();