Action

TinyURL

Posted by Andrew Skotzko, Last update over 2 years ago

Shortens URLs (including x-callback-url) via TinyURL, and pastes the shortened URL onto clipboard.

Uses only Javascript, so should work cross-platform.

Steps

  • script

    // See online documentation for examples
    // https://docs.getdrafts.com/docs/actions/scripting
    
    let url = draft.content.trim();
    let endpoint = `https://tinyurl.com/api-create.php?url=${url}`;
    
    let http = new HTTP();
    let response = http.request({
      "url": endpoint,
      "method": "GET"
    });
    
    if (response.success) {
      app.setClipboard(response.responseText);
    }
    else {
      console.log(`ERROR: ${response.statusCode} ${response.error}`);
      context.fail();
    }

Options

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