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

Set Safari's home page via WiLMa and AppleScript Web Browsers
I am using WiLMa to switch locations on my PowerBook. I used to use Location X for this purpose, but it no longer works for me. Specifically, I can use WiLMa to change the Network settings like IP address and proxy when I go from home to work. Location X also allowed me to change the web home page setting in Safari, but WiLMa doesn't.

So I spent some time searching MacScripter, and came up with this Applescript.

I have placed two similar versions of the script in the /Library/Scripts folder (compiled as applications), and WiLMa will run them when I switch locations. One set's Google as the home page, and the other sets my ISP's home page as my home page.

Now I am very inexperienced at this sort of thing. The script works, except when I trigger a switch unintentionally and the web home page is already set and Safari is not running. When this happens, the script finishes without starting Safari. Just a slight hiccup. I would love someone else to pull it apart, improve it, and maybe convert it to a shell script.
    •    
  • Currently 2.75 / 5
  You rated: 2 / 5 (4 votes cast)
 
[15,599 views]  

Set Safari's home page via WiLMa and AppleScript | 2 comments | Create New Account
Click here to return to the 'Set Safari's home page via WiLMa and AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set Safari's home page via WiLMa and AppleScript
Authored by: yesiamnhoj on Feb 14, '07 02:03:54PM
I'm not sure why you'd want to make this change dependant on location, but here is a reduced version of your script that launches Safari whatever happens.
--reset the value of the Home Page
set HomePage to "http://www.google.com.au"
-- 'path to' is in the Standard Additions dictionary
set pListpath to ((path to preferences from user domain) as Unicode text) & "com.apple.internetconfigpriv.plist"

tell application "System Events"
	-- if the plist item does not contain the text
	if (value of property list item "WWWHomePage" of property list file pListpath) is not HomePage then
		-- set the item to the text
		set (value of property list item "WWWHomePage" of property list file pListpath) to HomePage
		-- if Safari is running, quit it
		if (name of every process) contains "Safari" then tell application "Safari" to quit
	end if
	-- whatever happens start Safari
	tell application "Safari" to launch
end tell
Best wishes
John M

[ Reply to This | # ]
Set Safari's home page via WiLMa and AppleScript
Authored by: DragonMac on Mar 09, '07 10:08:19PM
Anyone know a way to make this work in HTML ? Is there a way to use a Javascript test for Safari and if you click the link it will set Safari home page. See the "[if IE]" can it be made like "[if Safari]" and then exacute script code that will work only for Safari users? IE code below

<!--[if IE]>
<a class="chlnk" style="cursor:hand;font-weight:bold;color:#004080;font-family:Verdana" HREF onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.mydomain.com/');">Click here to make MyDomain your default homepage!</a>
<![endif]-->

---
Can't wait for Tiger ;-)>

[ Reply to This | # ]