Skip to content

Instantly share code, notes, and snippets.

@uroshekic
Last active July 22, 2017 17:57
Show Gist options
  • Save uroshekic/7954511 to your computer and use it in GitHub Desktop.
Save uroshekic/7954511 to your computer and use it in GitHub Desktop.
Automatically adds links to search engines for each new episode. FollowMy.TV
// ==UserScript==
// @name Followmy.tv AutoSearch
// @namespace followmy
// @version 0.1
// @description Automatically adds links to search engines for each new episode.
// @match http://followmy.tv/*
// @copyright 2013+, Uros Hekic ( http//urosh.net/ )
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
// ==/UserScript==
var searchEngines = [
'<a href="http://rarbg.to/torrents.php?search={QUERY}&category%5B%5D=18&category%5B%5D=41&category%5B%5D=49">rarbg</a>',
// '<a href="http://kat.ph/usearch/{QUERY}" target="_blank"><img src="http://kastatic.com/images/favicon.ico" width="12"></a>',
// '<a href="http://kat.ph/usearch/{QUERY}" target="_blank">kat.ph</a>',
'<a href="http://thepiratebay.org/search/{QUERY}" target="_blank">tpb</a>',
];
function followmyTVAutoSearch() {
var eps = $('div.row-inner');
if (eps.length == 0) return setTimeout(followmyTVAutoSearch, 100);
eps.each(function (index) {
var $this = $(this);
if ($this.hasClass('past') || $this.hasClass('yesterday') || $this.hasClass('today')) {
var name, ep, query, node, urls,
$actions,
$c = $($this.children());
// TV Series
name = $($($c[1]).children()[0]).text();
// Episode number
ep = $($($c[0]).children()[0]).text();
ep = ep.split('x');
if (ep.length < 2) ep = ['0', '0'];
if (ep[0].length == 1) ep[0] = '0' + ep[0];
if (ep[1].length == 1) ep[1] == '0' + ep[1];
ep = 'S' + ep[0] + 'E' + ep[1];
// Query
query = name + ' ' + ep;
// Actions
$actions = $($c[3]);
$actions.show();
urls = searchEngines.join('');
node = $('<li>' + urls.replace(/{QUERY}/g, query) + '</li>');
$actions.prepend(node)
//console.log(query);
//console.log($this.html());
}
});
};
followmyTVAutoSearch();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment