Help write two macros to move current tab in Safari as first pinned tab and one to replace current left pinned tab with URL



I would like to create a macro that would take current tab (easy in KM) and move it instantly as first pinned tab in Safari.

And one macro to do similar but instead of moving the current tab to first pinned tab, it would replace the first pinned tab URL with the current tab and switch to the tab whilst closing the current.

Thank you a lot for any help on this.


Hey Nikita,

The best you can really do is select “Pin Tab” from the Window menu, but you do NOT have control of where the pinned tab goes.

Safari WON'T let you change the URL of a pinned tab.

You'd have to unpin the tab, change the URL, re-pin the tab, and then somehow move it from the end of the pinned-tab-queue back to the front.

The latter would require some Found-Image action finesse and drag and drop, or it looks like you can find the positions of the pinned tabs with AppleScript UI-Scripting.

tell application "System Events"
   tell application process "Safari"
      tell (first window whose subrole is "AXStandardWindow")
         tell tab group 1
            tell (first radio button whose role description is "pinned tab")
               set firstPinnedTabPosition to its position
            end tell
            tell (last radio button whose role description is "pinned tab")
               set lastPinnedTabPosition to its position
            end tell
         end tell
      end tell
   end tell
end tell