NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Torrentz + IMDB Ratings Phoenix
// @namespace http://your.homepage/
// @version 0.09
// @description Show movie ratings and geners from IMDB for torrentz.eu movies.
// @author select
// @license MIT
// @include https://torrentz.eu/verifiedP?f=movies*
// @include https://torrentz.eu/verified?f=movies*
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @grant GM_xmlhttpRequest
// ==/UserScript==
// regext for cleaning the titles
var re = /\d{4}/;
movie_db = {};
try {
var getImdbInfo = function(title) {
if (title in movie_db) {
return true;
}
GM_xmlhttpRequest({
method: 'GET',
url: 'http://www.omdbapi.com/?i=&t=' + encodeURIComponent(title),
onload: function(response) {
var data = JSON.parse(response.responseText);
if (data.Response === 'False') {
movie_db[title] = false;
} else {
movie_db[title] = data;
}
localStorage.setItem('movie_db', JSON.stringify(movie_db));
},
onerror: function(){
console.warn('request failed: http://www.omdbapi.com/?t=' + title);
}
});
return false;
};
var c = localStorage.getItem('movie_db');
if (c) {
$.extend(movie_db, JSON.parse(c));
}
var count = 0;
$(document).ready(function() {
$('dl').each(function() {
var title = $('a', this).html(),
match = re.exec(title);
if (match && match.length && count < 5) {
title = title.substr(0, title.search(re));
if (getImdbInfo(title) === true) {
if (movie_db[title] !== false) {
var el = '<a href="http://www.imdb.com/title/' + movie_db[title].imdbID + '" target="_blank" title="' + movie_db[title].imdbVotes + ' votes">' + movie_db[title].imdbRating + '</a>';
var rating = parseFloat(movie_db[title].imdbRating);
if (rating > 7.7) {
el = '<b>'+el+'</b>';
}
$('b', this).prepend(movie_db[title].Genre);
$('dt', this).prepend(el+ ' ');
if(rating < 7.2){
$('dt', this).css({opacity: 0.5});
}
}
} else {
count++;
}
} else if (match && match.length) {
title = title.substr(0, title.search(re));
var nel = '<a href="http://www.imdb.com/find?ref_=nv_sr_fn&q=' + title + '&s=all" target="_blank">🔎</a>';
$('dt', this).prepend(nel+ ' ');
} else {
var nel = '<a href="http://www.imdb.com/find?ref_=nv_sr_fn&q=' + title + '&s=all" target="_blank">🔎</a>';
$('dt', this).prepend(nel+ ' ');
}
});
});
} catch (e) {
unsafeWindow.console.log(e);
}