开发者

How to reload a Safari Extension from the command line?

开发者 https://www.devze.com 2023-02-23 03:33 出处:网络
I need to \"Reload\" a Safari extension from the command line (and also build the package later). How can this be done?

I need to "Reload" a Safari extension from the command line (and also build the package later).

How can this be done?

Why?

I'd like to build in one step - my code is in CoffeeScript and thus I'm compiling 开发者_StackOverflowit anyway.

What have I tried?

Apart from googling hopelessly I tried using this AppleScript:

tell application "System Events"
   tell process "Safari"
       click the button "Reload" of window "Extension Builder"
   end tell
end tell

Which errors out with:

System Events got an error: Can’t get button "Reload" of window "Extension Builder" of process "Safari".

And this variation:

tell application "System Events"
    tell process "Safari"
       tell button "Reload" of window "Extension Builder" to perform action
    end tell
end tell

Which doesn't give an error but also doesn't actually do anything.


It may be that the button isn't "named" as you expect. Check out UI Browser in order to view an application's interface hierarchy for use with GUI scripting.

The "Reload" button is accessible with:

click button "Reload"  of UI element "ReloadUninstall[NAME OF EXTENSION HERE]" \
  of UI element 1 of scroll area 1 of window "Extension Builder"


Extension Browser's view hierarchy seems to have changed since the accepted answer was written. This script works for me:

tell application "System Events"
    tell process "Safari"
         click button "Reload" of UI element 0 of window "Extension Builder"
    end tell
end tell

Note that Safari and the Extension Builder window need to be open for this to work

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号