ProjectFreeTv Episode Guide

Enhance ProjectFreeTV links with episode information.

目前为 2016-06-14 提交的版本,查看 最新版本

// ==UserScript==
// @name         ProjectFreeTv Episode Guide
// @namespace    pftepisodeguide
// @version      0.1
// @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/*
// @grant        none
// @require      http://code.jquery.com/jquery-3.0.0.min.js
// ==/UserScript==

(function() {
	'use strict';

	// Your code here...
	$("table tr").each(function () {
		var episodeTableRow = $(this);
		var episodeLink = $("a:first-child", episodeTableRow);
		var parsedEpisode = episodeLink.text().match(/(.+) Season (\d+) Episode (\d+)/);

		var series = parsedEpisode[1]
		var season = parsedEpisode[2];
		var episode = parsedEpisode[3];

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

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

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