Using a Safari Extension would probably not work, since according to the Apple docs, they are written in _javascript_ so if I use _javascript_ to turn off _javascript_ in Safari, there is no obvious way to turn it back on.
Included below is my previous code for an AS app that allows you to pause and resume Safari manually based on the PID approach mentioned in my previous email. It should be just a copy and paste. Enjoy.
-- Basics for pausing and resuming an application (Safari) ala AppleScript.
-- need to wrap in detectors triggered when the application becomes active and when it moves to the back to auto pause and resume.
-- Alex Zavatone 2012
--
property pSafariPID : 0
property pSafariWebContentPID : 0
on run
main()
end run
on main()
GetSafariPID()
log (pSafariPID)
log (pSafariWebContentPID)
display dialog "Pause or Resume Safari?" buttons {"Pause", "Resume"} ¬
default button 1
copy the result as list to {buttonpressed}
try
if the buttonpressed is "Pause" then
PauseSafari()
else if the buttonpressed is "Resume" then
ResumeSafari()
end if
end try
end main
on GetSafariPID()
set myShellString to "ps -Ac"
-- set myResult to every paragraph of (do shell script myShellString) whose (word 4 is "Safari")
set myResultList to paragraphs of (do shell script myShellString)
-- set myParas to paragraphs of myResult where (word 4 = "Safari")
repeat with myItem in myResultList
set myCondition to (word 4 of myItem = "Safari")
if myCondition then
set pSafariPID to word 1 of myItem
--exit repeat
end if
set myCondition to (word 4 of myItem = "WebProcess")
if myCondition then
set pSafariWebContentPID to word 1 of myItem
--exit repeat
end if
end repeat
--return myPID
end GetSafariPID
on PauseSafari()
set myShellString to "set +o posix; kill -SIGSTOP " & pSafariPID
set myResult to do shell script myShellString
set myShellString to "set +o posix; kill -SIGSTOP " & pSafariWebContentPID
do shell script myShellString
end PauseSafari
on ResumeSafari()
set myShellString to "set +o posix; kill -SIGSTOP " & pSafariPID
do shell script myShellString
set myShellString to "set +o posix; kill -SIGSTOP " & pSafariWebContentPID
do shell script myShellString
end ResumeSafari