This script opens a new Safari window if none is open, maximizes the front window if minimized, and opens a new focused tab on the left with your bookmarks, with the text caret in the address bar.
I Googled for such a script to no avail so I made it myself. Bound it to ⌘T and scope Safari in Quıcĸsıɩⅴεʀ (of course you're using Quıcĸsıɩⅴεʀ, what else?) or any other lesser hotkey application. You can still use New Tab menu item to open tabs on the right by changing the shortcut in the Keyboard Shortcuts section of System Preferences, say to ⇧⌘T.
If you open bookmarks:// you may notice a flicker when setting the focus on the first tab. It may be due to the applescript command used — if you find a better method put it in the comments.
Also, I used clicking "Open Location…" instead of setting the "AXFocused" attribute because the item hierarchy changes when in full screen mode.
tell application "Safari"
if windows is {} then
make new document
else
tell first window
if miniaturized then
set miniaturized to false
make new tab at beginning with properties {URL:"bookmarks://"}
set current tab to first tab
tell application "System Events" to tell process "Safari" to tell menu bar 1 to tell menu bar item "File" to tell menu 1 to click menu item "Open Location…"
else
make new tab at beginning with properties {URL:"bookmarks://"}
set current tab to first tab
tell application "System Events" to tell process "Safari" to tell menu bar 1 to tell menu bar item "File" to tell menu 1 to click menu item "Open Location…"
end if
end tell
end if
end tell
Comments (0)
Mac OS X Hints
http://hints.macworld.com/article.php?story=20130806104605997