Adds a link in the right side panel for searching kg for torrents with the respective IMDb code
当前为
// ==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 Adds a link in the right side panel for searching kg for torrents with the respective IMDb code
// @include *://letterboxd.com/*
// @version 1.0
// @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'/> 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();
})();