完全に自分用で、Operaでしか確認してない。いつも通りのScriptです。
Enterで動画を開けるのは便利かなぁ。
Enterで動画を開けるのは便利かなぁ。
// ==UserScript==
// @name nico ldrize
// @namespace http://looxu.blogspot.com/
// @include http://www.nicovideo.jp/ranking/mylist/hourly/all
// @author Arc Cosine
// @version 1.0
// ==/UserScript==
(function(){
var keyHandler = {
'J' : function(){ NicoLDRize.scroll(1); },
'K' : function(){ NicoLDRize.scroll(-1); },
'ENT' : function(){ NicoLDRize.openTab(); }
}
var NicoLDRize = {};
NicoLDRize.init = function(){
var specialkey = {'13' : 'ENT'};
NicoLDRize.pos = 0;
var allow = document.createElement('div');
allow.id = 'nicoldrize';
allow.style.width = '16px';
allow.style.height= '16px';
allow.style.background= '#008800';
allow.style.position = 'absolute';
allow.style.top = '196px';
allow.style.left = '160px';
document.body.appendChild(allow);
window.addEventListener('keypress',function(e){
if( e.target.tagName == 'INPUT' || e.target.tagName == 'TEXTAREA' ) return;
var keyCode = e.which;
var pressKey= (typeof specialkey[keyCode] == 'undefined') ? String.fromCharCode(keyCode).toUpperCase() : specialkey[keyCode];
if( typeof keyHandler[pressKey] != "function" ) return;
e.preventDefault();
keyHandler[pressKey].apply();
},false );
}
NicoLDRize.scroll = function(num){
NicoLDRize.pos += num;
if (NicoLDRize.pos < 0) { NicoLDRize.pos = 0 };
if (NicoLDRize.pos > 100) { NicoLDRize.pos = 100 };
var divs = document.querySelectorAll('div.content_672 > div');
var pos = divs[NicoLDRize.pos].offsetTop - 20;
document.body.scrollTop = pos;
document.getElementById('nicoldrize').style.top = pos + 60 + 'px';
}
NicoLDRize.openTab = function(){
var aTags = document.querySelectorAll('div.content_672 a.watch');
var url = aTags[NicoLDRize.pos-1].href;
window.open(url);
}
NicoLDRize.init();
})();
コメント
コメントを投稿