Poor performance with background script with delay command

I wrote a script that checks if users are navigating certains web pages.
To accomplish such task, I wrote something like this:

repeat
	delay 60
	tell application "Safari"
		verifications
		if verification is true then quit
	end tell
end repeat

(at bottom is the full code)

The idea is to quit Safari if user is navigating certain pages, identified by its name or its URL.
To avoid users to stop the checking actions, it was necessary:

to set the compiled script as a background applications (with Drop Script Backgrounder)
to set the compiled application as startup item
to deny permision to user to change its startup items (via Parental Control)
to deny permision to execute Activity Monitor (via Parental Control)

It works fine, quitting Safari and Explorer if the user is visiting pages like e-messenger, elchat and so on.

BUT. the overall speed of the machine is poor (specially printing on a networked printer and saving on a file server) or using QuarkXPress

I suppose that delay xx is not the best solution.
Does someone know a better solution.

Thanks in advance

The full code working fine:

repeat
	delay 60
	set denegados to {"chat", "messenger", "meebo"}
	try
		tell application "System Events"
			
			-- Para Safari
			if "Safari" is in name of the processes then
				set salirSafari to "NO"
				tell application "Safari"
					if (count of windows) > 0 then
						repeat with v from 1 to count of windows
							if not modal of window v then
								repeat with d from 1 to count of denegados
									if item d of denegados is in name of window v or item d of denegados is in URL of document of window v then
										beep 2
										activate
										display dialog "No hay que chatear." & return & "Safari se va a cerrar." buttons {"OK"} default button 1 with icon stop giving up after 3
										
										quit application "Safari"
										set salirSafari to "SI"
									end if
									if salirSafari = "SI" then exit repeat
								end repeat
							end if
							if salirSafari = "SI" then exit repeat
						end repeat
					end if
				end tell
			end if
			
			
			-- Para Explorer
			set salirExplorer to "NO"
			if "Internet Explorer" is in name of the processes then
				
				tell application "Internet Explorer"
					set ventanas to ListWindows
					if (count of ventanas) > 0 then
						repeat with v from 1 to count of ventanas
							set info to GetWindowInfo item v of ventanas as string
							repeat with d from 1 to count of items of denegados
								if item d of denegados is in item 1 of info or item d of denegados is in item 2 of info then
									beep 2
									Activate
									display dialog "No hay que chatear." & return & "Explorer se va a cerrar." buttons {"OK"} default button 1 with icon stop giving up after 3
									quit application "Internet Explorer"
									set salirExplorer to "SI"
								end if
								if salirExplorer = "SI" then exit repeat
							end repeat
							if salirExplorer = "SI" then exit repeat
						end repeat
					end if
				end tell
			end if
		end tell
	on error
		-- nada
	end try
	run me
end repeat

You may use an “idle” handler, less CPU-intensive than “delay”. Just save something similar to this as “stay-open” app:

property denegados : {"chat", "messenger", "meebo"}

on idle
	try
		tell application "Finder" to if "sfri" is in creator type of processes then ¬
			tell application "Safari" to set {uerreeles, titulos} to {URL, name} of documents
		repeat with i in denegados
			if i is in uerreeles or i is in titulos then
				display dialog "NO!" buttons {"OK, OK."} default button 1 with icon 0 giving up after 3
				quit application "Safari"
				exit repeat
			end if
		end repeat
	end try
	
	--> same for IE
	
	return 60 --> execute idle handler every 60 seconds
end idle

it may be better to use ipfw the mac osx built in firewall to block those urls and they will never no how to fix it or even have permissions.

Thanks. I’m testing.
I’ve found another solution: not to include repeat nor on idle statements in my script and use Darwin cron:
I wrote a simple shell script, named StartNoChat.sh:

open /users/user001/library/MyScripts/NoChat.app

an added next entry in the crontab (via terminal using crontab -e command), in order to execute my script each minute:

          • /users/user001/library/MyScripts/StartNoChat.sh

Another thing:
In response to Kim Hunter:
Please teach me where is the configuration to block url acces. I was looking for it in Sharing preference, but I can’t find anything.

Thanks in advance.