A command-line tool to count the number of browser tabs currently open.
Firefox only - This tool currently only supports Mozilla Firefox. Support for other browsers (Chrome, Safari, Edge) may be added in the future.
The tool reads Firefox's session store file (a compressed JSON file in mozLz40 format), decompresses it, and counts the total number of tabs across all open windows.
Requirements:
- Go 1.16 or later
go build -o count-firefox-tabs count-firefox-tabs.go# macOS
GOOS=darwin GOARCH=amd64 go build -o count-firefox-tabs-macos count-firefox-tabs.go
# Linux
GOOS=linux GOARCH=amd64 go build -o count-firefox-tabs-linux count-firefox-tabs.go
# Windows
GOOS=windows GOARCH=amd64 go build -o count-firefox-tabs.exe count-firefox-tabs.goSimply run the binary:
./count-firefox-tabsOutput:
Firefox tabs open: 42
If Firefox is not running:
Firefox is not running
- macOS: Fully supported
- Linux: Should work (untested) - looks for Firefox profiles in
~/.mozilla/firefox/ - Windows: Should work (untested) - looks for Firefox profiles in
%APPDATA%/Mozilla/Firefox/Profiles
Note: The profile location detection currently assumes macOS paths. Cross-platform support would require updating the findFirefoxProfile() function.
Firefox stores your browsing session in compressed files:
sessionstore-backups/recovery.jsonlz4- Most recent session datasessionstore.jsonlz4- Backup session data
These files use Mozilla's mozLz40 compression format, which is LZ4 block compression with a custom header containing:
- 8-byte magic number:
mozLz40\0 - 4-byte little-endian uncompressed size
- Compressed JSON data
MIT