Help in replacing URL of pinned tab in Safari

I made this macro

40

Replace first pinned tab with current URL.kmmacros (26.2 KB)

The goal of it is to essentially replace the pinned tab (at position 1) with the URL I am currently viewing.

The issue is that Set Safari URL to action fails to do it. It doesn't actually replace the pinned tab's URL but opens a new tab with the URL (not pinned).

Is there a way I can replace URL of pinned tab? Perhaps with AppleScript or JXA?

Thanks.

This fails too :disappointed:

44

If you're still using an older version of macOS, I don't know if something might have changed between that and Mojave 10.14.5, but the Set Safari URL action works fine for me with Safari 12.1.1:

Example Macro.kmmacros (2.3 KB)
image

But if that doesn't work for you for whatever reason, you can try this AppleScript and see if it does the trick where the KM actions didn't:

tell application "Safari"
	tell front window
		set FrontmostTab to current tab
		set URL of tab 1 to URL of FrontmostTab
		close FrontmostTab
	end tell
end tell

Both the set safari URL & the applescript don't seem to work in macOS 10.14.5 version.

If you're also on 10.14.5 and neither of those methods work for you, I'm afraid I don't know what else to tell you. There is nothing unique about pinned tabs in terms of AppleScript that I can see, and both of those methods work fine on my own 10.14.5 install. Just to make sure, are you using the same version of Safari too (12.1.1)?