Somchai / Show Poster Rarbg

// ==UserScript==
// @name        Show Poster Rarbg
// @namespace   Show_Poster_Rarbg
// @description Shows high quality poster on every items of the torrent list.
// @icon        data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAADwCAYAAAA+VemSAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4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CG0i9eBzb0mbzhCuABU0Ov6fktpzK8wf17WQK2MZR27XomaX2zHvROrIKk1wyfJZSH1tp9w3vKneNaWOlTlwAXJFW5KB31R0cAGx9Kk1tPIzWa4qJ01NsOATY6lCa3ngdudIWL0lE/dAwwQ2lzPXLpRI5Gr3NhOrqgBQe7xrUx0qBLZ2I1V+bitNWoo4C5phYmK10C3C3pOReppe44jJdrauFFZy4BLki6zEVK3K6kU44DLsSHkXO9Ou+ei29m2K9bXKxEveMBXobS6fSNpB/5ArhL0gMu2gu74RFehtKd90tX3054UL1ctAO7L+moZ4C5PWq/P8nhF3yDOB94uT1qrw1J3/EVMIjDwsvtUeu9ddhn6jrgBuK8X/SPA8DL9Wytd5N8nj4AbvzPndfh15VA4HI9k7Uab0UthAS4eSIkL7OZ/5L04wDx5vV6GnmqzDfAjSWJ0NcVfxc43Lxdz8P6Mj7YopAHwI0GJd2MZ+pCuIifSfpgv+1yOSm065lkhvlm/HefaPdz8xlwc69KuiDpQ0lLHly8r+N9zO/FM40v5xRtKNczSUvx33Mh/vtS+axCAby3V/S/t8qPOtawpDcBGsz1TFJf/O838tlkCpiIso0PgQjARARgIgIwEYCJCMBEZK7/DgDLJ1XUnWAbHAAAAABJRU5ErkJggg==
// @version     16
// @author      Somchai Sappurit
// @updateURL   https://openuserjs.org/meta/Somchai/Show_Poster_Rarbg.meta.js
// @license     MIT
// @include     /https?://(.+)?rarbg.+?/torrents.php/
// ==/UserScript==

let table = document.querySelector("table.lista2t");

let headerColumn = document.createElement("td");
headerColumn.setAttribute("class", "header6 header40");
headerColumn.style.width = "250px";
headerColumn.style.backgroundColor = "#3860bb";
headerColumn.style.cursor = "default";
headerColumn.innerText = "Poster";
table.rows[0].insertBefore(headerColumn, table.rows[0].cells[1]);

Array.from(table.rows).forEach((row, i) =>
{
	if (i === 0)
		return;

	let link = row.querySelector("a[title]"),
		mouseoverAttr = link.getAttribute("onmouseover");

	let thumbColumn = document.createElement("td");
	thumbColumn.style.textAlign = "center";

	if (mouseoverAttr)
	{
		let matches = mouseoverAttr.match(/src=\\'(.*)?\\'/);

		if (matches.length != 2)
		{
			//console.error("Could not match image source on link: ", link, mouseoverAttr);
			return;
		}

		let thumbImage = new Image();
		thumbImage.style.minWidth = "250px";
		thumbImage.style.maxWidth = "250px";
		thumbImage.src = matches[1];
		thumbImage.src = thumbImage.src.replace(/static\/over\/(.)/,"posters2/$1/$1");  // This is XXX. You can add more categories.

		let thumbLink = document.createElement("a");
		thumbLink.href = link.href;
		thumbLink.style.Width    = "250px";
		thumbLink.style.display  = "block";
		thumbLink.style.overflow = "hidden";
		thumbLink.appendChild(thumbImage);

		thumbColumn.setAttribute("onmouseover", mouseoverAttr);
		thumbColumn.setAttribute("onmouseout", link.getAttribute("onmouseout"));
		thumbColumn.appendChild(thumbLink);
	}

	row.insertBefore(thumbColumn, link.parentNode);
});