nCore preview image replacer

it replaces the little [i] button on nCore to the actual image.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name			nCore preview image replacer
// @name:hu			nCore torrent oldalon, borítókép megjelenítő
// @author          Daniel Vasarhelyi
// @description 	it replaces the little [i] button on nCore to the actual image.
// @description:hu  Nem kell egyesével a listaoldalon [i]-re vinni az egeret, hogy lássuk a torrenthez tartozó borítóképet.
// @namespace		http://userscripts.org/users/293336
// @license         Creative Commons Attribution License
// @version         0.21
// @include			/^https?://ncore\.pro/torrents.php/
// @compatible      Greasemonkey
// ==/UserScript==

var rownodes = document.evaluate( '//div[@class="box_torrent" and div/div/div/div/div/div/img/@class="infobar_ico"]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );

for (i=0; i<rownodes.snapshotLength; i++)
{
	var row = rownodes.snapshotItem(i);


	// replace [i] with link and full image
	var preview_node = document.evaluate('.//img[@class="infobar_ico"]', 
		row, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
	
	var image_href = preview_node.getAttribute("onmouseover").match(/mutat\('([^']*)'/);

	var details_page = document.evaluate('.//div[@class="torrent_txt"]/a/@href', 
		row, null, XPathResult.STRING_TYPE, null).stringValue;

	var link=document.createElement("a");
	link.setAttribute("href", details_page);
	preview_node.parentNode.replaceChild(link, preview_node);
	link.appendChild(preview_node);
	
	preview_node.removeAttribute("onmouseover");
	preview_node.removeAttribute("onmouseout");
	preview_node.setAttribute("src", image_href[1]);
	preview_node.removeAttribute("class");
	preview_node.removeAttribute("border");


	// adjust the box horizontally
	var box_node = document.evaluate('./div[@class="box_nagy" or @class="box_nagy2"]', 
		row, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

	box_node.style.setProperty("height", "auto", "important");
	
	
}