Created
January 14, 2009 23:48
-
-
Save edvakf/47162 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name fastladder_fixed_item_height.user.js | |
// @namespace http://d.hatena.ne.jp/edvakf/ | |
// @description Limit the height of items on LDR/Fastladder | |
// @include http://reader.livedoor.com/reader/ | |
// @include http://reader.livedoor.com/public/* | |
// @include http://fastladder.com/reader/ | |
// ==/UserScript== | |
// The "IE OK?" lines **might** work for IE as well | |
(function(w){ | |
//////// config //////// | |
var cfg = { | |
item_style : ['max-height:400px;','overflow-x:hidden;','overflow-y:auto;'], | |
//down_key : 'd', | |
//up_key : 'u|D', | |
toggle_key : 'i', | |
//item_scroll_px : 200, | |
//integrated_scroll : true, | |
//integrated_next_feed : true | |
} | |
/////////////////////// | |
if(undefined !== w.Components){ // for Firefox | |
var style = document.createElement('style'); | |
style.innerHTML = '.item{'+cfg.item_style.join('')+'}'; | |
document.getElementsByTagName('head')[0].appendChild(style); | |
}else{// for Opera, Safari | |
w.LDR_addStyle('.item',cfg.item_style); | |
} | |
w.LDR_addStyle('.item.expanded',['max-height:none;','height:auto;','overflow-x:auto;','overflow-y:auto;']); | |
w.LDR_addStyle('.item.blocked',['max-height:none;','height:auto;','overflow-x:auto;','overflow-y:auto;']); // to be compatible with LDR-ad-entry-blocker-mod.user.js | |
w.addEventListener('load',function(){ | |
var keyfuncs = w.Keybind._keyfunc; | |
var j_func = keyfuncs['j'], s_func = keyfuncs['s'], k_func = keyfuncs['k'], a_func = keyfuncs['a']; | |
var currentItem = function(){return w.get_active_item(true).element.parentNode.parentNode.parentNode;}; | |
function item_down(){ | |
if(w.check_wait()) return; | |
var e = currentItem(); | |
if(w.hasClass(e,'expanded')) return; | |
if(e && e.clientHeight+e.scrollTop<e.scrollHeight) e.scrollTop+=(cfg.item_scroll_px||100); | |
else if(cfg.integrated_scroll){ | |
if(w.Control.next_item_offset()!=null) j_func(); | |
else if(cfg.integrated_next_feed) s_func(); | |
} | |
} | |
function item_up(){ | |
if(w.check_wait()) return; | |
var e = currentItem(); | |
if(w.hasClass(e,'expanded')) return; | |
if(e && e.scrollTop) e.scrollTop-=(cfg.item_scroll_px||100); | |
else if(cfg.integrated_scroll){ | |
if(w.$('right_container').scrollTop!=0) k_func(); | |
else if(cfg.integrated_next_feed) a_func(); | |
} | |
} | |
function item_style_toggle(){ | |
if(w.check_wait()) return; | |
var e = currentItem(); | |
if(e) w.hasClass(e,'expanded') ? w.removeClass(e,'expanded') : w.addClass(e,'expanded'); | |
} | |
if(cfg.down_key)w.Keybind.add(cfg.down_key,item_down); | |
if(cfg.up_key)w.Keybind.add(cfg.up_key,item_up); | |
if(cfg.toggle_key)w.Keybind.add(cfg.toggle_key,item_style_toggle); | |
},false); | |
})(this.unsafeWindow||window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment