ProjectFreeTv Episode Guide

Enhance ProjectFreeTV links with episode information.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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);
			});
		});
	}
})();