Drafts Action Directory

Wikipedia

Posted by @danny_ledesma, Last updated: 2018-07-04 15:03:05 UTC

Prompts to search EN Wikipedia or ES Wikipedia

Install

Steps

  • script

    // See online documentation for examples
    // http://getdrafts.com/scripting
    //Search Wikipedia
    /* Action created by Danny Ledesma, based on actions and scripts created/developed by Jimmy Reekes & Tim Nahumck  */
    
    var actions = ["EN Wikipedia","ES Wikipedia"];
    
    var p = Prompt.create();
    p.title = "Select Wikipedia Site";
    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 == "EN Wikipedia") {
        var ENWiki = "https://en.wikipedia.org/wiki/Special:Search?search="+output;
     
      var result = app.openURL(ENWiki);
      }
        if (p.buttonPressed == "ES Wikipedia") {
        var ESWiki = "https://es.wikipedia.org/wiki/Special:Search?search="+output;
        var result = app.openURL(ESWiki);
        }
     
        }
    else {
      context.cancel();
    }

Comments

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