// ==UserScript== // @name 键盘翻页 // @name:en Keyboard Page Up/Down // @description 使用键盘按键(PgUp: ← D P Ctrl+Shift+Space; PgDn: → F N Ctrl+Space) 点击页面上的上一页/下一页。脚本也支持其他网站,但需要用户修改此脚本,将上下页按键的选择器添加到脚本指定位置。 // @description:en Use key (PgUp: ← D P Ctrl+Shift+Space; PgDn: → F N Ctrl+Space) to click the privious or next button on the page. You can modify this script to support other pages. // @namespace https://greasyfork.org/zh-CN/scripts/419483 // @version 0.2.1 // @author oajsdfk // @match https://adnmb3.com/* // @match https://yande.re/* // @grant none // @downloadURL 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; else return; 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; default: return; } let ae = document.activeElement; const it = ['input', 'select', 'button', 'textarea']; if (ae && it.indexOf(ae.tagName.toLowerCase()) !== -1) return; const m = { "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"}, "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"]}, /// 可选项: 取消下面的注释,并把 match 行移动到顶部 /// Option: uncomment those lines and move the match line to the top // // @match https://konachan.com/* // @match https://*.iwara.tv/* // @match https://*.javlibrary.com/* // @match https://*.javbus.one/* // @match https://*.javbus.com/* // @match https://*.reimu.net/* //"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://(.*\.)?javbus[0-9]*\.[^/]*/.*": {"btn": ['#pre', '#next']}, //"https://(.*\.)?reimu\.net/.*": {"btn2": ['span.current']}, }; let u = window.location.href; let k = Object.keys(m).find(k => u.match(k)); if (!k) return; let t = m[k]; //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; if (t.btn2) { let c = document.querySelector(t.btn2[0]); if (c) { let a = (s===1) ? c.previousElementSibling : c.nextElementSibling; if (t.btn2.length === 3) a = a.querySelector(t.btn2[s]); if (a) a.click(); } return; } let a = document.querySelector(t.btn[s-1]); if (a) a.click(); }); })();