Last active
December 24, 2015 07:40
-
-
Save Qofar/6765701 to your computer and use it in GitHub Desktop.
[NicoCache_nl] livedoor Readerからnキーでfetch開始する
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_nicofetch | |
// @namespace http://www.nicovideo.jp/ | |
// @description Add the nicofetch function for livedoor reader. | |
// @include http://reader.livedoor.com/reader/* | |
// @version 0.3 | |
// ==/UserScript== | |
// memo http://os0x.hatenablog.com/entry/20080827/1219815828 | |
(function(){ | |
var w = (typeof unsafeWindow === 'undefined') ? window : unsafeWindow; | |
var _onload = w.onload; | |
w.onload = function(){ | |
_onload(); | |
w.Keybind.add("n", function() { | |
var item = w.get_active_item(true); | |
if(item === null) return; | |
var widget_nicofetch = item.element.parentElement.parentElement.getElementsByClassName("widget_nicofetch"); | |
if(widget_nicofetch.length === 1 && widget_nicofetch[0].firstChild.onclick ){ | |
widget_nicofetch[0].firstChild.onclick(); | |
} | |
}); | |
} | |
function loadMovieFetcher() { | |
if (!w.nlMovieFetcher) { | |
GM_log("nlMovieFetcher not found."); return; | |
} | |
w.nlMovieFetcher.prototype.callAPI = function(param, callback) { | |
setTimeout(function() { | |
GM_xmlhttpRequest({ | |
method: 'GET', | |
url: "http://www.nicovideo.jp/cache/fetch?"+param, | |
onload: callback | |
}); | |
}, 0); | |
} | |
} | |
var src = 'http://www.nicovideo.jp/local/nlMovieFetcher.js'; | |
var sc = document.createElement('script'); | |
sc.type = 'text/javascript'; | |
sc.onload = loadMovieFetcher; | |
sc.src = src; | |
document.body.appendChild(sc); | |
var description = "nicofetch for LDR"; | |
w.entry_widgets.add('nicofetch', function(feed, item) { | |
if (item.link.indexOf('http://www.nicovideo.jp/watch/') !== 0) return; | |
var id = item.link.substring(item.link.lastIndexOf("/") + 1); | |
return [ | |
'<a href="javascript:void(0);" onclick="nicofetch(this,\'', id, '\',2)" target="_self">', | |
'<img src="http://www.nicovideo.jp/favicon.ico" border="0">', | |
'</a>' | |
].join(''); | |
}, description); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment