ScrollCommand.user.js
// ==UserScript== // @name ScrollCommand // @namespace http://d.hatena.ne.jp/Constellation/ // @description Press j or k key , and scroll (in case that LDRize are not working on its page) // @include * // @exclude http://www.google.tld/reader/* // @exclude https://www.google.tld/reader/* // @exclude http://mail.google.tld/* // @exclude https://mail.google.tld/* // @author Constellation // @version 0.0.3 // ==/UserScript== function boot(ev){ if(ev) window.removeEventListener('GM_MinibufferLoaded', boot, false); if (!window.Minibuffer) return; //=========[Config]================== var SCROLLHEIGHT = 200; var TIME = 100; //=========[Application]============= var Class = function(){return function(){this.initialize.apply(this,arguments)}}; var Scroll = new Class(); Scroll.prototype = { initialize : function(down){ this.down = down; this.i = 0; this.height = 0; this.active = true; this.go(); }, go : function(){ if(!(Scroll.down == this.down) && !this.i==0) return this.cancel(); var self = this; var height = Scroll.h[this.i++]; var value = height - self.height; self.height = height; if(!self.down) value = -(value); window.scrollBy(0, value); var f = function(){self.go.call(self)}; if(this.i < 10) this.scl = setTimeout(f, Scroll.delay); else this.active = false; }, cancel : function(){ if(this.enable){ clearTimeout(this.scl); this.active = false; } } } Scroll.set = function(){ Scroll.enable = true; var t = []; for (var i = 0;i < 10;i++){ var a = i+1; t[i] = Math.round(SCROLLHEIGHT * (Math.sin(Math.PI * a / 20))); } Scroll.h = t; Scroll.delay = Math.round(TIME / 9); } Scroll.enable = false; [ { key:'SPC', description: 'scrollcommand::next', command: function(){ if(!Scroll.enable) Scroll.set(); Scroll.down = true; var scroll = new Scroll(true); } }, { key:'SHIFT-SPC', description: 'scrollcommand::prev', command: function(){ if(!Scroll.enable) Scroll.set(); Scroll.down = false; var scroll = new Scroll(false); } } ] .forEach(window.Minibuffer.addShortcutkey); if (window.LDRize && window.LDRize.getSiteinfo() == undefined) { [ { key:'j', description: 'scrollcommand::next', command: function(){ if(!Scroll.enable) Scroll.set(); Scroll.down = true; var scroll = new Scroll(true); } }, { key:'k', description: 'scrollcommand::prev', command: function(){ if(!Scroll.enable) Scroll.set(); Scroll.down = false; var scroll = new Scroll(false); } } ] .forEach(window.Minibuffer.addShortcutkey); } } if(window.Minibuffer){ boot(); } else { window.addEventListener('GM_MinibufferLoaded', boot, false); }
nice and smooth な scroll command になった http://is.gd/L5mf でも minibuffer.user.js にパッチが必要 http://is.gd/L5mh
space, shift+space でのスクロールをスムースなヤツに置き換え。ldrize が効いてないときには "j", "k" キーでもスクロールするんですヨ
minibuffer のパッチ、はやく本家に取り込まれないかなー
&&
と ||
が間違ってた。論理演算だ。わかってないなあ
LDRizeの存在確認とLDRizeが働いていないことの確認はしているのでたぶん(F)LDRとかでは不具合はないと思うんですが、