Action

Open all URLs in Safari

Posted by cdf1982, Last update 8 days ago

This action scans the current draft for all URLs using a regular expression, compiles them into a clean newline-separated list, and sends the list to a Shortcut named “Open URLs in sequence”.
Then, the Shortcut opens each link in Safari (or the default browser) with a 0.5-second pause between them.

Setup Instructions
1. Create the Shortcut
• Name it exactly: Open URLs in sequence (or adjust the script accordingly).
• Add these steps:
1. Get Text from Input — receives the URL list from Drafts.
2. Split Text by new lines.
3. Repeat with Each Item:
• Open URL = Repeat Item.
• Wait 0.5 seconds.
2. Install this Drafts Action
• Ensure the shortcutName variable in the script step matches the Shortcut’s name exactly.
3. Usage
• Select any draft containing one or more URLs.
• Run this action.
• The Shortcut will open each URL in sequence with the set delay.

Steps

  • script

    // Extract all URLs from draft content
    let text = draft.content;
    let urlRegex = /(https?:\/\/[^\s]+)/g;
    let urls = text.match(urlRegex) || [];
    
    if (urls.length === 0) {
        alert("No URLs found in this draft.");
    } else {
        // Create newline-separated list of URLs
        let urlList = urls.join("\n");
        
        // Encode for Shortcuts
        let encoded = encodeURIComponent(urlList);
        
        // Run the shortcut
        let shortcutName = "Open URLs in sequence";
        let cb = CallbackURL.create();
        cb.baseURL = "shortcuts://run-shortcut";
        cb.addParameter("name", shortcutName);
        cb.addParameter("input", urlList); // pass directly
        cb.open();
        script.complete();
    }

Options

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