ProjectFreeTv Episode Guide

Enhance ProjectFreeTV links with episode information.

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

  1. // ==UserScript==
  2. // @name ProjectFreeTv Episode Guide
  3. // @namespace pftepisodeguide
  4. // @version 0.1
  5. // @description Enhance ProjectFreeTV links with episode information.
  6. // @author splttingatms
  7. // @include http://projectfreetv.im/free/*
  8. // @include https://projectfreetv.im/free/*
  9. // @include http://*.projectfreetv.im/free/*
  10. // @include https://*.projectfreetv.im/free/*
  11. // @grant none
  12. // @require http://code.jquery.com/jquery-3.0.0.min.js
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. // Your code here...
  19. $("table tr").each(function () {
  20. var episodeTableRow = $(this);
  21. var episodeLink = $("a:first-child", episodeTableRow);
  22. var parsedEpisode = episodeLink.text().match(/(.+) Season (\d+) Episode (\d+)/);
  23.  
  24. var series = parsedEpisode[1]
  25. var season = parsedEpisode[2];
  26. var episode = parsedEpisode[3];
  27.  
  28. $.getJSON(`https://www.omdbapi.com/?t=${encodeURIComponent(series)}&Season=${season}&Episode=${episode}&callback=?`, function(result){
  29. episodeLink.text(`S${season}E${episode} ${result.Title}`);
  30.  
  31. var plot = $("</p>")
  32. .text(result.Plot)
  33. .css({margin: 0, textAlign: 'left'});
  34.  
  35. $("th", episodeTableRow).append(plot);
  36. });
  37. });
  38. })();