Skip to content

Instantly share code, notes, and snippets.

@ba3r
Created September 3, 2009 09:42
Show Gist options
  • Save ba3r/180214 to your computer and use it in GitHub Desktop.
Save ba3r/180214 to your computer and use it in GitHub Desktop.
piratebay doesnt work
//function 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({
names: ["tpb"],
icon:"http://thepiratebay.org/favicon.ico",
arguments: [{role: 'object', nountype: noun_arb_text, label: "what"}],
homepage: "http://gist.github.com/57852",
author: { name: "A.BLANC", email: "amau96@gmail.com"},
license: "MPL",
description: "Find a torrent without opening thepiratebay in a new window. Click on the green double arrow to start the download directly",
preview: function(previewBlock,args) {
previewBlock.innerHTML ="Welcome to the pirate search, type the name of what you are looking for, or type \"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(args.object.text!="" && input.text!="top")
url="http://thepiratebay.org/search/"+args.object.text+"/0/7/0";
if(args.object.text=="top")
url="http://thepiratebay.org/top/all";
if(args.object.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