I’m currently triggering a KM script remotely using either my iPhone or iPad Pro but that pesky little new Safari tab has to go. I know the built-in functions for Safari will not allow this to happen but there must be a method for doing so using Javascript on the page and having the Shortcut automatically run that JS on the currently opened tab?
There is no way to run something like that automatically, only from the share sheet. The fastest way would be just to press & hold on the tabs button until a menu pops up and then tap Close Tab.
If you have a shortcut already accessing the website via the share sheet, then the method from @dustinknopoff would work. But I wouldn’t create a shortcut just to close a tab.
You could also add a bookmark to your favourites with the address pointing to
Now there are caveats to its use that are covered in the Keyboard Maestro wiki article linked above.
An alternative, and my preference, would be to use SSH (and potentially a VPN connection too) to get a really secure connection into your machine and trigger the macro that way.
This was discussed on the forum back in January and includes a brief write-up on how to implement an SSH-based approach.