// ==UserScript==
// @name           GRSpacekey
// @namespace      http://d.hatena.ne.jp/hamabebe/
// @description    LDR-Like behavior of space key in Google Reader.
// @include        *
// ==/UserScript==

if ((/www.google.com\/reader|www.google.co.jp\/reader/).test(window.location.href) &&
    typeof unsafeWindow != "undefined") {

	var w = unsafeWindow;

  var patch = function() {
    w.R.qh=function(a){
      if(this.ka&&!this.Ee||!this.Ka)return;
      var b=this.Ee?u(PD):this.ea();
      b.scrollTop+=a?+100:-100;
    };
    w.R.down=function(a){this.qh(!a)};
    w.R.up=function(a){this.qh(a)};
  };

  w._grspacekey = function(evt) {
    if (evt.keyCode == 32) {
      patch();
      w.document.removeEventListener("keydown", w._grspacekey, true);
    }
  };

  w.document.addEventListener("keydown", w._grspacekey, true);
}
