Hey Folks,
I finally got annoyed enough to update my Choose Safari Tab script to handle duplicate tab names.
The script produces a choose from list to pick the tab you want to bring forward. It displays the number of open document-windows and tabs, and it shows which is the current tab in each window.
Tabs are segregated by window and listed in index order.
Pure vanilla; very fast.
------------------------------------------------------------------------------------------
# Auth: Christopher Stone <junksieve@thestoneforge.com>>
# dCre: 2010-10-16 : 00:42
# dMod: 2013-05-30 : 18:25
# Appl: Safari
# Task: Display a list of tab names and also a count of both documents & tabs.
# : Select a tab name to bring it to the front.
# : Adjusted to deal properly with duplicate tab names on 2013-05-30.
# Libs: Only stock OSX components used.
# Osax: None
# Tags: @Applescript, @Safari, @Choose, @Display, @Tabs, @Windows
-------------------------------------------------------------------------------------------
try
set sep to "----------------------------------------------------------------------------------------------------"
tell application "Safari"
if (count of document) ââ°ÂĽ 1 then
set frontWindoc to document of front window
else
error "No pages are open in Safari"
end if
tell (every window where its document is not missing value)
set docCount to count
set currentTabIndex to index of current tab
set tabCount to count of tabs
set tabNames to name of tabs
end tell
if docCount < 10 then set docCount to "0" & docCount
set hdrText to "Window Count: " & docCount & return & " Tab Count: " & tabCount
# Add tab-index to tab names to deal with duplicate names.
set ndx to 0
repeat with i in tabNames
repeat with n from 1 to (length of i)
if n < 10 then
set _num to "0" & n
else
set _num to n
end if
tell (a reference to item n of i) to set its contents to its contents & " ¡ [" & _num & "]"
end repeat
end repeat
# Mark Current Tabs of each document window with 'âĹâ'
# tabNames is a list of lists.
set ndx to 0
repeat with i in tabNames
set ndx to ndx + 1
tell (a reference to i's item (item ndx of currentTabIndex)) to set its contents to (its contents) & " âĹâ"
if ndx = 1 then
set currentTabName to result
end if
set end of i to sep
end repeat
set beginning of item 1 of tabNames to sep
set AppleScript's text item delimiters to return
set tabNames to paragraphs of (tabNames as text)
set _tab to choose from list tabNames with title "¢¢ Safari Tab Names ¢¢" with prompt hdrText 
default items {currentTabName} with empty selection allowed
if _tab = false then return
set _tab to item 1 of _tab # De-listify.
set AppleScript's text item delimiters to " ¡ "
set tabName to text item 1 of _tab
set AppleScript's text item delimiters to {"[", "]"}
set tabIndex to (text item 2 of _tab) as integer
tell windows
set tabID to tabs whose name contains tabName and index is tabIndex
end tell
repeat with i in tabID
try
set tabID to item 1 of i
exit repeat
end try
end repeat
try
tabID as number
on error eStr
set AppleScript's text item delimiters to " of "
repeat with i in (text items of eStr)
if i contains "window id" then
set winOfTabID to run script ((contents of i) & " of application \"Safari\"")
exit repeat
end if
end repeat
end try
set winOfTabIdDoc to winOfTabID's document
if current tab of winOfTabID âⰠtabID then set current tab of winOfTabID to tabID
if winOfTabIdDoc âⰠfrontWindoc then
set newDoc to make new document
set index of winOfTabID to 1
close newDoc
end if
end tell
on error e number n
set e to e & return & return & "Num: " & n
tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
if button returned of dDlg = "Copy" then set the clipboard to e
end try
-------------------------------------------------------------------------------------------