Greasy Fork

Greasy Fork is available in English.

Goodreads giveaways arrow pager

Navigate giveaway pages with left and right arrow keys

当前为 2018-05-28 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name          Goodreads giveaways arrow pager
// @namespace     randomecho.com
// @description   Navigate giveaway pages with left and right arrow keys
// @include       https://www.goodreads.com/giveaway*
// @include       http://www.goodreads.com/giveaway*
// @grant         none
// @copyright     2014 Soon Van
// @author        Soon Van - randomecho.com
// @license       http://opensource.org/licenses/BSD-3-Clause
// @version       1.1
// ==/UserScript==

function arrowPager(e) {
  pager_class = detectArrowKeyPressed(e);

  if (pager_class !== false) {
    changeToPage(document.getElementsByClassName(pager_class));
  }
}

function changeToPage(pager_node) {
  if (typeof(pager_node[0]) != 'undefined') {
    page_url = pager_node[0].getAttribute('href');

    // First and last pager links will not have a URL set
    if (page_url) {
      document.location = page_url;
    }
  }
}

function detectArrowKeyPressed(e) {
  if (e.keyCode == 39) {
    return 'next_page';
  } else if (e.keyCode == 37) {
    return 'previous_page';
  }

  return false;
}

document.addEventListener('keydown', arrowPager, false);