Skip to content

Instantly share code, notes, and snippets.

@amau96
Created February 4, 2009 00:36
Show Gist options
  • Save amau96/57852 to your computer and use it in GitHub Desktop.
Save amau96/57852 to your computer and use it in GitHub Desktop.
Find a torrent without opening thepiratebay in a new window. Click on the double green arrow to direct start the download
//fonction to transform link
function processNode() {
var href = jQuery(this).attr("href");
if(/[a-z]\:\/\//.exec(href) === null) {
if(href[0] == "/")
jQuery(this).attr("href", "http://thepiratebay.org" + href);
}
}
CmdUtils.CreateCommand({
name: "tpb",
icon:"http://thepiratebay.org/favicon.ico",
takes: {"input": noun_arb_text},
homepage: "http://gist.github.com/57852",
author: { name: "A.BLANC", email: "amau96@gmail.com"},
license: "MPL",
description: "Find a torrent without open thepiratebay in a new window. Clic on the double green arrow to direct start the download",
preview: function(previewBlock,input) {
previewBlock.innerHTML ="Welcome to the pirate search, put the name of what you are looking for, or put \"top\" to have the top 100 of thePirateBay<br /><center><img src=\"http://static.thepiratebay.org/img/tpb.jpg\" width=\"50%\" height=\"50%\" ></center>";
if(input.text!="" && input.text!="top")
url="http://thepiratebay.org/search/"+input.text+"/0/7/0";
if(input.text=="top")
url="http://thepiratebay.org/top/all";
if(input.text!=""){
Utils.parseRemoteDocument(
url, // URL
null, // post data
function(doc) { // success callback
//on n'affiche pas la premiere colone
jQuery(".vertTh",doc).css("display","none");
//on definit la couleur du fond de la ligne
jQuery("tr",doc).css("background","#F6F1EE none repeat scroll 0 0");
//on definit la couleur de l'autre ligne
jQuery("tr.alt",doc).css("background","#ccc none repeat scroll 0 0");
//on definit la couleur des lien
jQuery("a",doc).css("color","#000099");
//on n'affiche que les 10 premiers elements
jQuery("tr",doc).slice(10, 100).hide();
//on n'affiche pas les titres
jQuery("th",doc).slice(2, 3).hide();
//on n'affiche pas les bordure des images
jQuery("img",doc).css("border","0 none");
//on definit la couleur du text
jQuery("*",doc).css("color","#000099");
jQuery("#searchResult",doc).find("a").each(processNode);
previewBlock.innerHTML = jQuery("#main-content", doc).html();
},
function() { // error callback
previewBlock.innerHTML = "Error!";
}
);
}//end of if input.text==""
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment