Trigger on safari url

I am trying to figure out how I can trigger a macro based on safari navigating to a particular url. I would like to open safari, click a bookmark, and when that page loads fill out a form and submit it.f

I’ve found several examples that may help me fill out the form and submit it. However, I can’t find anything about a trigger based on our a url.

Thanks!

Jason

You cannot trigger a macro when the Safari URL changes. You could trigger on the window title changing and then check the URL and then perform your macro.

The way I would normally do this would instead trigger the macro by some other manual method and have it open the URL and perform the actions.

Hey Jason,

You wouldn’t like the overhead it would take to continuously poll Safari’s front window for its URL.

tell application "Safari"
  make new document with properties {URL:"https://www.google.com"}
end tell

OR

tell application "Safari"
  set URL of front document to "https://www.google.com"
end tell

OR

tell application "Safari"
  set safariURL to URL of front document
  if safariURL = "https://www.google.com/" then
    # Do something.
  else
    # Do something else.
  end if
end tell

Also examine the Safari Control category in the Action Inspector in the KM Editor.

Your options are many.

-Chris

Hi and good day,

Copied those scripts, might need them one day!

/
with best regards,
Omar KN
Stockholm, Sweden