Calling a scriptable from a scriptable

Basically, I have a script that retrieves a list of domain names from a server, and dumps them into a list of anchor tags and loads them into a WebView. Clicking the link needs to then hit the server and retrieve more info about that domain (think Master->Detail view)

My thought was to build my anchors calling another scriptable passing in the domainid, and then fetch the rest, etc…

I’ve built the anchors using the urlscheme found in the settings, but when running it and clicking the links nothing happens. I can long-press the links and copy the urlscheme to my clipboard, paste it into safari and it fires off as expected.

Am I doing something wrong here… is there a better way to go about this?

Let me make sure I understand. Do you have something like this?

let html = `
<meta name="viewport" content="width=device-width">
<a href="scriptable:///run?scriptName=Pollen">Pollen</a>
`
WebView.loadHTML(html)

The script presents some HTML which has an anchor that invokes Scriptables URL scheme when clicked.

This is not supported in the current build but will be supported in the next build.

2 Likes

Yes, pretty much that. All my anchors are

<a href="scriptable:///run?scriptName=GetDomainInfo&domain=blah.com">blah.com</a>

Is there another way to go about that or just wait for the next build?

— also… such a great application… there’s soooo many possibilities. :+1:

1 Like

Depending on your use case, you could present your list of links as actions in an alert and then use the Safari API to open the URL scheme. However, I’ll send the next build soon.

let scriptNames = [
  "Pollen",
  "TV schedule"
]
let alert = new Alert()
for (scriptName of scriptNames) {
  alert.addAction(scriptName)
}
alert.addCancelAction("Cancel")
let idx = await alert.presentSheet()
if (idx != -1) {
  let scriptName = scriptNames[idx]
  let encoded = encodeURIComponent(scriptName)
  let url = "scriptable:///run?scriptName=" + encoded
  Safari.open(url)
}
2 Likes

The latest update handles this great. Thanks!