Goodreads giveaways arrow pager

Navigate giveaway pages with left and right arrow keys

目前為 2015-02-21 提交的版本,檢視 最新版本

// ==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.0
// ==/UserScript==

function arrowPager(e)
{
  var pager_class = '';

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

  if (pager_class != '')
  {
    // There should be only one link classed as either, so grab it
    var pager_node = document.getElementsByClassName(pager_class);
    
    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;
      }
    }
  }
}

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址