Guru3D Keyboard Shortcuts

Use arrow keys combined with Control key to navigate through articles.

当前为 2019-12-25 提交的版本,查看 最新版本

// ==UserScript==
// @name         Guru3D Keyboard Shortcuts
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Use arrow keys combined with Control key to navigate through articles.
// @author       RevoLand
// @require      https://code.jquery.com/jquery-3.4.1.slim.min.js
// @include      *://*guru3d.com/articles-pages/*.html
// @grant        none
// ==/UserScript==

this.$ = this.jQuery = jQuery.noConflict(true);

(function() {
    'use strict';
    var previousPageLink = $('.pagelinkselected').prev().contents().attr('href');
    var nextPageLink = $('.pagelinkselected').next().contents().attr('href');
    var keys = {};

    $(document).keydown(function(e) {
        keys[e.which] = true;

        if (keys[17] && keys[37] && previousPageLink != undefined) { // Ctrl + left arrow key
            window.location.href = window.location.origin + '/' + previousPageLink;
        }

        if (keys[17] && keys[39] && nextPageLink != undefined) { // Ctrl + right arrow key
            window.location.href = window.location.origin + '/' + nextPageLink;
        }
    });

    $(document).keyup(function(e) {
        delete keys[e.which];
    });
})();