nicothumbcatch

By 22century Last update Dec 6, 2008 — Installed 292 times. Daily Installs: 0, 0, 0, 0, 6, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2

There are 3 previous versions of this script.

// ==UserScript==
// @name           nicothumbcatch
// @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[1]//td[2]', d, null, 9, null).singleNodeValue;
	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")//div[@class="switch_bg"]//tr', d, null, 9, null).singleNodeValue;
	var td_run = d.createElement("td");
	
	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.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);
			}
		}
	}
})();