// ==UserScript==
// @name Kinopoisk+
// @namespace https://greasyfork.org/en/users/899-lain-inverse
// @description Adds links to torrent and other search engintes under movie poster
// @include https://kinopoisk.ru/film/*
// @include https://www.kinopoisk.ru/film/*
// @version 2.0
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// ==/UserScript==
// Script based on script with the same name by https://greasyfork.org/users/3348-xant1k
// Updated to load favicons even with CSP and create link to imdb.com without omdbapi.com which now requires API key
(function(){
'use strict';
let $ = unsafeWindow.$;
if (!$)
throw 'Unable to locate jQuery!';
let imgs_y = "https://favicon.yandex.net/favicon/";
let imgs_g = "https://plus.google.com/_/favicon?domain=";
let movie_eng = $("span[itemprop='alternativeHeadline']");
let movie = '';
if (movie_eng.text() != "") {
movie = movie_eng.text()
} else {
let movie_rus = $(".moviename-big[itemprop='name']");
let newLbl = $(movie_rus[0].outerHTML);
$("span", newLbl).remove();
movie = newLbl.text();
}
let movie_enc = encodeURIComponent(movie);
let year = $(".info a").html();
let links = [
'http://rutracker.org/forum/tracker.php?nm=',
'http://kinozal.tv/browse.php?s=',
'http://rutor.org/search/',
'http://nnm-club.me/forum/tracker.php?nm=',
'http://hdtracker.org/browse.php?search=',
'http://hdclub.org/browse.php?search=',
'https://broadcasthe.net/torrents.php?searchstr=',
'http://www.youtube.com/results?search_query=',
'http://hdwing.com/browse.php?search=',
'http://chdbits.org/torrents.php?search=',
'https://hdbits.org/browse.php?search=',
'http://cinemageddon.net/browse.php?search=',
'https://karagarga.net/browse.php?search=',
'http://www.bitmetv.org/browse.php?search=',
'http://www.allmovie.com/search/movies/',
'http://cinematik.net/browse.php?search=',
'https://tls.passthepopcorn.me/torrents.php?searchstr=',
'http://x264.me/browse.php?search=',
'http://asiandvdclub.org/browse.php?search=',
'https://www.hd-spain.com/browse.php?',
'https://scenehd.org/browse.php?search=',
'https://www.bit-hdtv.com/torrents.php?search=',
'https://awesome-hd.net/torrents.php?searchstr=',
'https://www.imdb.com/search/title?title='
];
let post = '<br><div class="torrents">';
let domain, i = 0;
unsafeWindow.reloadFaviconIfBroken = function(img, domain, status) {
let is_fine = (img.clientWidth > 1 ? 1 : 0) || 0;
if (is_fine)
return;
GM_xmlhttpRequest({
method: 'GET',
url: `${imgs_g}${domain}`,
responseType: 'blob',
onload: res => {
if (res.status !== 200)
return;
let reader = new FileReader();
reader.onload = e => {
img.src = e.target.result.replace('data:;','data:image/png;');
};
reader.readAsDataURL(res.response);
}
});
};
for (let link of links) {
domain = link.match(/:\/\/([^/]+)\//)[1];
post += `<a target="_blank" title="${domain}" href="${link}${movie_enc}${domain==='www.imdb.com'?(year?`&release_date=${year}-01-01,${year}-12-31`:''):`%20${year}`}">
<img src="${imgs_y}${domain}" onload="reloadFaviconIfBroken(this, '${domain}', 1)" onerror="reloadFaviconIfBroken(this, '${domain}', 0)">
</a>`;
i += 1;
if (i > 6) {
post += '<br>';
i = 0;
}
}
post += '</div>';
if ($("#photoBlock.originalPoster").length > 0) {
$("#div_mustsee_main").before(post);
$(".torrents").css({
"padding-left": "15px",
"margin-top": "-20px",
"margin-bottom": "10px",
"background-color": "#f2f2f2",
width: "180px"
});
$(".torrents a").css({
margin: "4px",
display: 'inline-block',
width: '16px',
height: '16px',
"margin-top": "3px",
"margin-bottom": "3px"
});
} else {
$("#div_mustsee_main").before(post);
$(".torrents").css({
"margin-top": "-20px",
"margin-bottom": "10px",
"background-color": "#f2f2f2",
width: "135px"
});
$(".torrents a").css({
margin: "7px",
display: 'inline-block',
width: '16px',
height: '16px',
"margin-top": "3px",
"margin-bottom": "3px"
});
}
$(".torrents a img").css({
boder: 0
});
})();