JavaScript Console in Custom HTML Prompt

So, somehow the JavaScript in my Custom HTML Prompt isn’t working. How do I access the console and/or where the JavaScript errors are logged out?

(I realize in many cases I can just debug the page in a browser, but there are cases like this one where it’s failing as I’m trying to do the Keyboard Maestro integration)

Would you mind sharing your KM macro where you use the Custom HTML Prompt?

I have been wanting to try that, but wasn't sure how to use.
This would also probably help others help you solve your issue.

Thanks.

There is an example in the Macro Library. The log messages might make it in to the Engine.log file, I’m not sure.

It doesn't look like they do :crying_cat_face:

However, I did find a solution that works...turning on the web inspector. I did this at the Terminal:

defaults write com.stairways.keyboardmaestro.engine WebKitDeveloperExtras TRUE 

And now I can right click in a Custom HTML Prompt and select Inspect Element and get an inspector window, including a Console tab.

Assuming you don't want to turn this on for all users, it might useful to add this to the list of hidden preferences on the website

4 Likes

@2shortplanks, thanks for sharing that pref setting.

Are you referring to Safari, Chrome, or both?

Hey JM,

He means inside the Keyboard Maestro Custom HTML Prompt.

-Chris

1 Like

OK, thanks.

For everyone, like me, wondering just how this works, and what it looks like, here are a couple of screenshots I made AFTER running the above command in Terminal:

I'll add of this to the KM wiki when I get a chance.

The more I learn about the KM Custom HTML Prompt, the more I like it.

To everyone reading this, if you have a working example, please post it to the KM forum. Peter provided one, but it will really help us all learn how to use this if we have more examples.

Thanks.

3 Likes

This is awesome!

I know I’m late to this thread, but does anyone know if there’s any harm in leaving this turned on?

(And of course I just discovered this AFTER spending hours and hours debugging stupid mistakes…)

There’s no harm in leaving this on as far as I can tell (it is just a standard web view under the hood after all)

I suspect the only reason it’s off by default is to prevent novices accidentally right clicking and selecting it and getting confused with some macro someone shared with them.

Thanks!

Where can I check the inspector?
I ran the command in terminal, restarted the KM engine.
When I right click custom html prompt, I get things like try, disable, rename, and so on. I couldn’t find inspector.
Thanks!

It sounds like you are right-clicking on the KM Action in your Macro.
You need to right-click on the HTML Prompt when you actually display it.
See my screenshot in the above post.

Ah, got it! This is awesome! Thanks!

I see this is a very old thread but is still referenced from the wiki. I have run the command in terminal, restarted the Keyboard Maestro engine but I don't get any response when I right click in the custom HTML prompt. I have tried the form example as well as my own prompt but no joy.

Has something changed in the last 5 years?

I am running KM 10.1.1 on MacOS Monterey 12.5 on Apple Silicon.

Answering myself .. it was operator error (again).

For the record I was trying to right click on the prompt when it was running normally, as opposed to when previewing it in BBEdit. This is my first venture into web code so it's taking me a while to fully understand this new framework.

This should do the trick (notice the -bool)

defaults write com.stairways.keyboardmaestro.engine WebKitDeveloperExtras -bool true

Mentioned earlier on this page