How to trigger a Macro when I launch an internet search on Safari or Chrome?

Screenshot 2022-04-28 at 06.45.45

So I have a macro setup which I'm happy with how it works.

the only problem is how it's triggered.

I have it as a periodic check every 20 seconds.

but the macro would be much better if it was triggered when I do an internet search on Safari or Chrome and a new web page is loaded, then the macro begins.

is that possible?

Thanks

@keithrego21 Try this:

New Web Search Trigger.kmmacros (24 KB)

Macro screenshot

Change the browser choice in the AppleScript if need be.