Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nicolaselhani

macrumors member
Original poster
Oct 1, 2015
91
49
Hello,

I have a Safari Extension called Shortshare (great extension btw check if out if you haven't https://josten.io/project/shortshare.html)

I'd like to make a custom Shortcut to trigger it.

I guess AppleScript is the way to go as seen here https://bit.ly/3yT0rmW

This is what the user is using to custom shortcut his own extension:

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

Does anyone know how i could modify the code above to trigger the Shortshare extension?

Thanks

Nick
 
The app has that feature: "The main feature of the app is URL shortening. It can be done with the menu bar icon, a keyboard shortcut,"
Shortshare.jpg
 
Thanks @bogdanw for your reply.

Unfortunately this shortcut button:
1. needs to have the main app (not the extension) open in the background
2. it opens an on-screen box with the prefilled URL that you have to manually copy and then you have to manually click on "Shorten Link" so it's 4 total steps vs. 1 for the potential shortcut I'm looking for in AppleScript

I reached out to the developer to ask if he can integrate a shortcut that mimicks just that one-click button in the toolbar, but in the meantime if anyone knows how to AppleScript it or have hints that would be great!

Thanks again
 
Hover with the cursor over the extension button in Safari’s toolbar, use the name displayed instead of Recent Tab List in the script.
 
  • Like
Reactions: nicolaselhani
Hover with the cursor over the extension button in Safari’s toolbar, use the name displayed instead of Recent Tab List in the script.

Thanks so much @bogdanw! It worked great.

For anyone looking to do this:

1. I attached a Screenshot if someone wants to duplicate the Quick Action (be sure you select Workflow receives no input)
2. Make sure you Go to macOS - System Preferences - Security & Privacy - Privacy - Accessibility - Enable Safari
3. Go to macOS - System Preferences - Keyboard - Shortcuts - Services - Locate the Service - Add a Custom Shortcut

Sorry but final question to top this off:

I'm assuming if I hide the "Shortshare" icon from my Safari toolbar, this AppleScript won't work because it seeks the UI Element. Do you think there's a way to get this to work, with me hiding the UI Element itself. So instead of seeking the UI element in the toolbar, to seek installed Extensions or something similar?

Thanks again really appreciated!

Screen Shot 2022-10-19 at 11.47.46 AM.png

Screen Shot 2022-10-19 at 11.36.23 AM.png
 
To prevent the shortcut from interfering with other apps, choose Safari instead of “any application”.
Yes, if you remove the button from the toolbar, or even change its position, the script will stop working.
 
Thanks for the heads-up went ahead and changed it.

If anyone has any ideas as to how to AppleScript to run the shortcut without having the Extension visible in the toolbar would be great. Thanks again
 
I don't think it's possible, as you have to tell Safari to do something, click a button or select a menu item. And the extension action is not in any Safari menu. From Preferences, you can only enable/disable it. (I presume, I don't have it installed)
 
Yeah exactly. I'm gonna try and see if I can figure something out related to the two running processes "Shortshare" and "Shortshare Extension (Safari)". Will update here if I find anything. Thanks again for your help
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.