nCore preview image replacer

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

נכון ליום 26-08-2023. ראה הגרסה האחרונה.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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.2
// @include			/^https?://ncore\.cc/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");
	
	
}