Action

Search Field Mega Action

Last update about 4 years ago

Search Amazon, AppStore, DuckDuckGo, Google, Google Images, Google Translate, IMDB, iTunes, Rotten Tomatoes, Twitter, Wikipedia, WolframAlpha, or YouTube. Same function as previous action, the script in this one is cleaned up a bit and this version adds a text field so the action can be run without creating a new draft

Steps

  • script

    //Search Mega Action 
    /* Action created by Jimmy Reekes, based on actions created by Tim Nahumck */
    
    var content = draft.processTemplate("[[selection]]")
    
    var p = Prompt.create();
    p.title = "Select Search Action";
    p.addTextField("search", "Search", content);
    var actions = ["Amazon","AppStore","DuckDuckGo","Google","GoogleImages","GoogleTranslate","IMDB","iTunes","RottenTomatoes","Twitter","Wikipedia","WolframAlpha","YouTube"];
    for (action of actions) {
      p.addButton(action);
    }
    var con = p.show();
    //Actions based on button presses
    if (con) {
      var input = p.fieldValues["search"];
      var output = encodeURIComponent(input);
    	var state = "true";
    	if (p.buttonPressed == "Amazon") {
    		var url = "http://amazon.com/s?ie=UTF8&index=blended&keywords="+output;
    	}
    	if (p.buttonPressed == "AppStore") {
    		var url = "itms-apps://search.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?media=software&term="+output;
    		var state = "";
    	}
    	if (p.buttonPressed == "DuckDuckGo"){
    		var url = "https://duckduckgo.com/?q="+output;
    	}
    	if (p.buttonPressed == "Google") {
    		var url = "https://google.com/search?q="+output;
    	}
    	if (p.buttonPressed == "GoogleImages") {
    		var url = "https://google.com/search?tbm=isch&q="+output;
    	}
    	if (p.buttonPressed == "GoogleTranslate") {
    		var url = "http://translate.google.com/#auto/en/"+output;
    	}
    	if (p.buttonPressed == "IMDB") {
    		var url = "https://www.imdb.com/find?q="+output;
    	}
    	if (p.buttonPressed == "iTunes") {
    		var url = "itms:/search?term="+output;
    		var state = "false";
    	}
    	if (p.buttonPressed == "RottenTomatoes") {
    		var url = "http://www.rottentomatoes.com/search/?search="+output;
    	}
    	if (p.buttonPressed == "Twitter") {
    		var url = "https://twitter.com/search?q="+output;
    		var state = "";
    	}
    	if (p.buttonPressed == "Wikipedia") {
    		var url = "https://en.wikipedia.org/wiki/Special:Search?search="+output;
    	}
    	if (p.buttonPressed == "WolframAlpha") {
    		var url = "http://wolframalpha.com/input/?i="+output;
    	}
    	if (p.buttonPressed == "YouTube") {
    		var url = "http://www.youtube.com/results?search_query="+output;
    		var state = ""
    	}
    	var result = app.openURL(url, state);
    }
    else {
    	context.cancel();
    }

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.