Greasy Fork

Kinopoisk+

Add links to search torrent sites under movie poster

目前为 2018-11-14 提交的版本。查看 最新版本

// ==UserScript==
// @name        Kinopoisk+
// @namespace   https://greasyfork.org/en/users/899-lain-inverse
// @description Add links to search torrent sites under movie poster
// @include     https://kinopoisk.ru/film/*
// @include     https://www.kinopoisk.ru/film/*
// @version     2.1
// @grant       GM_xmlhttpRequest
// @grant       unsafeWindow
// ==/UserScript==
// Script based on script with the same name by xant1k:
// https://greasyfork.org/users/3348-xant1k https://greasyfork.org/users/19952-xant1k-bt
// Updated to work with CSP and 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 = [
        //RUSSIAN
        'https://rutracker.org/forum/tracker.php?nm=',
        'http://kinozal.tv/browse.php?s=',
        'http://rutor.info/search/',
        'https://nnmclub.to/forum/tracker.php?nm=',
        'http://hdclub.org/browse.php?search=',
        'http://bluebird-hd.org/browse.php?search=',
        //TV SHOW
        'https://broadcasthe.net/torrents.php?searchstr=',
        'https://www.tvchaosuk.com/all=/browse.php?keywords=',
        'https://www.morethan.tv/browse.php?search=',
        'http://www.bitmetv.org/browse.php?search=',
        'https://tv-vault.me/all=torrents.php?searchstr=',
        'https://freshon.tv/browse.php?search=',
        //ASIAN
        'https://hdchina.club/browse.php?search=',
        'https://asiandvdclub.org/all=/browse.php?search=',
        'https://hdcorea.me/browse.php?search=',
        'https://tp.m-team.cc/browse.php?search=',
        'https://totheglory.im/browse.php?search=',
        //HD
        'https://hdbits.org/all=/browse.php?incldead=0&search=',
        'https://scenehd.org/browse.php?search=',
        'https://awesome-hd.me/torrents.php?searchstr=',
        'https://pixelhd.me/browse.php?search=',
        'https://hdme.eu/browse.php?search=',
        'https://privatehd.to/browse.php?search=',
        'https://uhdbits.org/browse.php?search=',
        'https://www.hdarea.co/browse.php?search=',
        'https://www.hd-bits.com/browse.php?search=',
        'https://hdsky.me/browse.php?search=',
        'https://hd-space.org/browse.php?search=',
        'https://hdcenter.cc/browse.php?search=',
        'http://ultrahdclub.org/browse.php?search=',
        'https://hd-torrents.org/browse.php?search=',
        'https://beyondhd.xyz/browse.php?search=',
        'https://world-in-hd.net/browse.php?search=',
        'https://www.bit-hdtv.com/torrents.php?search=',
        'https://www.hd-spain.com/browse.php?',
        'https://chdbits.co/torrents.php?search=',
        //DVD/VHS
        'http://www.dvdseed.eu/browse.php?search=',
        //SCENE, 0-day
        'https://www.torrentday.com/browse.php?search=',
        'https://www.thegft.org/browse.php?search=',
        'https://sceneaccess.org/browse.php?search=',
        'http://piratethe.net/browse.php?search=',
        'https://iptorrents.com/all=/t?q=',
        'https://tls.passthepopcorn.me/torrents.php?searchstr=',
        'https://revolutiontt.me/browse.php?search=',
        //OTHER
        'https://cinemageddon.net/all=/browse.php?search=',
        'https://karagarga.in/all=/browse.php?incldead=1&search=',
        'http://www.bitmetv.org/browse.php?search=',
        'https://cinematik.net/all=/browse.php?incldead=0&director=0&search=',
        'https://x264.me/browse.php?search=',
        'https://polishsource.cz/browse.php?search=',
        'https://hon3yhd.com/browse.php?search=',
        'https://torrentvault.org/browse.php?search=',
        'https://torrentshack.me/browse.php?search=',
        'https://torrentbytes.net/browse.php?search=',
        'https://www.nordicbits.eu/browse.php?search=',
        'https://bithumen.be/browse.php?search=',
        'https://avistaz.to/browse.php?search=',
        'http://www.iloveclassics.com/browse.php?search=',
        'http://www.gormogon.com/browse.php?search=',
        'http://www.bithq.org/all=/search.php?search=',
        'https://tehconnection.eu/browse.php?search=',
        'https://horrorcharnel.org/browse.php?search=',
        'https://cinemaz.to/browse.php?search=',
        'https://danishbits.org/browse.php?search=',
        'https://norbits.net/browse.php?search=',
        'https://polishtracker.net/browse.php?search=',
        'https://privatehd.to/all=/index.php?page=torrents&search=',
        //CARTOONS, COMICS
        'http://www.cartoonchaos.org/browse.php?search=',
        'https://32pag.es/browse.php?search=',
        //SUBTITLES
        'https://www.opensubtitles.org/browse.php?search=',
        'https://subscene.com/browse.php?search=',
        'http://www.subtitleseeker.com/browse.php?search=',
        //WEB
        'http://www.blu-ray.com/search/?quicksearch=1&quicksearch_country=all&section=bluraymovies&quicksearch_keyword=',
        //'https://m.youtube.com/results?ajax=1&tsp=1&q=',
        'https://www.youtube.com/results?search_query=',
        '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
    });
})();