Can KBM trigger a macro when a url of one of the open safari tabs contains a keyword?

I am trying to create a macro to warn me when I try to connect to certain sites.
Can KBM monitor the URLs of all open safari tabs and carry out an action if one of the URLs has a keyword.
For example, can a macro be triggered to warn me if the URL of one of the open safari tabs contains the keyword “library”?

Hey Mirizzi,

You could hack something together that would monitor this, but for it to work in realtime it would be processor intensive and difficult to manage.

Doing something manual or at a timed interval wouldn’t be too difficult though.

set keyWord to "stackexchange"

tell application "Safari"
  set urlList to URL of tabs of (windows where its document is not missing value)
end tell
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, linefeed}
set urlList to urlList as text
set AppleScript's text item delimiters to oldTIDS
if urlList contains keyWord then
  beep 2
end if


1 Like