Raw Source
Perilin / Add Various Torrent Search Links to Trakt.tv Calendar

// ==UserScript==
// @name         Add Various Torrent Search Links to Trakt.tv Calendar
// @version      0.5.7
// @description  Adds  Various (ie, ExtraTorrent.ag, TorrentFunk, RARBG (etc,etc)) Search Links to Trakt.tv Calendar Page
//               See bottom row of icons on each calendar item (skull&bones icons)
//               Search results sorted by size ascending.
//               -- TorrentProject gives errors. ExtraTorrent is back --
// @author       Perilin Night <perilin.night@gmail.com>
// @copyright    2018, Perilin Night
// @date         2016/12/03-2018/06/27
// @match        https://trakt.tv/calendars*
// @match        http://trakt.tv/calendars*
// @grant        none
// @run-at       document-end
// @downloadURL  https://openuserjs.org/install/Perilin/Add_Various_Search_Links_to_Trakt.tv_Calendar.user.js
// @updateURL    https://openuserjs.org/meta/Perilin/Add_Various_Search_Links_to_Trakt.tv_Calendar.meta.js
// @priority     1
// @license      MIT
// @icon         https://cdn0.iconfinder.com/data/icons/security-outlines/100/11-128.png
// @screenshot   https://greasyfork.org/system/screenshots/screenshots/000/006/000/original/Untitled.png?1481634810
// @namespace    https://greasyfork.org/users/84102
// ==/UserScript==
(function () {
  'use strict';
  var myStyles = $('<style type="text/css">' +
    '.trakt-icon-skull-bones-extratorrent:before ' +
    '{' +
    '  content: "\\e620";' +
    '  color: rgb(131, 201, 244);' +
    '}' +

    '.trakt-icon-skull-bones-torrentfunk:before ' +
    '{' +
    '  content: "\\e620";' +
    '  color: rgb(135, 212, 44);' +
    '}' +

    '.trakt-icon-skull-bones-rarbg:before ' +
    '{' +
    '  content: "\\e620";' +
    '  color: rgb(56, 96, 187);' +
    '}' +

    '.trakt-icon-skull-bones-idope:before ' +
    '{' +
    '  content: "\\e620";' +
    '  color: rgb(233, 68, 53);' +
    '}' +

    '.trakt-icon-skull-bones-ddl:before ' +
    '{' +
    '  content: "\\e620";' +
    '  color: white;' +
    '}' +

    '.trakt-icon-skull-bones-rlsbb:before ' +
    '{' +
    '  content: "\\e620";' +
    '  color: orange;' +
    '}' +
				   
    '</style>');
  $('head').append(myStyles);
  $('div[itemprop="episode"] ').each(function (index) {
    var objParent = $($(this).find(' > a')[0]);
    var objActions = $($(this).find('> div.quick-icons > div.actions')[0]);
    var objNumbers = $($(objParent).find('span.main-title-sxe')[0]);
    var strNumbers = objNumbers.text();
    var arrNumbers = strNumbers.split('x');
    arrNumbers.forEach(function (item, index, arr) {
      if (item.length <= 1) {
        arr[index] = '0' + item;
      }
    });
    var strEpiNumber = 's' + arrNumbers.join('e').replace('Special', '00');
    var objSeries = $($(objParent).find('span[itemprop="partOfSeries"] meta[itemprop="name"]')[0]);
    var strSeries = objSeries.attr('content');

    var strURL_ExtraTorrent = "http://extratorrent.ag/search/?s_cat=&pp=&srt=size&order=asc&search=" + encodeURIComponent(strSeries + " " + strEpiNumber);
    objActions.append(
      '<a class="torrsearch" data-original-title="Search for this episode on ExtraTorrent" title="Search for this episode on ExtraTorrent" href="' + strURL_ExtraTorrent + '" target="' + strSeries + " " + strEpiNumber + '-extratorrent"> ' +
      ' <div class="base"></div>' +
      ' <div class="trakt-icon-skull-bones-extratorrent"></div>' +
      '</a>'
    );

    var strURL_TorrentFunk = 'https://www.torrentfunk.com/television/torrents/' + encodeURIComponent(strSeries.toLowerCase().replace(/ +/g, '-').replace("'",'') + '-' + strEpiNumber.toLowerCase().replace(/ +/g, '-')) + '.html?v=&smi=&sma=&i=50&sort=size&o=asc';
    objActions.append('<a class="torrsearch" data-original-title="Search for this episode on TorrentFunk" title="Search for this episode on TorrentFunk" href="' + strURL_TorrentFunk + '" target="' + strSeries + ' ' + strEpiNumber + '-torrentfunk"> ' +
      ' <div class="base"></div>' +
      ' <div class="trakt-icon-skull-bones-torrentfunk"></div>' +
      '</a>'
    );

    var strURL_RARBG = 'https://rarbg.to/torrents.php?order=size&by=ASC&search=' + encodeURIComponent(strSeries + ' ' + strEpiNumber);
    objActions.append('<a class="torrsearch" data-original-title="Search for this episode on RARBG" title="Search for this episode on RARBG" href="' + strURL_RARBG + '" target="' + strSeries + ' ' + strEpiNumber + '-rarbg"> ' +
      ' <div class="base"></div>' +
      ' <div class="trakt-icon-skull-bones-rarbg"></div>' +
      '</a>'
    );

    var strURL_iDope = 'https://idope.se/torrent-list/' + encodeURIComponent(strSeries + ' ' + strEpiNumber) + '/?&o=2&c=3';
    objActions.append('<a class="torrsearch" data-original-title="Search for this episode on iDope" title="Search for this episode on iDope" href="' + strURL_iDope + '" target="' + strSeries + ' ' + strEpiNumber + '-idope"> ' +
      ' <div class="base"></div>' +
      ' <div class="trakt-icon-skull-bones-idope"></div>' +
      '</a>'
    );

    var strURL_DDL = 'https://www.google.co.za/search?q=%22' + encodeURIComponent(strSeries + ' ' + strEpiNumber) + '%22+%2B(mp4|avi|mkv|mpg|mov|)+-inurl:(jsp|pl|php|html|aspx|htm|cf|shtml|xml) intitle:index.of+-inurl:(listen77|mp3raid|mp3toss|mp3drug|index_of|wallywashis|feeds)';
    objActions.append('<a class="torrsearch" data-original-title="Search for this episode on Google" title="Search for this episode on Google" href="' + strURL_DDL + '" target="' + strSeries + ' ' + strEpiNumber + '-ddl"> ' +
      ' <div class="base"></div>' +
      ' <div class="trakt-icon-skull-bones-ddl"></div>' +
      '</a>'
    );

    var strURL_rlsBB = 'http://search.rlsbb.ru/search/' + encodeURIComponent(strSeries + ' ' + strEpiNumber);
    objActions.append('<a class="torrsearch" data-original-title="Search for this episode on ReleaseBB" title="Search for this episode on ReleaseBB" href="' + strURL_rlsBB + '" target="' + strSeries + ' ' + strEpiNumber + '-rlsbb"> ' +
      ' <div class="base"></div>' +
      ' <div class="trakt-icon-skull-bones-rlsbb"></div>' +
      '</a>'
    );

  });
})();