• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Browser tab
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Browser tab


  • Subject: Browser tab
  • From: Tony <email@hidden>
  • Date: Sun, 30 Apr 2017 18:08:46 -0700

I have several scripts that I use in a FileMaker database to scrape data from various webpages — using a filemaker perform AppleScript step.  To eliminate proliferating browser tabs, I use a script routine that searches my existing open safari tabs, and use the existing tab for a particular website for subsequent searches on that site.  If not open tab exists, then a new tab is created.

Starting with safari 10.1, the make new document lines are started creating safari crashes (albeit this script line does not cause an exception if run directly from script editor.

This routine works generally, but I’m looking for any general guidance or suggestions on a better way to run this routine.  

TIA



on pickTab(tabName, tabURL)
set safariPreferenceTabs to {"General", "Tabs", "Autofill", "Search", "Security", "Privacy", "Notifications", "Extensions", "Advanced"}
try
tell application "Safari"
repeat with w in (every window where visible is true)
set currWinName to name of w
if currWinName is not "" and currWinName is not in safariPreferenceTabs then --in case of zombie windows or preference window
try
repeat with t in tabs of w
set currTabName to name of t
if currTabName starts with tabName then
tell w to set current tab to t
set index of w to 1
end if
end repeat
end try
end if
end repeat
try
tell window 1
if name of current tab starts with tabName then
set the URL of the current tab to tabURL
else
set current tab to (make new tab with properties {URL:tabURL})
end if
end tell
on error
tell application "Safari"
--make new document with properties {URL:tabURL}
end tell
end try
end tell
on error
tell application "Safari"
--make new document with properties {URL:tabURL}
end tell
end try
end pickTab

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Browser tab
      • From: Christopher Stone <email@hidden>
  • Prev by Date: Re: Copying the path of files selected in Finder
  • Next by Date: Re: Copying the path of files selected in Finder
  • Previous by thread: Re: display as text anomaly
  • Next by thread: Re: Browser tab
  • Index(es):
    • Date
    • Thread