Embedding links to taks

I’m trying to create a shortcut that opens any resources attached to a task. That may be a folder on my Mac, a Visual Studio Code project or a website. For the folder and Visual Studio code project.

What I found the easiest is to add any such resource to to a task or project’s LinkedFileURL array and my script simply uses the .open() function on the first of entry.

task.linkedFileURLs[0].open()

So, I also need to then be able to easily add such resources. I’m having trouble doing so with URL to websites.
I have the following four ways to add a URL to a project:

  1. Have the URL in a note
  2. Create a Web Internet Location file and link to it
  3. Create a Web Internet Location and embed it
  4. Add the url as an attachment

With method 2, I can easily view it in safari using the same .open() method, but I now have to keep a file on my Mac.

Any suggestion for how I could add a URL to a tasks and make easily available to open via a script? (I am trying to avoid having to parse the note to find available links…)

Not sure but could you do this using Brett Terpstras “Bunch” Link. You would then only need an embedded link to the Bunch file, a simple text file no OF scripting needed.

Hook app I guess could also do this.

It may save you a lot of work reinventing the wheel?

I will have to look at the Hook app one day, but for now, I simply added in the URL in the notes and I’ll open the first URL included this way

    const re = /\b(?:https?:\/\/)(\S+)\b/g
    if (task.note && re.test(task.note)) {
        const link = task.note.match(re)[0]
        const url = URL.fromString(link)
        url.open()
        return
    }