Open All URLs

Posted by RoyRogers, Last update 20 days ago

Opens all URLs in current draft in Safari.

Steps

  • script

    // Open All URLs
    // RV 2020-03-10 at 22:48
    
    // Opens All URL links in a draft
    
    // Alt. 1: If you have Markdown links:
    // let re = /\[.*?\]\((.+?)\)/g;
    
    // Alt. 2: Plain URLs, simplified pattern, `http(s)//` required!:
    let re = /(https?:\/\/)([a-z0-9]{3,40}\.)+[a-z]{2,6}[^ \t\n\(\)'";:]*/gi;
    
    let text = draft.content;
    
    let links = text.matchAll(re);
    let found = false;
    
    for (const link of links) {
    	app.openURL(link[0], true);
    	found = true;
    }
    
    if (!found) app.displayInfoMessage('No URLs found!');
    
    

Options

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