title: Applescript run Safari in background
body: <p>I have an applescript that is now doing what I want it to do: Open a specific URL, close the page and wait 2 seconds then do it again.  The script works.</p>
  
  <p>The problem is that when I run this on my machine, and I am trying to do something else at the same time, the Safari windows keeps popping up. I would really like to run this in the background so that I can continue to work on whatever I am doing.</p>
  
  <p>The code I have is:</p>
  
  <pre><code>set theURL to "https://sites.google.com/site/whatever/"
  
  repeat 100 times
      tell application "Safari"
          activate
          try
              tell window 1 to set current tab to make new tab --with properties {URL:theURL}
              set URL of document 1 to theURL
          on error
              open location theURL
          end try
          delay 2
          try
              close window 1
          end try
      end tell
  
      tell application "Safari"
          quit
      end tell
  
      delay 1
  end repeat
  </code></pre>
  
  <p>Anyone have a solution to this one?</p>