Admittedly, I know almost nothing about applescript. I borrowed this script from a user on a forum and applied it to my own needs.
All I am trying to do is make a script that will open Pandora in a Safari tab and refresh it every hour because I like to turn my display off while letting Pandora run. I've saved this script as a stay open application. Right now, the script works perfectly for what I want. But when I quit it, I must also go to the Safari tab and close Pandora, or it will continue to run. What I would like to add, is something like this.
I tried adding it several different ways, but no matter what I do, the application won't quit. Am I just missing some simple thing here? Any help would be appreciated.
Code:
on idle
tell application "Safari"
if name of documents as string does not contain "Pandora" then -- check window name
activate -- comment this out if you want it in the background
open location "http://pandora.com" -- open new Pandora window if there is none
else -- refresh existing Pandora window
set _documents to documents
repeat with _document in _documents
if name of _document contains "Pandora" then
activate -- comment this out if you want it in the background
do JavaScript "
window.location = 'http://pandora.com';
" in document 1
end if
end repeat
end if
end tell
return 3600 -- every 60 mins
end idle
All I am trying to do is make a script that will open Pandora in a Safari tab and refresh it every hour because I like to turn my display off while letting Pandora run. I've saved this script as a stay open application. Right now, the script works perfectly for what I want. But when I quit it, I must also go to the Safari tab and close Pandora, or it will continue to run. What I would like to add, is something like this.
Code:
on quit
tell application "Safari"
repeat with t in tabs of windows
tell t
if name of documents as string contains "Pandora" then close
end tell
end repeat
end tell
I tried adding it several different ways, but no matter what I do, the application won't quit. Am I just missing some simple thing here? Any help would be appreciated.