Raw Source
rcinee / Filmow - Imdb, Torrents, Legendas links

// ==UserScript==
// @name        Filmow - Imdb, Torrents, Legendas links
// @namespace   pootz
// @description Cria links de pesquisa pro imdb, torrents, legendas pros filmes do filmow
// @include     http*://*filmow.com/*-t*
// @history     1.3 - Trocado MetaSearch por Torrent-Finder
// @history     1.2 - Adicionado MetaSearch & Speed.cd
// @history     1.1 - Pra funcionar em https
// @version     1.3
// @require     https://code.jquery.com/jquery-2.1.1.min.js
// @updateURL   https://openuserjs.org/meta/pootz/Filmow_-_Imdb,_Torrents,_Legendas_links.meta.js
// @downloadURL https://openuserjs.org/install/pootz/Filmow_-_Imdb,_Torrents,_Legendas_links.user.js
// @grant       GM_xmlhttpRequest
// ==/UserScript==


//icones
var iconeBJ             = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAIAAACpTQvdAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIXSURBVChTY7h7/tzdDRseXbny+sWLt2Bw98TxW/v3P7xwAcJFAwyPHtx/UpB3oqnpyuzZN6ZOfXrhwov29vf1dffWrYMqQQUMQHx13ZqXEREX09N+d3Vf6Oj4X1p2NisLIo0JQBpePX5809fnZEDAw7DQ/+npr8JCH+zeDZHGBCANQHCpp+tpQMD94OD/oWHbszMhgnDw+unzS/Pm3Zgz5/zu3VANrx49uhAc9NfX76Gz06aqitsLFtyaPfvS9On3jxx+deXKjY0b18dEbgkNfHT3LlTDm9evT0VH/nZ3XxsRviE64lNU5P/o6CNpyTunTHoxY+bTCRMe5WQfykwHqoRquDV//gMfnxf29mdjYw6nJN2ztX1uZr6ipvqwh+t7Z+evrq6PbG3vb94I1QCMgRNubi/t7B4am7ywsXllZ//G3GKrk8PjGzeubFx/0sryrZX1gchIsMlgDVe2bj4gKHhaRfmsluYZVZULWppHjI3ObATFw9W+/sf2Dmf19O7t3AFWD9bw4smTB9ev3Tp57OaxIzdOnzwze+bpNaseXb3y5PDhs6Ghj42M9kZFQFQDAdQPEPDwzJmTWVlXzcwvu7vfqay8WVh4z9LykIL8g317oCqQNbx5/vyQucUDI+NriorXlZSuA0l5+etycrvDw6EqwACh4f6lS+vUVXcaG+00BaEdJka7TY3WWJk+OHYUqgII3r4FAAiz3mIBcNVmAAAAAElFTkSuQmCC";
var iconeIMdB           = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAPCAYAAADtc08vAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAFNSURBVDhPY9y1RPY/AwUAbICVNRuUy8Dw9y+U/g2h//yB0lA+CPz5BaFv3PnFwARhQjSCMVAhMZphFjF+ua/8nxRb0dUyVOQKgsLg/8opUmBagI/p/6vLymA2CE9pFoezjXU4/l/fqwRm3zmgDGbDvQADHz79Y7hxG8lqKABawHD2yg+GaYvfg/m//4LMYWBggjkXBoAuYEgsfA6mkYGxDieUBQGN/W8YYvKfIQIRBoQFmRnuPvwNprEBmN+F+JnBLsIwwMIQYhOM/gt1IczJMOBiyQOmmeChCQVCAhCbYTQMnDr3A8pCBRgu8HHiZVCWZ4XyECC+9BkwHDjgNieUPwXTjPePgqMM7jeYU//+ZATTIPAXKgZLCzDw8zvQBWu2fcapGaQRm2aQRhA+ev0LxAsgjSAM0oisGQRAGmGaYRqRAWN3tRhEJVmAgQEAh2y7OoQawIIAAAAASUVORK5CYII=";
var iconeLegendas       = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAMCAIAAADkharWAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAG9SURBVChTY3iLDN68+fD48MeHO9++fvH29fOP1/Z+uHkWKAiVBQNUDUDw6tmXG3O/nW39dqnhy9VFb188g4rDAEjD+2fXP59d8/nMyi+nV349OvfboY5fu2J+HQj7frLs+9mK7+fLvl2uAdoM1fD+xa2fZ6P/LnX6uT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9i2Gqn77/EWXlPLu6TP2bp+5d8t8IZvJR46fPHX+pM50YatZsuazZCwny5m3yD679xKs+u3bazdurqyvLVZVXrf94IRsYU4pXp0KgbMnzzfPrzKaIGLYJWzQIHzl4lWoaklLMWk/wTVbV+3YtC0mPZJbQdW0WtiwWUy7g0+/XdCwUVSriu/+07tQ1c+ePz9x6riy0ayly5dJmK5cfGCBXomAfpWQQa2wQY2Adhn/ii3LgMqgqiFA3PrQ8RNnICEFJM9dOHPoyMGjp488fPQIouDt27cANMyhC7EBWRUAAAAASUVORK5CYII=";
var iconeOSub           = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAADASURBVDhPzVLBEYMwDHO6QTICK7ACK5BVWIEVWIFZWIEVYATXEth37ZP0Ud2JCJkodo4kImp8jBceqko+0QxowW9GaMFHwLIsMd+6rrcr0nWdHMcRNWhHBEzTxDWlRALuIazWSr+UIud50nfgDnTfd7WTqMGcMz2vDcMQtS9ewtriJn+HhgeNzQ6E9X0f3xkvYe2q3UEUoOd5pvYVRJh3djOE2qz3OUrt/rZt7MYxjmPU/uQ/sK7IJ7q5g8Y7EHkD16jY5znqcfoAAAAASUVORK5CYII=";
var iconePTP            = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAABrSURBVDhPY2RgYPgPxGQDJhDx//9/MCaHDTaAEkCxF8AG/K9JY2CwALLMGRi+CDEx8DLPYOi9X85w67Mgw38ORQYGYV2GWcJaDGlbnjEwXHrKwPDoI4P2P1aG/Fn2lHth1IDBYMBoXmBgAAAzz1LbS73ksQAAAABJRU5ErkJggg==";
var iconeYTube          = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAA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izBVRX1xw1uVpfL0iy+wbpMTaOs6hX0ybjZJV8J7uQm9chLwYGD00Sc3NYziwBlRyoqyFjo8JmiE/q0oQWe+sU+HkFLS03Dk1qa+uMwS/ylSRIxzEbZfKZuJCmy5Ch4Zf6WW0yO/senzwfgYscFL+lW8dsxlnQYmcN+H0ugObma3oOqfSmBEMhwQ+urI4d8oUokzfkNuSObUvSWTA2i5BLHsjISFTUswq97nwiAVxQFaOu7JlSh3vOTbv8Sn6wGZ52c6tUNKIpGCzcUJCvrKoCnrBgL0yQYfKaKP0HgNfrZQF0dT3C4yngIc/FKVE6mUwGz/v7kMvl4Ckrw+nS0sK0amAhHInA4hZXicX4S7SZX8IE+AsnaCDPEc0wOgAAAABJRU5ErkJggg==";
//var iconeMetaSearch     = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAB+SURBVDhPYxTnF/zPgATOXrsGZUGAooIclAUB9x88grIggAlKkw0G3gDGx0+eoYTBoucfoCziwHAIA1ZWVpQwuHf/IZQFAehhEicpAGVBAPW98P//fxSMDtDlKQ+DR4+folijrKQAZUFAw7GLUBYExErwQ1kQMPDRSKEBDAwAGnMyLr5kCJEAAAAASUVORK5CYII=";
var iconeTorrentFinder  = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAYAAAAmL5yKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAIZSURBVDhPhVM9b9NQFD15sdMkFjTIdYuEqihgsnXoUClSi5StbHQoylQ+xjLwC0LVAXXMRlV+AHOKVAboiqhEJCpCJRS3SjokFDVOmi87thPHXL8B0SHhSNey5XPPu+fe+wKWZXudTge5XA5nZxqmp28hk8kglUohFArhf2D+Y2fnNT5/+ogFZRb6ryp2d9/g+PgbRqMRJ00Cs20bhwcfEI/HcUGVLN29h2q1inx+H7quw/O8icFqtRoioghGpwUFAQ3TRHz+Do6OvkDTNE6aBKbX61CnptDv9zFwHNi+UICh2WxygaHrwpcYF8wbDtCmZMMw4NsZUYJjO/zk8/MKbMsiJlHHBAtHJcxT4k0q3Rdx6N0lUcYY9aABi76JOjaYrMzgZ6uFVruNLjXRohMHVIFA/egZPV7VJLAZGp1B81bIf6TbhUl2/HDdISrlMgqFAvw9GdfM4KutrW394je0wlfIkgQzGoVHVvS+Sf5tVKgP9ctLROlfLBaDSBP7FwHDML2GXsfL5WXIlLywuIh3Jyfo0TT4nKkXkXAYs3NzWF19iHQ6jUQiwS36CGaz2W1f/baqQqSRHhaLaIRErD1aw+bmC5TJhr9YnU4bP4rfUSqVuKgsy5AoL2CY/b/m2ldXyL/fh6reRzKZhKIovIq3e3t8vQVRQIB4knQDKw9WsLHx5LrAJJyelvB4fZ22VaQ7MuS78vTZc/wBavM+beNWFZYAAAAASUVORK5CYII=";

var dirigidoPor   = $(".span6");
var originalTitle = $(".movie-original-title")[0];
var ano           = $(".item.release_date div")[0].textContent.trim();

//buscas
var urlIMDB     = "http://www.imdb.com/find?q=" + encodedTitle() + "&s=tt&exact=true";
var urlYTube    = 'https://www.youtube.com/results?search_query=' + encodedTitle();
var urlBJ       = 'https://bj-share.me/torrents.php?searchstr=' + encodedTitle() + '&te=3&tp=0';
var urlMS       = 'http://www.manicomio-share.com/pesquisa.php?busca=' + encodedTitle() + '&cat=0&opt2=0&vnc=0&ano='+ grabYear() + '&opt=0';
var urlSpeed    = 'http://speed.cd/browse.php?search=' + encodedTitle() ;
//var urlMeta     = 'http://metasearch.torrentproject.com/?search=' + encodedTitle() + "#!search=" + encodedTitle() ;
var urlPTP      = 'http://passthepopcorn.me/torrents.php?action=advanced&searchstr=' + encodedTitle() + '&year=' + grabYear() + '&order_by=relevance';
var urlLegendas = 'http://legendas.tv/busca?q=' + encodedTitle();
var urlOSub     = 'http://www.opensubtitles.org/en/search2/sublanguageid-pob/movieyearsign-1/movieyear-' + grabYear() + '/moviename-' + encodedTitle();
var urlTFinder  = 'http://torrent-finder.info/show.php?q=' + encodedTitle() + "&Browse=tabs&PageLoad=oneattime&select=ALL&sids=31-29-412-6-404-421-325-389-406-4-";

GM_xmlhttpRequest ( {
    method:         "GET",
    url:            urlIMDB,
    onload:         imdbResults
});

function insertImdbButton(imdb) {

    if (imdb != "undefined" || imdb !== null) {

        dirigidoPor.append("<br>");
        dirigidoPor.append('<a class="btn" href="' + imdb + '" target="_blank" title="imdb"><img src="' + iconeIMdB + '"></img></a>');
        dirigidoPor.append('<a class="btn" href="' + urlYTube + '" target="_blank" title="YouTube"><img src="' + iconeYTube + '"></img></a>');
        dirigidoPor.append('<a class="btn" href="' + urlBJ + '" target="_blank" title="BJ"><img src="' + iconeBJ + '"></img></a>');
        dirigidoPor.append('<a class="btn" href="' + urlMS + '" target="_blank" title="MS"><img src="' + iconeMS + '"></img></a>');
        dirigidoPor.append('<a class="btn" href="' + urlSpeed + '" target="_blank" title="KickAss"><img src="' + iconeSpeed + '"></img></a>');
        //dirigidoPor.append('<a class="btn" href="' + urlMeta + '" target="_blank" title="PirateBay"><img src="' + iconeMetaSearch + '"></img></a>');
        dirigidoPor.append('<a class="btn" href="' + urlTFinder + '" target="_blank" title="PirateBay"><img src="' + iconeTorrentFinder + '"></img></a>');
        dirigidoPor.append('<a class="btn" href="' + urlPTP + '" target="_blank" title="PTP"><img src="' + iconePTP + '"></img></a>');
        dirigidoPor.append('<a class="btn" href="' + urlLegendas + '" target="_blank" title="Legendas.tv"><img src="' + iconeLegendas + '"></img></a>');
        dirigidoPor.append('<a class="btn" href="' + urlOSub + '" target="_blank" title="OpenSubtitles"><img src="' + iconeOSub + '"></img></a>');


    }
}

function imdbResults(object) {

    var respDoc = $(object.responseText);
    var linkTitleYear = respDoc.find('.result_text');
    var imdb = "http://www.imdb.com";
    var foundIt = false;
    var year = grabYear();

    for (var i = 0; i < linkTitleYear.length; i++) {

        var searchTitle = linkTitleYear[i].textContent;
        var iLink = linkTitleYear[i].getElementsByTagName("a")[0].getAttribute("href");

        if (searchTitle.indexOf( year ) != -1) {

            foundIt = true;
            var searchLink = iLink.slice( iLink, iLink.indexOf("/?") );
            imdb = imdb + searchLink;
            insertImdbButton(imdb);
            break;

        }
    }

    if (!foundIt) {
        imdb = urlIMDB;
        insertImdbButton(imdb);
    }

}

function grabYear() {

    var regex = /20[0-3][0-9]|19[0-9][0-9]/;

    return ano.match(regex)[0];
}

function encodedTitle() {

    var grabTitle = originalTitle.textContent.toLowerCase();

    grabTitle = grabTitle.replace(/  |   /g, " ");
    grabTitle = grabTitle.replace(/ VS | vs /g," vs. ");

    if (grabTitle.charAt(0) == " ") {
        grabTitle = grabTitle.slice(1);
    }
    if (grabTitle.charAt(grabTitle.length - 1) == " ") {
        grabTitle = grabTitle.slice(0,-1);
    }


    var grabEncodedTitle = grabTitle.replace(/&/g,"%26");
    grabEncodedTitle = grabEncodedTitle.replace(/\?/g,"%3F");
    grabEncodedTitle = grabEncodedTitle.replace(/=/g,"%3D");
    grabEncodedTitle = grabEncodedTitle.replace(/ /g,"+");


    return grabEncodedTitle;

}