on run {}
main()
end run
on main()
repeat while true
set myResult to (do shell script "ps -Ac | sed -En '/Safari$/p'") ≠ ""
log (myResult)
if (do shell script "ps -Ac | sed -En '/Safari$/p'") ≠ "" then
tell application "Safari"
if not frontmost then
# Kill _javascript_
end if
end tell
end if
DoDelay(1)
end repeat
end main
on DoDelay(timeInSeconds)
-- We do this shell command because on some versions of the Mac OS, if this is running as a compiled app,
-- using the delay command will use up 100% of an entire core until the delay is finished.
-- Therefore, we have to wrap a call to a shell script which is synchronous and will not do this.
-- Lame.
set myShellScript to "sleep " & timeInSeconds
do shell script myShellScript
end DoDelay
On Apr 3, 2013, at 2:28 PM, Christopher Stone wrote:
if (do shell script "ps -Ac | sed -En '/Safari$/p'") ≠ "" then
tell application "Safari"
if not frontmost then
# Kill _javascript_
end if
end tell
end if