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
|