Drafts Action Directory

Search

Posted by jayelevy, Last update 3 months ago

Single action with choice of search services/apps. Optimized for use as a keyboard action.

Install

Steps

  • script

    // See online documentation for examples
    // http://drafts5-help.agiletortoise.com/
    
    var searchText = encodeURIComponent(draft.content);
    
    var urls = {
    	"1Password":"onepassword://search/"+searchText,
    	"Amazon":"http://www.amazon.com/s/field-keywords="+searchText,
    	"Google":"http://www.google.com/search?q="+searchText,
    	"Maps":"http://maps.apple.com/?q="+searchText,
    	"Terminology":"terminology://x-callback-url/lookup?text="+searchText+"&x-source=Drafts&x-success=drafts4%3A%2F%2F",
    	"Wikipedia":"https://en.wikipedia.org/wiki/Special:Search?search="+searchText,
       "YouTube":"http://www.youtube.com/results?search_query="+searchText
    };
    
    // url scheme to launch search built in Workflow with draft as input...
    // "workflow://run-workflow?name=WorkflowName&input=text&text="+searchText
    
    var p = Prompt.create();
    
    p.title = "Search";
    
    for (var name of Object.keys(urls)){
    	p.addButton(name);
    }
    
    var searchSelect = p.show();
    
    app.openURL(urls[p.buttonPressed]);
    

Options

  • After Success Trash
    Notification Info
    Log Level Info

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.