var noun_sharebee_method = new CmdUtils.NounType( "Method", ["zSHARE", "RapidShare", "Badongo", "Megaupload"]); var sharebee_method_dictionary = {"rapidshare":"RapidShare","zshare":"zSHARE","badongo":"Badongo","megaupload":"Megaupload"}; CmdUtils.CreateCommand({ name: "sharebee-download", author: {name: "Timofei Shatrov", email: "timofei.shatrov@gmail.com"}, icon: "http://planet.lisp.org/favicon.ico", takes: {"link":noun_arb_text}, modifiers:{with:noun_sharebee_method}, description: "Download from sharebee link, using the selected method. Use the full link or just the hash.", preview: "Download from sharebee link, using the selected method. Use the full link or just the hash.", execute: function (O_link, mods) { var method = mods.with.text || "RapidShare"; var link = O_link.text; var hash = link.replace("www.sharebee.com/", "").replace("sharebee.com/","").replace("http://",""); var sharebee_url = "http://sharebee.com/" + hash; jQuery.get (sharebee_url, function (doc) { var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "div"); tempElement.innerHTML = doc; var onclick=jQuery("a:contains('"+sharebee_method_dictionary[method]+"')",tempElement).attr("onclick"); var link=/window\.open\('(.*)'\)/.exec(onclick)[1]; Utils.openUrlInBrowser(link)}) } })