-
-
Save xbourn/76698 to your computer and use it in GitHub Desktop.
This file contains 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
makeSearchCommand({ | |
name: "scholar", | |
url: "http://www.google.com/scholar?q={QUERY}", | |
icon: "http://www.google.com/favicon.ico", | |
description: "Searches Google Scholar for a paper." | |
}); | |
makeSearchCommand({ | |
name: "mininova", | |
url: "http://www.mininova.org/search/?search={QUERY}", | |
icon: "http://static.mininova.org/images/favicon.ico", | |
description: "Search mininova for a torrent." | |
}); | |
makeSearchCommand({ | |
name: "xunlei", | |
url: "http://www.gougou.com/search?search={QUERY}&sortby=6", | |
icon: "http://img.gougou.com/comm/gougou.ico", | |
description: "Searches Xunlei for something" | |
}); | |
CmdUtils.CreateCommand({ | |
name: "chinese", | |
description: "Translates from one language to Chinese.", | |
icon: "http://www.google.com/favicon.ico", | |
takes: {"text to translate": noun_arb_text}, | |
modifiers: {to: noun_type_language, from: noun_type_language}, | |
execute: function( directObj, languages ) { | |
var toLang = "Chinese"; | |
var fromLang = languages.from.text || ""; | |
var toLangCode = Languages[toLang.toUpperCase()]; | |
var fromLangCode = Languages[fromLang.toUpperCase()]; | |
//translateTo( directObj.text, {to:toLangCode} ); | |
if (fromLang.length > 0){ | |
translateTo( directObj.text, {from:fromLangCode, to:toLangCode} ); | |
} else { | |
var dictURL = "http://dict.cn/" + directObj.text; | |
Utils.openUrlInBrowser(dictURL); | |
CmdUtils.setLastResult(dictURL); | |
}; | |
}, | |
preview: function( pblock, directObj, languages ) { | |
var toLang = languages.to.text || "Chinese"; | |
var textToTranslate = directObj.text; | |
var toLangCode = Languages[toLang.toUpperCase()]; | |
var lang = toLang[0].toUpperCase() + toLang.substr(1); | |
pblock.innerHTML = "Replaces the selected text with the " + lang + " translation:<br/>"; | |
translateTo( textToTranslate, {to:toLangCode}, function( translation ) { | |
pblock.innerHTML = "Replaces the selected text with the " +lang + " translation:<br/>"; | |
pblock.innerHTML += "<i style='padding:10px;color: #CCC;display:block;'>" + translation + "</i>"; | |
}); | |
} | |
}); | |
CmdUtils.CreateCommand({ | |
name: "english", | |
takes: {search: noun_arb_text}, | |
author: { name: "LI Gang", email: "superligang at gmail.com"}, | |
description: "look up the word for the english explanation", | |
preview: function( pblock, directObject) { | |
var query = directObject.text; | |
var urlobject = "http://www.objectgraph.com/dictionary/dict.aspx?k={QUERY}"; | |
if (query.length > 0) { | |
var urlString = urlobject.replace("{QUERY}", query); | |
var running = "searching for " + query; | |
var msg = running + "<TABLE bgcolor=WHITE><tr><td><iframe background-color=WHITE src='" + urlString + "' width=480 height=480/></td></tr></TABLE>"; | |
pblock.innerHTML = msg; | |
} | |
}, | |
execute: function(directObject) { | |
var urldict = "http://www.dictionary.hm/search_function.php?q={QUERY}"; | |
var query = directObject.text; | |
if (query.length > 0) { | |
var urlString = urldict.replace("{QUERY}", query); | |
Utils.openUrlInBrowser(urlString); | |
} | |
} | |
}); | |
makeSearchCommand({ | |
name: "douban", | |
url: "http://www.douban.com/subject_search?ie=utf-8&search_text={QUERY}", | |
icon: "http://lotho.douban.com/favicon.ico", | |
description: "Searches douban for your title", | |
author: { name: "LI Gang", email: "superligang at gmail.com"}, | |
preview: function( pblock, directObject) { | |
var query = directObject.text; | |
var urlobject = "http://www.douban.com/subject_search?search_text={QUERY}"; | |
if (query.length > 0) { | |
var urlString = urlobject.replace("{QUERY}", query); | |
var running = "searching for " + query; | |
var msg = running + "<TABLE bgcolor=WHITE><tr><td><iframe background-color=WHITE src='" + urlString + "' width=800 height=600/></td></tr></TABLE>"; | |
pblock.innerHTML = msg; | |
} | |
} | |
}); | |
makeSearchCommand({ | |
name: "verycd", | |
url: "http://www.verycd.com/search/folders/{QUERY}", | |
icon: "http://www.verycd.com/favicon.ico", | |
description: "Searches verycd for your title", | |
}); | |
CmdUtils.CreateCommand({ | |
name: "news", | |
takes: { | |
"news title": noun_arb_text | |
}, | |
preview: function(pblock, title) { | |
pblock.innerHTML = "Will search for news titles containing: " + title.text; | |
}, | |
execute: function(directObject) { | |
var url = "http://news.google.com/news?q={QUERY}"; | |
var query = directObject.text; | |
var urlString = url.replace("{QUERY}", query); | |
Utils.openUrlInBrowser(urlString); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment