FireGestures 用鼠标手势快速翻页(上一页)(下一页)的脚本

下一页

———————————————————————-

// derived from All-in-One Gestures created by Marc Boullet

////////////////////////////////////////////////////////////////
// OPTIONS

// "prev" or "next"
// const PREV_NEXT = "prev";
const PREV_NEXT = "next";

// part of string which the link should contain
// const KEYWORDS = ["prev", "上页", "上一页", "前一页", "前页"];
const KEYWORDS = ["next", "下页", "下一页", "后一页", "后页","后一页>","后一页>>"];

////////////////////////////////////////////////////////////////
// PROGRAM

// first, we search for LINK tags
var doc = FireGestures.sourceNode.ownerDocument;
var links = doc.getElementsByTagName("link");
for (var i = 0; i < links.length; i++) {
  if (links[i].href &&
      links[i].hasAttribute("rel") &&
      links[i].getAttribute("rel").toLowerCase().indexOf(PREV_NEXT) == 0) {
    loadURI(links[i].href);
    return;
  }
}

// second, we search for A tags
var regexp = new RegExp("(?:" + KEYWORDS.join("|") + ")", "i");
links = doc.links;
for (i = 0; i < links.length; i++) {
  if (links[i].href &&
      links[i].textContent &&
      links[i].textContent.match(regexp)) {
    loadURI(links[i].href);
    return;
  }
}

上一页

———————————————————————-

// derived from All-in-One Gestures created by Marc Boullet

////////////////////////////////////////////////////////////////
// OPTIONS

// "prev" or "next"
const PREV_NEXT = "prev";

// part of string which the link should contain
const KEYWORDS = ["prev", "上页", "上一页", "前一页", "前页"];

////////////////////////////////////////////////////////////////
// PROGRAM

// first, we search for LINK tags
var doc = FireGestures.sourceNode.ownerDocument;
var links = doc.getElementsByTagName("link");
for (var i = 0; i < links.length; i++) {
  if (links[i].href &&
      links[i].hasAttribute("rel") &&
      links[i].getAttribute("rel").toLowerCase().indexOf(PREV_NEXT) == 0) {
    loadURI(links[i].href);
    return;
  }
}

// second, we search for A tags
var regexp = new RegExp("(?:" + KEYWORDS.join("|") + ")", "i");
links = doc.links;
for (i = 0; i < links.length; i++) {
  if (links[i].href &&
      links[i].textContent &&
      links[i].textContent.match(regexp)) {
    loadURI(links[i].href);
    return;
  }
}