-
-
Save Schnubby/85963 to your computer and use it in GitHub Desktop.
Ubiquity: Google Images search including search for colors
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
noun_type_color = new CmdUtils.NounType( "Color", | |
["red", "orange", "yellow", "green", "blue", "black", "white", "grey", "brown", "purple", "magenta", "indigo", "pink"] ); | |
CmdUtils.CreateCommand({ | |
name: "google-images", | |
synonyms: ["pic", "image", "color"], | |
takes: {search: noun_arb_text}, | |
modifiers: {in: noun_type_color}, | |
author: {name: "Christian Roth", email: "schnubby@traces-of-nuts.eu"}, | |
icon: "http://www.google.de/favicon.ico", | |
description: "Searches Google Images , in a given color.", | |
preview: function(pblock, directObject, mods) { | |
var color = mods.in.text; | |
var searchterm = directObject.text; | |
if(searchterm.length < 1) { | |
pblock.innerHTML = "Searches Google for images."; | |
return; | |
} | |
if(color.length < 1) { | |
pblock.innerHTML = "Searches Google Images for <b>" + searchterm + "</b>."; | |
return; | |
} | |
pblock.innerHTML = "Searches Google Images for <b>" + searchterm + "</b> in <b>" + color + "</b>." | |
}, | |
execute: function(directObject, mods, search) { | |
var color = mods.in.text; | |
var searching = directObject.text; | |
var searchUrl = "http://images.google.de/images?imgcolor=" + color + "&q=" + searching | |
if(color.length < 1) { | |
var searchUrl = "http://images.google.de/images?q=" + searching; | |
} | |
Utils.openUrlInBrowser(searchUrl); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment