4

Is there a place in safari that allows user to assign keyboard shortcut for extensions?

For more specific information, I am trying to assign a shortcut key for this extension: Recent Tab list

However I did not find shortcut customization page on its page. So I am experimenting whether there is such a customization page at the safari level. Any advice is appreciated.

I am using MacBook Pro with OS X Sierra 10.12

4

It is possible to do this yourself using AppleScript and other tools.

Requirement: System Preferences > Security & Privacy > Accessibility to be checked on for Alfred 3.

tell application "System Events" to tell process "Safari"

    with timeout of 0 seconds
        set allElements to entire contents of toolbar 1 of window 1
    end timeout

    repeat with uiElement in allElements
        if class of uiElement is button and description of uiElement is "Recent Tab List" then click uiElement
    end repeat

end tell

I use Alfred to trigger the AppleScript using a hotkey or keyword.

screen shot 2018-06-06 at 16 38 04

Here's my workflow: https://0x0.st/s_jz.zip

(I originally posted this answer on GitHub)

EDIT March 2019:

Quicker AppleScript is as follows. It works from Script Editor but I've not been able to get it to work from Alfred. YMMV.

tell application "System Events"
    tell process "Safari"
        set extVar to "Recent Tab List"

        tell first UI element of last group of last toolbar of first window
            click (first button where its description = extVar)
        end tell
    end tell
end tell
2
  • I used your excellent AppleScript to do this via BetterTouchTool, however it has a 3 second response time! Does Alfred do it quicker?
    – Siddhartha
    Feb 22 '19 at 16:12
  • The delay comes from scanning though user interface elements. It will depend on how busy your Safari windows are and also the speed of your computer; on my machine it's just over 1 second. I did it that way so the user could specify the button they want clicked as part of the workflow. It could be rewritten to click a specific element in a much quicker and efficient manner. Mar 14 '19 at 10:38
0

Yes but it is System preferences -> Keyboard and choose the Shortcuts tab. Choose App shortcuts from the left hand box. The + to add a shortcut and choose Safari as the app

1
  • This works for toolbars added by Safari Extensions, as they have their own menu item. Sadly toolbar buttons do not. Jun 6 '18 at 15:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .