Greasy Fork is available in English.

iThome Arrow Key Pager

iThome Arrow Key Pager - Use ← (Go to Previous Page), → (Go to Next Page)

2019/12/03のページです。最新版はこちら。

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name         iThome Arrow Key Pager
// @namespace    https://github.com/livinginpurple
// @version      2019.12.03.10
// @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/*
// @include 	 *
// @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 === null) {
                alert("Last Page!!");
                return false;
            }
            nextPage.click();
        }
        if (keyName === "ArrowLeft") {
            if (previousPage === null) {
                alert("First Page!!");
                return false;
            }
            previousPage.click();
        }
    });
    console.log(GM_info.script.name + " is running.");
})(document);