Last active
May 29, 2022 07:56
-
-
Save edenwaith/24a9529bfb871ec95150c07c748f4764 to your computer and use it in GitHub Desktop.
AppleScript: Count the number of open tabs in Google Chrome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- CountOpenChromeTabs.scpt | |
-- Author: Chad Armstrong | |
-- Date: 30 August 2019 | |
-- Description: Count the number of open tabs in Google Chrome | |
-- To run from CLI: osascript CountOpenChromeTabs.scpt | |
-- To create an alias command: | |
-- In ~/.bash_profile, add the line: alias counttabs='osascript ~/Projects/Scripts/CountOpenChromeTabs.scpt' | |
-- Refresh the bash shell environment: source ~/.bash_profile | |
tell application "Google Chrome" | |
--Variables | |
set windowlist to every window | |
set totaltabcount to 0 | |
-- Loop through each window to count the number of open tabs | |
repeat with chromewindow in windowlist | |
try | |
set tabcount to number of tabs in chromewindow | |
set totaltabcount to totaltabcount + tabcount | |
on error errmsg | |
-- log "error message: " & errmsg | |
end try | |
end repeat | |
log "There are " & totaltabcount & " Chrome tabs open." | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment