PDA

View Full Version : Safari Scripting




TheStu
Nov 12, 2007, 04:11 PM
So my buddy wants to switch to Safari, but is held back by 2 things.

AdBlock: I have already taken care of this by showing him how well Safari-Adblock works.

Multiple Tabs as homepage: I found a script from about 4 years ago that still works with Safari, and have since modified it to launch Safari and then close itself once the tabs are loaded.

What I want to know is, is there anyway to make that script
A: Launch with Safari, so instead of having to use that script to launch Safari, it instead will be launched by Safari, and then after running itself will close like it already does
B: Make it more user friendly. Right now, to change the sites that open, you have to edit the script directly, and although he is more than capable of doing this, if I wanted to distribute this script out so others could have it, they might not want to edit it directly.

Really, A is the important one, finding a way to have it launch with Safari so he doesn't have to have an extra item on his dock.



TheStu
Nov 13, 2007, 06:52 PM
I really am curious to know if this is possible. Surely this is not so difficult that it has all of you stumped beyond the capability to form rational thoughts.

toddburch
Nov 13, 2007, 07:08 PM
Can you post your script that you want modified?

TheStu
Nov 13, 2007, 07:28 PM
Can you post your script that you want modified?

set the URL_list to {"http://forums.anandtech.com", "http://forums.macrumors.com"}

do shell script "open -a Safari"

tell application "Safari"
activate
repeat with i from 1 to number of items in URL_list
set this_URL to item i of URL_list
my new_tab()
set the URL of document 1 to this_URL
end repeat
end tell

on new_tab()
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
click menu item "New Tab" of
menu "File" of menu bar 1
end tell
end tell
end new_tab

toddburch
Nov 13, 2007, 09:55 PM
Sorry: applescript - I can't help you.

Todd