Created
March 15, 2011 09:35
-
-
Save nkmrgk/870499 to your computer and use it in GitHub Desktop.
LDR open in background tab mod
This file contains hidden or 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 LDR open in background tab mod | |
// @namespace http://ss-o.net/ | |
// @include http://reader.livedoor.com/reader/ | |
// @include http://reader.livedoor.com/public/* | |
// @include http://fastladder.com/reader/ | |
// @include http://fastladder.com/public/* | |
// @version 1.0.3 | |
// ==/UserScript== | |
(function(window, load){ | |
if (this.chrome && !load){ | |
var fn = '(' + arguments.callee.toString() + ')(this, true);'; | |
var script = document.createElement('script'); | |
script.appendChild(document.createTextNode(fn)); | |
document.body.appendChild(script); | |
return; | |
} | |
var native_open = window.native_open = window.open; | |
window.open = this.chrome ? function(url,name){ | |
if (url === void 0) return native_open(url,name); | |
var a = document.createElement('a'); | |
a.href = url; | |
if (name) a.target = name; | |
var event = document.createEvent('MouseEvents'); | |
event.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 1, null); | |
a.dispatchEvent(event); | |
return true; | |
} : function(url,name){ | |
if (url === void 0) return native_open(url,name); | |
setTimeout(function(){ | |
GM_openInTab(url); | |
}); | |
return true; | |
}; | |
document.addEventListener('click',function(evt){ | |
if (evt.target.href && evt.target.target === '_blank'){ | |
evt.preventDefault(); | |
window.open(evt.target.href, '_blank'); | |
} | |
},false); | |
var _onload = window.onload; | |
window.onload = function(){ | |
_onload(); | |
var p = window.Control.pin; | |
var v = window.Control.view_original; | |
var force_next_item = function(){ | |
var i = window.get_active_item(); | |
window.Control.scroll_next_item(); | |
if(i == window.get_active_item()){ | |
window.Control.scroll_next_item(); | |
} | |
}; | |
var pin = function(){ | |
var res = p.apply(this, arguments); | |
force_next_item(); | |
return res; | |
}; | |
var view_original = function(){ | |
var res = v.apply(this, arguments); | |
force_next_item(); | |
return res; | |
}; | |
window.Keybind.add("p", pin); | |
window.Keybind.add("v", view_original); | |
}; | |
var Control = window.Control; | |
window.Keybind.add("d", Control.go_next); //次へ | |
window.Keybind.add("D", Control.go_prev); //前へ | |
window.Keybind.add("u", Control.unsubscribe); //購読停止 | |
window.Keybind.add('l', Control.reload_subs); //リロード | |
window.Keybind.add("n", Control.read_next_subs); //次フィードへ | |
window.Keybind.add("b", Control.read_prev_subs); //前フィードへ | |
window.Keybind.add('i', Control.view_original); //開く | |
window.Keybind.add('V', function(){ //開く+次へ | |
var item = get_active_item(true); | |
if (!item) return; | |
window.open(item.link); | |
Control.go_next(); | |
}) | |
window.Keybind.add('h', function(){ //はてブ開く | |
var item = get_active_item(true); | |
if (item) { | |
var link = 'http://b.hatena.ne.jp/entry/' + | |
item.link.replace(/#/, '%23'); | |
window.open(link); | |
} | |
}) | |
window.Keybind.add('P', function(){ //ピン+次へ | |
var res = Control.pin.apply(this, arguments); | |
Control.go_next(); | |
return res; | |
}) | |
window.Keybind.add('M', function(){ //全て開く | |
var queue = new Queue(); | |
get_active_feed().items.forEach(function(item){ | |
queue.push(function(){ | |
window.open(item.link); | |
}); | |
}); | |
queue.interval = 200; | |
queue.exec(); | |
}) | |
window.Keybind.add('m', function(){ //既読にする | |
touch_all(window.State.last_feed.subscribe_id); | |
}) | |
function rate(rate){ | |
var el = document.getElementById("rate_img"); | |
if(-1 < el.src.indexOf(rate+".gif")){ | |
return; | |
} | |
var sid = el.getAttribute("sid"); | |
set_rate(sid,rate) | |
el.src = Rate.image_path_p + rate + ".gif"; | |
el.setAttribute("orig_src",el.src); | |
} | |
window.Keybind.add("0", function(){rate("0")}); //レート0 | |
window.Keybind.add("1", function(){rate("1")}); //レート1 | |
window.Keybind.add("2", function(){rate("2")}); //レート2 | |
window.Keybind.add("3", function(){rate("3")}); //レート3 | |
window.Keybind.add("4", function(){rate("4")}); //レート4 | |
window.Keybind.add("5", function(){rate("5")}); //レート5 | |
window.Keybind.add("j", Control.go_next); //次へ(+次フィード) | |
window.Keybind.add("k", Control.go_prev); //前へ(+前フィード) | |
['ads_top', 'ads_bottom'].forEach(function(v){ //ADSクリア | |
DOM.hide(v); | |
}); | |
// 起動時にZキー3回 | |
var toggle_fullscreen_with_control = function(){ | |
var fs = []; | |
var elements = ['header', 'menu', 'control', 'footer']; | |
fs[0] = ['header', 'menu', 'control', 'footer']; | |
fs[1] = ['menu', 'control']; | |
fs[2] = ['control']; | |
fs[3] = []; | |
if (!State.fullscreen) { | |
State.fullscreen = 1; | |
} else if (State.fullscreen == fs.length-1){ | |
State.fullscreen = 0; | |
} else { | |
State.fullscreen++ | |
} | |
Element.hide(elements); | |
Element.show(fs[State.fullscreen]); | |
fit_screen() | |
}; | |
Keybind.add('Z', toggle_fullscreen_with_control); | |
var i = 3; | |
while (i) { | |
toggle_fullscreen_with_control(); | |
i--; | |
} | |
// 起動画面のシンプル化 | |
var css = ".GuideNavigationWrapper, #GuideHeadBox, .FullBox { display: none !important; }"; | |
if (typeof GM_addStyle != "undefined") { | |
GM_addStyle(css); | |
} else if (typeof PRO_addStyle != "undefined") { | |
PRO_addStyle(css); | |
} else if (typeof addStyle != "undefined") { | |
addStyle(css); | |
} else { | |
var heads = document.getElementsByTagName("head"); | |
if (heads.length > 0) { | |
var node = document.createElement("style"); | |
node.type = "text/css"; | |
node.appendChild(document.createTextNode(css)); | |
heads[0].appendChild(node); | |
} | |
} | |
})(this.unsafeWindow); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment