apple script
May. 17th, 2024 06:11 pmI've been doing a very half-arsed exploration of apple script. A while ago I wrote two tiny (as in 'three lines of code' tiny) scripts, one of which counted all open tabs, and the other counted open tabs in the front window. And I used these for a while, and was happy.
And then a week or two ago I decided it was time to try combining these. My first pass worked, but I wasn't as happy with it as I might have been. Today, I've tweaked it just a little bit more. And I ran it, and got the output
"There are 461 open tabs, in 36 windows. 241 of these are in the front tab"
The code:
tell application "Safari"
set frontTabs to count of tabs of front window
set windowCount to count of window
set allTabs to count of tabs of every window
set tabText to "There are " & ¬
allTabs & ¬
" open tabs, in " & windowCount & " windows. " & ¬
frontTabs & ¬
" of these are in the front tab"
end tell
tabText