ProjectFreeTv Episode Guide

Enhance ProjectFreeTV links with episode information.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         ProjectFreeTv Episode Guide
// @namespace    pftepisodeguide
// @version      0.2
// @description  Enhance ProjectFreeTV links with episode information.
// @author       splttingatms
// @include      http://projectfreetv.im/free/*
// @include      https://projectfreetv.im/free/*
// @include      http://*.projectfreetv.im/free/*
// @include      https://*.projectfreetv.im/free/*
// @include      http://projectfreetv.im/episode/*
// @include      https://projectfreetv.im/episode/*
// @include      http://*.projectfreetv.im/episode/*
// @include      https://*.projectfreetv.im/episode/*
// @grant        none
// @require      http://code.jquery.com/jquery-3.0.0.min.js
// ==/UserScript==

(function() {
	'use strict';

	function isEpisodePage() {
		return window.location.href.indexOf("episode") !== -1;
	}

	function parseFullEpisodeTitle(title) {
		var parsedEpisode = title.match(/(.+) Season (\d+) Episode (\d+)/);
		return {
			series: parsedEpisode[1],
			season: parsedEpisode[2],
			episode: parsedEpisode[3]
		};
	}
	
	if (isEpisodePage()) {
		var fullEpisodeTitle = $(".title")[0].innerText;
		var episode = parseFullEpisodeTitle(fullEpisodeTitle);

		$.getJSON(`https://www.omdbapi.com/?t=${encodeURIComponent(episode.series)}&Season=${episode.season}&Episode=${episode.episode}&callback=?`, function(result) {
			$(".box b")[3].nextSibling.data = result.Plot;
		});
	} else {
		$("table tr").each(function () {
			var episodeTableRow = $(this);
			var episodeLink = $("a:first-child", episodeTableRow);
			var episode = parseFullEpisodeTitle(episodeLink.text());

			$.getJSON(`https://www.omdbapi.com/?t=${encodeURIComponent(episode.series)}&Season=${episode.season}&Episode=${episode.episode}&callback=?`, function(result) {
				episodeLink.text(`S${episode.season}E${episode.episode} ${result.Title}`);

				var plot = $("</p>")
				.text(result.Plot)
				.css({margin: 0, textAlign: 'left'});

				$("th", episodeTableRow).append(plot);
			});
		});
	}
})();