Action

Search Mega Action

Posted by jmreekes, Last update over 6 years ago

Search Amazon, AppStore, DuckDuckGo, Google, Google Images, Google Translate, IMDB, iTunes, Rotten Tomatoes, Twitter, Wikipedia, WolframAlpha, or YouTube

Steps

  • script

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