Writing URL into note body

As I see it, you can use @chrillek’s script (but don’t tell Jim :see_no_evil: ) - Jim’s suggestion to use error trapping in the script is something I would advocate (it’s often not helpful getting error messages if the document simply doesn’t fulfil the criteria) - but by running the script as a smart rule which already defines the condition “URL is not empty” (chrillek’s version) or “URL is http*” (your version) you’ve already defined that the script will only run if a URL is present. So you’ve covered that base.

Other than that: you’ve received help from the resident script masters :wink: take your pick, in my experience they’re all brilliant :+1:

1 Like

Thanks for all the praise.

The fact that my script adds the title whereas Jim’s doesn’t is (in my view) a pure coincidence. As you can see, my script uses “URL as string” for the part in square brackets. Apparently, that give the title of the HTML page. And I have no idea why. In fact, I have very little knowledge of AppleScript, preferring JavaScript over it. It just seems that the former is the preferred language in the DT3 community. And it also seems that URL as string produces the title of the page.

If that’s one of the weird things in AppleScript or intentional, I don’t know.

Jim does actually do error trapping twice: He first checks that the URL contains http* in the smart rule conditions and then that the URL is not empty in the script itself.

Since the script is internal to the rule, that seems a bit too much to me, but it doesn’t do any harm. And it also permits the script to be used in other circumstances, where the smart rule might be set up differently.

1 Like

Yes it is a double-check in this case and not necessary. It was put in as an error trap from @ngan’s original offering and I just left it in there.