Created
February 11, 2009 03:05
-
-
Save azu/61792 to your computer and use it in GitHub Desktop.
nicothumbcatch.user.js
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 nicothumbcatch.user.js | |
// @namespace http://22century.cute.bz/ | |
// @description nicovideo ranking thumbnail catcher. | |
// @include http://www.nicovideo.jp/ranking/* | |
// @exclude http://www.nicovideo.jp/ranking/*/ichiba | |
// ==/UserScript== | |
(function() | |
{ | |
var d = document; | |
var __openvalue = "\u30B5\u30E0\u30CD\u30A4\u30EB\u8868\u793A"; | |
var __closevalue = "\u5143\u306B\u623B\u3059"; | |
var td_rank = d.evaluate('id("PAGEBODY")//table[2]/tbody/tr/td[2]', d, null, 9, null).singleNodeValue;//id("PAGEBODY")//td[@width="560"]の方がいいかも | |
var div_channels = d.createElement("div"); | |
var div_popup = d.createElement("div"); | |
var input_run = d.createElement("input"); | |
var tr_sort = d.evaluate('id("PAGEBODY")//a[@class="switch_1"]', d, null, 9, null).singleNodeValue; | |
var td_run = d.createElement("div"); | |
div_channels.style.cssText = "display:none;text-align:center;width:auto"; | |
div_popup.style.cssText = "display:none;position:absolute;border:#ccc solid 2px;background:#fff;font:bold 0.8em Sans-serif;width:130px;padding:3px;"; | |
td_run.style.paddingLeft = "8px"; | |
input_run.type = "button"; | |
input_run.className = "submit"; | |
input_run.value = __openvalue; | |
input_run.addEventListener("click", thumbcatchrun, false); | |
d.body.appendChild(div_popup); | |
td_run.appendChild(input_run); | |
tr_sort.parentNode.appendChild(td_run); | |
function thumbcatchrun() | |
{ | |
input_run.value = (input_run.value == __openvalue) ? __closevalue : __openvalue; | |
td_rank.style.display = (td_rank.style.display == "none") ? "block" : "none"; | |
div_channels.style.display = (div_channels.style.display == "block") ? "none" : "block"; | |
if ( !div_channels.hasChildNodes() ) { | |
td_rank.parentNode.insertBefore(div_channels, td_rank); | |
var thumbs = d.evaluate('//a[contains(@href,"watch/") and @class=false()]', td_rank, null, 7, null); | |
var a_thumb, img_thumb; | |
for (var i=0; i < thumbs.snapshotLength; i++) { | |
a_thumb = thumbs.snapshotItem(i).cloneNode(true); | |
img_thumb = a_thumb.getElementsByTagName("img")[0]; | |
img_thumb.style.cssText = "width:130px;height:100px;"; | |
img_thumb.addEventListener("mousemove",function(e) { | |
div_popup.style.left = e.pageX - 140 + "px"; | |
div_popup.style.top = e.pageY + 20 + "px"; | |
}, false); | |
img_thumb.addEventListener("mouseover", function() { | |
div_popup.style.display = "block"; | |
div_popup.textContent = this.alt; | |
}, false); | |
img_thumb.addEventListener("mouseout", function(){ | |
div_popup.style.display = "none"; | |
}, false); | |
if (i%4==0) div_channels.appendChild( d.createElement("br") ); | |
div_channels.appendChild(a_thumb); | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment