I asked chatGPT for an apple script for Safari to switch tabs

Hi,

there's a bug in macSonoma where the system forgets my personal key commands together with an "Arrow", for example "go to next tab" in Safari is ctrl+option+right arrow. From one day to another the arrow in the key command entry list was deleted.
So I use BTT. I asked ChatGPT to write me an Apple Script, but it is not working and I am unused to code, that I want to ask you here in the Forum. :slight_smile:

property direction : "next" -- oder "previous"

on run

tell application "Safari"

set currentTabIndex to index of current tab of front window

set tabCount to number of tabs in front window

if direction is "next" then

if currentTabIndex < tabCount then

set index of current tab of front window to (currentTabIndex + 1)

else

-- Zum ersten Tab springen, wenn am Ende der Liste

set current tab of front window to tab 1 of front window

end if

else if direction is "previous" then

if currentTabIndex > 1 then

set index of current tab of front window to (currentTabIndex - 1)

else

-- Zum letzten Tab springen, wenn am Anfang der Liste

set current tab of front window to tab tabCount of front window

end if

end if

end tell

end run

you can use the "Trigger Menubar Menu Item" action to trigger these Safari functions.

1 Like

So simple. So reliable. Awesome :smiley:

Now I have to make sure that I don't spend the next hour using this new function for everything. :smile: :smile: :smile: