KAT Meta Integration

Adds a KAT link to other sites using KAT.

当前为 2016-05-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name KAT Meta Integration
  3. // @namespace PXgamer
  4. // @version 0.1
  5. // @description Adds a KAT link to other sites using KAT.
  6. // @author PXgamer
  7. // @include *giantbomb.com/*
  8. // @include *imdb.com/title/tt*
  9. // @grant none
  10. // ==/UserScript==
  11. /*jshint multistr: true */
  12.  
  13. (function() {
  14. 'use strict';
  15. var kt = {};
  16.  
  17. kt = {
  18. init: function() {
  19. kt.cor = false;
  20. kt.url = location.href;
  21. if (kt.url.indexOf('giantbomb.com/') > -1) {
  22. kt.glin = 'https://kat.cr/g-g';
  23. kt.gurl = kt.url.split('/')[4].split('-')[1];
  24. kt.kurl = kt.glin + kt.gurl + '/';
  25. kt.cor = true;
  26. }
  27. else if (kt.url.indexOf('imdb.com/') > -1) {
  28. kt.glin = 'https://kat.cr/i-i';
  29. kt.gurl = kt.url.split('/')[4].split('tt')[1];
  30. kt.kurl = kt.glin + kt.gurl + '/';
  31. kt.cor = true;
  32. }
  33. else if (kt.url.indexOf('amazon.') >= -1) {
  34. kt.cor = true;
  35. }
  36. else {kt.cor = false;}
  37.  
  38. if (kt.checkAvail()) {
  39. if (kt.cor) {
  40. kt.addFeatures();
  41. }
  42. }
  43. },
  44. addFeatures: function() {
  45. if (kt.url.indexOf('giantbomb.com/') > -1) {
  46. $('ul.system-list').append('<li class="system"><a href="'+kt.kurl+'" target="_blank"><img src="https://pximg.xyz/images/377713844639dbc0456d2dfd483d8f13.png"/></a></li>');
  47. }
  48. else if (kt.url.indexOf('imdb.com/') > -1) {
  49. $('.winner-option.watch-option').after('<div class="watch-option secondary-watch-option blueBadgeImdb"><a href="'+kt.kurl+'" target="_blank">\
  50. <div class=""><img src="https://pximg.xyz/images/8fbebe200ba1c18b65ab0a6374ea5d7b.png" style="width: 34px; height: 30px;" /></div>\
  51. <div class="secondary-info">ON&nbsp;KAT</div>\
  52. </a></div>');
  53. $( "div.blueBadgeImdb" ).hover(
  54. function() {
  55. $( this ).css( 'background', '#136CB2' );
  56. },
  57. function() {
  58. $( this ).css( 'background', '#EEEEEE' );
  59. }
  60. );
  61. }
  62. else if (kt.url.indexOf('amazon.') >= -1) {
  63. }
  64. else {}
  65. },
  66. checkAvail: function() {
  67. // REMOVE THIS LATER
  68. return true;
  69. var returnedData;
  70. $.ajax({
  71. type: "GET",
  72. url: kt.kurl,
  73. async: false,
  74. success: function (data) {
  75. returnedData = data;
  76. },
  77. returnData: "json"
  78. });
  79. if (returnedData.indexOf('<div class="errorpage">') == -1) {
  80. return true;
  81. }
  82. return false;
  83. }
  84. };
  85.  
  86. kt.init();
  87.  
  88. console.info(kt);
  89. })();