Labs/JavaScript/Firegestures/LRのコマンドをカスタマイズ

const LR = "L"; //R

// Adapted from Google Reader Auto-Read
// http://userscripts.org/scripts/show/2035
function simulateClick(node) {
  if(!node) return;
  var event = node.ownerDocument.createEvent("MouseEvents");
  event.initMouseEvent("click",
    true, // can bubble
    true, // cancellable
    node.ownerDocument.defaultView,
    1, // clicks
    50, 50, // screen coordinates
    50, 50, // client coordinates
    false, false, false, false, // control/alt/shift/meta
    0, // button,
    node
  );
  node.dispatchEvent(event);
}

var loc = window.content.document.location.toString();

if(loc.match(/http(s?):\/\/(www?)\.google.co(m|\.\w{2})\/reader.*/i)!=null) {
  //Google Readerの記事を移動
  simulateClick(window.content.document.getElementById(LR=="L"?"entries-up":"entries-down"));
  return;
} else if(loc.match(/http(s?):\/\/mail\.google.co(m|\.\w{2}).*/i)!=null) {
  // GmailのMouse gesturesを使っているので。
  return;
} else {
  // 履歴を進む/戻る
  document.getElementById(LR=="L"?"Browser:Back":"Browser:Forward").doCommand();
}