您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
iThome Arrow Key Pager - Use ← (Go to Previous Page), → (Go to Next Page)
- // ==UserScript==
- // @name iThome Arrow Key Pager
- // @namespace https://github.com/livinginpurple
- // @version 2019.12.03.12
- // @description iThome Arrow Key Pager - Use ← (Go to Previous Page), → (Go to Next Page)
- // @description:zh-TW 使用方向鍵前往上一頁(←)、下一頁(→)
- // @license WTFPL
- // @author livinginpurple
- // @match https://ithelp.ithome.com.tw/*
- // @run-at document-end
- // @grant none
- // @grant GM.xmlHttpRequest
- // ==/UserScript==
- (function () {
- 'use strict';
- console.log(GM_info.script.name + " is loading.");
- const previousPage = document.getElementsByClassName("fa fa-fw fa-angle-left")[0];
- const nextPage = document.getElementsByClassName("fa fa-fw fa-angle-right")[0];
- document.addEventListener('keydown', (event) => {
- let keyName = event.key;
- //console.log('keydown event\n\n' + 'key: ' + keyName);
- if ((event.altKey && (keyName === "ArrowLeft" || keyName === "ArrowRight"))) {
- return false;
- }
- if (keyName === "ArrowRight") {
- if (nextPage === undefined || nextPage === null) {
- alert("Last Page!!");
- return false;
- }
- nextPage.click();
- }
- if (keyName === "ArrowLeft") {
- if (previousPage === undefined || previousPage === null) {
- alert("First Page!!");
- return false;
- }
- previousPage.click();
- }
- });
- console.log(GM_info.script.name + " is running.");
- })(document);