Torrent.lt poster preview

Script Torrent.lt poster preview

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        Torrent.lt poster preview
// @namespace   torrent_script
// @description Script Torrent.lt poster preview
// @include     https://torrent.lt/lt/torrents*
// @require		http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @version     1.4
// @grant       none
// @locale      LT
// ==/UserScript==
jQuery(document).ready(function ($) {

	var number = 0;
	$("table.torrents_table tr").each(function (index) {
		var sitas = $(this);
		//	console.log(sitas.find('td').next().find('a').attr('href'));
		setTimeout(function () {
			var nuoroda = sitas.find('td').next().find('a').attr('href');
			number += 1;

			$.ajax({
				url: nuoroda,
				context: document.body
			}).done(function (data) {
				var result = '';
				var step = 5;
				var pradzia = data.indexOf('id="covercontainer');

				if (pradzia == -1) {
					pradzia = data.indexOf('class="torrentapr');
				}
				console.log(nuoroda + ' ' + pradzia);
				if (pradzia != -1) {
					var kerpam = data.substr(pradzia, 500);
					var url_start = kerpam.indexOf('src="') + step;
					kerpam = kerpam.substr(url_start, 400);
					var url_end = kerpam.indexOf('"');
					result = kerpam.substr(0, url_end);

					sitas.find('td').eq(2).html('<a href="' + nuoroda + '" target="_blank"><img style="max-width:100px" src="' + result + '" alt="" /></a>');

				}
			});
		}, index * 500);

	});

});