Keyboard navigation e621

Change the current page with arrow keys

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Keyboard navigation e621
// @version      0.2
// @description  Change the current page with arrow keys
// @author       koreso
// @match        https://e621.net/posts/*
// @namespace https://greasyfork.org/users/510304
// ==/UserScript==

(function() {
    'use strict';

    // check if a next or previous button exists on the current page
    if(document.querySelector(".next")||document.querySelector(".prev"))window.onkeydown = page;

    function page(e) {
        // if the current focused element is a text box, abort
        if(document.activeElement.nodeName.match(/TEXTAREA|INPUT/))return;

        // 39 = right arrow key, 37 = left arrow key
        switch(e.keyCode){
            case 39:
                // change current url to the next button's url
                window.location.assign(document.querySelector(".next"));
                break;
            case 37:
                // idem but for the previous button
                window.location.assign(document.querySelector(".prev"));
                break;
        }
    }
})();