// ==UserScript== // @name Torrentz : The Bobcat add-on // @namespace http://torrentzBobCat // @homepage http://www.youtube.com/watch?v=1QyuIDw0CIw&feature=youtu.be // @description Torrentz.eu: Add IMDB ratings, download links, movie plot/actors, and other goodies. Also features an light built-in serie tracker. Torrentz gets so much simpler and efficient! Demo video here: http://www.youtube.com/watch?v=1QyuIDw0CIw&feature=youtu.be // @author CoolMatt // @version 1.6.0 // @grant none // @include *://torrentz.* // @match *://torrentz.com/* // @match *://torrentz.eu/* // @match *://torcache.net/* // @downloadURL none // ==/UserScript== // @date 19 Jun 2013 // @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html //Define the namespace var Torrentz = Torrentz || {}; Torrentz.GM = {}; Torrentz.GM.BobCatTorrentz = {}; Torrentz.GM.BobCatTorrentz = { //Store info about movies of the page PageCache_movieInfo: {}, //Lookup table [torrentId -> movieKey] - as several torrents can point at the same movie info PageCache_lk_id_info: {}, start: function () { // Load and inject css initCss(); // Add the 'bobcat touch' this.addBadgeAndButtons(); //// Prevent scripts to bounce you to another page //window.onbeforeunload = function () { // return "Exit this page?"; //}; // Hide visual spam $("div.cloud").hide(); // Load store var moviesStore = Enbalaba.GetLocalStore("moviesInfo"), moviesData = moviesStore.get(), that = this, results; //Calculate cache size and clear it if too big this.checkCacheSize(moviesStore); //Get rid of this incredibly annoying & ridiculous advertising banner $("body>iframe:first").hide(); // Append download modal $("body").append("
Click a link below in order to download your torrent
: New episode(s)
: No new episodes
:New episode(s)
: No new episodes");
/*Populate dropdowns*/
var i, htmlddSeasons = "", htmlddEpisodes = "";
for (i = 1; i < 16; i++) htmlddSeasons += "";
for (i = 1; i < 31; i++) htmlddEpisodes += "";
$("#st_ddSeasonNew").html(htmlddSeasons);
$("#st_ddEpisodeNew").html(htmlddEpisodes);
htmlddSeasons = ""; //blank variable because of closures
htmlddEpisodes = "";
/*Display Series*/
this.displayTrackedSeries();
/*Search for new*/
this.searchForNewEpisodes(this.episodeFoundCallback);
/*Add Serie event*/
var that = this;
$("#btAddSerie").click(function () {
var name = $("#st_tbNameNew").val();
if ($.trim(name) == "") {
$("#st_lblOutput").text("Enter a Name");
}
else { //---ADDITION
var store = Enbalaba.GetLocalStore("trackedSeriesInfo"), serieInfo = store.get()
, id = serieInfo.CurrentId;
serieInfo.CurrentId = id + 1;
serieInfo.Ids.push(id);
store.set(serieInfo);
var store = Enbalaba.GetLocalStore("ts_" + id)
, isFinished = $("#cbIsFinishedSeason").is(":checked")
, serie = { Name: name, Season: parseInt($("#st_ddSeasonNew").val(), 10), Current: { e: parseInt($("#st_ddEpisodeNew").val(), 10) }, History: [], id: id };
if (isFinished) {
serie.isFinished = true;
serie.NbTotEpisodes = parseInt($("#tbSeasonNbEpisodes").val(), 10);
if (isNaN(serie.NbTotEpisodes)) { alert("Enter a valid number of episodes"); return; }
}
store.set(serie);
that.displayTrackedSeries();
that.searchForNewEpisodes(that.episodeFoundCallback);
//that.displayTrackedSeries(serieStore);
$("#st_lblOutput").text("");
}
});
$("#st_lblSuggestion").click(function () {
$("#st_tbNameNew").val($(this).text());
});
// Logic serie name live suggestions
$("#st_tbNameNew").keypress(function (e) {
if (e.keyCode >= 20 && e.keyCode <= 40 && e.keyCode != 32) return true; //arrows, shift, and other keys that don't change the input. 32 is 'space'
var txt = $(this).val();
if (txt.length >= 3) {
var url = encodeURI("https://torrentz.eu/suggestions.php?q=" + $.trim(txt));
$("").css("display", "none").load(url, function (data) {
var res = $.parseJSON(data);
if (res && res.length == 2 && res[1] != null && res[1].length > 0) {
console.log(res[1][0]);
$("#st_lblSuggestion").text(res[1][0]);
}
else $("#st_lblSuggestion").val("-");
});
}
});
$("#st_btDeleteAll").click(function () {
if (confirm("Do you want to delete all the currently tracked series ?")) {
Enbalaba.GetLocalStore("trackedSeriesInfo").set({ Ids: [], CurrentId: 1 });
that.displayTrackedSeries();
}
});
}
this.SerieTrackerMode = true;
}
else {
// Back to the list of torrents
this.SerieTrackerMode = false;
$("div.results h3,div.recent").nextAll().not("#downloadModal,#downloadModalOverlay").show();
$("#serieContainer").hide();
$("#btSerieTracker").text("Serie Tracker");
}
}
, displayTrackedSeries: function () {
var serieIds = Enbalaba.GetLocalStore("trackedSeriesInfo").get().Ids;
var dl = $("#serieContainer dl");
dl.empty();
for (var i = 0, serie, id; i < serieIds.length; i++) {
this.displaySerie(serieIds[i]);
}
}
, displaySerie: function (serieId) {
var serie = Enbalaba.GetLocalStore("ts_" + serieId).get(), time
, hasNew = false;
if (!serie.History) serie.History = [];
var html = "