Action

Search DDG

Posted by @nahumck, Last update over 6 years ago

Search on DuckDuckGo with an optional !bang parameter.

!bangs can be found at:
https://duckduckgo.com/bang

Steps

  • script

    //DDG Search (w/ !bangs)
    
    var content = draft.processTemplate("[[selection]]")
    
    var p = Prompt.create();
    p.title = "Enter search and optional !bang";
    p.addTextField("search", "Search", content);
    p.addTextField("bang", "!bang", "", {placeholder:"eg. !g, !images, etc."});
    p.addButton("Go");
    var con = p.show();
    
    if (con) {
      var input = p.fieldValues["search"];
      var output = encodeURIComponent(input);
      var bang = p.fieldValues["bang"];
    
      if (bang == "") {	
        var searchBang = "!ddg";}
      else {
        var searchBang = bang;
      }
      var url = "https://duckduckgo.com/?q="+searchBang+"%20"+output;
      var result = app.openURL(url, true);
    }
    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.