-
-
Save ba3r/180129 to your computer and use it in GitHub Desktop.
imdbpreview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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://www.imdb.com" + href); | |
} | |
} | |
CmdUtils.CreateCommand({ | |
names: ["imdbPreview", "IMDB preview"], | |
icon:"http://www.imdb.com/favicon.ico", | |
homepage: "http://gist.github.com/180129", | |
author: { name: "Michael Baer", homepage: "http://twitter.com/synapsos"}, | |
license: "GPL", | |
description: "Find information about a movie on IMDB.com, works with 0.5+ (parser 2)", | |
help: "Try imdbpre matrix or prev johnny depp and wait for the fully clickable preview.", | |
arguments: [{role: 'object', nountype: noun_arb_text, label: "query"}], | |
preview: function(previewBlock,args) { | |
previewBlock.innerHTML ="Please enter the name of the movie/actor/director :<br /><center><img src=\"http://i.media-imdb.com/images/nb15/logo2.gif\" width=\"30%\" height=\"30%\" ></center>"; | |
url="http://www.google.com/search?btnI=ok&q=imdb+"+args.object.text; | |
if(args.object.text!=""){ | |
Utils.parseRemoteDocument( | |
url, // URL | |
null, // post data | |
function(doc) { // success callback | |
jQuery("*",doc).css("color","#CCC"); | |
jQuery("a",doc).css("color","#FFFF00"); | |
jQuery("span",doc).css("font-size","59%"); | |
jQuery("#top_center_wrapper",doc).hide(); | |
jQuery("#top_center_after",doc).hide(); | |
jQuery("#tn15adrhs",doc).hide(); | |
jQuery(".starbar .inner",doc).css("background","transparent url(http://i.media-imdb.com/images/SF9cafc9501d815ffdcef81a364ea168dd/tn15/stars.gif) no-repeat scroll 0 -20px"); | |
jQuery(".starbar .inner",doc).css("height","20px"); | |
jQuery(".starbar .inner",doc).css("position","absolute"); | |
jQuery(".starbar .inner",doc).css("top","-3em"); | |
jQuery(".starbar .inner",doc).css("margin-bottom","3px"); | |
jQuery("#tn15rating.two .general",doc).css("top","-20"); | |
jQuery("#tn15rating.two .us",doc).css("height","2em"); | |
jQuery("#tn15rating .rating",doc).css("position","relative"); | |
jQuery("#tn15rating .rating",doc).css("height","2em"); | |
jQuery("#tn15rating .rating",doc).css("margin-bottom","2px"); | |
jQuery(".starbar .outer",doc).css("background","transparent url(http://i.media-imdb.com/images/SF9cafc9501d815ffdcef81a364ea168dd/tn15/stars.gif) no-repeat scroll 0 0"); | |
jQuery(".starbar .outer",doc).css("width","200px"); | |
jQuery(".meta",doc).css("position","absolute"); | |
jQuery("#tn15rating .bottom div.left",doc).css("top","20px"); | |
jQuery("#tn15rating .bottom div.left",doc).css("position","absolute"); | |
jQuery("#tn15main .info h5",doc).css("position","absolute"); | |
jQuery("#tn15main .info h5",doc).css("margin-left","-10em"); | |
jQuery("#tn15main .info",doc).css("margin-left","10em"); | |
jQuery("#tn15main h5",doc).css("font-size","100%"); | |
jQuery("#tn15rating.two .usr",doc).css("height","3em"); | |
jQuery("#tn15main .info h5",doc).css("margin-top","0"); | |
jQuery("table",doc).find("a").each(processNode); | |
jQuery(".info",doc).find("a").each(processNode); | |
previewBlock.innerHTML = "<div style=\"position:relative; min-height:50px;max-height: 500px;overflow-y: scroll;\">"+jQuery("#tn15title", doc).html()+jQuery("#tn15content", doc).html()+"</div>"; | |
}, | |
function() { // error callback | |
previewBlock.innerHTML = "Error!"; | |
} | |
); | |
}//end of if args.object.text=="" | |
} //end of preview | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment