Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Tim in Phoenix

macrumors member
Original poster
Apr 9, 2010
39
0
Guys

I like to pull up charts on websites to follow certain investments; can I have Safari refresh the window every minute or two to keep the charts current?


.
 
Auto Refresh with Safari and being able to continue using browser

Hey guys, I just posted this in another thread, but might as well post here. I wish I stumbled upon these threads earlier haha. Well here is the script that i wrote that will hopefully help someone. If you need help reply here and I'll try my best to help you out!

This is the link to the script from a Snippet host - Snipt.org:
http://snipt.org/Aggif4/Default

And here is the raw code if the snipt page is deleted:
Code:
property url_list : {"", "", "", "", ""}
property _defaultTotalRefreshes : 0
property _defaultTotalSeconds : 1

set _numoftabs to (choose from list {"1", "2", "3", "4", "5"} with prompt "How many tabs will you have open for auto Refreshing?" default items "1" OK button name "This Many" cancel button name "Nevermind")

--These two variables are very self explanatory
set _total to the text returned of (display dialog "How many total refreshes?" default answer ¬
	_defaultTotalRefreshes with title "Total")
set _seconds to the text returned of (display dialog "How many seconds per refresh?" default answer ¬
	_defaultTotalSeconds with title "Seconds")

--Set the default seconds to the previously entered number so it will be remembered 
--for the next time the user runs the script
set _defaultTotalSeconds to _seconds
set _defaultTotalRefreshes to _total

if _numoftabs = false then --Determine if the user wants to quit
	error "User canceled." number -128
else
	repeat with i from 1 to _numoftabs --Fill the list with urls
		set item i of url_list to text returned of (display dialog "What website do you want to set for tab " & i & "?" default answer "http://" with title "Enter the WHOLE address (http:// too)")
	end repeat
	
	tell application "Safari"
		make new document
		set winID to the id of window 1 --crucial for not crossing over to other window
		repeat with j from 1 to _numoftabs --open that list in new tabs
			set URL of tab j of window id winID to item j of url_list
			if j is less than _numoftabs then --opens the amount of tabs specified
				make new tab of window id winID
			end if
		end repeat
		
		-- HERE IS THE AUTO REFRESH PART
		repeat with _count from 0 to _total
			repeat with k from 1 to _numoftabs
				set URL of tab k of window id winID to item k of url_list
				delay _seconds
			end repeat
		end repeat
	end tell
	
end if
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.