Action

Send to GoodLinks

Last update 10 months ago

Finds the first valid URL in the draft and sends it Good Links, a very fine read later app for iOS and Mac.

Steps

  • script

    // based on https://stackoverflow.com/questions/33211233/how-to-detect-and-get-url-on-string-javascript
    // for an alternative method: see https://stackoverflow.com/questions/11209016/javascript-extract-urls-from-string-inc-querystring-and-return-array
    
    let matches = draft.content.match(/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig);
    let first_match = matches[0];
    
    // uncomment to check matches 
    // alert(matches[0])
    
    app.setClipboard(matches[0])
  • callbackUrl

    template
    goodlinks://x-callback-url/save?&url=[[clipboard]]
    waitForResponse
    false
    encodeTags
    true

Options

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