Letterboxd.com to KG

Search kg for torrents with the respective IMDb code

目前為 2014-05-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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();
       
})();