// ==UserScript==
// @name Cinemagia & IMDB To Filelist
// @namespace http://use.i.E.your.homepage/
// @version 0.6
// @description Helps you to search movies from cinemagia or IMDB, on filelist.ro
// @match https://www.cinemagia.ro/*
// @match https://www.imdb.com/*
// @copyright 2014, mytzusky
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// ==/UserScript==
var cinemagiaIconSize = 20;
var imdbIconSize = 25;
var categories = {
19:{visible: true, id:"19", name:"Filme HD-RO", img:"https://filelist.ro/styles/images/cat/hd-ro.png"},
20:{visible: false, id:"20", name:"Filme BluRay", img:"https://filelist.ro/styles/images/cat/bluray.png"},
27:{visible: false, id:"27", name:"Seriale 4K", img:"https://filelist.ro/styles/images/cat/4ks.png"},
6:{visible: true, id:"6", name:"Filme 4K", img:"https://filelist.ro/styles/images/cat/4k.png"},
};
$(function() {
var pathname = window.location.pathname;
console.log("Filelist script enabled on : " + pathname);
// h1 a: Pagina unui film (la titlu)
// h2 a: Filme pe categorii sau an. Ex: http://www.cinemagia.ro/filme-animatie/2013/
// Filme de urmarit la TV
//.film a: Box Office section
//.movie a: BoxOffice page. Ex: http://www.cinemagia.ro/boxoffice/romania/
$('h1 a, h2 a, .film a, .movie a').filter(function() {
return this.href.match('(http|https)://www.cinemagia.ro/filme/[^/]*/$');
}).each(function() {
for (categ in categories) {
if (categories[categ].visible){
addCinemagiaSearchIcon(this, $(this).html(), categories[categ]);
}
}
});
// http://www.cinemagia.ro/club/pagina-mea/filme/
$('.list_7 a').filter(function() {
return (this.href.match('^(http|https)://www.cinemagia.ro/filme/[a-zA-Z0-9]'));
}).each(function() {
for (categ in categories) {
if (categories[categ].visible){
addCinemagiaSearchIcon(this, $(this).find("strong").html(), categories[categ]);
}
}
});
$('.title_wrapper h1').each(function() {
for (categ in categories) {
if (categories[categ].visible){
addIMDBSearchIcon(this, $(this).html(), categories[categ]);
}
}
});
});
var order = 1;
function addCinemagiaSearchIcon(movieLink, movieTitle, category) {
order++;
var searchTerm = movieTitle.replace(" ", "+");
console.log(order + ". "+searchTerm);
var iconHtml = getCinemagiaFilelistIcon(searchTerm, category, cinemagiaIconSize);
$(movieLink).parent().prepend(iconHtml);
}
function addIMDBSearchIcon(movieLink, movieTitle, category) {
order++;
var searchTerm = movieTitle.substring(0, movieTitle.indexOf(' ')).replace(" ", "+");
console.log(order + ". "+searchTerm);
var iconHtml = getIMDBFilelistIcon(searchTerm, category, imdbIconSize);
$('.title_wrapper').append(iconHtml);
}
function getCinemagiaFilelistIcon(searchTerm, category, size) {
return '<a href="http://filelist.ro/browse.php?search='+searchTerm+'&cat='+category.id+'" style="margin-right:5px;"><img width="'+size+'" height="'+size+'" src="'+category.img+'"></a>';
}
function getIMDBFilelistIcon(searchTerm, category, size) {
return '<a href="http://filelist.ro/browse.php?search='+searchTerm+'&cat='+category.id+'" style="margin-right:5px;"><img style="margin-top:5px;" width="'+size+'" height="'+size+'" src="'+category.img+'"></a>';
}