Created
July 31, 2012 08:03
-
-
Save stevoyoung/3214759 to your computer and use it in GitHub Desktop.
Open a new Safari window and load multiple URL in it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This AppleSciript is used to open a new Safari window and load various URLs into it. | |
-- The original code is from Antal S-Z on Stackooverflow. Go vote it up if like it. | |
-- http://stackoverflow.com/a/11708517/303343 | |
property the_urls : {¬ | |
"http://www.example.com", ¬ | |
"http://www.apple.com", ¬ | |
"http://www.stevoyoung.com"} | |
tell application "Safari" | |
if the_urls = {} then | |
-- If you don't want to open a new window for an empty list, replace the | |
-- following line with just "return" | |
set {first_url, rest_urls} to {"", {}} | |
else | |
-- `item 1 of ...` gets the first item of a list, `rest of ...` gets | |
-- everything after the first item of a list. We treat the two | |
-- differently because the first item must be placed in a new window, but | |
-- everything else must be placed in a new tab. | |
set {first_url, rest_urls} to {item 1 of the_urls, rest of the_urls} | |
end if | |
make new document at end of documents with properties {URL:first_url} | |
tell window 1 | |
repeat with the_url in rest_urls | |
make new tab at end of tabs with properties {URL:the_url} | |
end repeat | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment