Last active
April 17, 2025 11:12
-
-
Save AFutureD/7b702d5ef43658d70606d0d9b054d981 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Events" | |
tell process "Safari" | |
set frontmost to true | |
-- Reference Safari window | |
set safariWindow to front window | |
delay 0.5 | |
set sidebarVisible to false | |
try | |
set sidebarVisible to exists (group 1 of splitter group 1 of window 1) | |
end try | |
if not sidebarVisible then | |
-- Use the keyboard shortcut to show the sidebar (Command+Shift+L) | |
keystroke "l" using {command down, shift down} | |
delay 0.5 -- Wait for the sidebar to appear | |
end if | |
if exists button 1 of group 1 of splitter group 1 of window 1 then | |
set backButton to button 1 of group 1 of splitter group 1 of window 1 | |
if description of backButton contains "Back" then | |
click backButton | |
end if | |
end if | |
set sidebarGroup to outline 1 of scroll area 1 of group 1 of splitter group 1 of window 1 | |
tell sidebarGroup to perform action "AXShowMenu" | |
--- set tabGroup to the first row of sidebarGroup whose description of UI element 1 contains "Tab Group" | |
--- log tabGroup | |
set sidebarMenu to menu 1 of outline 1 of scroll area 1 of group 1 of splitter group 1 of window 1 | |
if exists menu item "Show Tabs in Sidebar" of sidebarMenu then | |
set target to menu item "Show Tabs in Sidebar" of sidebarMenu | |
tell target to perform action "AXPress" | |
else | |
tell sidebarMenu to perform action "AXCancel" | |
end if | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment