Fixed Wait for Safari to Finish Loading Plug In Action

Here is a Plug In Action that performs similarly to the Wait For Safari to Finish Loading action. It is not as good, since the Stop menu used to be quite helpful in determining whether a page was loading, but since that is no longer the case in Safari 12.1 this will have to do.

It is pretty straight forward, but I have not done much testing of it. Hopefully it works - if any AppleScript gurus (@ccstone?) want to look and check I have not messed up my AppleScript coding, that might be wise.

Fixed Wait for Safari to Finish (17.6 KB)

1 Like

Hey Peter,

It looks okay to me.


1 Like

Working perfectly for me Peter. Thank you!

1 Like

Working for me too. Thanks!

1 Like

Unfortunately, I can't get the Plug In Action to work for me. I've put it into my macro in place of the "Wait for Safari to Finish Loading" Action (which I disabled), but the macro fails at the next action (because Safari hasn't finished loading). The log says:

2019-04-06 10:43:54 /Users/justus/Library/Application Support/Keyboard Maestro/Keyboard Maestro Actions/Fixed Wait for Safari to Finish Loading/Action.scpt: execution error: Can’t make "3693.340345" into type number. (-1700)

From what I can see with my limited AppleScript knowledge, it's happening in the line

tell application "Keyboard Maestro Engine" to set n to 0 + (calculate "SECONDS()")

Any ideas?

I fixed it myself by changing the line as follows:

tell application "Keyboard Maestro Engine" to set n to 0 + (round (calculate "SECONDS()"))

Now it seems to be working, even though I am not sure why it wasn’t working on my system before.

The problem with that is you want the calculation to work with fractions, which is why I chose to use SECONDS(). If you are working in a non-english language, it is likely that AppleScript is using a different format for decimal numbers, and failing to cope with Keyboard Maestro (which always uses decimal numbers with “.”).

That was it, thank you! My system is set to English, but the decimal separator (Settings > Language & Region > Advanced) is set to comma. I've now modified the AppleScript with an additional function to replace the dot with a comma and the conversion works without any problems.

1 Like

The plugin's working for me. Thanks!

Thank you!

Super-tiny typo in the plug-in Action tool-tip:

I love super tiny typo bug reports, they are generally so easy to fix.

In this case, the typo was when I published that action, but it is no longer required in v9 since the Wait for Safari to Finish Loading action now ignores the fact that Safari does not enable/disable the Stop menu like a well behaved Mac application should.

And, unfortunately, I can't fix this one because it does not actually ship with Keyboard Maestro.

But definitely let me know about any others you find.

1 Like