Letterboxd.com to KG

Search kg for torrents with the respective IMDb code

当前为 2014-05-11 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Letterboxd.com to KG
// @require       http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @namespace   http://userscripts.org/users/luckyluciano
// @description Search kg for torrents with the respective IMDb code
// @include     *://letterboxd.com/*
// @version     0.9
// @grant       none
// ==/UserScript==



//Object.prototype.insertAfter = function (newNode) { this.parentNode.insertBefore(newNode, this.nextSibling); }


function addLink() {
    //var st = xpath("//td[@class='film-title prettify']");
    //var i = 0;
   // while(i < st.snapshotLength && st.snapshotItem(i).innerHTML != "Directed by") i++;
    /*if(i < st.snapshotLength) 
    {
        var node = st.snapshotItem(i).nextSibling;
        //var imdb = getImdb(node.firstChild.href);
        //if(imdb != null) {
          
            
          
    }*/
    
     
     var parent = document.getElementById('featured-film-header');
           
          
            var link = document.createElement("a");
            
            
            link.alt = "Search torrents on KG";
            //var img = document.createElement("img");
            //img.style.marginLeft="5px";
            //img.src= LBlogo;
            
             link.innerHTML="search torrents on KG";
             var imdbUrl = $(".text-link a").first().attr("href");
              
             link.href = "https://karagarga.net/browse.php?search=" + getImdb(imdbUrl) + "&search_type=imdb";
             
             
            
              
            var l = $("#userpanel ul");
    
    
           var parent = l[0];
            var listItem = document.createElement('li');
            listItem.setAttribute('id','listitem');
             
            
            
             listItem.innerHTML = "<a href='"+link.href+"'>"+"<img src='http://i.imgur.com/aliLFI7.png' width=18 height=18 align='left'/> &nbsp;&nbsp;&nbsp;Search torrents on KG";
             
             
            parent.appendChild(listItem);
           
           
           
            
            $(l[0]).listview("refresh");
    
        
    }






function getImdb(href) {
    var from = href.indexOf("imdb.com/title/tt") + 17;
    if(from < 17)
        return null;
    var to = href.indexOf("/", from);
    if(to < 0)
        to = href.length;
    return href.substring(from, to);
}

function makeLink(imdb) {
    var link = document.createElement("input");
    link.type = "text";
    link.id = "permlink";
    link.readOnly = "readonly";
    link.size = "100";
    link.value = "http://letterboxd.com/imdb/" + imdb;
    link.addEventListener('click', SelectPerm, true);
    return link;
}

function SelectPerm()
{
    document.getElementById("permlink").focus();
    document.getElementById("permlink").select();
}

String.prototype.contains = function(it) {
    return this.indexOf(it) != -1;
}

function xpath(query) {
    return document.evaluate(query, document.body, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
}

(function () {
    var href = window.location.href;
    if(href.contains("http://letterboxd.com/film"))
       addLink();
       
})();