Would like to create a warning when visiting a web site

Would like to create a warning when visiting a web site. I want to get the url from Safari and compare the domain name. Sounds simple but everything I have tried hasn't worked. I am not a KM expert, though a loyal user since version 1. Any help would be helpful.

FYI: I am trying to post a notification to remind my wife to wait 24 hours for non necessary purchases.

1 Like

I'm chuckling at your intended purpose, I almost need one for myself.
Here's my attempt to help.
First get the name or the URL of the site/page by using the first macro here:

aa TBD TESTING 01 - Name of Window or URL.kmmacros (3.2 KB)

Then use this macro in your 'browser' group, say Safari or Chrome etc.
This will trigger a large display if the window or the URL match what you have entered in for the condition.
Hope this helps.
2nd part =

aa TBD TESTING 02 - display based on Window Name or URL.kmmacros (2.6 KB)

The information you provide seems good, but I have a different approach and if you'll allow me, here it is. My approach includes the cyclic triggering code, a condensed way to list the offensive websites, and a novel/intimidating way to display the offence. Make sure you choose "Display Results Large" in the Execute Shell Script action.

Repeat check Safari.kmmacros (2.4 KB)

Thank you so much for taking the time to do this for me. Funny you we're correct in picking the site I wanted the warning for. Unfortunately, I must be doing something wrong because I can't get it to activate when on amazon. Testing number 2 does recognize that I am on amazon when the browser is open to an Amazon page and active however, it doesn't activate the script. I believe it has something to do with the trigger. I am assuming that the trigger should be activated by the "Or by Script" Trigger because if I had to activate the macro by selecting it from the status menu, it wouldn't serve the purpose correctly. Any additional help activating the Macro would be helpful. Thank you again for taking this time to help.

I'm happy to help. But my help isn't always perfect, because you get what you pay for.

One possibility is that my script may be case sensitive. Another possibility is that you might be using Amazon.ca instead of Amazon.com, for example. For a quick test just delete .com from Amazon.com in the script.

While you do that I'll think of the next step. We can fix it.

The macro activates itself every 10 seconds, assuming that the KM Engine is on. You aren't supposed to activate it manually. I'm not certain if you understand that. If the Safari browser has one of the three websites listed as part of its URL in its selected window, the user will see a big warning appear on the screen. it's working for me. Your testing must be to open each illegal website in Safari and then wait ten seconds at most.

I'm not sure why it doesn't work for you. I'm still guessing you aren't on amazon.com but perhaps on a different amazon site like amazon.ca or something.

It's not part of your problem, but we probably should skip the macro if Safari isn't the front window. That's not related to your problem, but it might be a good upgrade to this macro.

Personally I like what this macro does. It flashes a warning on the screen. I think a warning is good enough, but your situation may differ. Every ten seconds seems fair, but you may want 12, 15, 20, 30 or so. It's probably best to pick a number that divides into 60 evenly.

Another good idea: I think the script should print $1 instead of var. It guarantees a more readable warning message.

You don’t forcibly need a periodic trigger here:


[test] Warn Me When a Malicious Host is Connected (Safari).kmmacros (3.2 KB)

Make sure the macro is in a group that is enabled for Safari.

Using a non-periodic trigger here has the advantage that the macro is only triggered when actually something changes with Safari’s window (which should be enough).


Dang I didn't know that. Am I fired?

No, of course not. (I never would hire you :wink: )

1 Like

I am sorry, I wasn't implying you misdirected me, I really appreciate your help. your part 2 turns positive when I load amazon, it is getting the trigger to run without doing it from status bar.

Thank You Kindly...

I'm confused. So I'm going to guess what you mean by the statement above. If I'm wrong, please correct me, and perhaps reword the statement above.

Did you mean clicking the "Try" button on the KM Editor status bar? That button doesn't run the macro, it runs only the action that you highlighted. If you highlighted only the first action in my macro, then the second one won't run. If you've highlighted only the second one, then the first one won't run and so the second one "probably" won't have the data it needs to run.

So the way I designed this macro, the Try button will usually not do anything.

I'm not sure why you would want to click on the Try button. This macro runs every 10 seconds. There's no need to click on Try.

Or are you asking me about running Tom's macro from the status bar? If so, I'll have to read what his macro does. His macro seems to be similar to mine, but there are some differences which I'm not fond of.

You don't need to apologize to me. You are fine.

@DonPerreault, just in case you really were referring to my macro: You don’t need to launch it manually. It is meant to be triggered by window title changes in Safari.

I wanted to take a moment and thank you guys for all your help. I was able to come up with a terrific solution thanks to you. My solution allows me to disable the macro with a command key when I need to purchase something from Amazon with being bombarded by notifications and automatically turn it self back on, in case I forget.

Thanks Again