nCore preview image replacer

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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");
	
	
}