Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Automatically zoom new pages in Safari' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically zoom new pages in Safari
Authored by: grav on Jan 22, '10 07:06:03AM

Script improved by trosberg. A couple of bugfixes by grav.

Save as application and check Stay Open

global appPath, previousURL

on run
	set appPath to (path to application "Safari")
	set previousURL to ""
end run
on idle
	if SafariRunningTest() is true then
		set p to (path to frontmost application)
		if p is not appPath then -- Safari is not the frontmost application
			-- idle on!
		else -- Safari is the frontmost app
			tell application "Safari"
				set currentURL to URL of current tab of window 1 -- window 1 is apparently always the active window in Safari
			end tell
				if currentURL is not "" then -- this will ignore new tabs where a page is not yet loaded
					if currentURL is not previousURL then -- check, if we have already zoomed in this tab
						if ActualSizeChecked() is false then
							-- here we fire off the key shortcuts 
							-- these may differ according to the OS X language
							tell application "System Events"
								keystroke "+" using command down
								--							keystroke "+" using command down
							end tell
							set previousURL to currentURL
						end if
					end if
				end if
			end try
		end if
	end if
	return 1 -- to repeat every 1 second
end idle
on SafariRunningTest()
	tell application "System Events"
		return exists of process "Safari"
	end tell
end SafariRunningTest
on ActualSizeChecked()
	tell application "System Events"
		tell process "Safari"
			-- these differ according to language chosen in System Prefs
			return enabled of menu item "Actual Size" of menu "View" of menu bar item "View" of menu bar 1
		end tell
	end tell
end ActualSizeChecked

[ Reply to This | # ]