Safari Scripting

Discussion in 'Mac Programming' started by TheStu, Nov 12, 2007.

  1. macrumors 65816

    Joined:
    Aug 20, 2006
    Location:
    Carlisle, PA
    #1
    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.
     
  2. thread starter macrumors 65816

    Joined:
    Aug 20, 2006
    Location:
    Carlisle, PA
    #2
    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.
     
  3. macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #3
    Can you post your script that you want modified?
     
  4. thread starter macrumors 65816

    Joined:
    Aug 20, 2006
    Location:
    Carlisle, PA
    #4
    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
     
  5. macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas

Share This Page