// ==UserScript== // @name 偶然中文快捷翻页脚本 // @namespace http://tampermonkey.net/ // @version 0.2 // @description 使用键盘左右键或ad键进行页面翻页,双击进行章节跳转 // @author coccvo // @match *://www.or77.net/* // @icon https://www.or77.net/favicon.ico // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 模拟点击函数 function simulateClickByText(textContent) { // 查找所有标签 const links = document.querySelectorAll('a'); // 遍历每个标签 for (let i = 0; i < links.length; i++) { // 如果文本内容匹配,则模拟点击 if (links[i].textContent.trim() === textContent) { links[i].click(); break; } } } // 双击检测变量 let clickTimer = null; // 键盘事件监听 document.addEventListener('keydown', function(e) { // 左键或 'a' 键(上一页) if (e.key === 'ArrowLeft' || e.key === 'a') { if (clickTimer == null) { clickTimer = setTimeout(function() { simulateClickByText('上一页'); clickTimer = null; }, 300); } else { clearTimeout(clickTimer); clickTimer = null; simulateClickByText('上一章'); } } // 右键或 'd' 键(下一页) else if (e.key === 'ArrowRight' || e.key === 'd') { if (clickTimer == null) { clickTimer = setTimeout(function() { simulateClickByText('下一页'); clickTimer = null; }, 300); } else { clearTimeout(clickTimer); clickTimer = null; simulateClickByText('下一章'); } } }); })();